Skip to content

Commit 82f23d5

Browse files
make sure we still eagerly emit errors
1 parent a992def commit 82f23d5

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ impl<'tcx> Cx<'tcx> {
652652
promoted: None,
653653
},
654654
tcx.type_of(anon_const.def_id).instantiate_identity(),
655-
);
655+
)
656+
.normalize(tcx, self.param_env);
656657
let span = tcx.def_span(anon_const.def_id);
657658

658659
InlineAsmOperand::Const { value, span }
@@ -668,7 +669,8 @@ impl<'tcx> Cx<'tcx> {
668669
promoted: None,
669670
},
670671
tcx.type_of(anon_const.def_id).instantiate_identity(),
671-
);
672+
)
673+
.normalize(tcx, self.param_env);
672674
let span = tcx.def_span(anon_const.def_id);
673675

674676
InlineAsmOperand::SymFn { value, span }

tests/ui/asm/const-error.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// only-x86_64
2+
// needs-asm-support
3+
4+
#![feature(asm_const)]
5+
6+
// Test to make sure that we emit const errors eagerly for inline asm
7+
8+
use std::arch::asm;
9+
10+
fn test<T>() {
11+
unsafe { asm!("/* {} */", const 1 / 0); }
12+
//~^ ERROR evaluation of
13+
}
14+
15+
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:11:37
3+
|
4+
LL | unsafe { asm!("/* {} */", const 1 / 0); }
5+
| ^^^^^ attempt to divide `1_i32` by zero
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)