@@ -858,17 +858,19 @@ fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
858
858
fcx
859
859
} ;
860
860
861
- fcx. check_casts ( ) ;
862
-
863
861
// All type checking constraints were added, try to fallback unsolved variables.
864
862
fcx. select_obligations_where_possible ( ) ;
865
863
for ty in & fcx. unsolved_variables ( ) {
866
- fcx. fallback_if_possible ( ty, Fallback :: Full ) ;
864
+ fcx. fallback_if_possible ( ty) ;
867
865
}
868
866
fcx. select_obligations_where_possible ( ) ;
869
867
868
+ // Even though coercion casts provide type hints, we check casts after fallback for
869
+ // backwards compatibility. This makes fallback a stronger type hint than a cast coercion.
870
+ fcx. check_casts ( ) ;
871
+
870
872
// Closure and generater analysis may run after fallback
871
- // because they doen 't constrain other type variables.
873
+ // because they don 't constrain other type variables.
872
874
fcx. closure_analyze ( body) ;
873
875
assert ! ( fcx. deferred_call_resolutions. borrow( ) . is_empty( ) ) ;
874
876
fcx. resolve_generator_interiors ( def_id) ;
@@ -1734,12 +1736,6 @@ enum TupleArgumentsFlag {
1734
1736
TupleArguments ,
1735
1737
}
1736
1738
1737
- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
1738
- pub enum Fallback {
1739
- Full ,
1740
- Numeric
1741
- }
1742
-
1743
1739
impl < ' a , ' gcx , ' tcx > FnCtxt < ' a , ' gcx , ' tcx > {
1744
1740
pub fn new ( inh : & ' a Inherited < ' a , ' gcx , ' tcx > ,
1745
1741
param_env : ty:: ParamEnv < ' tcx > ,
@@ -2149,7 +2145,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2149
2145
// unconstrained floats with f64.
2150
2146
// Fallback becomes very dubious if we have encountered type-checking errors.
2151
2147
// In that case, fallback to TyError.
2152
- fn fallback_if_possible ( & self , ty : Ty < ' tcx > , fallback : Fallback ) {
2148
+ fn fallback_if_possible ( & self , ty : Ty < ' tcx > ) {
2153
2149
use rustc:: ty:: error:: UnconstrainedNumeric :: Neither ;
2154
2150
use rustc:: ty:: error:: UnconstrainedNumeric :: { UnconstrainedInt , UnconstrainedFloat } ;
2155
2151
@@ -2158,12 +2154,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2158
2154
_ if self . is_tainted_by_errors ( ) => self . tcx ( ) . types . err ,
2159
2155
UnconstrainedInt => self . tcx . types . i32 ,
2160
2156
UnconstrainedFloat => self . tcx . types . f64 ,
2161
- Neither if self . type_var_diverges ( ty) => {
2162
- match fallback {
2163
- Fallback :: Full => self . tcx . mk_diverging_default ( ) ,
2164
- Fallback :: Numeric => return ,
2165
- }
2166
- }
2157
+ Neither if self . type_var_diverges ( ty) => self . tcx . mk_diverging_default ( ) ,
2167
2158
Neither => return
2168
2159
} ;
2169
2160
debug ! ( "default_type_parameters: defaulting `{:?}` to `{:?}`" , ty, fallback) ;
0 commit comments