Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify region variables when projecting associated types
This is required to avoid cycles when evaluating auto trait predicates.
- Loading branch information
1 parent
435f97c
commit ba2ef58
Showing
29 changed files
with
133 additions
and
35 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
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`. |