@@ -66,7 +66,6 @@ use rustc::hir;
66
66
use rustc:: hir:: def_id:: DefId ;
67
67
use rustc:: infer:: { Coercion , InferResult , InferOk } ;
68
68
use rustc:: infer:: type_variable:: TypeVariableOrigin ;
69
- use rustc:: lint;
70
69
use rustc:: traits:: { self , ObligationCause , ObligationCauseCode } ;
71
70
use rustc:: ty:: adjustment:: { Adjustment , Adjust , AutoBorrow } ;
72
71
use rustc:: ty:: { self , TypeAndMut , Ty , ClosureSubsts } ;
@@ -736,27 +735,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
736
735
pub fn try_coerce ( & self ,
737
736
expr : & hir:: Expr ,
738
737
expr_ty : Ty < ' tcx > ,
739
- expr_diverges : Diverges ,
740
738
target : Ty < ' tcx > )
741
739
-> RelateResult < ' tcx , Ty < ' tcx > > {
742
740
let source = self . resolve_type_vars_with_obligations ( expr_ty) ;
743
741
debug ! ( "coercion::try({:?}: {:?} -> {:?})" , expr, source, target) ;
744
742
745
- // Special-ish case: we can coerce any type `T` into the `!`
746
- // type, but only if the source expression diverges.
747
- if target. is_never ( ) && expr_diverges. always ( ) {
748
- debug ! ( "permit coercion to `!` because expr diverges" ) ;
749
- if self . can_eq ( self . param_env , source, target) . is_err ( ) {
750
- self . tcx . lint_node (
751
- lint:: builtin:: COERCE_NEVER ,
752
- expr. id ,
753
- expr. span ,
754
- & format ! ( "cannot coerce `{}` to !" , source)
755
- ) ;
756
- return Ok ( target) ;
757
- }
758
- }
759
-
760
743
let cause = self . cause ( expr. span , ObligationCauseCode :: ExprAssignable ) ;
761
744
let coerce = Coerce :: new ( self , cause) ;
762
745
let ok = self . commit_if_ok ( |_| coerce. coerce ( source, target) ) ?;
@@ -1106,7 +1089,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
1106
1089
if self . pushed == 0 {
1107
1090
// Special-case the first expression we are coercing.
1108
1091
// To be honest, I'm not entirely sure why we do this.
1109
- fcx. try_coerce ( expression, expression_ty, expression_diverges , self . expected_ty )
1092
+ fcx. try_coerce ( expression, expression_ty, self . expected_ty )
1110
1093
} else {
1111
1094
match self . expressions {
1112
1095
Expressions :: Dynamic ( ref exprs) =>
0 commit comments