-
Notifications
You must be signed in to change notification settings - Fork 13.4k
drop global where-bounds before merging candidates #139791
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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
21 changes: 17 additions & 4 deletions
21
tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.stderr
This file contains hidden or 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,16 +1,29 @@ | ||
error[E0275]: overflow evaluating the requirement `MultipleNested: Trait` | ||
--> $DIR/inductive-cycle-but-err.rs:43:16 | ||
| | ||
LL | impl Trait for MultipleNested | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error[E0275]: overflow evaluating the requirement `MultipleCandidates: Trait` | ||
--> $DIR/inductive-cycle-but-err.rs:46:25 | ||
| | ||
LL | MultipleCandidates: Trait, | ||
| ^^^^^ | ||
|
||
error[E0277]: the trait bound `MultipleCandidates: Trait` is not satisfied | ||
--> $DIR/inductive-cycle-but-err.rs:46:19 | ||
--> $DIR/inductive-cycle-but-err.rs:54:19 | ||
| | ||
LL | impls_trait::<MultipleCandidates>(); | ||
| ^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `MultipleCandidates` | ||
| | ||
= help: the trait `Trait` is implemented for `MultipleCandidates` | ||
note: required by a bound in `impls_trait` | ||
--> $DIR/inductive-cycle-but-err.rs:43:19 | ||
--> $DIR/inductive-cycle-but-err.rs:51:19 | ||
| | ||
LL | fn impls_trait<T: Trait>() {} | ||
| ^^^^^ required by this bound in `impls_trait` | ||
|
||
error: aborting due to 1 previous error | ||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. | ||
Some errors have detailed explanations: E0275, E0277. | ||
For more information about an error, try `rustc --explain E0275`. |
33 changes: 33 additions & 0 deletions
33
tests/ui/traits/winnowing/global-where-bound-region-constraints-2.rs
This file contains hidden or 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,33 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
// Regression test for trait-system-refactor-initiative#172. | ||
// | ||
// In this test the global where-bound simply constrains the | ||
// object lifetime bound to 'static while the builtin impl | ||
// ends up also emitting a `dyn Any: 'static` type outlives | ||
// constraint. This previously resulted in ambiguity. We now | ||
// always prefer the impl. | ||
|
||
pub trait Any: 'static {} | ||
|
||
pub trait Downcast<T>: Any | ||
where | ||
T: Any, | ||
{ | ||
} | ||
|
||
// elided object lifetime: `dyn Any + 'static` | ||
impl dyn Any { | ||
pub fn is<T>(&self) | ||
where | ||
T: Any, | ||
// elaboration adds global where-clause `dyn Any + 'static: Any` | ||
Self: Downcast<T>, | ||
{ | ||
} | ||
} | ||
|
||
fn main() {} |
29 changes: 29 additions & 0 deletions
29
tests/ui/traits/winnowing/global-where-bound-region-constraints.rs
This file contains hidden or 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,29 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
// Regression test for trait-system-refactor-initiative#172. | ||
// | ||
// The next-generation trait solver previously simply tried | ||
// to merge the global where-bounds with the impl candidates. | ||
// This caused ambiguity in case the where-bound had stricter | ||
// region requirements than the impl. | ||
|
||
trait Trait {} | ||
struct Foo<'a, 'b>(&'a (), &'b ()); | ||
impl<'a> Trait for Foo<'a, 'static> {} | ||
|
||
fn impls_trait<T: Trait>() {} | ||
fn foo() | ||
where | ||
Foo<'static, 'static>: Trait, | ||
{ | ||
// impl requires `'1 to be 'static | ||
// global where-bound requires both '0 and '1 to be 'static | ||
// | ||
// we always prefer the impl here. | ||
impls_trait::<Foo<'_, '_>>(); | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.