Skip to content

Commit e7d308c

Browse files
committed
trait_sel: delay bug for removed pointeesized
This code path isn't hit during normal compilation, only in error reporting, so delaying the bug is sufficient. It might be possible to trigger this with `dyn PointeeSized` and code that doesn't error but no such example could be found at the time of writing.
1 parent 27733d4 commit e7d308c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
101101
);
102102
}
103103
Some(LangItem::PointeeSized) => {
104-
bug!("`PointeeSized` is removed during lowering");
104+
tcx.dcx().delayed_bug("`PointeeSized` is removed during lowering");
105105
}
106106
Some(LangItem::Unsize) => {
107107
self.assemble_candidates_for_unsizing(obligation, &mut candidates);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(sized_hierarchy)]
2+
3+
use std::marker::PointeeSized;
4+
5+
fn main() {
6+
let x = main;
7+
let y: Box<dyn PointeeSized> = x;
8+
//~^ ERROR mismatched types
9+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/dyn-pointeesized-issue-142652.rs:7:38
3+
|
4+
LL | let y: Box<dyn PointeeSized> = x;
5+
| --------------------- ^ expected `Box<dyn PointeeSized>`, found fn item
6+
| |
7+
| expected due to this
8+
|
9+
= note: expected struct `Box<dyn PointeeSized>`
10+
found fn item `fn() {main}`
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)