-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc_middle: Pretty-print negative bounds correctly
- Loading branch information
Showing
6 changed files
with
174 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ LL | fn test5<T>() where T: !Fn() -> i32 {} | |
| ^^^^^^^^^^^ | ||
|
||
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` |
69 changes: 69 additions & 0 deletions
69
tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.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,69 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/opaque-type-unsatisfied-bound.rs:15:36 | ||
| | ||
LL | fn weird0() -> impl Sized + !Sized {} | ||
| ------------------- ^^ types differ | ||
| | | ||
| the expected opaque type | ||
| | ||
= note: expected opaque type `impl !Sized + Sized` | ||
found unit type `()` | ||
|
||
error[E0271]: type mismatch resolving `() == impl !Sized + Sized` | ||
--> $DIR/opaque-type-unsatisfied-bound.rs:15:16 | ||
| | ||
LL | fn weird0() -> impl Sized + !Sized {} | ||
| ^^^^^^^^^^^^^^^^^^^ types differ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/opaque-type-unsatisfied-bound.rs:18:36 | ||
| | ||
LL | fn weird1() -> impl Sized + !Sized {} | ||
| ------------------- ^^ types differ | ||
| | | ||
| the expected opaque type | ||
| | ||
= note: expected opaque type `impl !Sized + Sized` | ||
found unit type `()` | ||
|
||
error[E0271]: type mismatch resolving `() == impl !Sized + Sized` | ||
--> $DIR/opaque-type-unsatisfied-bound.rs:18:16 | ||
| | ||
LL | fn weird1() -> impl Sized + !Sized {} | ||
| ^^^^^^^^^^^^^^^^^^^ types differ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/opaque-type-unsatisfied-bound.rs:21:28 | ||
| | ||
LL | fn weird2() -> impl !Sized {} | ||
| ----------- ^^ types differ | ||
| | | ||
| the expected opaque type | ||
| | ||
= note: expected opaque type `impl !Sized` | ||
found unit type `()` | ||
|
||
error[E0271]: type mismatch resolving `() == impl !Sized` | ||
--> $DIR/opaque-type-unsatisfied-bound.rs:21:16 | ||
| | ||
LL | fn weird2() -> impl !Sized {} | ||
| ^^^^^^^^^^^ types differ | ||
|
||
error[E0277]: the trait bound `impl !Trait: Trait` is not satisfied | ||
--> $DIR/opaque-type-unsatisfied-bound.rs:12:13 | ||
| | ||
LL | consume(produce()); | ||
| ------- ^^^^^^^^^ the trait `Trait` is not implemented for `impl !Trait` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `consume` | ||
--> $DIR/opaque-type-unsatisfied-bound.rs:9:20 | ||
| | ||
LL | fn consume(_: impl Trait) {} | ||
| ^^^^^ required by this bound in `consume` | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
Some errors have detailed explanations: E0271, E0277, E0308. | ||
For more information about an error, try `rustc --explain E0271`. |
9 changes: 9 additions & 0 deletions
9
tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-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,9 @@ | ||
// compile-flags: -Znext-solver | ||
|
||
#![feature(negative_bounds, unboxed_closures)] | ||
|
||
fn produce() -> impl !Fn<(u32,)> {} | ||
//~^ ERROR mismatched types | ||
//~| ERROR type mismatch resolving `() == impl !Fn<(u32,)>` | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.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,21 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:34 | ||
| | ||
LL | fn produce() -> impl !Fn<(u32,)> {} | ||
| ---------------- ^^ types differ | ||
| | | ||
| the expected opaque type | ||
| | ||
= note: expected opaque type `impl !Fn<(u32,)>` | ||
found unit type `()` | ||
|
||
error[E0271]: type mismatch resolving `() == impl !Fn<(u32,)>` | ||
--> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:17 | ||
| | ||
LL | fn produce() -> impl !Fn<(u32,)> {} | ||
| ^^^^^^^^^^^^^^^^ types differ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0271, E0308. | ||
For more information about an error, try `rustc --explain E0271`. |