forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#94869 - jackh726:gats_extended, r=compiler-…
…errors Add the generic_associated_types_extended feature Right now, this only ignore obligations that reference new placeholders in `poly_project_and_unify_type`. In the future, this might do other things, like allowing object-safe GATs. **This feature is *incomplete* and quite likely unsound. This is mostly just for testing out potential future APIs using a "relaxed" set of rules until we figure out *proper* rules.** Also drive by cleanup of adding a `ProjectAndUnifyResult` enum instead of using a `Result<Result<Option>>`. r? `@nikomatsakis`
- Loading branch information
Showing
13 changed files
with
249 additions
and
33 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
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
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
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: 6 additions & 0 deletions
6
src/test/ui/feature-gates/feature-gate-generic_associated_types_extended.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,6 @@ | ||
#![feature(generic_associated_types)] | ||
|
||
// This feature doesn't *currently* fire on any specific code; it's just a | ||
// behavior change. Future changes might. | ||
#[rustc_error] //~ the | ||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/feature-gates/feature-gate-generic_associated_types_extended.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,11 @@ | ||
error[E0658]: the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable | ||
--> $DIR/feature-gate-generic_associated_types_extended.rs:5:1 | ||
| | ||
LL | #[rustc_error] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
26 changes: 26 additions & 0 deletions
26
src/test/ui/generic-associated-types/extended/lending_iterator.base.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,26 @@ | ||
error[E0276]: impl has stricter requirements than trait | ||
--> $DIR/lending_iterator.rs:14:45 | ||
| | ||
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self; | ||
| ------------------------------------------------------------------------ definition of `from_iter` from trait | ||
... | ||
LL | fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> Self { | ||
| ^^^^^^^^^^^^ impl has extra requirement `I: 'x` | ||
|
||
error[E0311]: the parameter type `Self` may not live long enough | ||
--> $DIR/lending_iterator.rs:35:9 | ||
| | ||
LL | <B as FromLendingIterator<A>>::from_iter(self) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider adding an explicit lifetime bound `Self: 'a`... | ||
= note: ...so that the type `Self` will meet its required lifetime bounds... | ||
note: ...that is required by this bound | ||
--> $DIR/lending_iterator.rs:10:45 | ||
| | ||
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self; | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0276`. |
40 changes: 40 additions & 0 deletions
40
src/test/ui/generic-associated-types/extended/lending_iterator.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,40 @@ | ||
// revisions: base extended | ||
//[base] check-fail | ||
//[extended] check-pass | ||
|
||
#![feature(generic_associated_types)] | ||
#![cfg_attr(extended, feature(generic_associated_types_extended))] | ||
#![cfg_attr(extended, allow(incomplete_features))] | ||
|
||
pub trait FromLendingIterator<A>: Sized { | ||
fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self; | ||
} | ||
|
||
impl<A> FromLendingIterator<A> for Vec<A> { | ||
fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> Self { | ||
//[base]~^ impl has stricter | ||
let mut v = vec![]; | ||
while let Some(item) = iter.next() { | ||
v.push(item); | ||
} | ||
v | ||
} | ||
} | ||
|
||
pub trait LendingIterator { | ||
type Item<'z> | ||
where | ||
Self: 'z; | ||
fn next(&mut self) -> Option<Self::Item<'_>>; | ||
|
||
fn collect<A, B: FromLendingIterator<A>>(self) -> B | ||
where | ||
Self: Sized, | ||
Self: for<'q> LendingIterator<Item<'q> = A>, | ||
{ | ||
<B as FromLendingIterator<A>>::from_iter(self) | ||
//[base]~^ the parameter type | ||
} | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.