diff options
| author | bors <bors@rust-lang.org> | 2020-09-03 23:27:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-03 23:27:45 +0000 |
| commit | af3c6e733a40e671550e0f0f5aeecaa13772ba56 (patch) | |
| tree | 6234193bc514a97e899369463b0937774a4b159d /src/test/ui/array-slice-vec | |
| parent | 0d0f6b113047b2cf9afbde990cee30fd5b866469 (diff) | |
| parent | e7d7615105332f269a27cbd7273029377a96ccdf (diff) | |
| download | rust-af3c6e733a40e671550e0f0f5aeecaa13772ba56.tar.gz rust-af3c6e733a40e671550e0f0f5aeecaa13772ba56.zip | |
Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkov
diagnostics: shorten paths of unique symbols This is a step towards implementing a fix for #50310, and continuation of the discussion in [Pre-RFC: Nicer Types In Diagnostics - compiler - Rust Internals](https://internals.rust-lang.org/t/pre-rfc-nicer-types-in-diagnostics/11139). Impressed upon me from previous discussion in #21934 that an RFC for this is not needed, and I should just come up with code. The recent improvements to `use` suggestions that I've contributed have given rise to this implementation. Contrary to previous suggestions, it's rather simple logic, and I believe it only reduces the amount of cognitive load that a developer would need when reading type errors. ----- If a symbol name can only be imported from one place, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path to the last component. 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 from anywhere.
Diffstat (limited to 'src/test/ui/array-slice-vec')
| -rw-r--r-- | src/test/ui/array-slice-vec/slice-pat-type-mismatches.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/test/ui/array-slice-vec/slice-pat-type-mismatches.rs b/src/test/ui/array-slice-vec/slice-pat-type-mismatches.rs index 34adb42a32f..521b898e7fe 100644 --- a/src/test/ui/array-slice-vec/slice-pat-type-mismatches.rs +++ b/src/test/ui/array-slice-vec/slice-pat-type-mismatches.rs @@ -1,7 +1,7 @@ fn main() { match "foo".to_string() { ['f', 'o', ..] => {} - //~^ ERROR expected an array or slice, found `std::string::String` + //~^ ERROR expected an array or slice, found `String` _ => { } }; diff --git a/src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr b/src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr index c4548142c13..20a5b99845b 100644 --- a/src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr +++ b/src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr @@ -4,11 +4,11 @@ error[E0425]: cannot find value `does_not_exist` in this scope LL | match does_not_exist { | ^^^^^^^^^^^^^^ not found in this scope -error[E0529]: expected an array or slice, found `std::string::String` +error[E0529]: expected an array or slice, found `String` --> $DIR/slice-pat-type-mismatches.rs:3:9 | LL | ['f', 'o', ..] => {} - | ^^^^^^^^^^^^^^ pattern cannot match with input type `std::string::String` + | ^^^^^^^^^^^^^^ pattern cannot match with input type `String` error[E0527]: pattern requires 1 element but array has 3 --> $DIR/slice-pat-type-mismatches.rs:18:9 |
