Skip to content

Commit

Permalink
Make "tuple pattern not applied to a tuple" a span_delayed_bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Feb 22, 2024
1 parent d8b0069 commit 4dbb48d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
match ty.kind() {
ty::Tuple(args) => Ok(args.len()),
_ => {
self.tcx().dcx().span_bug(span, "tuple pattern not applied to a tuple");
self.tcx().dcx().span_delayed_bug(span, "tuple pattern not applied to a tuple");
Err(())
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/typeck/issue-121410.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
fn test_missing_unsafe_warning_on_repr_packed() {
struct Foo {
x: String,
}

let foo = Foo { x: String::new() };

let c = || {
let (_, t2) = foo.x; //~ ERROR mismatched types
};

c();
}

fn main() {}
14 changes: 14 additions & 0 deletions tests/ui/typeck/issue-121410.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/issue-121410.rs:9:13
|
LL | let (_, t2) = foo.x;
| ^^^^^^^ ----- this expression has type `String`
| |
| expected `String`, found `(_, _)`
|
= note: expected struct `String`
found tuple `(_, _)`

error: aborting due to 1 previous error

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

0 comments on commit 4dbb48d

Please sign in to comment.