-
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
Make negative_bounds
internal & fix some of its issues
#119354
Merged
Merged
Changes from all commits
Commits
Show all changes
4 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#![feature(negative_bounds, associated_type_bounds)] | ||
//~^ WARN the feature `negative_bounds` is incomplete and may not be safe to use and/or cause compiler crashes | ||
|
||
trait Trait { | ||
type Assoc; | ||
|
@@ -17,4 +16,7 @@ fn test3<T: !Trait<Assoc: Send>>() {} | |
fn test4<T>() where T: !Trait<Assoc: Send> {} | ||
//~^ ERROR associated type constraints not allowed on negative bounds | ||
|
||
fn test5<T>() where T: !Fn() -> i32 {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one used to ice with |
||
//~^ ERROR parenthetical notation may not be used for negative bounds | ||
|
||
fn main() {} |
20 changes: 9 additions & 11 deletions
20
tests/ui/traits/negative-bounds/associated-constraints.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 |
---|---|---|
@@ -1,34 +1,32 @@ | ||
error: associated type constraints not allowed on negative bounds | ||
--> $DIR/associated-constraints.rs:8:19 | ||
--> $DIR/associated-constraints.rs:7:19 | ||
| | ||
LL | fn test<T: !Trait<Assoc = i32>>() {} | ||
| ^^^^^^^^^^^ | ||
|
||
error: associated type constraints not allowed on negative bounds | ||
--> $DIR/associated-constraints.rs:11:31 | ||
--> $DIR/associated-constraints.rs:10:31 | ||
| | ||
LL | fn test2<T>() where T: !Trait<Assoc = i32> {} | ||
| ^^^^^^^^^^^ | ||
|
||
error: associated type constraints not allowed on negative bounds | ||
--> $DIR/associated-constraints.rs:14:20 | ||
--> $DIR/associated-constraints.rs:13:20 | ||
| | ||
LL | fn test3<T: !Trait<Assoc: Send>>() {} | ||
| ^^^^^^^^^^^ | ||
|
||
error: associated type constraints not allowed on negative bounds | ||
--> $DIR/associated-constraints.rs:17:31 | ||
--> $DIR/associated-constraints.rs:16:31 | ||
| | ||
LL | fn test4<T>() where T: !Trait<Assoc: Send> {} | ||
| ^^^^^^^^^^^ | ||
|
||
warning: the feature `negative_bounds` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/associated-constraints.rs:1:12 | ||
error: parenthetical notation may not be used for negative bounds | ||
--> $DIR/associated-constraints.rs:19:25 | ||
| | ||
LL | #![feature(negative_bounds, associated_type_bounds)] | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
LL | fn test5<T>() where T: !Fn() -> i32 {} | ||
| ^^^^^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors; 1 warning emitted | ||
error: aborting due to 5 previous errors | ||
|
23 changes: 23 additions & 0 deletions
23
tests/ui/traits/negative-bounds/opaque-type-unsatisfied-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// compile-flags: -Znext-solver | ||
|
||
#![feature(negative_bounds, negative_impls)] | ||
|
||
trait Trait {} | ||
impl !Trait for () {} | ||
|
||
fn produce() -> impl !Trait {} | ||
fn consume(_: impl Trait) {} | ||
|
||
fn main() { | ||
consume(produce()); //~ ERROR the trait bound `impl !Trait: Trait` is not satisfied | ||
} | ||
|
||
fn weird0() -> impl Sized + !Sized {} | ||
//~^ ERROR mismatched types | ||
//~| ERROR type mismatch resolving `() == impl !Sized + Sized` | ||
fn weird1() -> impl !Sized + Sized {} | ||
//~^ ERROR mismatched types | ||
//~| ERROR type mismatch resolving `() == impl !Sized + Sized` | ||
fn weird2() -> impl !Sized {} | ||
//~^ ERROR mismatched types | ||
//~| ERROR type mismatch resolving `() == impl !Sized` |
Oops, something went wrong.
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.
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.
I wonder if I should reject
!Sized + ?Sized
: (kinda) “redundant?Sized
bound” // “!Sized
already opts out ofSized
”.