File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
src/librustc_codegen_llvm/debuginfo Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -56,14 +56,19 @@ impl InternalDebugLocation<'ll> {
5656 pub fn from_span ( cx : & CodegenCx < ' ll , ' _ > , scope : & ' ll DIScope , span : Span ) -> Self {
5757 let pos = cx. sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
5858
59- // FIXME: Rust likes to emit zero-width spans just after the end of a function. For now,
60- // zero-width spans to the preceding column to avoid emitting a column that points past the
61- // end of a line. E.g.,
62- // |xyz = None
63- // x|yz = 1
64- // xy|z = 2
59+ // Rust likes to emit zero-width spans that point just after a closing brace to denote e.g.
60+ // implicit return from a function. Instead of mapping zero-width spans to the column at
61+ // `span.lo` like we do normally, map them to the column immediately before the span. This
62+ // ensures that we point to a closing brace in the common case, and that debuginfo doesn't
63+ // point past the end of a line. A zero-width span at the very start of the line gets
64+ // mapped to `0`, which is used to represent "no column information" in DWARF. For example,
6565 //
66- // See discussion in https://github.com/rust-lang/rust/issues/65437
66+ // Span len = 0 Span len = 1
67+ //
68+ // |xyz => 0 (None) |x|yz => 1
69+ // x|yz => 1 x|y|z => 2
70+ //
71+ // See discussion in https://github.com/rust-lang/rust/issues/65437 for more info.
6772 let col0 = pos. col . to_usize ( ) ;
6873 let col1 = if span. is_empty ( ) {
6974 NonZeroUsize :: new ( col0)
You can’t perform that action at this time.
0 commit comments