Skip to content

wrong backtrace line for .unwrap() if it is on the next line #61645

Open
@matthiaskrgr

Description

@matthiaskrgr

meta:

rustc 1.37.0-nightly (5eeb567a2 2019-06-06)
binary: rustc
commit-hash: 5eeb567a27eba18420a620ca7d0c007e29d8bc0c
commit-date: 2019-06-06
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0

I had a Command::new()....unwrap() and some methods in between that were also unwrapping their arguments.
The panic that I got however was not pointing to any of the unwrap()s but to the first line of the statement (the Command::new()) which is quite confusing.

Here is similar example:

 fn a(_: i32, _: i16, _: i8, _: i32, _: i16, _: i8) -> i32 {
    4
}

fn main() {
    let X: i32 = a(
        9,
        Some(4)
        .unwrap(),
        Some(7)
        .unwrap(),
        Some(9)
        .unwrap(),
        Some( // backtrace points here
        None
        )
        .unwrap()
        .unwrap(), // should point here
        7,
    );
}

the backtrace points to line 15 which contains Some( which is very confusing, imo it should point to line 19 which is the panicking unwrap()

Can reproduce on stable, beta and nightly.
Playground: https://play.rust-lang.org/?version=beta&mode=debug&edition=2018&gist=be591b1d4dbf5b729c5733a831c823e9

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-backtraceArea: BacktracesA-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions