@@ -1767,17 +1767,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1767
1767
}
1768
1768
}
1769
1769
1770
- /// Apply "fallbacks" to some types
1771
- /// ! gets replaced with (), unconstrained ints with i32, and unconstrained floats with f64.
1772
1770
fn default_type_parameters ( & self ) {
1773
- use middle:: ty:: error:: UnconstrainedNumeric :: Neither ;
1774
- use middle :: ty :: error :: UnconstrainedNumeric :: { UnconstrainedInt , UnconstrainedFloat } ;
1775
- for ty in & self . infcx ( ) . unsolved_variables ( ) {
1771
+ use middle:: ty:: error:: UnconstrainedNumeric :: { UnconstrainedInt , UnconstrainedFloat , Neither } ;
1772
+ let unsolved_variables = self . infcx ( ) . candidates_for_defaulting ( ) ;
1773
+ for & ( ref ty , _ ) in & unsolved_variables {
1776
1774
let resolved = self . infcx ( ) . resolve_type_vars_if_possible ( ty) ;
1777
- if self . infcx ( ) . type_var_diverges ( resolved) {
1775
+ let diverges = self . infcx ( ) . type_var_diverges ( resolved) ;
1776
+ if diverges {
1778
1777
demand:: eqtype ( self , codemap:: DUMMY_SP , * ty, self . tcx ( ) . mk_nil ( ) ) ;
1779
1778
} else {
1780
- match self . infcx ( ) . type_is_unconstrained_numeric ( resolved) {
1779
+ let unconstrained =
1780
+ self . infcx ( ) . type_is_unconstrained_numeric ( resolved) ;
1781
+ match unconstrained {
1781
1782
UnconstrainedInt => {
1782
1783
demand:: eqtype ( self , codemap:: DUMMY_SP , * ty, self . tcx ( ) . types . i32 )
1783
1784
} ,
@@ -1809,10 +1810,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1809
1810
use middle:: ty:: error:: UnconstrainedNumeric :: Neither ;
1810
1811
use middle:: ty:: error:: UnconstrainedNumeric :: { UnconstrainedInt , UnconstrainedFloat } ;
1811
1812
1812
- // For the time being this errs on the side of being memory wasteful but provides better
1813
- // error reporting.
1814
- // let type_variables = self.infcx().type_variables.clone();
1815
-
1816
1813
// It is a possible that this algorithm will have to run an arbitrary number of times
1817
1814
// to terminate so we bound it by the compiler's recursion limit.
1818
1815
for _ in ( 0 ..self . tcx ( ) . sess . recursion_limit . get ( ) ) {
@@ -2067,21 +2064,6 @@ impl<'a, 'tcx> RegionScope for FnCtxt<'a, 'tcx> {
2067
2064
}
2068
2065
}
2069
2066
2070
- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
2071
- pub enum LvaluePreference {
2072
- PreferMutLvalue ,
2073
- NoPreference
2074
- }
2075
-
2076
- impl LvaluePreference {
2077
- pub fn from_mutbl ( m : ast:: Mutability ) -> Self {
2078
- match m {
2079
- ast:: MutMutable => PreferMutLvalue ,
2080
- ast:: MutImmutable => NoPreference ,
2081
- }
2082
- }
2083
- }
2084
-
2085
2067
/// Whether `autoderef` requires types to resolve.
2086
2068
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
2087
2069
pub enum UnresolvedTypeAction {
0 commit comments