Skip to content

Only suggest adding type param if path being resolved was a type #106909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions tests/ui/suggestions/constrain-suggest-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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<S, F>{
| +++
| ^ 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
Expand Down
5 changes: 0 additions & 5 deletions tests/ui/typeck/issue-104513-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ error[E0405]: cannot find trait `Oops` in this scope
|
LL | let _: S<impl Oops> = S;
| ^^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | fn f<Oops>() {
| ++++++

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