Rollup merge of #106909 - compiler-errors:only-types-can-be, r=estebank

Only suggest adding type param if path being resolved was a type
This commit is contained in:
Matthias Krüger 2023-01-15 21:17:36 +01:00 committed by GitHub
commit fc78b1e7f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 16 deletions

View file

@ -3373,7 +3373,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
sugg.to_string(), sugg.to_string(),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
)) ))
} else if res.is_none() { } else if res.is_none() && matches!(source, PathSource::Type) {
this.report_missing_type_error(path) this.report_missing_type_error(path)
} else { } else {
None None

View file

@ -24,16 +24,7 @@ error[E0425]: cannot find value `F` in this scope
--> $DIR/constrain-suggest-ice.rs:6:9 --> $DIR/constrain-suggest-ice.rs:6:9
| |
LL | F LL | F
| ^ | ^ help: a local variable with a similar name exists: `x`
|
help: a local variable with a similar name exists
|
LL | x
| ~
help: you might be missing a type parameter
|
LL | struct Bug<S, F>{
| +++
error: generic `Self` types are currently not permitted in anonymous constants error: generic `Self` types are currently not permitted in anonymous constants
--> $DIR/constrain-suggest-ice.rs:3:21 --> $DIR/constrain-suggest-ice.rs:3:21

View file

@ -3,11 +3,6 @@ error[E0405]: cannot find trait `Oops` in this scope
| |
LL | let _: S<impl Oops> = S; LL | let _: S<impl Oops> = S;
| ^^^^ not found in this scope | ^^^^ 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 error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-104513-ice.rs:3:14 --> $DIR/issue-104513-ice.rs:3:14