-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Given the Rust program:
fn main() {
let option: Option<bool> = None;
option.unwrap();
}
Running the program outputs:
thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:365
The same program using expect
instead of unwrap
outputs:
thread '<main>' panicked at 'oops', ../src/libcore/option.rs:333
In a program of non-trivial size, figuring out which call to unwrap
or expect
generated the panic is harder than it needs to be, since the line shown is where the panic actually happens inside libcore. For improved ergonomics, the file and line reported should be from the user's source code where the unwrap
or expect
was called.
yberreby
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.