Skip to content

Commit 3d91c3e

Browse files
Rollup merge of rust-lang#151962 - TaKO8Ki:pointee-sized-next-solver-ice, r=lcnr
Fix next-solver ICE on PointeeSized goals Fixes rust-lang#151957
2 parents 8d50bcc + ca74063 commit 3d91c3e

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,6 +2632,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
26322632
trait_def_id != def_id
26332633
&& trait_name == self.tcx.item_name(def_id)
26342634
&& trait_has_same_params(def_id)
2635+
// `PointeeSized` is removed during lowering.
2636+
&& !self.tcx.is_lang_item(def_id, LangItem::PointeeSized)
26352637
&& self.predicate_must_hold_modulo_regions(&Obligation::new(
26362638
self.tcx,
26372639
obligation.cause.clone(),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0277]: the trait bound `i32: PointeeSized` is not satisfied
2+
--> $DIR/pointee-sized-next-solver-ice.rs:19:21
3+
|
4+
LL | require_trait::<i32>();
5+
| ^^^ the trait `PointeeSized` is not implemented for `i32`
6+
|
7+
help: this trait has no implementations, consider adding one
8+
--> $DIR/pointee-sized-next-solver-ice.rs:14:1
9+
|
10+
LL | trait PointeeSized {}
11+
| ^^^^^^^^^^^^^^^^^^
12+
note: required by a bound in `require_trait`
13+
--> $DIR/pointee-sized-next-solver-ice.rs:16:21
14+
|
15+
LL | fn require_trait<T: PointeeSized>() {}
16+
| ^^^^^^^^^^^^ required by this bound in `require_trait`
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0277]: the trait bound `i32: PointeeSized` is not satisfied
2+
--> $DIR/pointee-sized-next-solver-ice.rs:19:21
3+
|
4+
LL | require_trait::<i32>();
5+
| ^^^ the trait `PointeeSized` is not implemented for `i32`
6+
|
7+
help: this trait has no implementations, consider adding one
8+
--> $DIR/pointee-sized-next-solver-ice.rs:14:1
9+
|
10+
LL | trait PointeeSized {}
11+
| ^^^^^^^^^^^^^^^^^^
12+
note: required by a bound in `require_trait`
13+
--> $DIR/pointee-sized-next-solver-ice.rs:16:21
14+
|
15+
LL | fn require_trait<T: PointeeSized>() {}
16+
| ^^^^^^^^^^^^ required by this bound in `require_trait`
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ revisions: current next
2+
//@[next] compile-flags: -Znext-solver
3+
//@ ignore-compare-mode-next-solver (explicit revisions)
4+
5+
// Regression test for https://github.com/rust-lang/rust/issues/151957
6+
//
7+
// When a user-defined trait shares the name `PointeeSized` with
8+
// `core::marker::PointeeSized`, error reporting tries to check whether
9+
// the type implements the lang-item `PointeeSized` trait via
10+
// `predicate_must_hold_modulo_regions`. This creates a `PointeeSized`
11+
// solver obligation which causes an ICE. We avoid this by skipping the
12+
// `PointeeSized` lang item during the "similarly named trait" suggestion.
13+
14+
trait PointeeSized {}
15+
16+
fn require_trait<T: PointeeSized>() {}
17+
18+
fn main() {
19+
require_trait::<i32>();
20+
//~^ ERROR the trait bound `i32: PointeeSized` is not satisfied
21+
}

0 commit comments

Comments
 (0)