-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make regionck care about placeholders in outlives components
- Loading branch information
1 parent
290fc68
commit 8f267e2
Showing
16 changed files
with
177 additions
and
13 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
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
14 changes: 14 additions & 0 deletions
14
tests/ui/coherence/negative-coherence-check-placeholder-outlives.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,14 @@ | ||
#![feature(negative_impls)] | ||
#![feature(with_negative_coherence)] | ||
|
||
struct Wrap<T>(T); | ||
|
||
trait Foo {} | ||
impl<T: 'static> !Foo for Box<T> {} | ||
|
||
trait Bar {} | ||
impl<T> Bar for T where T: Foo {} | ||
impl<T> Bar for Box<T> {} | ||
//~^ ERROR conflicting implementations of trait `Bar` for type `Box<_>` | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui/coherence/negative-coherence-check-placeholder-outlives.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[E0119]: conflicting implementations of trait `Bar` for type `Box<_>` | ||
--> $DIR/negative-coherence-check-placeholder-outlives.rs:11:1 | ||
| | ||
LL | impl<T> Bar for T where T: Foo {} | ||
| ------------------------------ first implementation here | ||
LL | impl<T> Bar for Box<T> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0119`. |
26 changes: 26 additions & 0 deletions
26
tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.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 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/placeholders-dont-outlive-static.rs:6:12 | ||
| | ||
LL | #![feature(non_lifetime_binders)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0310]: the placeholder type `!1_"T"` may not live long enough | ||
--> $DIR/placeholders-dont-outlive-static.rs:13:5 | ||
| | ||
LL | foo(); | ||
| ^^^^^ | ||
| | | ||
| the placeholder type `!1_"T"` must be valid for the static lifetime... | ||
| ...so that the type `T` will meet its required lifetime bounds | ||
| | ||
help: consider adding an explicit lifetime bound | ||
| | ||
LL | fn bad() where !1_"T": 'static { | ||
| +++++++++++++++++++++ | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0310`. |
26 changes: 26 additions & 0 deletions
26
tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.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 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/placeholders-dont-outlive-static.rs:6:12 | ||
| | ||
LL | #![feature(non_lifetime_binders)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0310]: the placeholder type `!1_"T"` may not live long enough | ||
--> $DIR/placeholders-dont-outlive-static.rs:19:5 | ||
| | ||
LL | foo(); | ||
| ^^^^^ | ||
| | | ||
| the placeholder type `!1_"T"` must be valid for the static lifetime... | ||
| ...so that the type `T` will meet its required lifetime bounds | ||
| | ||
help: consider adding an explicit lifetime bound | ||
| | ||
LL | fn good() where for<T> T: 'static, !1_"T": 'static { | ||
| +++++++++++++++++ | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0310`. |
22 changes: 22 additions & 0 deletions
22
tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.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,22 @@ | ||
// revisions: good bad | ||
|
||
//[good] known-bug: unknown | ||
// `for<T> T: 'static` doesn't imply itself when processing outlives obligations | ||
|
||
#![feature(non_lifetime_binders)] | ||
//[bad]~^ WARN the feature `non_lifetime_binders` is incomplete | ||
|
||
fn foo() where for<T> T: 'static {} | ||
|
||
#[cfg(bad)] | ||
fn bad() { | ||
foo(); | ||
//[bad]~^ ERROR the placeholder type `!1_"T"` may not live long enough | ||
} | ||
|
||
#[cfg(good)] | ||
fn good() where for<T> T: 'static { | ||
foo(); | ||
} | ||
|
||
fn main() {} |
3 changes: 1 addition & 2 deletions
3
tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.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
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