diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 67630fd4e582b..430b9407409a1 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -315,11 +315,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // FIXME: currently we never try to compose autoderefs // and ReifyFnPointer/UnsafeFnPointer, but we could. - _ => bug!( - "while adjusting {:?}, can't compose {:?} and {:?}", - expr, - entry.get(), - adj + _ => self.tcx.sess.delay_span_bug( + expr.span, + &format!( + "while adjusting {:?}, can't compose {:?} and {:?}", + expr, + entry.get(), + adj + ), ), }; *entry.get_mut() = adj; diff --git a/src/test/ui/structs/issue-92010-update-ice.rs b/src/test/ui/structs/issue-92010-update-ice.rs new file mode 100644 index 0000000000000..45ac3ce223c58 --- /dev/null +++ b/src/test/ui/structs/issue-92010-update-ice.rs @@ -0,0 +1,14 @@ +// Regression test for issue #92010 +// Tests that we don't ICE on an incorrect struct update usage + +#[derive(Clone)] +struct P { + x: T, + y: f64, +} + +impl P { + fn y(&self, y: f64) -> Self { P{y, .. self.clone() } } //~ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/structs/issue-92010-update-ice.stderr b/src/test/ui/structs/issue-92010-update-ice.stderr new file mode 100644 index 0000000000000..bcecd558681e2 --- /dev/null +++ b/src/test/ui/structs/issue-92010-update-ice.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/issue-92010-update-ice.rs:11:43 + | +LL | fn y(&self, y: f64) -> Self { P{y, .. self.clone() } } + | ^^^^^^^^^^^^ expected struct `P`, found `&P` + | + = note: expected struct `P` + found reference `&P` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`.