From 566202b97511b27e66312f67faacffb7272d7dbb Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 15 Jan 2023 16:33:08 +0000 Subject: [PATCH] Only suggest adding type param if path being resolved was a type --- compiler/rustc_resolve/src/late.rs | 2 +- tests/ui/suggestions/constrain-suggest-ice.stderr | 11 +---------- tests/ui/typeck/issue-104513-ice.stderr | 5 ----- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index ca43762aa21..6ca7cd3e713 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -3373,7 +3373,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { sugg.to_string(), Applicability::MaybeIncorrect, )) - } else if res.is_none() { + } else if res.is_none() && matches!(source, PathSource::Type) { this.report_missing_type_error(path) } else { None diff --git a/tests/ui/suggestions/constrain-suggest-ice.stderr b/tests/ui/suggestions/constrain-suggest-ice.stderr index 477eb278679..2af7c2f6971 100644 --- a/tests/ui/suggestions/constrain-suggest-ice.stderr +++ b/tests/ui/suggestions/constrain-suggest-ice.stderr @@ -24,16 +24,7 @@ error[E0425]: cannot find value `F` in this scope --> $DIR/constrain-suggest-ice.rs:6:9 | LL | F - | ^ - | -help: a local variable with a similar name exists - | -LL | x - | ~ -help: you might be missing a type parameter - | -LL | struct Bug{ - | +++ + | ^ help: a local variable with a similar name exists: `x` error: generic `Self` types are currently not permitted in anonymous constants --> $DIR/constrain-suggest-ice.rs:3:21 diff --git a/tests/ui/typeck/issue-104513-ice.stderr b/tests/ui/typeck/issue-104513-ice.stderr index 5561673f3c6..42cfe38aed8 100644 --- a/tests/ui/typeck/issue-104513-ice.stderr +++ b/tests/ui/typeck/issue-104513-ice.stderr @@ -3,11 +3,6 @@ error[E0405]: cannot find trait `Oops` in this scope | LL | let _: S = S; | ^^^^ not found in this scope - | -help: you might be missing a type parameter - | -LL | fn f() { - | ++++++ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding --> $DIR/issue-104513-ice.rs:3:14