From 4c72efc8167405ca1cc3002266a9bf15f70dafb3 Mon Sep 17 00:00:00 2001 From: mibac138 <5672750+mibac138@users.noreply.github.com> Date: Thu, 6 May 2021 14:33:23 +0200 Subject: Fix impl type parameter suggestion involving consts --- .../missing-items/missing-type-parameter2.rs | 6 ++- .../missing-items/missing-type-parameter2.stderr | 52 ++++++++++++++++++---- 2 files changed, 49 insertions(+), 9 deletions(-) (limited to 'src/test/ui/missing') diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.rs b/src/test/ui/missing/missing-items/missing-type-parameter2.rs index e5d90bb6ff0..15dc5ef797b 100644 --- a/src/test/ui/missing/missing-items/missing-type-parameter2.rs +++ b/src/test/ui/missing/missing-items/missing-type-parameter2.rs @@ -11,7 +11,11 @@ impl X {} //~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| ERROR unresolved item provided when a constant was expected -fn bar(a: A) {} +fn foo(_: T) where T: Send {} +//~^ ERROR cannot find type `T` in this scope +//~| ERROR cannot find type `T` in this scope + +fn bar(_: A) {} //~^ ERROR cannot find type `A` in this scope fn main() { diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.stderr b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr index 545be1c34fb..985a9bb2a3f 100644 --- a/src/test/ui/missing/missing-items/missing-type-parameter2.stderr +++ b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr @@ -30,26 +30,62 @@ LL | impl X {} | ^ help: you might be missing a type parameter | -LL | impl X {} - | ^^^ +LL | impl X {} + | ^^^ + +error[E0412]: cannot find type `T` in this scope + --> $DIR/missing-type-parameter2.rs:14:20 + | +LL | struct X(); + | ------------------------ similarly named struct `X` defined here +... +LL | fn foo(_: T) where T: Send {} + | ^ + | +help: a struct with a similar name exists + | +LL | fn foo(_: T) where X: Send {} + | ^ +help: you might be missing a type parameter + | +LL | fn foo(_: T) where T: Send {} + | ^^^ + +error[E0412]: cannot find type `T` in this scope + --> $DIR/missing-type-parameter2.rs:14:11 + | +LL | struct X(); + | ------------------------ similarly named struct `X` defined here +... +LL | fn foo(_: T) where T: Send {} + | ^ + | +help: a struct with a similar name exists + | +LL | fn foo(_: X) where T: Send {} + | ^ +help: you might be missing a type parameter + | +LL | fn foo(_: T) where T: Send {} + | ^^^ error[E0412]: cannot find type `A` in this scope - --> $DIR/missing-type-parameter2.rs:14:24 + --> $DIR/missing-type-parameter2.rs:18:24 | LL | struct X(); | ------------------------ similarly named struct `X` defined here ... -LL | fn bar(a: A) {} +LL | fn bar(_: A) {} | ^ | help: a struct with a similar name exists | -LL | fn bar(a: X) {} +LL | fn bar(_: X) {} | ^ help: you might be missing a type parameter | -LL | fn bar(a: A) {} - | ^^^ +LL | fn bar(_: A) {} + | ^^^ error[E0747]: unresolved item provided when a constant was expected --> $DIR/missing-type-parameter2.rs:6:8 @@ -79,7 +115,7 @@ help: if this generic argument was intended as a const parameter, surround it wi LL | impl X<{ N }> {} | ^ ^ -error: aborting due to 6 previous errors +error: aborting due to 8 previous errors Some errors have detailed explanations: E0412, E0747. For more information about an error, try `rustc --explain E0412`. -- cgit 1.4.1-3-g733a5