From 4934a9e6430b3fcb98f77205f8a625c7ffebd628 Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Tue, 3 May 2022 02:07:47 +0000 Subject: [PATCH] Tweak wording --- compiler/rustc_resolve/src/diagnostics.rs | 9 ++++----- src/test/ui/macros/macro-outer-attributes.stderr | 4 ++-- src/test/ui/namespace/namespace-mix.stderr | 16 ++++++++-------- src/test/ui/parser/circular_modules_main.stderr | 4 ++-- .../ui/resolve/enums-are-namespaced-xc.stderr | 12 ++++++------ src/test/ui/resolve/issue-50599.stderr | 4 ++-- src/test/ui/resolve/missing-in-namespace.stderr | 4 ++-- src/test/ui/resolve/privacy-enum-ctor.stderr | 4 ++-- .../ui/resolve/resolve-primitive-fallback.stderr | 4 ++-- ...hadowed-path-in-trait-bound-suggestion.stderr | 4 ++-- 10 files changed, 32 insertions(+), 33 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index f75ea583d852..5d80f49626a0 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2484,15 +2484,14 @@ fn show_candidates( ("one of these", "items", String::new()) }; - let tail = if path.len() > 1 { "..." } else { "" }; let instead = if let Instead::Yes = instead { " instead" } else { "" }; let mut msg = if let IsPattern::Yes = is_pattern { format!( - "if you meant to match on {}{}{}, use the full path in the pattern{}", - kind, instead, name, tail + "if you meant to match on {}{}{}, use the full path in the pattern", + kind, instead, name ) } else { - format!("consider importing {} {}{}{}", determiner, kind, instead, tail) + format!("consider importing {} {}{}", determiner, kind, instead) }; for note in accessible_path_strings.iter().flat_map(|cand| cand.3.as_ref()) { @@ -2523,7 +2522,7 @@ fn show_candidates( if let [first, .., last] = &path[..] { err.span_suggestion_verbose( first.ident.span.until(last.ident.span), - "...and refer to it directly", + &format!("if you import `{}`, refer to it directly", last.ident), String::new(), Applicability::Unspecified, ); diff --git a/src/test/ui/macros/macro-outer-attributes.stderr b/src/test/ui/macros/macro-outer-attributes.stderr index a9fb79b7b27c..91073d3698d9 100644 --- a/src/test/ui/macros/macro-outer-attributes.stderr +++ b/src/test/ui/macros/macro-outer-attributes.stderr @@ -4,11 +4,11 @@ error[E0425]: cannot find function `bar` in module `a` LL | a::bar(); | ^^^ not found in `a` | -help: consider importing this function... +help: consider importing this function | LL | use b::bar; | -help: ...and refer to it directly +help: if you import `bar`, refer to it directly | LL - a::bar(); LL + bar(); diff --git a/src/test/ui/namespace/namespace-mix.stderr b/src/test/ui/namespace/namespace-mix.stderr index dd9c969fc82f..037a858d7e10 100644 --- a/src/test/ui/namespace/namespace-mix.stderr +++ b/src/test/ui/namespace/namespace-mix.stderr @@ -12,13 +12,13 @@ help: a tuple struct with a similar name exists | LL | check(m1::TS); | ~~ -help: consider importing one of these items instead... +help: consider importing one of these items instead | LL | use m2::S; | LL | use xm2::S; | -help: ...and refer to it directly +help: if you import `S`, refer to it directly | LL - check(m1::S); LL + check(S); @@ -40,13 +40,13 @@ help: a tuple struct with a similar name exists | LL | check(xm1::TS); | ~~ -help: consider importing one of these items instead... +help: consider importing one of these items instead | LL | use m2::S; | LL | use xm2::S; | -help: ...and refer to it directly +help: if you import `S`, refer to it directly | LL - check(xm1::S); LL + check(S); @@ -71,13 +71,13 @@ help: a tuple variant with a similar name exists | LL | check(m7::TV); | ~~ -help: consider importing one of these items instead... +help: consider importing one of these items instead | LL | use m8::V; | LL | use xm8::V; | -help: ...and refer to it directly +help: if you import `V`, refer to it directly | LL - check(m7::V); LL + check(V); @@ -104,13 +104,13 @@ help: a tuple variant with a similar name exists | LL | check(xm7::TV); | ~~ -help: consider importing one of these items instead... +help: consider importing one of these items instead | LL | use m8::V; | LL | use xm8::V; | -help: ...and refer to it directly +help: if you import `V`, refer to it directly | LL - check(xm7::V); LL + check(V); diff --git a/src/test/ui/parser/circular_modules_main.stderr b/src/test/ui/parser/circular_modules_main.stderr index f6f3babc2d5e..c5434c72b382 100644 --- a/src/test/ui/parser/circular_modules_main.stderr +++ b/src/test/ui/parser/circular_modules_main.stderr @@ -10,11 +10,11 @@ error[E0425]: cannot find function `hi_str` in module `circular_modules_main` LL | println!("{}", circular_modules_main::hi_str()); | ^^^^^^ not found in `circular_modules_main` | -help: consider importing this function... +help: consider importing this function | LL | use hi_str; | -help: ...and refer to it directly +help: if you import `hi_str`, refer to it directly | LL - println!("{}", circular_modules_main::hi_str()); LL + println!("{}", hi_str()); diff --git a/src/test/ui/resolve/enums-are-namespaced-xc.stderr b/src/test/ui/resolve/enums-are-namespaced-xc.stderr index f501683ebc95..1d26a2c00587 100644 --- a/src/test/ui/resolve/enums-are-namespaced-xc.stderr +++ b/src/test/ui/resolve/enums-are-namespaced-xc.stderr @@ -4,11 +4,11 @@ error[E0425]: cannot find value `A` in crate `namespaced_enums` LL | let _ = namespaced_enums::A; | ^ not found in `namespaced_enums` | -help: consider importing this unit variant... +help: consider importing this unit variant | LL | use namespaced_enums::Foo::A; | -help: ...and refer to it directly +help: if you import `A`, refer to it directly | LL - let _ = namespaced_enums::A; LL + let _ = A; @@ -20,11 +20,11 @@ error[E0425]: cannot find function, tuple struct or tuple variant `B` in crate ` LL | let _ = namespaced_enums::B(10); | ^ not found in `namespaced_enums` | -help: consider importing this tuple variant... +help: consider importing this tuple variant | LL | use namespaced_enums::Foo::B; | -help: ...and refer to it directly +help: if you import `B`, refer to it directly | LL - let _ = namespaced_enums::B(10); LL + let _ = B(10); @@ -36,11 +36,11 @@ error[E0422]: cannot find struct, variant or union type `C` in crate `namespaced LL | let _ = namespaced_enums::C { a: 10 }; | ^ not found in `namespaced_enums` | -help: consider importing this variant... +help: consider importing this variant | LL | use namespaced_enums::Foo::C; | -help: ...and refer to it directly +help: if you import `C`, refer to it directly | LL - let _ = namespaced_enums::C { a: 10 }; LL + let _ = C { a: 10 }; diff --git a/src/test/ui/resolve/issue-50599.stderr b/src/test/ui/resolve/issue-50599.stderr index ef0b30d98d88..4cc035cb11e2 100644 --- a/src/test/ui/resolve/issue-50599.stderr +++ b/src/test/ui/resolve/issue-50599.stderr @@ -4,13 +4,13 @@ error[E0425]: cannot find value `LOG10_2` in module `std::f64` LL | const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; | ^^^^^^^ not found in `std::f64` | -help: consider importing one of these items... +help: consider importing one of these items | LL | use std::f32::consts::LOG10_2; | LL | use std::f64::consts::LOG10_2; | -help: ...and refer to it directly +help: if you import `LOG10_2`, refer to it directly | LL - const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; LL + const M: usize = (f64::from(N) * LOG10_2) as usize; diff --git a/src/test/ui/resolve/missing-in-namespace.stderr b/src/test/ui/resolve/missing-in-namespace.stderr index 265f370494aa..338a5423aa47 100644 --- a/src/test/ui/resolve/missing-in-namespace.stderr +++ b/src/test/ui/resolve/missing-in-namespace.stderr @@ -4,11 +4,11 @@ error[E0433]: failed to resolve: could not find `hahmap` in `std` LL | let _map = std::hahmap::HashMap::new(); | ^^^^^^^ not found in `std::hahmap` | -help: consider importing this struct... +help: consider importing this struct | LL | use std::collections::HashMap; | -help: ...and refer to it directly +help: if you import `HashMap`, refer to it directly | LL - let _map = std::hahmap::HashMap::new(); LL + let _map = HashMap::new(); diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index 4ac18c0e7959..ed89170fd8a7 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -99,13 +99,13 @@ help: a function with a similar name exists | LL | let _: E = m::f; | ~ -help: consider importing one of these items instead... +help: consider importing one of these items instead | LL | use std::f32::consts::E; | LL | use std::f64::consts::E; | -help: ...and refer to it directly +help: if you import `E`, refer to it directly | LL - let _: E = m::E; LL + let _: E = E; diff --git a/src/test/ui/resolve/resolve-primitive-fallback.stderr b/src/test/ui/resolve/resolve-primitive-fallback.stderr index 3db3706ecf51..fcbc28475f99 100644 --- a/src/test/ui/resolve/resolve-primitive-fallback.stderr +++ b/src/test/ui/resolve/resolve-primitive-fallback.stderr @@ -10,11 +10,11 @@ error[E0412]: cannot find type `u8` in the crate root LL | let _: ::u8; | ^^ not found in the crate root | -help: consider importing this builtin type... +help: consider importing this builtin type | LL | use std::primitive::u8; | -help: ...and refer to it directly +help: if you import `u8`, refer to it directly | LL - let _: ::u8; LL + let _: u8; diff --git a/src/test/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr b/src/test/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr index 413a0c8d60e2..a8b275f98034 100644 --- a/src/test/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr +++ b/src/test/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr @@ -4,11 +4,11 @@ error[E0405]: cannot find trait `Trait` in `A` LL | pub struct A(pub H); | ^^^^^ not found in `A` | -help: consider importing this trait... +help: consider importing this trait | LL | use A::Trait; | -help: ...and refer to it directly +help: if you import `Trait`, refer to it directly | LL - pub struct A(pub H); LL + pub struct A(pub H);