-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify region variables when projecting associated types #73452
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions
4
src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.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
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
src/test/ui/auto-traits/auto-trait-projection-recursion.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 @@ | ||
// Checking the `Send` bound in `main` requires: | ||
// | ||
// checking <C<'static> as Y>::P: Send | ||
// which normalizes to Box<X<C<'?1>>>: Send | ||
// which needs X<C<'?1>>: Send | ||
// which needs <C<'?1> as Y>::P: Send | ||
// | ||
// At this point we used to normalize the predicate to `Box<X<C<'?2>>>: Send` | ||
// and continue in a loop where we created new region variables to the | ||
// recursion limit. To avoid this we now "canonicalize" region variables to | ||
// lowest unified region vid. This means we instead have to prove | ||
// `Box<X<C<'?1>>>: Send`, which we can because auto traits are coinductive. | ||
|
||
// check-pass | ||
|
||
// Avoid a really long error message if this regresses. | ||
#![recursion_limit="20"] | ||
|
||
trait Y { | ||
type P; | ||
} | ||
|
||
impl<'a> Y for C<'a> { | ||
type P = Box<X<C<'a>>>; | ||
} | ||
|
||
struct C<'a>(&'a ()); | ||
struct X<T: Y>(T::P); | ||
|
||
fn is_send<S: Send>() {} | ||
|
||
fn main() { | ||
is_send::<X<C<'static>>>(); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,30 @@ | ||
// Test that we don't hit the recursion limit for short cycles involving lifetimes. | ||
|
||
// Shouldn't hit this, we should realize that we're in a cycle sooner. | ||
#![recursion_limit="20"] | ||
|
||
trait NotAuto {} | ||
trait Y { | ||
type P; | ||
} | ||
|
||
impl<'a> Y for C<'a> { | ||
type P = Box<X<C<'a>>>; | ||
} | ||
|
||
struct C<'a>(&'a ()); | ||
struct X<T: Y>(T::P); | ||
|
||
impl<T: NotAuto> NotAuto for Box<T> {} | ||
impl<T: Y> NotAuto for X<T> where T::P: NotAuto {} | ||
impl<'a> NotAuto for C<'a> {} | ||
|
||
fn is_send<S: NotAuto>() {} | ||
//~^ NOTE: required | ||
|
||
fn main() { | ||
// Should only be a few notes. | ||
is_send::<X<C<'static>>>(); | ||
//~^ ERROR overflow evaluating | ||
//~| NOTE: required | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/traits/traits-inductive-overflow-lifetime.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,14 @@ | ||
error[E0275]: overflow evaluating the requirement `std::boxed::Box<X<C<'_>>>: NotAuto` | ||
--> $DIR/traits-inductive-overflow-lifetime.rs:27:5 | ||
| | ||
LL | fn is_send<S: NotAuto>() {} | ||
| ------- required by this bound in `is_send` | ||
... | ||
LL | is_send::<X<C<'static>>>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: required because of the requirements on the impl of `NotAuto` for `X<C<'static>>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0275`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we refactor with a helper like
I guess it wouldn't be quite as fast. I'd like to see that pattern used in more places, though.