Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ee4cfe8

Browse files
committedOct 5, 2023
make sure we still eagerly emit errors
1 parent cd4cf56 commit ee4cfe8

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
@@ -657,7 +657,8 @@ impl<'tcx> Cx<'tcx> {
657657
promoted: None,
658658
},
659659
tcx.type_of(anon_const.def_id).instantiate_identity(),
660-
);
660+
)
661+
.normalize(tcx, self.param_env);
661662
let span = tcx.def_span(anon_const.def_id);
662663

663664
InlineAsmOperand::Const { value, span }
@@ -673,7 +674,8 @@ impl<'tcx> Cx<'tcx> {
673674
promoted: None,
674675
},
675676
tcx.type_of(anon_const.def_id).instantiate_identity(),
676-
);
677+
)
678+
.normalize(tcx, self.param_env);
677679
let span = tcx.def_span(anon_const.def_id);
678680

679681
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)
Please sign in to comment.