Skip to content

Commit 4c0a9ef

Browse files
make sure we still eagerly emit errors
1 parent b408efe commit 4c0a9ef

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

compiler/rustc_mir_build/src/thir/cx/expr.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ impl<'tcx> Cx<'tcx> {
655655
promoted: None,
656656
},
657657
tcx.type_of(anon_const.def_id).instantiate_identity(),
658-
);
658+
)
659+
.normalize(tcx, self.param_env);
659660
let span = tcx.def_span(anon_const.def_id);
660661

661662
InlineAsmOperand::Const { value, span }
@@ -671,7 +672,8 @@ impl<'tcx> Cx<'tcx> {
671672
promoted: None,
672673
},
673674
tcx.type_of(anon_const.def_id).instantiate_identity(),
674-
);
675+
)
676+
.normalize(tcx, self.param_env);
675677
let span = tcx.def_span(anon_const.def_id);
676678

677679
InlineAsmOperand::SymFn { value, span }

tests/ui/asm/const-error.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(asm_const)]
2+
3+
// Test to make sure that we emit const errors eagerly for inline asm
4+
5+
use std::arch::asm;
6+
7+
fn test<T>() {
8+
unsafe { asm!("/* {} */", const 1 / 0); }
9+
//~^ ERROR evaluation of
10+
}
11+
12+
fn main() {}

tests/ui/asm/const-error.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0080]: evaluation of `test::<T>::{constant#0}` failed
2+
--> $DIR/const-error.rs:8:37
3+
|
4+
LL | unsafe { asm!("/* {} */", const 1 / 0); }
5+
| ^^^^^ attempt to divide `1_i32` by zero
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)