Skip to content

Commit 8abdf02

Browse files
committed
Auto merge of #141372 - khuey:ir_call_dbg_loc, r=<try>
Use the fn_span when emitting function calls for better debug info. This especially improves the developer experience for long chains of function calls that span multiple lines, which is common with builder patterns, chains of iterator/future combinators, etc. try-job: armhf-gnu try-job: test-various try-job: x86_64-msvc-1 r? `@jieyouxu`
2 parents d423c81 + bcaa604 commit 8abdf02

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11811181
(_, Some(llfn)) => llfn,
11821182
_ => span_bug!(span, "no instance or llfn for call"),
11831183
};
1184+
self.set_debug_loc(bx, mir::SourceInfo { span: fn_span, ..source_info });
11841185
helper.do_call(
11851186
self,
11861187
bx,

src/tools/compiletest/src/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ impl<'test> TestCx<'test> {
589589

590590
if missing_patterns.len() == 1 {
591591
self.fatal_proc_rec(
592-
&format!("error pattern '{}' not found!", missing_patterns[0]),
592+
&format!("error pattern '{}' not found in {output_to_check}!", missing_patterns[0]),
593593
proc_res,
594594
);
595595
} else {

tests/debuginfo/multiline-calls.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//@ compile-flags:-g
2+
//@ min-gdb-version: 16.0
3+
4+
// === GDB TESTS ===================================================================================
5+
6+
// gdb-command: run
7+
// gdb-check:[...]#break[...]
8+
// gdb-command: up
9+
// gdb-check:[...]zzz[...]
10+
11+
// === LLDB TESTS ==================================================================================
12+
13+
// lldb-command:run
14+
// lldb-check:[...]#break[...]
15+
// lldb-command: up
16+
// lldb-check:[...]zzz[...]
17+
18+
struct Foo;
19+
20+
impl Foo {
21+
fn bar(self) -> Foo {
22+
println!("bar");
23+
self
24+
}
25+
fn baz(self) -> Foo {
26+
println!("baz"); // #break
27+
self
28+
}
29+
}
30+
31+
fn main() {
32+
let f = Foo;
33+
f.bar() // aaa
34+
.baz(); // zzz
35+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ run-fail
2+
//@ compile-flags: -Cstrip=none -Cdebuginfo=line-tables-only -Copt-level=0
3+
//@ exec-env:RUST_BACKTRACE=1
4+
//@ regex-error-pattern: location-detail-unwrap-multiline\.rs:10:10\n
5+
//@ needs-unwind
6+
7+
fn main() {
8+
let opt: Option<u32> = None;
9+
opt
10+
.unwrap();
11+
}

0 commit comments

Comments
 (0)