diff options
| author | Michael Howell <michael@notriddle.com> | 2021-09-28 12:48:58 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2021-09-28 13:02:45 -0700 |
| commit | befdfb5c7113b3d82d973b1acfdcc2b0d9c14ab1 (patch) | |
| tree | 7f534baa92c6a38aabb23987876c0e5a4fb520f3 /src | |
| parent | 8a7c1306b43895a97c0675c6d854afa468a22aad (diff) | |
Improve error messages for bad type constraints
Co-authored-by: Esteban Kuber <esteban@kuber.com.ar>
Diffstat (limited to 'src')
4 files changed, 14 insertions, 19 deletions
diff --git a/src/test/ui/const-generics/parser-error-recovery/issue-89013-no-assoc.stderr b/src/test/ui/const-generics/parser-error-recovery/issue-89013-no-assoc.stderr index 533d381fa31..ddddd86ab9c 100644 --- a/src/test/ui/const-generics/parser-error-recovery/issue-89013-no-assoc.stderr +++ b/src/test/ui/const-generics/parser-error-recovery/issue-89013-no-assoc.stderr @@ -3,6 +3,12 @@ error: expected lifetime, type, or constant, found keyword `const` | LL | impl Foo<const 3> for Bar { | ^^^^^ + | +help: the `const` keyword is only needed in the definition of the type + | +LL - impl Foo<const 3> for Bar { +LL + impl Foo<3> for Bar { + | error: aborting due to previous error diff --git a/src/test/ui/const-generics/parser-error-recovery/issue-89013-type.rs b/src/test/ui/const-generics/parser-error-recovery/issue-89013-type.rs index c34936d1976..0ec6762b6e2 100644 --- a/src/test/ui/const-generics/parser-error-recovery/issue-89013-type.rs +++ b/src/test/ui/const-generics/parser-error-recovery/issue-89013-type.rs @@ -8,7 +8,6 @@ const T: usize = 42; impl Foo<N = type 3> for Bar { //~^ERROR missing type to the right of `=` -//~^^ERROR found keyword `type` fn do_x(&self) -> [u8; 3] { [0u8; 3] } diff --git a/src/test/ui/const-generics/parser-error-recovery/issue-89013-type.stderr b/src/test/ui/const-generics/parser-error-recovery/issue-89013-type.stderr index 0f33f4b0df6..f0d0d90c774 100644 --- a/src/test/ui/const-generics/parser-error-recovery/issue-89013-type.stderr +++ b/src/test/ui/const-generics/parser-error-recovery/issue-89013-type.stderr @@ -2,23 +2,7 @@ error: missing type to the right of `=` --> $DIR/issue-89013-type.rs:9:13 | LL | impl Foo<N = type 3> for Bar { - | ^ - | -help: to constrain the associated type, add a type after `=` - | -LL | impl Foo<N = TheType type 3> for Bar { - | +++++++ -help: remove the `=` if `N` is a type - | -LL - impl Foo<N = type 3> for Bar { -LL + impl Foo<N type 3> for Bar { - | - -error: expected one of `,`, `>`, a const expression, lifetime, or type, found keyword `type` - --> $DIR/issue-89013-type.rs:9:14 - | -LL | impl Foo<N = type 3> for Bar { - | ^^^^ expected one of `,`, `>`, a const expression, lifetime, or type + | ^---- expected type, found keyword `type` -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/const-generics/parser-error-recovery/issue-89013.stderr b/src/test/ui/const-generics/parser-error-recovery/issue-89013.stderr index 3df459ce162..a60e17aef58 100644 --- a/src/test/ui/const-generics/parser-error-recovery/issue-89013.stderr +++ b/src/test/ui/const-generics/parser-error-recovery/issue-89013.stderr @@ -3,6 +3,12 @@ error: expected lifetime, type, or constant, found keyword `const` | LL | impl Foo<N = const 3> for Bar { | ^^^^^ + | +help: the `const` keyword is only needed in the definition of the type + | +LL - impl Foo<N = const 3> for Bar { +LL + impl Foo<N = 3> for Bar { + | error: cannot constrain an associated constant to a value --> $DIR/issue-89013.rs:9:10 |
