diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-20 15:34:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-20 15:34:08 +0200 |
| commit | ae3708e4b20036b1bccc7e0ecb344e0ef9ce442b (patch) | |
| tree | e489f2917609ef4da2679ed89a08a91a4c1c5a9a /compiler | |
| parent | 8e7601e10e0e3e3f9d7d4e5cd5ea515cd1c80fcf (diff) | |
| parent | 14d097f6418eacf58e300abfb1531111192e9767 (diff) | |
| download | rust-ae3708e4b20036b1bccc7e0ecb344e0ef9ce442b.tar.gz rust-ae3708e4b20036b1bccc7e0ecb344e0ef9ce442b.zip | |
Rollup merge of #144190 - scottmcm:spanned-errors-in-mir-validation, r=RalfJung
Give a message with a span on MIR validation error It was handy to get a source+line link for rust-lang/rust#143833, even if it's just to the function and not necessarily to the statement. r? mir
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir_transform/src/validate.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index cbb9bbfd12f..659ca4df159 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -119,14 +119,16 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> { #[track_caller] fn fail(&self, location: Location, msg: impl AsRef<str>) { // We might see broken MIR when other errors have already occurred. - assert!( - self.tcx.dcx().has_errors().is_some(), - "broken MIR in {:?} ({}) at {:?}:\n{}", - self.body.source.instance, - self.when, - location, - msg.as_ref(), - ); + if self.tcx.dcx().has_errors().is_none() { + span_bug!( + self.body.source_info(location).span, + "broken MIR in {:?} ({}) at {:?}:\n{}", + self.body.source.instance, + self.when, + location, + msg.as_ref(), + ); + } } fn check_edge(&mut self, location: Location, bb: BasicBlock, edge_kind: EdgeKind) { |
