-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #109748 - compiler-errors:new-solver-discr-kind-ice, …
…r=lcnr Don't ICE on `DiscriminantKind` projection in new solver As title says, since we now actually call `Ty::discriminant_kind` on placeholder types 😃 Also drive-by simplify `Pointee::Metadata` projection logic, and fix the UI test because the `<T as Pointee>::Metadata` tests weren't actually exercising the new projection logic, since we still eagerly normalize (which hits `project.rs` in the old solver) in HIR typeck. r? `@lcnr` tho feel free to re-roll, this pr is very low-priority and not super specific to the new trait solver. Fixes compiler-errors/next-solver-hir-issues#14
- Loading branch information
Showing
5 changed files
with
94 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// compile-flags: -Ztrait-solver=next | ||
// check-pass | ||
|
||
fn foo<T>(x: T) { | ||
std::mem::discriminant(&x); | ||
} | ||
|
||
fn main() {} |
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,18 @@ | ||
// compile-flags: -Ztrait-solver=next | ||
|
||
// Check that `<T::Assoc as DiscriminantKind>::Discriminant` doesn't normalize | ||
// to itself and cause overflow/ambiguity. | ||
|
||
trait Foo { | ||
type Assoc; | ||
} | ||
|
||
trait Bar {} | ||
fn needs_bar(_: impl Bar) {} | ||
|
||
fn foo<T: Foo>(x: T::Assoc) { | ||
needs_bar(std::mem::discriminant(&x)); | ||
//~^ ERROR the trait bound `Discriminant<<T as Foo>::Assoc>: Bar` is not satisfied | ||
} | ||
|
||
fn main() {} |
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,17 @@ | ||
error[E0277]: the trait bound `Discriminant<<T as Foo>::Assoc>: Bar` is not satisfied | ||
--> $DIR/projection-discr-kind.rs:14:15 | ||
| | ||
LL | needs_bar(std::mem::discriminant(&x)); | ||
| --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `Discriminant<<T as Foo>::Assoc>` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `needs_bar` | ||
--> $DIR/projection-discr-kind.rs:11:22 | ||
| | ||
LL | fn needs_bar(_: impl Bar) {} | ||
| ^^^ required by this bound in `needs_bar` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |