diff options
| author | Michael Goulet <michael@errs.io> | 2021-12-27 14:10:59 -0800 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2021-12-27 23:34:52 -0800 |
| commit | e37d012a0629a20ea9a79efc8434d636f37487d9 (patch) | |
| tree | 2737a79d8a0ac80682f7f6311008c50e6d965ce8 /src | |
| parent | 51e8031e14a899477a5e2d78ce461cab31123354 (diff) | |
Tighten span when suggesting lifetime on path
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.rs | 34 | ||||
| -rw-r--r-- | src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.stderr | 43 | ||||
| -rw-r--r-- | src/test/ui/lint/reasons.stderr | 6 |
3 files changed, 80 insertions, 3 deletions
diff --git a/src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.rs b/src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.rs new file mode 100644 index 00000000000..800f03302ed --- /dev/null +++ b/src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.rs @@ -0,0 +1,34 @@ +#![feature(generic_associated_types)] +#![allow(unused)] + +trait Trait<'a> { + type Foo; + + type Bar<'b> + //~^ NOTE associated type defined here, with 1 lifetime parameter + //~| NOTE + where + Self: 'b; +} + +struct Impl<'a>(&'a ()); + +impl<'a> Trait<'a> for Impl<'a> { + type Foo = &'a (); + type Bar<'b> = &'b (); +} + +type A<'a> = Impl<'a>; + +type B<'a> = <A<'a> as Trait>::Foo; +//~^ ERROR missing lifetime specifier +//~| NOTE expected named lifetime parameter + +type C<'a, 'b> = <A<'a> as Trait>::Bar; +//~^ ERROR missing lifetime specifier +//~| ERROR missing generics for associated type +//~| NOTE expected named lifetime parameter +//~| NOTE these named lifetimes are available to use +//~| NOTE expected 1 lifetime argument + +fn main() {} diff --git a/src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.stderr b/src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.stderr new file mode 100644 index 00000000000..f1b951fc826 --- /dev/null +++ b/src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.stderr @@ -0,0 +1,43 @@ +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-alias.rs:23:24 + | +LL | type B<'a> = <A<'a> as Trait>::Foo; + | ^^^^^ expected named lifetime parameter + | +help: consider using the `'a` lifetime + | +LL | type B<'a> = <A<'a> as Trait<'a>>::Foo; + | ~~~~~~~~~ + +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-alias.rs:27:28 + | +LL | type C<'a, 'b> = <A<'a> as Trait>::Bar; + | ^^^^^ expected named lifetime parameter + | +note: these named lifetimes are available to use + --> $DIR/missing-lifetime-in-alias.rs:27:8 + | +LL | type C<'a, 'b> = <A<'a> as Trait>::Bar; + | ^^ ^^ + +error[E0107]: missing generics for associated type `Trait::Bar` + --> $DIR/missing-lifetime-in-alias.rs:27:36 + | +LL | type C<'a, 'b> = <A<'a> as Trait>::Bar; + | ^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'b` + --> $DIR/missing-lifetime-in-alias.rs:7:10 + | +LL | type Bar<'b> + | ^^^ -- +help: add missing lifetime argument + | +LL | type C<'a, 'b> = <A<'a> as Trait>::Bar<'a>; + | ~~~~~~~ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0106, E0107. +For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/lint/reasons.stderr b/src/test/ui/lint/reasons.stderr index f797c89a032..a692d6af703 100644 --- a/src/test/ui/lint/reasons.stderr +++ b/src/test/ui/lint/reasons.stderr @@ -1,8 +1,8 @@ warning: hidden lifetime parameters in types are deprecated - --> $DIR/reasons.rs:20:29 + --> $DIR/reasons.rs:20:34 | LL | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - | ^^^^^^^^^^^^^^ expected named lifetime parameter + | ^^^^^^^^^ expected named lifetime parameter | = note: explicit anonymous lifetimes aid reasoning about ownership note: the lint level is defined here @@ -13,7 +13,7 @@ LL | #