forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for rust-lang#66757
- Loading branch information
Nicholas Matsakis
committed
Dec 14, 2019
1 parent
96511ce
commit 99d9f97
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/test/ui/never_type/never-value-fallback-issue-66757.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { } |