Skip to content

Commit d1f4c50

Browse files
committed
Use delay_span_bug when incorrect adjustment occurs
Fixes rust-lang#92010
1 parent d3f3004 commit d1f4c50

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
315315
}
316316
// FIXME: currently we never try to compose autoderefs
317317
// and ReifyFnPointer/UnsafeFnPointer, but we could.
318-
_ => bug!(
319-
"while adjusting {:?}, can't compose {:?} and {:?}",
320-
expr,
321-
entry.get(),
322-
adj
318+
_ => self.tcx.sess.delay_span_bug(
319+
expr.span,
320+
&format!(
321+
"while adjusting {:?}, can't compose {:?} and {:?}",
322+
expr,
323+
entry.get(),
324+
adj
325+
),
323326
),
324327
};
325328
*entry.get_mut() = adj;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Regression test for issue #92010
2+
// Tests that we don't ICE on an incorrect struct update usage
3+
4+
#[derive(Clone)]
5+
struct P<T> {
6+
x: T,
7+
y: f64,
8+
}
9+
10+
impl<T> P<T> {
11+
fn y(&self, y: f64) -> Self { P{y, .. self.clone() } } //~ ERROR mismatched types
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-92010-update-ice.rs:11:43
3+
|
4+
LL | fn y(&self, y: f64) -> Self { P{y, .. self.clone() } }
5+
| ^^^^^^^^^^^^ expected struct `P`, found `&P<T>`
6+
|
7+
= note: expected struct `P<T>`
8+
found reference `&P<T>`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)