Skip to content

Commit

Permalink
Rollup merge of #65295 - estebank:gotta-go-fast, r=nnethercote
Browse files Browse the repository at this point in the history
Move diagnostics code out of the critical path

Follow up to #65077.

r? @nnethercote
  • Loading branch information
Centril authored Oct 13, 2019
2 parents 540278c + 5bb0a03 commit 433ea1a
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/librustc_typeck/check/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,27 +213,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
segment,
);

let mut needs_mut = false;
if let ty::Ref(region, t_type, mutability) = self_ty.kind {
let trait_type = self.tcx.mk_ref(region, ty::TypeAndMut {
ty: t_type,
mutbl: mutability.invert(),
});
match self.lookup_probe(
span,
segment.ident,
trait_type,
call_expr,
ProbeScope::TraitsInScope
) {
Ok(ref new_pick) if *new_pick != pick => {
needs_mut = true;
if result.illegal_sized_bound {
let mut needs_mut = false;
if let ty::Ref(region, t_type, mutability) = self_ty.kind {
let trait_type = self.tcx.mk_ref(region, ty::TypeAndMut {
ty: t_type,
mutbl: mutability.invert(),
});
// We probe again to see if there might be a borrow mutability discrepancy.
match self.lookup_probe(
span,
segment.ident,
trait_type,
call_expr,
ProbeScope::TraitsInScope
) {
Ok(ref new_pick) if *new_pick != pick => {
needs_mut = true;
}
_ => {}
}
_ => {}
}
}

if result.illegal_sized_bound {
// We probe again, taking all traits into account (not only those in scope).
let candidates = match self.lookup_probe(
span,
Expand Down

0 comments on commit 433ea1a

Please sign in to comment.