Skip to content

Fix spans for asm diagnostics #99192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,8 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl

let mut template_strs = Vec::with_capacity(args.templates.len());

for template_expr in args.templates.into_iter() {
if !template.is_empty() {
for (i, template_expr) in args.templates.into_iter().enumerate() {
if i != 0 {
template.push(ast::InlineAsmTemplatePiece::String("\n".to_string()));
}

Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/asm/aarch64/srcloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,12 @@ fn main() {
//~^^^^^^^^^^ ERROR: unrecognized instruction mnemonic
//~^^^^^^^ ERROR: unrecognized instruction mnemonic
//~^^^^^^^^ ERROR: unrecognized instruction mnemonic

asm!(
"",
"\n",
"invalid_instruction"
);
//~^^ ERROR: unrecognized instruction mnemonic
}
}
14 changes: 13 additions & 1 deletion src/test/ui/asm/aarch64/srcloc.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,17 @@ note: instantiated into assembly here
LL | invalid_instruction4
| ^

error: aborting due to 23 previous errors
error: unrecognized instruction mnemonic
--> $DIR/srcloc.rs:125:14
|
LL | "invalid_instruction"
| ^
|
note: instantiated into assembly here
--> <inline asm>:4:1
|
LL | invalid_instruction
| ^

error: aborting due to 24 previous errors

7 changes: 7 additions & 0 deletions src/test/ui/asm/x86_64/srcloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,12 @@ fn main() {
//~^^^^^^^^^^ ERROR: invalid instruction mnemonic 'invalid_instruction2'
//~^^^^^^^ ERROR: invalid instruction mnemonic 'invalid_instruction3'
//~^^^^^^^^ ERROR: invalid instruction mnemonic 'invalid_instruction4'

asm!(
"",
"\n",
"invalid_instruction"
);
//~^^ ERROR: invalid instruction mnemonic 'invalid_instruction'
}
}
14 changes: 13 additions & 1 deletion src/test/ui/asm/x86_64/srcloc.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,17 @@ note: instantiated into assembly here
LL | invalid_instruction4
| ^^^^^^^^^^^^^^^^^^^^

error: aborting due to 23 previous errors; 1 warning emitted
error: invalid instruction mnemonic 'invalid_instruction'
--> $DIR/srcloc.rs:127:14
|
LL | "invalid_instruction"
| ^
|
note: instantiated into assembly here
--> <inline asm>:5:1
|
LL | invalid_instruction
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to 24 previous errors; 1 warning emitted