From c88c54ec5a2b406ac007f98d9b1248c750c6d5b9 Mon Sep 17 00:00:00 2001 From: Andrew Cann Date: Sat, 25 Jun 2016 20:02:09 +0800 Subject: [PATCH] Invoke coercions on ! --- src/librustc_typeck/check/coercion.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 9dd737f3a61..cf5cfff6037 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -68,7 +68,8 @@ use rustc::traits::{self, ObligationCause}; use rustc::ty::adjustment::{AutoAdjustment, AutoDerefRef, AdjustDerefRef}; use rustc::ty::adjustment::{AutoPtr, AutoUnsafe, AdjustReifyFnPointer}; use rustc::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; -use rustc::ty::{self, LvaluePreference, TypeAndMut, Ty}; +use rustc::ty::adjustment::AdjustEmptyToAny; +use rustc::ty::{self, TypeVariants, LvaluePreference, TypeAndMut, Ty}; use rustc::ty::fold::TypeFoldable; use rustc::ty::error::TypeError; use rustc::ty::relate::RelateResult; @@ -167,6 +168,10 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { return self.identity(b); } + if let TypeVariants::TyEmpty = a.sty { + return Ok((b, AdjustEmptyToAny(b))); + } + // Consider coercing the subtype to a DST let unsize = self.coerce_unsized(a, b); if unsize.is_ok() {