Skip to content

Commit 4dbb48d

Browse files
committed
Make "tuple pattern not applied to a tuple" a span_delayed_bug.
Fixes #121410.
1 parent d8b0069 commit 4dbb48d

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

compiler/rustc_hir_typeck/src/mem_categorization.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
582582
match ty.kind() {
583583
ty::Tuple(args) => Ok(args.len()),
584584
_ => {
585-
self.tcx().dcx().span_bug(span, "tuple pattern not applied to a tuple");
585+
self.tcx().dcx().span_delayed_bug(span, "tuple pattern not applied to a tuple");
586+
Err(())
586587
}
587588
}
588589
}

tests/ui/typeck/issue-121410.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
fn test_missing_unsafe_warning_on_repr_packed() {
2+
struct Foo {
3+
x: String,
4+
}
5+
6+
let foo = Foo { x: String::new() };
7+
8+
let c = || {
9+
let (_, t2) = foo.x; //~ ERROR mismatched types
10+
};
11+
12+
c();
13+
}
14+
15+
fn main() {}

tests/ui/typeck/issue-121410.stderr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-121410.rs:9:13
3+
|
4+
LL | let (_, t2) = foo.x;
5+
| ^^^^^^^ ----- this expression has type `String`
6+
| |
7+
| expected `String`, found `(_, _)`
8+
|
9+
= note: expected struct `String`
10+
found tuple `(_, _)`
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)