Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use delay_span_bug when incorrect adjustment occurs #92083

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/structs/issue-92010-update-ice.rs
Original file line number Diff line number Diff line change
@@ -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<T> {
x: T,
y: f64,
}

impl<T> P<T> {
fn y(&self, y: f64) -> Self { P{y, .. self.clone() } } //~ ERROR mismatched types
}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/structs/issue-92010-update-ice.stderr
Original file line number Diff line number Diff line change
@@ -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<T>`
|
= note: expected struct `P<T>`
found reference `&P<T>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.