-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #92333 - compiler-errors:elided-lifetime-spans, r=cjg…
…illot Tighten span when suggesting lifetime on path This is kind of a hack. Really the issue here is that we want to suggest the segment's span if the path resolves to something defined outside of the macro, and the macro's span if it resolves to something defined within.. I'll look into seeing if we can do something like that. Fixes #92324 r? `@cjgillot`
- Loading branch information
Showing
5 changed files
with
89 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
43 changes: 43 additions & 0 deletions
43
src/test/ui/in-band-lifetimes/missing-lifetime-in-alias.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters