Skip to content

Commit 2c4a75b

Browse files
committed
rustc_typeck: rename LvaluePreference::PreferMutLvalue to Needs::MutPlace.
1 parent 800166c commit 2c4a75b

File tree

7 files changed

+80
-82
lines changed

7 files changed

+80
-82
lines changed

src/librustc_typeck/check/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc::infer;
1515
use rustc::infer::type_variable::TypeVariableOrigin;
1616
use rustc::traits::ObligationCauseCode;
1717
use rustc::ty::{self, Ty, TypeFoldable};
18-
use check::{FnCtxt, Expectation, Diverges, LvaluePreference};
18+
use check::{FnCtxt, Expectation, Diverges, Needs};
1919
use check::coercion::CoerceMany;
2020
use util::nodemap::FxHashMap;
2121

@@ -584,7 +584,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
584584
});
585585
let discrim_ty;
586586
if let Some(m) = contains_ref_bindings {
587-
discrim_ty = self.check_expr_with_lvalue_pref(discrim, LvaluePreference::from_mutbl(m));
587+
discrim_ty = self.check_expr_with_needs(discrim, Needs::maybe_mut_place(m));
588588
} else {
589589
// ...but otherwise we want to use any supertype of the
590590
// discriminant. This is sort of a workaround, see note (*) in

src/librustc_typeck/check/autoderef.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use astconv::AstConv;
1212

13-
use super::{FnCtxt, LvalueOp, LvaluePreference};
13+
use super::{FnCtxt, LvalueOp, Needs};
1414
use super::method::MethodCallee;
1515

1616
use rustc::infer::InferOk;
@@ -162,19 +162,19 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
162162
}
163163

164164
/// Returns the adjustment steps.
165-
pub fn adjust_steps(&self, pref: LvaluePreference)
165+
pub fn adjust_steps(&self, needs: Needs)
166166
-> Vec<Adjustment<'tcx>> {
167-
self.fcx.register_infer_ok_obligations(self.adjust_steps_as_infer_ok(pref))
167+
self.fcx.register_infer_ok_obligations(self.adjust_steps_as_infer_ok(needs))
168168
}
169169

