diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 81ce58a93fa9d..9d777d4121d73 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -101,7 +101,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ); } Some(LangItem::PointeeSized) => { - bug!("`PointeeSized` is removed during lowering"); + tcx.dcx().delayed_bug("`PointeeSized` is removed during lowering"); } Some(LangItem::Unsize) => { self.assemble_candidates_for_unsizing(obligation, &mut candidates); diff --git a/tests/ui/sized-hierarchy/dyn-pointeesized-issue-142652.rs b/tests/ui/sized-hierarchy/dyn-pointeesized-issue-142652.rs new file mode 100644 index 0000000000000..31f3287601cac --- /dev/null +++ b/tests/ui/sized-hierarchy/dyn-pointeesized-issue-142652.rs @@ -0,0 +1,9 @@ +#![feature(sized_hierarchy)] + +use std::marker::PointeeSized; + +fn main() { + let x = main; + let y: Box = x; +//~^ ERROR mismatched types +} diff --git a/tests/ui/sized-hierarchy/dyn-pointeesized-issue-142652.stderr b/tests/ui/sized-hierarchy/dyn-pointeesized-issue-142652.stderr new file mode 100644 index 0000000000000..77b4fdb6af580 --- /dev/null +++ b/tests/ui/sized-hierarchy/dyn-pointeesized-issue-142652.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/dyn-pointeesized-issue-142652.rs:7:38 + | +LL | let y: Box = x; + | --------------------- ^ expected `Box`, found fn item + | | + | expected due to this + | + = note: expected struct `Box` + found fn item `fn() {main}` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`.