rust/src/test/ui/repeat_count.rs
Dan Aloni 07e7823c01 pretty: trim paths of unique symbols
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.
2020-09-02 22:26:37 +03:00

35 lines
989 B
Rust

// Regression test for issue #3645
fn main() {
let n = 1;
let a = [0; n];
//~^ ERROR attempt to use a non-constant value in a constant [E0435]
let b = [0; ()];
//~^ ERROR mismatched types
//~| expected `usize`, found `()`
let c = [0; true];
//~^ ERROR mismatched types
//~| expected `usize`, found `bool`
let d = [0; 0.5];
//~^ ERROR mismatched types
//~| expected `usize`, found floating-point number
let e = [0; "foo"];
//~^ ERROR mismatched types
//~| expected `usize`, found `&str`
let f = [0; -4_isize];
//~^ ERROR mismatched types
//~| expected `usize`, found `isize`
let f = [0_usize; -1_isize];
//~^ ERROR mismatched types
//~| expected `usize`, found `isize`
let f = [0; 4u8];
//~^ ERROR mismatched types
//~| expected `usize`, found `u8`
struct G {
g: (),
}
let g = [0; G { g: () }];
//~^ ERROR mismatched types
//~| expected `usize`, found struct `G`
}