From bf0623e3633a371374341265c8729f6255bfde4c Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 8 Jan 2023 23:27:22 +0000 Subject: [PATCH] Don't suggest dyn as parameter to add --- compiler/rustc_resolve/src/late/diagnostics.rs | 6 +++++- src/tools/clippy/tests/ui/crashes/ice-6252.stderr | 9 ++++++--- tests/ui/issues/issue-86756.stderr | 5 ----- tests/ui/parser/dyn-trait-compatibility.stderr | 15 --------------- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index d92f5a7c05e6d..d92b046d0b9f2 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -2065,7 +2065,11 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { path: &[Segment], ) -> Option<(Span, &'static str, String, Applicability)> { let (ident, span) = match path { - [segment] if !segment.has_generic_args && segment.ident.name != kw::SelfUpper => { + [segment] + if !segment.has_generic_args + && segment.ident.name != kw::SelfUpper + && segment.ident.name != kw::Dyn => + { (segment.ident.to_string(), segment.ident.span) } _ => return None, diff --git a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr index 638e4a5484932..efdd56dd47d39 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr @@ -17,9 +17,12 @@ error[E0412]: cannot find type `VAL` in this scope --> $DIR/ice-6252.rs:10:63 | LL | impl TypeVal for Multiply where N: TypeVal {} - | - ^^^ not found in this scope - | | - | help: you might be missing a type parameter: `, VAL` + | ^^^ not found in this scope + | +help: you might be missing a type parameter + | +LL | impl TypeVal for Multiply where N: TypeVal {} + | +++++ error[E0046]: not all trait items implemented, missing: `VAL` --> $DIR/ice-6252.rs:10:1 diff --git a/tests/ui/issues/issue-86756.stderr b/tests/ui/issues/issue-86756.stderr index e0f37129fd2ed..bfa7459ab4a39 100644 --- a/tests/ui/issues/issue-86756.stderr +++ b/tests/ui/issues/issue-86756.stderr @@ -11,11 +11,6 @@ error[E0412]: cannot find type `dyn` in this scope | LL | eq:: | ^^^ not found in this scope - | -help: you might be missing a type parameter - | -LL | fn eq() { - | +++++ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-86756.rs:5:15 diff --git a/tests/ui/parser/dyn-trait-compatibility.stderr b/tests/ui/parser/dyn-trait-compatibility.stderr index 6a946ea2ae098..0cae01bd1e329 100644 --- a/tests/ui/parser/dyn-trait-compatibility.stderr +++ b/tests/ui/parser/dyn-trait-compatibility.stderr @@ -27,22 +27,12 @@ error[E0412]: cannot find type `dyn` in this scope | LL | type A2 = dyn; | ^^^ not found in this scope - | -help: you might be missing a type parameter - | -LL | type A2 = dyn; - | +++++ error[E0412]: cannot find type `dyn` in this scope --> $DIR/dyn-trait-compatibility.rs:5:20 | LL | type A2 = dyn; | ^^^ not found in this scope - | -help: you might be missing a type parameter - | -LL | type A2 = dyn; - | +++++ error[E0412]: cannot find type `dyn` in this scope --> $DIR/dyn-trait-compatibility.rs:9:11 @@ -55,11 +45,6 @@ error[E0412]: cannot find type `dyn` in this scope | LL | type A3 = dyn<::dyn>; | ^^^ not found in this scope - | -help: you might be missing a type parameter - | -LL | type A3 = dyn<::dyn>; - | +++++ error: aborting due to 8 previous errors