Skip to content

Commit

Permalink
Avoid passing a full Expr when only the Span is used
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jan 8, 2025
1 parent 1f81f90 commit 9942b77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// We always require that the type provided as the value for
// a type parameter outlives the moment of instantiation.
let args = self.typeck_results.borrow().node_args(expr.hir_id);
self.add_wf_bounds(args, expr);
self.add_wf_bounds(args, expr.span);

ty
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

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

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {

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

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

0 comments on commit 9942b77

Please sign in to comment.