forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#118247 - spastorino:type-equality-subtyping, …
…r=<try> Fix for TypeId exposes equality-by-subtyping vs normal-form-syntactic-equality unsoundness Fixes rust-lang#97156 This PR revives rust-lang#97427 idea, it sits on top of rust-lang#118118 because the idea uncovered some problems with IATs. r? `@lcnr` This is ICEing yet for `tests/ui/traits/new-solver/escaping-bound-vars-in-writeback-normalization.rs` using the new trait solver. After rust-lang#118118 and this ICE is fixed, we would need a rebase and a crater run. Opening as a WIP for now.
- Loading branch information
Showing
16 changed files
with
141 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
error: higher-ranked subtype error | ||
--> $DIR/issue-111404-1.rs:10:1 | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-111404-1.rs:10:11 | ||
| | ||
LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | ||
| | ||
= note: expected struct `Foo<fn(&())>` | ||
found struct `Foo<for<'b> fn(&'b ())>` | ||
|
||
error: higher-ranked subtype error | ||
--> $DIR/issue-111404-1.rs:10:1 | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-111404-1.rs:10:11 | ||
| | ||
LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | ||
| | ||
= note: expected struct `Foo<fn(&())>` | ||
found struct `Foo<for<'b> fn(&'b ())>` | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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
10 changes: 6 additions & 4 deletions
10
tests/ui/coherence/coherence-fn-covariant-bound-vs-static.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,13 +1,15 @@ | ||
error[E0119]: conflicting implementations of trait `Trait` for type `for<'r> fn(fn(&'r ()))` | ||
--> $DIR/coherence-fn-covariant-bound-vs-static.rs:17:1 | ||
warning: conflicting implementations of trait `Trait` for type `for<'r> fn(fn(&'r ()))` | ||
--> $DIR/coherence-fn-covariant-bound-vs-static.rs:19:1 | ||
| | ||
LL | impl Trait for for<'r> fn(fn(&'r ())) {} | ||
| ------------------------------------- first implementation here | ||
LL | impl<'a> Trait for fn(fn(&'a ())) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'r> fn(fn(&'r ()))` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105> | ||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details | ||
= note: `#[warn(coherence_leak_check)]` on by default | ||
|
||
error: aborting due to 1 previous error | ||
warning: 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0119`. |
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,13 +1,15 @@ | ||
error[E0119]: conflicting implementations of trait `Trait` for type `for<'a, 'b> fn(&'a u32, &'b u32)` | ||
--> $DIR/coherence-fn-inputs.rs:15:1 | ||
warning: conflicting implementations of trait `Trait` for type `for<'a, 'b> fn(&'a u32, &'b u32)` | ||
--> $DIR/coherence-fn-inputs.rs:17:1 | ||
| | ||
LL | impl Trait for for<'a, 'b> fn(&'a u32, &'b u32) {} | ||
| ----------------------------------------------- first implementation here | ||
LL | impl Trait for for<'c> fn(&'c u32, &'c u32) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u32, &'b u32)` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105> | ||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details | ||
= note: `#[warn(coherence_leak_check)]` on by default | ||
|
||
error: aborting due to 1 previous error | ||
warning: 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0119`. |
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
11 changes: 11 additions & 0 deletions
11
tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-covariant.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: implementation of `Trait` is not general enough | ||
--> $DIR/hrtb-exists-forall-trait-covariant.rs:34:5 | ||
| | ||
LL | foo::<()>(); | ||
| ^^^^^^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `()` must implement `Trait<for<'b> fn(fn(&'b u32))>` | ||
= note: ...but it actually implements `Trait<fn(fn(&'0 u32))>`, for some specific lifetime `'0` | ||
|
||
error: aborting due to 1 previous error | ||
|
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0308]: `match` arms have incompatible types | ||
--> $DIR/old-lub-glb-hr-eq.rs:13:14 | ||
| | ||
LL | let z = match 22 { | ||
| _____________- | ||
LL | | 0 => x, | ||
| | - this is found to be of type `for<'a, 'b> fn(&'a u8, &'b u8)` | ||
LL | | _ => y, | ||
| | ^ one type is more general than the other | ||
LL | | | ||
LL | | }; | ||
| |_____- `match` arms have incompatible types | ||
| | ||
= note: expected fn pointer `for<'a, 'b> fn(&'a u8, &'b u8)` | ||
found fn pointer `for<'a> fn(&'a u8, &'a u8)` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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
22 changes: 22 additions & 0 deletions
22
tests/ui/traits/new-solver/member-constraints-in-root-universe.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,22 @@ | ||
error: the type `<for<'a, 'b> fn(&'a u8, &'b u8) as Trait>::Ty` is not well-formed | ||
--> $DIR/member-constraints-in-root-universe.rs:12:16 | ||
| | ||
LL | fn test<'a>(_: <fn(&u8, &u8) as Trait>::Ty) -> impl Sized { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0277]: the size for values of type `<for<'a, 'b> fn(&'a u8, &'b u8) as Trait>::Ty` cannot be known at compilation time | ||
--> $DIR/member-constraints-in-root-universe.rs:12:13 | ||
| | ||
LL | fn test<'a>(_: <fn(&u8, &u8) as Trait>::Ty) -> impl Sized { | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `<for<'a, 'b> fn(&'a u8, &'b u8) as Trait>::Ty` | ||
= help: unsized fn params are gated as an unstable feature | ||
help: function arguments must have a statically known size, borrowed types always have a known size | ||
| | ||
LL | fn test<'a>(_: &<fn(&u8, &u8) as Trait>::Ty) -> impl Sized { | ||
| + | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |