fix lifetime shadowing check in GATs

This commit is contained in:
Mikhail Babenko 2020-02-07 23:38:13 +03:00
parent b5e21dbb5c
commit 953f6ecb6a
3 changed files with 25 additions and 6 deletions

View file

@ -2,8 +2,8 @@
#![feature(generic_associated_types)]
trait Shadow<'a> {
//FIXME(#44265): The lifetime parameter shadowing should cause an error.
type Bar<'a>;
//~^ ERROR lifetime name `'a` shadows a lifetime name that is already in scope
}
trait NoShadow<'a> {
@ -11,8 +11,8 @@ trait NoShadow<'a> {
}
impl<'a> NoShadow<'a> for &'a u32 {
//FIXME(#44265): The lifetime parameter shadowing should cause an error.
type Bar<'a> = i32;
//~^ ERROR lifetime name `'a` shadows a lifetime name that is already in scope
}
trait ShadowT<T> {

View file

@ -14,6 +14,22 @@ LL | impl<T> NoShadowT<T> for Option<T> {
LL | type Bar<T> = i32;
| ^ already used
error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope
--> $DIR/shadowing.rs:5:14
|
LL | trait Shadow<'a> {
| -- first declared here
LL | type Bar<'a>;
| ^^ lifetime 'a already in scope
error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope
--> $DIR/shadowing.rs:14:14
|
LL | impl<'a> NoShadow<'a> for &'a u32 {
| -- first declared here
LL | type Bar<'a> = i32;
| ^^ lifetime 'a already in scope
error: type-generic associated types are not yet implemented
--> $DIR/shadowing.rs:19:5
|
@ -30,6 +46,7 @@ LL | type Bar<U>; // OK
|
= note: for more information, see https://github.com/rust-lang/rust/issues/44265
error: aborting due to 4 previous errors
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0403`.
Some errors have detailed explanations: E0403, E0496.
For more information about an error, try `rustc --explain E0403`.