Rollup merge of #99192 - Amanieu:fix-asm-srcloc, r=petrochenkov

Fix spans for asm diagnostics

Line spans were incorrect if the first line of an asm statement was an
empty string.
This commit is contained in:
Dylan DPC 2022-07-14 19:24:05 +05:30 committed by GitHub
commit d3a1aa0b43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 4 deletions

View File

@ -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()));
}

View File

@ -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
}
}

View File

@ -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

View File

@ -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'
}
}

View File

@ -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