Skip to content

Commit

Permalink
Define values and err as non mutable
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Dec 2, 2022
1 parent 4dacf4f commit 8904743
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,18 +1576,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
return;
}

let mut values = None;

self.probe(|_| {
let ocx = ObligationCtxt::new_in_snapshot(self);
let mut err = error.err;

// try to find the mismatched types to report the error with.
//
// this can fail if the problem was higher-ranked, in which
// cause I have no idea for a good error message.
let bound_predicate = predicate.kind();
if let ty::PredicateKind::Clause(ty::Clause::Projection(data)) =
let (values, err) = if let ty::PredicateKind::Clause(ty::Clause::Projection(data)) =
bound_predicate.skip_binder()
{
let data = self.replace_bound_vars_with_fresh_vars(
Expand Down Expand Up @@ -1628,10 +1625,13 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
normalized_ty,
expected_ty,
) {
values = Some((data, is_normalized_ty_expected, normalized_ty, expected_ty));
err = new_err;
(Some((data, is_normalized_ty_expected, normalized_ty, expected_ty)), new_err)
} else {
(None, error.err)
}
}
} else {
(None, error.err)
};

let msg = values
.and_then(|(predicate, _, normalized_ty, expected_ty)| {
Expand Down

0 comments on commit 8904743

Please sign in to comment.