If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
68 lines
1.9 KiB
Text
68 lines
1.9 KiB
Text
error[E0606]: casting `&[i32]` as `usize` is invalid
|
|
--> $DIR/fat-ptr-cast.rs:10:5
|
|
|
|
|
LL | a as usize;
|
|
| ^^^^^^^^^^
|
|
|
|
|
= help: cast through a raw pointer first
|
|
|
|
error[E0606]: casting `&[i32]` as `isize` is invalid
|
|
--> $DIR/fat-ptr-cast.rs:11:5
|
|
|
|
|
LL | a as isize;
|
|
| ^^^^^^^^^^
|
|
|
|
|
= help: cast through a raw pointer first
|
|
|
|
error[E0606]: casting `&[i32]` as `i16` is invalid
|
|
--> $DIR/fat-ptr-cast.rs:12:5
|
|
|
|
|
LL | a as i16;
|
|
| ^^^^^^^^
|
|
|
|
|
= help: cast through a raw pointer first
|
|
|
|
error[E0606]: casting `&[i32]` as `u32` is invalid
|
|
--> $DIR/fat-ptr-cast.rs:13:5
|
|
|
|
|
LL | a as u32;
|
|
| ^^^^^^^^
|
|
|
|
|
= help: cast through a raw pointer first
|
|
|
|
error[E0605]: non-primitive cast: `Box<[i32]>` as `usize`
|
|
--> $DIR/fat-ptr-cast.rs:14:5
|
|
|
|
|
LL | b as usize;
|
|
| ^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
|
|
|
error[E0606]: casting `*const [i32]` as `usize` is invalid
|
|
--> $DIR/fat-ptr-cast.rs:15:5
|
|
|
|
|
LL | p as usize;
|
|
| ^^^^^^^^^^
|
|
|
|
|
= help: cast through a thin pointer first
|
|
|
|
error[E0607]: cannot cast thin pointer `*const i32` to fat pointer `*const [i32]`
|
|
--> $DIR/fat-ptr-cast.rs:19:5
|
|
|
|
|
LL | q as *const [i32];
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
error[E0606]: casting `usize` as `*mut (dyn Trait + 'static)` is invalid
|
|
--> $DIR/fat-ptr-cast.rs:22:41
|
|
|
|
|
LL | let t: *mut (dyn Trait + 'static) = 0 as *mut _;
|
|
| ^^^^^^^^^^^
|
|
|
|
error[E0606]: casting `usize` as `*const str` is invalid
|
|
--> $DIR/fat-ptr-cast.rs:23:32
|
|
|
|
|
LL | let mut fail: *const str = 0 as *const str;
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
error: aborting due to 9 previous errors
|
|
|
|
Some errors have detailed explanations: E0605, E0606, E0607.
|
|
For more information about an error, try `rustc --explain E0605`.
|