170-
pub fn adjust_steps_as_infer_ok(&self, pref: LvaluePreference)
170+
pub fn adjust_steps_as_infer_ok(&self, needs: Needs)
171171
-> InferOk<'tcx, Vec<Adjustment<'tcx>>> {
172172
let mut obligations = vec![];
173173
let targets = self.steps.iter().skip(1).map(|&(ty, _)| ty)
174174
.chain(iter::once(self.cur_ty));
175175
let steps: Vec<_> = self.steps.iter().map(|&(source, kind)| {
176176
if let AutoderefKind::Overloaded = kind {
177-
self.fcx.try_overloaded_deref(self.span, source, pref)
177+
self.fcx.try_overloaded_deref(self.span, source, needs)
178178
.and_then(|InferOk { value: method, obligations: o }| {
179179
obligations.extend(o);
180180
if let ty::TyRef(region, mt) = method.sig.output().sty {

src/librustc_typeck/check/callee.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use super::{Expectation, FnCtxt, LvaluePreference, TupleArgumentsFlag};
11+
use super::{Expectation, FnCtxt, Needs, TupleArgumentsFlag};
1212
use super::autoderef::Autoderef;
1313
use super::method::MethodCallee;
1414

@@ -96,7 +96,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
9696
// If the callee is a bare function or a closure, then we're all set.
9797
match adjusted_ty.sty {
9898
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
99-
let adjustments = autoderef.adjust_steps(LvaluePreference::NoPreference);
99+
let adjustments = autoderef.adjust_steps(Needs::None);
100100
self.apply_adjustments(callee_expr, adjustments);
101101
return Some(CallStep::Builtin(adjusted_ty));
102102
}
@@ -113,7 +113,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
113113
infer::FnCall,
114114
&closure_ty)
115115
.0;
116-
let adjustments = autoderef.adjust_steps(LvaluePreference::NoPreference);
116+
let adjustments = autoderef.adjust_steps(Needs::None);
117117
self.record_deferred_call_resolution(def_id, DeferredCallResolution {
118118
call_expr,
119119
callee_expr,
@@ -143,7 +143,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
143143
}
144144

145145
self.try_overloaded_call_traits(call_expr, adjusted_ty).map(|(autoref, method)| {
146-
let mut adjustments = autoderef.adjust_steps(LvaluePreference::NoPreference);
146+
let mut adjustments = autoderef.adjust_steps(Needs::None);
147147
adjustments.extend(autoref);
148148
self.apply_adjustments(callee_expr, adjustments);
149149
CallStep::Overloaded(method)

src/librustc_typeck/check/coercion.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
//! sort of a minor point so I've opted to leave it for later---after all
6161
//! we may want to adjust precisely when coercions occur.
6262
63-
use check::{Diverges, FnCtxt, LvaluePreference};
63+
use check::{Diverges, FnCtxt, Needs};
6464

6565
use rustc::hir;
6666
use rustc::hir::def_id::DefId;
@@ -409,9 +409,9 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
409409
return success(vec![], ty, obligations);
410410
}
411411

412-
let pref = LvaluePreference::from_mutbl(mt_b.mutbl);
412+
let needs = Needs::maybe_mut_place(mt_b.mutbl);
413413
let InferOk { value: mut adjustments, obligations: o }
414-
= autoderef.adjust_steps_as_infer_ok(pref);
414+
= autoderef.adjust_steps_as_infer_ok(needs);
415415
obligations.extend(o);
416416
obligations.extend(autoderef.into_obligations());
417417

src/librustc_typeck/check/method/confirm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use super::{probe, MethodCallee};
1212

1313
use astconv::AstConv;
14-
use check::{FnCtxt, LvalueOp, callee, LvaluePreference, PreferMutLvalue};
14+
use check::{FnCtxt, LvalueOp, callee, Needs};
1515
use hir::def_id::DefId;
1616
use rustc::ty::subst::Substs;
1717
use rustc::traits;
@@ -155,7 +155,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
155155
let (_, n) = autoderef.nth(pick.autoderefs).unwrap();
156156
assert_eq!(n, pick.autoderefs);
157157

158-
let mut adjustments = autoderef.adjust_steps(LvaluePreference::NoPreference);
158+
let mut adjustments = autoderef.adjust_steps(Needs::None);
159159

160160
let mut target = autoderef.unambiguous_final_ty();
161161

@@ -449,10 +449,10 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
449449
.adjustments_mut()
450450
.remove(expr.hir_id);
451451
if let Some(mut adjustments) = previous_adjustments {
452-
let pref = LvaluePreference::PreferMutLvalue;
452+
let needs = Needs::MutPlace;
453453
for adjustment in &mut adjustments {
454454
if let Adjust::Deref(Some(ref mut deref)) = adjustment.kind {
455-
if let Some(ok) = self.try_overloaded_deref(expr.span, source, pref) {
455+
if let Some(ok) = self.try_overloaded_deref(expr.span, source, needs) {
456456
let method = self.register_infer_ok_obligations(ok);
457457
if let ty::TyRef(region, mt) = method.sig.output().sty {
458458
*deref = OverloadedDeref {
@@ -505,7 +505,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
505505
.ty;
506506

507507
let method = self.try_overloaded_lvalue_op(
508-
expr.span, base_ty, arg_tys, PreferMutLvalue, op);
508+
expr.span, base_ty, arg_tys, Needs::MutPlace, op);
509509
let method = match method {
510510
Some(ok) => self.register_infer_ok_obligations(ok),
511511
None => return self.tcx.sess.delay_span_bug(expr.span, "re-trying op failed")

0 commit comments

Comments
 (0)