Skip to content

Use the fn_span when emitting function calls for better debug info. #141372

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
(_, Some(llfn)) => llfn,
_ => span_bug!(span, "no instance or llfn for call"),
};
self.set_debug_loc(bx, mir::SourceInfo { span: fn_span, ..source_info });
helper.do_call(
self,
bx,
Expand Down
35 changes: 35 additions & 0 deletions tests/debuginfo/multiline-calls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//@ compile-flags:-g
//@ min-gdb-version: 16.0

// === GDB TESTS ===================================================================================

// gdb-command: run
// gdb-check:[...]#break[...]
// gdb-command: up
// gdb-check:[...]zzz[...]

// === LLDB TESTS ==================================================================================

// lldb-command:run
// lldb-check:[...]#break[...]
// lldb-command: up
// lldb-check:[...]zzz[...]

struct Foo;

impl Foo {
fn bar(self) -> Foo {
println!("bar");
self
}
fn baz(self) -> Foo {
println!("baz"); // #break
self
}
}

fn main() {
let f = Foo;
f.bar() // aaa
.baz(); // zzz
}
12 changes: 12 additions & 0 deletions tests/ui/panics/location-detail-unwrap-multiline.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ run-fail
//@ compile-flags: -Cstrip=none -Cdebuginfo=line-tables-only -Copt-level=0
//@ exec-env:RUST_BACKTRACE=1
//@ regex-error-pattern: location-detail-unwrap-multiline\.rs:11(:10)?\n
//@ needs-unwind
//@ ignore-android FIXME #17520

fn main() {
let opt: Option<u32> = None;
opt
.unwrap();
}