Skip to content

Commit 56c2469

Browse files
committed
Avoid passing a full Expr when only the Span is used
1 parent 37e7459 commit 56c2469

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
835835
// We always require that the type provided as the value for
836836
// a type parameter outlives the moment of instantiation.
837837
let args = self.typeck_results.borrow().node_args(expr.hir_id);
838-
self.add_wf_bounds(args, expr);
838+
self.add_wf_bounds(args, expr.span);
839839

840840
ty
841841
}

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
579579
}
580580

581581
/// Registers obligations that all `args` are well-formed.
582-
pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, expr: &hir::Expr<'_>) {
582+
pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, span: Span) {
583583
for arg in args.iter().filter(|arg| {
584584
matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
585585
}) {
586-
self.register_wf_obligation(arg, expr.span, ObligationCauseCode::WellFormed(None));
586+
self.register_wf_obligation(arg, span, ObligationCauseCode::WellFormed(None));
587587
}
588588
}
589589

compiler/rustc_hir_typeck/src/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
611611

612612
// this is a projection from a trait reference, so we have to
613613
// make sure that the trait reference inputs are well-formed.
614-
self.add_wf_bounds(all_args, self.call_expr);
614+
self.add_wf_bounds(all_args, self.call_expr.span);
615615

616616
// the function type must also be well-formed (this is not
617617
// implied by the args being well-formed because of inherent

0 commit comments

Comments
 (0)