Skip to content

Commit 566202b

Browse files
Only suggest adding type param if path being resolved was a type
1 parent fc11ee0 commit 566202b

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
lines changed

compiler/rustc_resolve/src/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3373,7 +3373,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
33733373
sugg.to_string(),
33743374
Applicability::MaybeIncorrect,
33753375
))
3376-
} else if res.is_none() {
3376+
} else if res.is_none() && matches!(source, PathSource::Type) {
33773377
this.report_missing_type_error(path)
33783378
} else {
33793379
None

tests/ui/suggestions/constrain-suggest-ice.stderr

+1-10
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,7 @@ error[E0425]: cannot find value `F` in this scope
2424
--> $DIR/constrain-suggest-ice.rs:6:9
2525
|
2626
LL | F
27-
| ^
28-
|
29-
help: a local variable with a similar name exists
30-
|
31-
LL | x
32-
| ~
33-
help: you might be missing a type parameter
34-
|
35-
LL | struct Bug<S, F>{
36-
| +++
27+
| ^ help: a local variable with a similar name exists: `x`
3728

3829
error: generic `Self` types are currently not permitted in anonymous constants
3930
--> $DIR/constrain-suggest-ice.rs:3:21

tests/ui/typeck/issue-104513-ice.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ error[E0405]: cannot find trait `Oops` in this scope
33
|
44
LL | let _: S<impl Oops> = S;
55
| ^^^^ not found in this scope
6-
|
7-
help: you might be missing a type parameter
8-
|
9-
LL | fn f<Oops>() {
10-
| ++++++
116

127
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
138
--> $DIR/issue-104513-ice.rs:3:14

0 commit comments

Comments
 (0)