From 99d9f97a443b53cd275e4fa444c60dd6a76e7193 Mon Sep 17 00:00:00 2001 From: Nicholas Matsakis Date: Wed, 11 Dec 2019 10:09:40 -0500 Subject: [PATCH] Add regression test for #66757 --- .../never-value-fallback-issue-66757.rs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/ui/never_type/never-value-fallback-issue-66757.rs diff --git a/src/test/ui/never_type/never-value-fallback-issue-66757.rs b/src/test/ui/never_type/never-value-fallback-issue-66757.rs new file mode 100644 index 0000000000000..f2e9e087307db --- /dev/null +++ b/src/test/ui/never_type/never-value-fallback-issue-66757.rs @@ -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: !) { + >::from(never); // Ok + >::from(never); // Inference fails here +} + +fn main() { }