Skip to content

Commit

Permalink
Rollup merge of rust-lang#99404 - jmqd:master, r=compiler-errors
Browse files Browse the repository at this point in the history
Use span_bug for unexpected field projection type

Improves the compiler error backtrace information, as shown in rust-lang#99363,
by using `span_bug` instead of `bug`.

New output:

```
build/aarch64-apple-darwin/stage1/bin/rustc /tmp/test.rs --edition=2021
error: internal compiler error: compiler/rustc_middle/src/ty/closure.rs:185:25: Unexpected type Opaque(DefId(0:5 ~ test[db0f]::main::T::{opaque#0}), []) for `Field` projection
  --> /tmp/test.rs:11:27
   |
11 |         let Foo((a, b)) = foo;
   |                           ^^^

thread 'rustc' panicked at 'Box<dyn Any>', /Users/jmq/src/forked/rust/compiler/rustc_errors/src/lib.rs:1331:9
stack backtrace:
```

(Remainder of output truncated.)
  • Loading branch information
Dylan-DPC authored Jul 19, 2022
2 parents 34be64d + 38f090b commit 6f05f53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/rustc_middle/src/ty/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ impl<'tcx> CapturedPlace<'tcx> {
.unwrap();
}
ty => {
bug!("Unexpected type {:?} for `Field` projection", ty)
span_bug!(
self.get_capture_kind_span(tcx),
"Unexpected type {:?} for `Field` projection",
ty
)
}
},

Expand Down

0 comments on commit 6f05f53

Please sign in to comment.