Formatting

This commit is contained in:
Esteban Küber 2023-01-03 20:32:15 -08:00
parent 9cc8d86190
commit 4ac7d1c3ab

View File

@ -294,7 +294,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let id = map.get_parent_item(hir_id);
let hir_id: hir::HirId = id.into();
if let Some(node) = map.find(hir_id) && let Some(body_id) = node.body_id() {
let Some(node) = map.find(hir_id) else { return false; };
let Some(body_id) = node.body_id() else { return false; };
let body = map.body(body_id);
expr_finder.visit_expr(body.value);
let mut eraser = TypeEraser { tcx };
@ -311,7 +312,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
kind: hir::StmtKind::Expr(expr) | hir::StmtKind::Semi(expr),
..
})) = &map.find(parent)
&& let hir::ExprKind::MethodCall(s, rcvr, args, _span) = expr.kind
&& let hir::ExprKind::MethodCall(segment, rcvr, args, _span) = expr.kind
&& rcvr.hir_id == binding.hir_id
&& let Some(def_id) = self.typeck_results.borrow().type_dependent_def_id(expr.hir_id)
{
@ -323,7 +324,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Get the evaluated type *after* calling the method call, so that the influence
// of the arguments can be reflected in the receiver type. The receiver
// expression has the type *before* theis analysis is done.
let ty = match self.lookup_probe(s.ident, rcvr_ty, expr, probe::ProbeScope::TraitsInScope) {
let ty = match self.lookup_probe(
segment.ident,
rcvr_ty,
expr,
probe::ProbeScope::TraitsInScope,
) {
Ok(pick) => pick.self_ty,
Err(_) => rcvr_ty,
};
@ -396,7 +402,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
// We only point at the first place where the found type was inferred.
err.span_label(
s.ident.span,
segment.ident.span,
with_forced_trimmed_paths!(format!(
"here the type of `{ident}` is inferred to be `{ty}`",
)),
@ -409,7 +415,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if ty.references_error() {
break;
}
if ty != prev && let Some(span) = prev_span && self.can_eq(self.param_env, ty, found).is_ok() {
if ty != prev
&& let Some(span) = prev_span
&& self.can_eq(self.param_env, ty, found).is_ok()
{
// We only point at the first place where the found type was inferred.
// We use the *previous* span because if the type is known *here* it means
// it was *evaluated earlier*. We don't do this for method calls because we
@ -431,7 +440,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
prev_span = Some(binding.span);
}
}
true
}