@@ -76,7 +76,6 @@ type parameter).
76
76
77
77
*/
78
78
79
- pub use self :: LvaluePreference :: * ;
80
79
pub use self :: Expectation :: * ;
81
80
pub use self :: compare_method:: { compare_impl_method, compare_const_impl} ;
82
81
use self :: TupleArgumentsFlag :: * ;
@@ -95,6 +94,7 @@ use middle::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace, TypeSpace
95
94
use middle:: traits:: { self , report_fulfillment_errors} ;
96
95
use middle:: ty:: { FnSig , GenericPredicates , TypeScheme } ;
97
96
use middle:: ty:: { Disr , ParamTy , ParameterEnvironment } ;
97
+ use middle:: ty:: { LvaluePreference , NoPreference , PreferMutLvalue } ;
98
98
use middle:: ty:: { self , HasTypeFlags , RegionEscape , ToPolyTraitRef , Ty } ;
99
99
use middle:: ty:: { MethodCall , MethodCallee } ;
100
100
use middle:: ty_fold:: { TypeFolder , TypeFoldable } ;
@@ -2086,21 +2086,6 @@ impl<'a, 'tcx> RegionScope for FnCtxt<'a, 'tcx> {
2086
2086
}
2087
2087
}
2088
2088
2089
- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
2090
- pub enum LvaluePreference {
2091
- PreferMutLvalue ,
2092
- NoPreference
2093
- }
2094
-
2095
- impl LvaluePreference {
2096
- pub fn from_mutbl ( m : hir:: Mutability ) -> Self {
2097
- match m {
2098
- hir:: MutMutable => PreferMutLvalue ,
2099
- hir:: MutImmutable => NoPreference ,
2100
- }
2101
- }
2102
- }
2103
-
2104
2089
/// Whether `autoderef` requires types to resolve.
2105
2090
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
2106
2091
pub enum UnresolvedTypeAction {
@@ -2156,7 +2141,7 @@ pub fn autoderef<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>,
2156
2141
}
2157
2142
2158
2143
// Otherwise, deref if type is derefable:
2159
- let mt = match resolved_t. builtin_deref ( false ) {
2144
+ let mt = match resolved_t. builtin_deref ( false , lvalue_pref ) {
2160
2145
Some ( mt) => Some ( mt) ,
2161
2146
None => {
2162
2147
let method_call =
@@ -2245,7 +2230,7 @@ fn make_overloaded_lvalue_return_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
2245
2230
}
2246
2231
2247
2232
// method returns &T, but the type as visible to user is T, so deref
2248
- ret_ty. builtin_deref ( true )
2233
+ ret_ty. builtin_deref ( true , NoPreference )
2249
2234
}
2250
2235
None => None ,
2251
2236
}
@@ -3293,7 +3278,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3293
3278
}
3294
3279
hir:: UnDeref => {
3295
3280
oprnd_t = structurally_resolved_type ( fcx, expr. span , oprnd_t) ;
3296
- oprnd_t = match oprnd_t. builtin_deref ( true ) {
3281
+ oprnd_t = match oprnd_t. builtin_deref ( true , NoPreference ) {
3297
3282
Some ( mt) => mt. ty ,
3298
3283
None => match try_overloaded_deref ( fcx, expr. span ,
3299
3284
Some ( MethodCall :: expr ( expr. id ) ) ,
0 commit comments