Reduce the amount of passed-around arguments that will get merged into one later anyway
This commit is contained in:
parent
1cbc45942d
commit
0c47deed9f
2 changed files with 12 additions and 12 deletions
|
@ -1,7 +1,5 @@
|
||||||
use crate::ty::subst::SubstsRef;
|
|
||||||
use crate::ty::{self, Ty, TyCtxt};
|
use crate::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
|
||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
@ -121,7 +119,8 @@ pub struct OverloadedDeref<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> OverloadedDeref<'tcx> {
|
impl<'tcx> OverloadedDeref<'tcx> {
|
||||||
pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> (DefId, SubstsRef<'tcx>) {
|
/// Get the zst function item type for this method call.
|
||||||
|
pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
let trait_def_id = match self.mutbl {
|
let trait_def_id = match self.mutbl {
|
||||||
hir::Mutability::Not => tcx.require_lang_item(LangItem::Deref, None),
|
hir::Mutability::Not => tcx.require_lang_item(LangItem::Deref, None),
|
||||||
hir::Mutability::Mut => tcx.require_lang_item(LangItem::DerefMut, None),
|
hir::Mutability::Mut => tcx.require_lang_item(LangItem::DerefMut, None),
|
||||||
|
@ -132,7 +131,7 @@ impl<'tcx> OverloadedDeref<'tcx> {
|
||||||
.find(|m| m.kind == ty::AssocKind::Fn)
|
.find(|m| m.kind == ty::AssocKind::Fn)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.def_id;
|
.def_id;
|
||||||
(method_def_id, tcx.mk_substs_trait(source, &[]))
|
tcx.mk_fn_def(method_def_id, tcx.mk_substs_trait(source, &[]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,10 @@ use rustc_middle::thir::*;
|
||||||
use rustc_middle::ty::adjustment::{
|
use rustc_middle::ty::adjustment::{
|
||||||
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCast,
|
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCast,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
|
use rustc_middle::ty::subst::InternalSubsts;
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, AdtKind, InlineConstSubsts, InlineConstSubstsParts, ScalarInt, Ty, UpvarSubsts, UserType,
|
self, AdtKind, InlineConstSubsts, InlineConstSubstsParts, ScalarInt, Ty, UpvarSubsts, UserType,
|
||||||
};
|
};
|
||||||
use rustc_span::def_id::DefId;
|
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
|
|
||||||
|
@ -806,12 +805,12 @@ impl<'tcx> Cx<'tcx> {
|
||||||
&mut self,
|
&mut self,
|
||||||
expr: &hir::Expr<'_>,
|
expr: &hir::Expr<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>,
|
overloaded_callee: Option<Ty<'tcx>>,
|
||||||
) -> Expr<'tcx> {
|
) -> Expr<'tcx> {
|
||||||
let temp_lifetime =
|
let temp_lifetime =
|
||||||
self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id);
|
self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id);
|
||||||
let (def_id, substs, user_ty) = match overloaded_callee {
|
let (ty, user_ty) = match overloaded_callee {
|
||||||
Some((def_id, substs)) => (def_id, substs, None),
|
Some(fn_def) => (fn_def, None),
|
||||||
None => {
|
None => {
|
||||||
let (kind, def_id) =
|
let (kind, def_id) =
|
||||||
self.typeck_results().type_dependent_def(expr.hir_id).unwrap_or_else(|| {
|
self.typeck_results().type_dependent_def(expr.hir_id).unwrap_or_else(|| {
|
||||||
|
@ -819,10 +818,12 @@ impl<'tcx> Cx<'tcx> {
|
||||||
});
|
});
|
||||||
let user_ty = self.user_substs_applied_to_res(expr.hir_id, Res::Def(kind, def_id));
|
let user_ty = self.user_substs_applied_to_res(expr.hir_id, Res::Def(kind, def_id));
|
||||||
debug!("method_callee: user_ty={:?}", user_ty);
|
debug!("method_callee: user_ty={:?}", user_ty);
|
||||||
(def_id, self.typeck_results().node_substs(expr.hir_id), user_ty)
|
(
|
||||||
|
self.tcx().mk_fn_def(def_id, self.typeck_results().node_substs(expr.hir_id)),
|
||||||
|
user_ty,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let ty = self.tcx().mk_fn_def(def_id, substs);
|
|
||||||
Expr { temp_lifetime, ty, span, kind: ExprKind::ZstLiteral { user_ty } }
|
Expr { temp_lifetime, ty, span, kind: ExprKind::ZstLiteral { user_ty } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,7 +958,7 @@ impl<'tcx> Cx<'tcx> {
|
||||||
&mut self,
|
&mut self,
|
||||||
expr: &'tcx hir::Expr<'tcx>,
|
expr: &'tcx hir::Expr<'tcx>,
|
||||||
place_ty: Ty<'tcx>,
|
place_ty: Ty<'tcx>,
|
||||||
overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>,
|
overloaded_callee: Option<Ty<'tcx>>,
|
||||||
args: Box<[ExprId]>,
|
args: Box<[ExprId]>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> ExprKind<'tcx> {
|
) -> ExprKind<'tcx> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue