Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2632,6 +2632,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
trait_def_id != def_id
&& trait_name == self.tcx.item_name(def_id)
&& trait_has_same_params(def_id)
// `PointeeSized` is removed during lowering.
&& !self.tcx.is_lang_item(def_id, LangItem::PointeeSized)
&& self.predicate_must_hold_modulo_regions(&Obligation::new(
self.tcx,
obligation.cause.clone(),
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/cycle-trait/pointee-sized-next-solver-ice.current.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error[E0277]: the trait bound `i32: PointeeSized` is not satisfied
--> $DIR/pointee-sized-next-solver-ice.rs:19:21
|
LL | require_trait::<i32>();
| ^^^ the trait `PointeeSized` is not implemented for `i32`
|
help: this trait has no implementations, consider adding one
--> $DIR/pointee-sized-next-solver-ice.rs:14:1
|
LL | trait PointeeSized {}
| ^^^^^^^^^^^^^^^^^^
note: required by a bound in `require_trait`
--> $DIR/pointee-sized-next-solver-ice.rs:16:21
|
LL | fn require_trait<T: PointeeSized>() {}
| ^^^^^^^^^^^^ required by this bound in `require_trait`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
20 changes: 20 additions & 0 deletions tests/ui/cycle-trait/pointee-sized-next-solver-ice.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error[E0277]: the trait bound `i32: PointeeSized` is not satisfied
--> $DIR/pointee-sized-next-solver-ice.rs:19:21
|
LL | require_trait::<i32>();
| ^^^ the trait `PointeeSized` is not implemented for `i32`
|
help: this trait has no implementations, consider adding one
--> $DIR/pointee-sized-next-solver-ice.rs:14:1
|
LL | trait PointeeSized {}
| ^^^^^^^^^^^^^^^^^^
note: required by a bound in `require_trait`
--> $DIR/pointee-sized-next-solver-ice.rs:16:21
|
LL | fn require_trait<T: PointeeSized>() {}
| ^^^^^^^^^^^^ required by this bound in `require_trait`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
21 changes: 21 additions & 0 deletions tests/ui/cycle-trait/pointee-sized-next-solver-ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)

// Regression test for https://github.com/rust-lang/rust/issues/151957
//
// When a user-defined trait shares the name `PointeeSized` with
// `core::marker::PointeeSized`, error reporting tries to check whether
// the type implements the lang-item `PointeeSized` trait via
// `predicate_must_hold_modulo_regions`. This creates a `PointeeSized`
// solver obligation which causes an ICE. We avoid this by skipping the
// `PointeeSized` lang item during the "similarly named trait" suggestion.

trait PointeeSized {}

fn require_trait<T: PointeeSized>() {}

fn main() {
require_trait::<i32>();
//~^ ERROR the trait bound `i32: PointeeSized` is not satisfied
}
Loading