Description
I was playing around with function pointers to track_caller
methods (which doesn't seem entirely implemented yet) and arrived at the following testcase:
fn call_it<T>(f: fn(T), x: T) {
f(x);
}
fn main() {
call_it(Result::unwrap, Err(0));
}
On stable, this behaves as expected:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: 0', src/libcore/result.rs:1165:5
On the latest nightly though, the message is different:
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libstd/panicking.rs:369:15
The line number points at this:
Line 369 in af95804
Two things seem odd here for me:
- I am actually surprised that this does not ICE, given that the
ReifyShim
stuff does not seem entirely implemented (at least this test still ICEs). - But the actual main bug here is that the comment about "always returns Some" seems wrong, so this panics at the wrong place. Clearly, the message shouldn't talk about
Option::unwrap()
when the actual panic is caused by aResult::unwrap
.
Cc @anp