Skip to content
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

Rollup of 7 pull requests #111287

Merged
merged 19 commits into from
May 6, 2023
Merged
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f0be145
drive-by cleanup of rustdoc comment
jyn514 Apr 29, 2023
2469afe
Make the BUG_REPORT_URL configurable by tools
jyn514 Apr 29, 2023
7dd59fc
Add Drop terminator to SMIR
spastorino Apr 20, 2023
10b69dd
debuginfo: split method declaration and definition
cuviper May 3, 2023
964fb67
Use fulfillment to check Drop impl compatibility
compiler-errors Apr 20, 2023
9d44f9b
Add test for #110557
compiler-errors Apr 20, 2023
2e346b6
Even more tests
compiler-errors Apr 21, 2023
4b85bea
Add Assert terminator to SMIR
spastorino Apr 24, 2023
698acc6
Add GeneratorDrop terminator to SMIR
spastorino Apr 24, 2023
a183ac6
add hint for =< as <=
zacklukem May 5, 2023
2a1ef34
More robust debug assertions for `Instance::resolve` on built-in trai…
compiler-errors May 6, 2023
bba2a1e
Fix spans in LLVM-generated inline asm errors
Amanieu Apr 29, 2023
bcc9aa0
Rollup merge of #110577 - compiler-errors:drop-impl-fulfill, r=lcnr
matthiaskrgr May 6, 2023
77004ea
Rollup merge of #110610 - spastorino:smir-terminator, r=oli-obk
matthiaskrgr May 6, 2023
8172ada
Rollup merge of #110985 - Amanieu:normalize_asm_spans, r=b-naber
matthiaskrgr May 6, 2023
8ec84dd
Rollup merge of #110989 - jyn514:bug-report-url, r=WaffleLapkin
matthiaskrgr May 6, 2023
f440999
Rollup merge of #111167 - cuviper:type-decl-disubprogram, r=michaelwo…
matthiaskrgr May 6, 2023
83b29ec
Rollup merge of #111230 - zacklukem:eq-less-to-less-eq, r=compiler-er…
matthiaskrgr May 6, 2023
3cb1a46
Rollup merge of #111279 - compiler-errors:core-item-resolve, r=cjgillot
matthiaskrgr May 6, 2023
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
12 changes: 9 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
@@ -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");
}

22 changes: 22 additions & 0 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1744,6 +1744,28 @@ impl SourceFile {
BytePos::from_u32(pos.0 - self.start_pos.0 + diff)
}

/// Calculates a normalized byte position from a byte offset relative to the
/// start of the file.
///
/// When we get an inline assembler error from LLVM during codegen, we
/// import the expanded assembly code as a new `SourceFile`, which can then
/// be used for error reporting with spans. However the byte offsets given
/// to us by LLVM are relative to the start of the original buffer, not the
/// normalized one. Hence we need to convert those offsets to the normalized
/// form when constructing spans.
pub fn normalized_byte_pos(&self, offset: u32) -> BytePos {
let diff = match self
.normalized_pos
.binary_search_by(|np| (np.pos.0 + np.diff).cmp(&(self.start_pos.0 + offset)))
{
Ok(i) => self.normalized_pos[i].diff,
Err(i) if i == 0 => 0,
Err(i) => self.normalized_pos[i - 1].diff,
};

BytePos::from_u32(self.start_pos.0 + offset - diff)
}

/// Converts an absolute `BytePos` to a `CharPos` relative to the `SourceFile`.
pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos {
// The number of extra bytes due to multibyte chars in the `SourceFile`.