rust/src/test/ui/conversion-methods.stderr
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

47 lines
2.2 KiB
Plaintext

error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:5:41
|
LL | let _tis_an_instants_play: String = "'Tis a fond Ambush—";
| ------ ^^^^^^^^^^^^^^^^^^^^^
| | |
| | expected struct `String`, found `&str`
| | help: try using a conversion method: `"'Tis a fond Ambush—".to_string()`
| expected due to this
error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:6:40
|
LL | let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise");
| ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | expected struct `PathBuf`, found `&Path`
| | help: try using a conversion method: `Path::new("/ern/her/own/surprise").to_path_buf()`
| expected due to this
error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:9:40
|
LL | let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here
| ------ ^
| | |
| | expected struct `String`, found integer
| | help: try using a conversion method: `2.to_string()`
| expected due to this
error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:12:47
|
LL | let _prove_piercing_earnest: Vec<usize> = &[1, 2, 3];
| ---------- ^^^^^^^^^^
| | |
| | expected struct `Vec`, found `&[{integer}; 3]`
| | help: try using a conversion method: `(&[1, 2, 3]).to_vec()`
| expected due to this
|
= note: expected struct `Vec<usize>`
found reference `&[{integer}; 3]`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.