Skip to content

Commit 9cefcd3

Browse files
committed
Rename resolve_type_vars_with_obligations to
resolve_vars_with_obligations, as it now also resolves const variables.
1 parent 925e304 commit 9cefcd3

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

Diff for: src/librustc_typeck/check/coercion.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
811811
target: Ty<'tcx>,
812812
allow_two_phase: AllowTwoPhase,
813813
) -> RelateResult<'tcx, Ty<'tcx>> {
814-
let source = self.resolve_type_vars_with_obligations(expr_ty);
814+
let source = self.resolve_vars_with_obligations(expr_ty);
815815
debug!("coercion::try({:?}: {:?} -> {:?})", expr, source, target);
816816

817817
let cause = self.cause(expr.span, ObligationCauseCode::ExprAssignable);
@@ -829,7 +829,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
829829

830830
/// Same as `try_coerce()`, but without side-effects.
831831
pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
832-
let source = self.resolve_type_vars_with_obligations(expr_ty);
832+
let source = self.resolve_vars_with_obligations(expr_ty);
833833
debug!("coercion::can({:?} -> {:?})", source, target);
834834

835835
let cause = self.cause(syntax_pos::DUMMY_SP, ObligationCauseCode::ExprAssignable);
@@ -853,8 +853,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
853853
-> RelateResult<'tcx, Ty<'tcx>>
854854
where E: AsCoercionSite
855855
{
856-
let prev_ty = self.resolve_type_vars_with_obligations(prev_ty);
857-
let new_ty = self.resolve_type_vars_with_obligations(new_ty);
856+
let prev_ty = self.resolve_vars_with_obligations(prev_ty);
857+
let new_ty = self.resolve_vars_with_obligations(new_ty);
858858
debug!("coercion::try_find_coercion_lub({:?}, {:?})", prev_ty, new_ty);
859859

860860
// Special-case that coercion alone cannot handle:
@@ -1333,7 +1333,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
13331333
err.span_label(return_sp, "expected because this return type...");
13341334
err.span_label( *sp, format!(
13351335
"...is found to be `{}` here",
1336-
fcx.resolve_type_vars_with_obligations(expected),
1336+
fcx.resolve_vars_with_obligations(expected),
13371337
));
13381338
}
13391339
err

Diff for: src/librustc_typeck/check/demand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
108108
expected: Ty<'tcx>,
109109
allow_two_phase: AllowTwoPhase)
110110
-> (Ty<'tcx>, Option<DiagnosticBuilder<'tcx>>) {
111-
let expected = self.resolve_type_vars_with_obligations(expected);
111+
let expected = self.resolve_vars_with_obligations(expected);
112112

113113
let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase) {
114114
Ok(ty) => return (ty, None),
@@ -117,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
117117

118118
let expr = expr.peel_drop_temps();
119119
let cause = self.misc(expr.span);
120-
let expr_ty = self.resolve_type_vars_with_obligations(checked_ty);
120+
let expr_ty = self.resolve_vars_with_obligations(checked_ty);
121121
let mut err = self.report_mismatched_types(&cause, expected, expr_ty, e);
122122

123123
if self.is_assign_to_bool(expr, expected) {

Diff for: src/librustc_typeck/check/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10101010
expr: &'tcx hir::Expr,
10111011
) -> Ty<'tcx> {
10121012
let flds = expected.only_has_type(self).and_then(|ty| {
1013-
let ty = self.resolve_type_vars_with_obligations(ty);
1013+
let ty = self.resolve_vars_with_obligations(ty);
10141014
match ty.kind {
10151015
ty::Tuple(ref flds) => Some(&flds[..]),
10161016
_ => None

Diff for: src/librustc_typeck/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
919919
// This occurs for UFCS desugaring of `T::method`, where there is no
920920
// receiver expression for the method call, and thus no autoderef.
921921
if let SelfSource::QPath(_) = source {
922-
return is_local(self.resolve_type_vars_with_obligations(rcvr_ty));
922+
return is_local(self.resolve_vars_with_obligations(rcvr_ty));
923923
}
924924

925925
self.autoderef(span, rcvr_ty).any(|(ty, _)| is_local(ty))

Diff for: src/librustc_typeck/check/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -2440,23 +2440,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24402440
self.cause(span, ObligationCauseCode::MiscObligation)
24412441
}
24422442

2443-
/// Resolves type variables in `ty` if possible. Unlike the infcx
2443+
/// Resolves type and const variables in `ty` if possible. Unlike the infcx
24442444
/// version (resolve_vars_if_possible), this version will
24452445
/// also select obligations if it seems useful, in an effort
24462446
/// to get more type information.
2447-
fn resolve_type_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
2448-
debug!("resolve_type_vars_with_obligations(ty={:?})", ty);
2447+
fn resolve_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
2448+
debug!("resolve_vars_with_obligations(ty={:?})", ty);
24492449

24502450
// No Infer()? Nothing needs doing.
24512451
if !ty.has_infer_types() && !ty.has_infer_consts() {
2452-
debug!("resolve_type_vars_with_obligations: ty={:?}", ty);
2452+
debug!("resolve_vars_with_obligations: ty={:?}", ty);
24532453
return ty;
24542454
}
24552455

24562456
// If `ty` is a type variable, see whether we already know what it is.
24572457
ty = self.resolve_vars_if_possible(&ty);
24582458
if !ty.has_infer_types() && !ty.has_infer_consts() {
2459-
debug!("resolve_type_vars_with_obligations: ty={:?}", ty);
2459+
debug!("resolve_vars_with_obligations: ty={:?}", ty);
24602460
return ty;
24612461
}
24622462

@@ -2467,7 +2467,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24672467
self.select_obligations_where_possible(false, |_| {});
24682468
ty = self.resolve_vars_if_possible(&ty);
24692469

2470-
debug!("resolve_type_vars_with_obligations: ty={:?}", ty);
2470+
debug!("resolve_vars_with_obligations: ty={:?}", ty);
24712471
ty
24722472
}
24732473

@@ -3668,7 +3668,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
36683668
formal_ret: Ty<'tcx>,
36693669
formal_args: &[Ty<'tcx>])
36703670
-> Vec<Ty<'tcx>> {
3671-
let formal_ret = self.resolve_type_vars_with_obligations(formal_ret);
3671+
let formal_ret = self.resolve_vars_with_obligations(formal_ret);
36723672
let ret_ty = match expected_ret.only_has_type(self) {
36733673
Some(ret) => ret,
36743674
None => return Vec::new()
@@ -4517,7 +4517,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
45174517
err.span_suggestion(
45184518
span,
45194519
"try adding a return type",
4520-
format!("-> {} ", self.resolve_type_vars_with_obligations(found)),
4520+
format!("-> {} ", self.resolve_vars_with_obligations(found)),
45214521
Applicability::MachineApplicable);
45224522
true
45234523
}
@@ -4993,7 +4993,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
49934993
// If no resolution is possible, then an error is reported.
49944994
// Numeric inference variables may be left unresolved.
49954995
pub fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
4996-
let ty = self.resolve_type_vars_with_obligations(ty);
4996+
let ty = self.resolve_vars_with_obligations(ty);
49974997
if !ty.is_ty_var() {
49984998
ty
49994999
} else {

Diff for: src/librustc_typeck/check/op.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
179179
self.check_expr_with_needs(lhs_expr, Needs::MutPlace)
180180
}
181181
};
182-
let lhs_ty = self.resolve_type_vars_with_obligations(lhs_ty);
182+
let lhs_ty = self.resolve_vars_with_obligations(lhs_ty);
183183

184184
// N.B., as we have not yet type-checked the RHS, we don't have the
185185
// type at hand. Make a variable to represent it. The whole reason
@@ -196,7 +196,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
196196

197197
// see `NB` above
198198
let rhs_ty = self.check_expr_coercable_to_type(rhs_expr, rhs_ty_var);
199-
let rhs_ty = self.resolve_type_vars_with_obligations(rhs_ty);
199+
let rhs_ty = self.resolve_vars_with_obligations(rhs_ty);
200200

201201
let return_ty = match result {
202202
Ok(method) => {

Diff for: src/librustc_typeck/check/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
251251
expected: Ty<'tcx>,
252252
mut def_bm: BindingMode,
253253
) -> (Ty<'tcx>, BindingMode) {
254-
let mut expected = self.resolve_type_vars_with_obligations(&expected);
254+
let mut expected = self.resolve_vars_with_obligations(&expected);
255255

256256
// Peel off as many `&` or `&mut` from the scrutinee type as possible. For example,
257257
// for `match &&&mut Some(5)` the loop runs three times, aborting when it reaches

0 commit comments

Comments
 (0)