about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-02-13 21:28:00 +0100
committerGitHub <noreply@github.com>2020-02-13 21:28:00 +0100
commit998daf36b9b71549af6606fac8a30c39c21d9218 (patch)
treee3be7173f7c1fc7f13ab5e3c8360134ef345ef73
parent89f5dcfb4316891fafb34d211b7bebc4cf8638d0 (diff)
parent953f6ecb6adc37b4f8e52102c1e7ca86cc5bc92c (diff)
downloadrust-998daf36b9b71549af6606fac8a30c39c21d9218.tar.gz
rust-998daf36b9b71549af6606fac8a30c39c21d9218.zip
Rollup merge of #68938 - Areredify:gat_lifetime_shadowing, r=estebank
fix lifetime shadowing check in GATs

closes #67512
-rw-r--r--src/librustc_resolve/lifetimes.rs6
-rw-r--r--src/test/ui/generic-associated-types/shadowing.rs4
-rw-r--r--src/test/ui/generic-associated-types/shadowing.stderr21
3 files changed, 25 insertions, 6 deletions
diff --git a/src/librustc_resolve/lifetimes.rs b/src/librustc_resolve/lifetimes.rs
index fd4d2c718c0..5bc5222f9fc 100644
--- a/src/librustc_resolve/lifetimes.rs
+++ b/src/librustc_resolve/lifetimes.rs
@@ -747,7 +747,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                     track_lifetime_uses: true,
                     opaque_type_parent: true,
                 };
-                self.with(scope, |_old_scope, this| {
+                self.with(scope, |old_scope, this| {
+                    this.check_lifetime_params(old_scope, &generics.params);
                     this.visit_generics(generics);
                     for bound in bounds {
                         this.visit_param_bound(bound);
@@ -804,7 +805,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
                     track_lifetime_uses: true,
                     opaque_type_parent: true,
                 };
-                self.with(scope, |_old_scope, this| {
+                self.with(scope, |old_scope, this| {
+                    this.check_lifetime_params(old_scope, &generics.params);
                     this.visit_generics(generics);
                     this.visit_ty(ty);
                 });
diff --git a/src/test/ui/generic-associated-types/shadowing.rs b/src/test/ui/generic-associated-types/shadowing.rs
index 7277c0d87c6..5c308948bd3 100644
--- a/src/test/ui/generic-associated-types/shadowing.rs
+++ b/src/test/ui/generic-associated-types/shadowing.rs
@@ -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> {
diff --git a/src/test/ui/generic-associated-types/shadowing.stderr b/src/test/ui/generic-associated-types/shadowing.stderr
index 3ae1e1a40c8..2d9a0d6fceb 100644
--- a/src/test/ui/generic-associated-types/shadowing.stderr
+++ b/src/test/ui/generic-associated-types/shadowing.stderr
@@ -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 issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
 
-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`.