Add regression test for #66757
This commit is contained in:
parent
d286113024
commit
dc49b2cdfd
29
src/test/ui/never_type/never-value-fallback-issue-66757.rs
Normal file
29
src/test/ui/never_type/never-value-fallback-issue-66757.rs
Normal file
@ -0,0 +1,29 @@
|
||||
// Regression test for #66757
|
||||
//
|
||||
// Test than when you have a `!` value (e.g., the local variable
|
||||
// never) and an uninferred variable (here the argument to `From`) it
|
||||
// doesn't fallback to `()` but rather `!`.
|
||||
//
|
||||
// run-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
// FIXME(#67225) -- this should be true even without the fallback gate.
|
||||
#![feature(never_type_fallback)]
|
||||
|
||||
struct E;
|
||||
|
||||
impl From<!> for E {
|
||||
fn from(_: !) -> E {
|
||||
E
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
#[allow(dead_code)]
|
||||
fn foo(never: !) {
|
||||
<E as From<!>>::from(never); // Ok
|
||||
<E as From<_>>::from(never); // Inference fails here
|
||||
}
|
||||
|
||||
fn main() { }
|
Loading…
Reference in New Issue
Block a user