diff options
| author | Amanieu d'Antras <amanieu@gmail.com> | 2023-04-29 12:01:13 +0100 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2023-05-06 09:31:57 +0100 |
| commit | bba2a1e07179c59b422e60411813446606b1b7f3 (patch) | |
| tree | bcc2cdd990a326092a4452dd339d78ad4cdf20b1 /compiler/rustc_codegen_ssa | |
| parent | af2c7e0f9b5730b9598ca70fc67360fa69b469c8 (diff) | |
Fix spans in LLVM-generated inline asm errors
Previously, incorrect spans were reported if inline assembly contained CRLF (Windows) line endings. Fixes #110885
Diffstat (limited to 'compiler/rustc_codegen_ssa')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/write.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index c80347448cb..d0bed71bd12 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1821,9 +1821,15 @@ impl SharedEmitterMain { let source = sess .source_map() .new_source_file(FileName::inline_asm_source_code(&buffer), buffer); - let source_span = Span::with_root_ctxt(source.start_pos, source.end_pos); - let spans: Vec<_> = - spans.iter().map(|sp| source_span.from_inner(*sp)).collect(); + let spans: Vec<_> = spans + .iter() + .map(|sp| { + Span::with_root_ctxt( + source.normalized_byte_pos(sp.start as u32), + source.normalized_byte_pos(sp.end as u32), + ) + }) + .collect(); err.span_note(spans, "instantiated into assembly here"); } |
