Stream: general

Topic: ui error annoations for multi-span errors?


RalfJ (Mar 31 2020 at 15:25, on Zulip):

I am trying to make compiletest accept the following output:

error: any use of this value will cause an error
  --> $DIR/dangling.rs:8:16
   |
LL | / const TEST: () = { unsafe {
LL | |     let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
LL | |     let _val = &*slice;
   | |                ^^^^^^^
   | |                |
   | |                invalid metadata in wide pointer: slice is bigger than largest supported object
   | |                inside `TEST` at $DIR/dangling.rs:8:16
LL | |
LL | |
LL | |
LL | | } };
   | |____-
   |
   = note: `#[deny(const_err)]` on by default

error: aborting due to previous error

but I cannot figure out how I have to set the annotations. I think this should work but it puts everything on the wrong line:

use std::{mem, usize};

// Make sure we error with the right kind of error on a too large slice.
const TEST: () = { unsafe { //~ NOTE
    let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
    let _val = &*slice; //~ ERROR: any use of this value will cause an error
    //~^^ NOTE: slice is bigger than largest supported object
    //~^^ inside `TEST`
    //~^^ on by default
} };

fn main() {}
RalfJ (Mar 31 2020 at 15:25, on Zulip):

is there documentation somewhere for what the right number of magic sigils is that needs to be put where?^^

RalfJ (Mar 31 2020 at 15:26, on Zulip):

ah, this worked:

use std::{mem, usize};

// Make sure we error with the right kind of error on a too large slice.
const TEST: () = { unsafe { //~ NOTE
    let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
    let _val = &*slice; //~ ERROR: any use of this value will cause an error
    //~^ NOTE: slice is bigger than largest supported object
    //~^^ NOTE: inside `TEST`
    //~^^^ on by default
} };

fn main() {}

I have no idea why though

RalfJ (Mar 31 2020 at 15:27, on Zulip):

I dont think I had to put increasing number of ^ before...

lqd (Mar 31 2020 at 15:30, on Zulip):

each ^ is how many lines up the error should appear

Jonas Schievink (Mar 31 2020 at 15:31, on Zulip):

You can use //~| to mean "same line as the above pattern" so you don't have to use so many ^s

lqd (Mar 31 2020 at 15:33, on Zulip):

and the sigils' documentation is here

RalfJ (Mar 31 2020 at 16:03, on Zulip):

Jonas Schievink said:

You can use //~| to mean "same line as the above pattern" so you don't have to use so many ^s

ah, | must be what I used otherwise

RalfJ (Mar 31 2020 at 16:03, on Zulip):

lqd said:

and the sigils' documentation is here

thanks! I was looking for a README file like we have it e.g. for codegen tests. looks like rustc-dev-guide is the btter location these days :)

Jake Goulding (Mar 31 2020 at 17:32, on Zulip):

TODO:

% cat README.md

Go [read the rustc-dev-guide](appropriate link)
Last update: Jun 05 2020 at 21:40UTC