mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 20:28:33 +00:00
Construct MIR error body for global_asm correctly
This commit is contained in:
parent
30f168ef81
commit
c867b8f11d
@ -612,7 +612,8 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
|
|||||||
| DefKind::AssocConst
|
| DefKind::AssocConst
|
||||||
| DefKind::AnonConst
|
| DefKind::AnonConst
|
||||||
| DefKind::InlineConst
|
| DefKind::InlineConst
|
||||||
| DefKind::Static { .. } => (vec![], tcx.type_of(def_id).instantiate_identity(), None),
|
| DefKind::Static { .. }
|
||||||
|
| DefKind::GlobalAsm => (vec![], tcx.type_of(def_id).instantiate_identity(), None),
|
||||||
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => {
|
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => {
|
||||||
let sig = tcx.liberate_late_bound_regions(
|
let sig = tcx.liberate_late_bound_regions(
|
||||||
def_id.to_def_id(),
|
def_id.to_def_id(),
|
||||||
|
11
tests/ui/asm/global-asm-with-error.rs
Normal file
11
tests/ui/asm/global-asm-with-error.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Ensure that we don't ICE when constructing the fake MIR body for a global
|
||||||
|
// asm when the body has errors. See #137470.
|
||||||
|
|
||||||
|
//@ needs-asm-support
|
||||||
|
|
||||||
|
use std::arch::global_asm;
|
||||||
|
|
||||||
|
global_asm!("/* {} */", sym a);
|
||||||
|
//~^ ERROR cannot find value `a` in this scope
|
||||||
|
|
||||||
|
fn main() {}
|
9
tests/ui/asm/global-asm-with-error.stderr
Normal file
9
tests/ui/asm/global-asm-with-error.stderr
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
error[E0425]: cannot find value `a` in this scope
|
||||||
|
--> $DIR/global-asm-with-error.rs:6:29
|
||||||
|
|
|
||||||
|
LL | global_asm!("/* {} */", sym a);
|
||||||
|
| ^ not found in this scope
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0425`.
|
Loading…
Reference in New Issue
Block a user