Skip to content

Commit 5f0d585

Browse files
authored
Rollup merge of rust-lang#114684 - compiler-errors:redundant-resolves, r=lcnr
Remove redundant calls to `resolve_vars_with_obligations` I've been auditing the calls to `resolve_vars_with_obligations` for the new solver, and have found a few that have no effect on diagnostics. Let's just remove 'em. Also remove a redundant `resolve_vars_with_obligations_and_mutate_fulfillment` call. r? ``@lcnr``
2 parents 7e3616d + 6f8bb9d commit 5f0d585

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10391039
/// Returns false if the coercion creates any obligations that result in
10401040
/// errors.
10411041
pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
1042+
// FIXME(-Ztrait-solver=next): We need to structurally resolve both types here.
10421043
let source = self.resolve_vars_with_obligations(expr_ty);
10431044
debug!("coercion::can_with_predicates({:?} -> {:?})", source, target);
10441045

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
260260
));
261261
let expr = expr.peel_drop_temps();
262262
let cause = self.misc(expr.span);
263-
let expr_ty = self.resolve_vars_with_obligations(checked_ty);
263+
let expr_ty = self.resolve_vars_if_possible(checked_ty);
264264
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);
265265

266266
let is_insufficiently_polymorphic =

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8585
/// to get more type information.
8686
// FIXME(-Ztrait-solver=next): A lot of the calls to this method should
8787
// probably be `try_structurally_resolve_type` or `structurally_resolve_type` instead.
88-
pub(in super::super) fn resolve_vars_with_obligations(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
89-
self.resolve_vars_with_obligations_and_mutate_fulfillment(ty, |_| {})
90-
}
91-
92-
#[instrument(skip(self, mutate_fulfillment_errors), level = "debug", ret)]
93-
pub(in super::super) fn resolve_vars_with_obligations_and_mutate_fulfillment(
94-
&self,
95-
mut ty: Ty<'tcx>,
96-
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
97-
) -> Ty<'tcx> {
88+
#[instrument(skip(self), level = "debug", ret)]
89+
pub(in super::super) fn resolve_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
9890
// No Infer()? Nothing needs doing.
9991
if !ty.has_non_region_infer() {
10092
debug!("no inference var, nothing needs doing");
@@ -112,7 +104,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
112104
// possible. This can help substantially when there are
113105
// indirect dependencies that don't seem worth tracking
114106
// precisely.
115-
self.select_obligations_where_possible(mutate_fulfillment_errors);
107+
self.select_obligations_where_possible(|_| {});
116108
self.resolve_vars_if_possible(ty)
117109
}
118110

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
950950
if !expected.is_unit() {
951951
return;
952952
}
953-
let found = self.resolve_vars_with_obligations(found);
953+
let found = self.resolve_vars_if_possible(found);
954954

955955
let in_loop = self.is_loop(id)
956956
|| self

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29942994
// This occurs for UFCS desugaring of `T::method`, where there is no
29952995
// receiver expression for the method call, and thus no autoderef.
29962996
if let SelfSource::QPath(_) = source {
2997-
return is_local(self.resolve_vars_with_obligations(rcvr_ty));
2997+
return is_local(rcvr_ty);
29982998
}
29992999

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

0 commit comments

Comments
 (0)