Skip to content

Commit 0c47dee

Browse files
committed
Reduce the amount of passed-around arguments that will get merged into one later anyway
1 parent 1cbc459 commit 0c47dee

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

compiler/rustc_middle/src/ty/adjustment.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use crate::ty::subst::SubstsRef;
21
use crate::ty::{self, Ty, TyCtxt};
32
use rustc_hir as hir;
4-
use rustc_hir::def_id::DefId;
53
use rustc_hir::lang_items::LangItem;
64
use rustc_macros::HashStable;
75
use rustc_span::Span;
@@ -121,7 +119,8 @@ pub struct OverloadedDeref<'tcx> {
121119
}
122120

123121
impl<'tcx> OverloadedDeref<'tcx> {
124-
pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> (DefId, SubstsRef<'tcx>) {
122+
/// Get the zst function item type for this method call.
123+
pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> Ty<'tcx> {
125124
let trait_def_id = match self.mutbl {
126125
hir::Mutability::Not => tcx.require_lang_item(LangItem::Deref, None),
127126
hir::Mutability::Mut => tcx.require_lang_item(LangItem::DerefMut, None),
@@ -132,7 +131,7 @@ impl<'tcx> OverloadedDeref<'tcx> {
132131
.find(|m| m.kind == ty::AssocKind::Fn)
133132
.unwrap()
134133
.def_id;
135-
(method_def_id, tcx.mk_substs_trait(source, &[]))
134+
tcx.mk_fn_def(method_def_id, tcx.mk_substs_trait(source, &[]))
136135
}
137136
}
138137

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ use rustc_middle::thir::*;
1414
use rustc_middle::ty::adjustment::{
1515
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCast,
1616
};
17-
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
17+
use rustc_middle::ty::subst::InternalSubsts;
1818
use rustc_middle::ty::{
1919
self, AdtKind, InlineConstSubsts, InlineConstSubstsParts, ScalarInt, Ty, UpvarSubsts, UserType,
2020
};
21-
use rustc_span::def_id::DefId;
2221
use rustc_span::Span;
2322
use rustc_target::abi::VariantIdx;
2423

@@ -806,23 +805,25 @@ impl<'tcx> Cx<'tcx> {
806805
&mut self,
807806
expr: &hir::Expr<'_>,
808807
span: Span,
809-
overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>,
808+
overloaded_callee: Option<Ty<'tcx>>,
810809
) -> Expr<'tcx> {
811810
let temp_lifetime =
812811
self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id);
813-
let (def_id, substs, user_ty) = match overloaded_callee {
814-
Some((def_id, substs)) => (def_id, substs, None),
812+
let (ty, user_ty) = match overloaded_callee {
813+
Some(fn_def) => (fn_def, None),
815814
None => {
816815
let (kind, def_id) =
817816
self.typeck_results().type_dependent_def(expr.hir_id).unwrap_or_else(|| {
818817
span_bug!(expr.span, "no type-dependent def for method callee")
819818
});
820819
let user_ty = self.user_substs_applied_to_res(expr.hir_id, Res::Def(kind, def_id));
821820
debug!("method_callee: user_ty={:?}", user_ty);
822-
(def_id, self.typeck_results().node_substs(expr.hir_id), user_ty)
821+
(
822+
self.tcx().mk_fn_def(def_id, self.typeck_results().node_substs(expr.hir_id)),
823+
user_ty,
824+
)
823825
}
824826
};
825-
let ty = self.tcx().mk_fn_def(def_id, substs);
826827
Expr { temp_lifetime, ty, span, kind: ExprKind::ZstLiteral { user_ty } }
827828
}
828829

@@ -957,7 +958,7 @@ impl<'tcx> Cx<'tcx> {
957958
&mut self,
958959
expr: &'tcx hir::Expr<'tcx>,
959960
place_ty: Ty<'tcx>,
960-
overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>,
961+
overloaded_callee: Option<Ty<'tcx>>,
961962
args: Box<[ExprId]>,
962963
span: Span,
963964
) -> ExprKind<'tcx> {

0 commit comments

Comments
 (0)