forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#46706 - sunjay:gat-lifetimes, r=nikomatsakis
Lifetime Resolution for Generic Associated Types Tracking Issue: rust-lang#44265 r? @nikomatsakis This PR implements lifetime resolution for generic associated types. 🎉 ## Remaining Work Before Merge I'm going to go do these things in the next day or so. Please let me know if you spot anything in my changes until then. - [x] If I'm not mistaken, at least some tests should pass now. I need to go through the tests and re-enable the ones that should work by removing the appropriate `~ ERROR` comments
- Loading branch information
Showing
9 changed files
with
155 additions
and
53 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
12 changes: 3 additions & 9 deletions
12
src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.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 |
---|---|---|
@@ -1,14 +1,8 @@ | ||
error[E0261]: use of undeclared lifetime name `'a` | ||
--> $DIR/construct_with_other_type.rs:24:37 | ||
| | ||
24 | type Quux<'a> = <T as Foo>::Bar<'a, 'static>; | ||
| ^^ undeclared lifetime | ||
|
||
error[E0110]: lifetime parameters are not allowed on this type | ||
--> $DIR/construct_with_other_type.rs:24:37 | ||
--> $DIR/construct_with_other_type.rs:25:37 | ||
| | ||
24 | type Quux<'a> = <T as Foo>::Bar<'a, 'static>; | ||
25 | type Quux<'a> = <T as Foo>::Bar<'a, 'static>; | ||
| ^^ lifetime parameter not allowed on this type | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to previous error | ||
|
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
6 changes: 0 additions & 6 deletions
6
src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.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 |
---|---|---|
@@ -1,8 +1,2 @@ | ||
error[E0261]: use of undeclared lifetime name `'a` | ||
--> $DIR/generic-associated-types-where.rs:34:32 | ||
| | ||
34 | type WithDefault<'a, T> = &'a Iterator<T>; | ||
| ^^ undeclared lifetime | ||
|
||
error: cannot continue compilation due to previous error | ||
|
31 changes: 31 additions & 0 deletions
31
src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.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,31 @@ | ||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(generic_associated_types)] | ||
|
||
use std::ops::Deref; | ||
|
||
//FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a | ||
//follow-up PR | ||
|
||
trait Iterable { | ||
type Item<'a>; | ||
type Iter<'a>: Iterator<Item = Self::Item<'a>> | ||
//~^ ERROR lifetime parameters are not allowed on this type [E0110] | ||
+ Deref<Target = Self::Item<'b>>; | ||
//~^ ERROR undeclared lifetime | ||
//~| ERROR lifetime parameters are not allowed on this type [E0110] | ||
|
||
fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; | ||
//~^ ERROR undeclared lifetime | ||
//~| ERROR lifetime parameters are not allowed on this type [E0110] | ||
} | ||
|
||
fn main() {} |
32 changes: 32 additions & 0 deletions
32
...t/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.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,32 @@ | ||
error[E0261]: use of undeclared lifetime name `'b` | ||
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37 | ||
| | ||
22 | + Deref<Target = Self::Item<'b>>; | ||
| ^^ undeclared lifetime | ||
|
||
error[E0261]: use of undeclared lifetime name `'undeclared` | ||
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41 | ||
| | ||
26 | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; | ||
| ^^^^^^^^^^^ undeclared lifetime | ||
|
||
error[E0110]: lifetime parameters are not allowed on this type | ||
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:20:47 | ||
| | ||
20 | type Iter<'a>: Iterator<Item = Self::Item<'a>> | ||
| ^^ lifetime parameter not allowed on this type | ||
|
||
error[E0110]: lifetime parameters are not allowed on this type | ||
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37 | ||
| | ||
22 | + Deref<Target = Self::Item<'b>>; | ||
| ^^ lifetime parameter not allowed on this type | ||
|
||
error[E0110]: lifetime parameters are not allowed on this type | ||
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41 | ||
| | ||
26 | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; | ||
| ^^^^^^^^^^^ lifetime parameter not allowed on this type | ||
|
||
error: aborting due to 5 previous errors | ||
|
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
18 changes: 9 additions & 9 deletions
18
src/test/ui/rfc1598-generic-associated-types/iterable.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