mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
Rename fn_trait_kind_from_{from_lang=>def_id}
to better convey meaning
This commit is contained in:
parent
0e9eee6811
commit
881862ecb7
@ -178,7 +178,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
});
|
||||
let kind = object_type
|
||||
.principal_def_id()
|
||||
.and_then(|did| self.tcx.fn_trait_kind_from_lang_item(did));
|
||||
.and_then(|did| self.tcx.fn_trait_kind_from_def_id(did));
|
||||
(sig, kind)
|
||||
}
|
||||
ty::Infer(ty::TyVar(vid)) => self.deduce_signature_from_predicates(
|
||||
@ -235,7 +235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
_ => None,
|
||||
};
|
||||
if let Some(closure_kind) =
|
||||
trait_def_id.and_then(|def_id| self.tcx.fn_trait_kind_from_lang_item(def_id))
|
||||
trait_def_id.and_then(|def_id| self.tcx.fn_trait_kind_from_def_id(def_id))
|
||||
{
|
||||
expected_kind = Some(
|
||||
expected_kind
|
||||
@ -263,7 +263,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
let trait_def_id = projection.trait_def_id(tcx);
|
||||
|
||||
let is_fn = tcx.fn_trait_kind_from_lang_item(trait_def_id).is_some();
|
||||
let is_fn = tcx.fn_trait_kind_from_def_id(trait_def_id).is_some();
|
||||
let gen_trait = tcx.require_lang_item(LangItem::Generator, cause_span);
|
||||
let is_gen = gen_trait == trait_def_id;
|
||||
if !is_fn && !is_gen {
|
||||
|
@ -401,7 +401,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
|
||||
if self_ty.value.is_closure()
|
||||
&& self
|
||||
.tcx()
|
||||
.fn_trait_kind_from_lang_item(expected_trait_ref.value.def_id)
|
||||
.fn_trait_kind_from_def_id(expected_trait_ref.value.def_id)
|
||||
.is_some()
|
||||
{
|
||||
let closure_sig = self_ty.map(|closure| {
|
||||
|
@ -27,7 +27,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn fn_trait_kind_from_lang_item(self, id: DefId) -> Option<ty::ClosureKind> {
|
||||
pub fn fn_trait_kind_from_def_id(self, id: DefId) -> Option<ty::ClosureKind> {
|
||||
let items = self.lang_items();
|
||||
match Some(id) {
|
||||
x if x == items.fn_trait() => Some(ty::ClosureKind::Fn),
|
||||
|
@ -1085,7 +1085,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
let mut resugared = false;
|
||||
|
||||
// Special-case `Fn(...) -> ...` and re-sugar it.
|
||||
let fn_trait_kind = cx.tcx().fn_trait_kind_from_lang_item(principal.def_id);
|
||||
let fn_trait_kind = cx.tcx().fn_trait_kind_from_def_id(principal.def_id);
|
||||
if !cx.should_print_verbose() && fn_trait_kind.is_some() {
|
||||
if let ty::Tuple(tys) = principal.substs.type_at(0).kind() {
|
||||
let mut projections = predicates.projection_bounds();
|
||||
|
@ -37,7 +37,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
|
||||
}
|
||||
ty::InstanceDef::FnPtrShim(def_id, ty) => {
|
||||
let trait_ = tcx.trait_of_item(def_id).unwrap();
|
||||
let adjustment = match tcx.fn_trait_kind_from_lang_item(trait_) {
|
||||
let adjustment = match tcx.fn_trait_kind_from_def_id(trait_) {
|
||||
Some(ty::ClosureKind::FnOnce) => Adjustment::Identity,
|
||||
Some(ty::ClosureKind::FnMut | ty::ClosureKind::Fn) => Adjustment::Deref,
|
||||
None => bug!("fn pointer {:?} is not an fn", ty),
|
||||
|
@ -2155,7 +2155,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
if generics.params.iter().any(|p| p.name != kw::SelfUpper)
|
||||
&& !snippet.ends_with('>')
|
||||
&& !generics.has_impl_trait()
|
||||
&& !self.tcx.fn_trait_kind_from_lang_item(def_id).is_some()
|
||||
&& !self.tcx.fn_trait_kind_from_def_id(def_id).is_some()
|
||||
{
|
||||
// FIXME: To avoid spurious suggestions in functions where type arguments
|
||||
// where already supplied, we check the snippet to make sure it doesn't
|
||||
|
@ -1680,7 +1680,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
let inputs = trait_ref.skip_binder().substs.type_at(1);
|
||||
let sig = match inputs.kind() {
|
||||
ty::Tuple(inputs)
|
||||
if infcx.tcx.fn_trait_kind_from_lang_item(trait_ref.def_id()).is_some() =>
|
||||
if infcx.tcx.fn_trait_kind_from_def_id(trait_ref.def_id()).is_some() =>
|
||||
{
|
||||
infcx.tcx.mk_fn_sig(
|
||||
inputs.iter(),
|
||||
|
@ -451,7 +451,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
candidates: &mut SelectionCandidateSet<'tcx>,
|
||||
) {
|
||||
let Some(kind) = self.tcx().fn_trait_kind_from_lang_item(obligation.predicate.def_id()) else {
|
||||
let Some(kind) = self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()) else {
|
||||
return;
|
||||
};
|
||||
|
||||
@ -489,7 +489,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
candidates: &mut SelectionCandidateSet<'tcx>,
|
||||
) {
|
||||
// We provide impl of all fn traits for fn pointers.
|
||||
if self.tcx().fn_trait_kind_from_lang_item(obligation.predicate.def_id()).is_none() {
|
||||
if self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()).is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -735,7 +735,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
) -> Result<ImplSourceClosureData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
|
||||
let kind = self
|
||||
.tcx()
|
||||
.fn_trait_kind_from_lang_item(obligation.predicate.def_id())
|
||||
.fn_trait_kind_from_def_id(obligation.predicate.def_id())
|
||||
.unwrap_or_else(|| bug!("closure candidate for non-fn trait {:?}", obligation));
|
||||
|
||||
// Okay to skip binder because the substs on closure types never
|
||||
|
@ -209,7 +209,7 @@ fn resolve_associated_item<'tcx>(
|
||||
substs: future_data.substs,
|
||||
}),
|
||||
traits::ImplSource::Closure(closure_data) => {
|
||||
let trait_closure_kind = tcx.fn_trait_kind_from_lang_item(trait_id).unwrap();
|
||||
let trait_closure_kind = tcx.fn_trait_kind_from_def_id(trait_id).unwrap();
|
||||
Instance::resolve_closure(
|
||||
tcx,
|
||||
closure_data.closure_def_id,
|
||||
|
@ -106,7 +106,7 @@ fn external_generic_args<'tcx>(
|
||||
) -> GenericArgs {
|
||||
let args = substs_to_args(cx, substs, has_self);
|
||||
|
||||
if cx.tcx.fn_trait_kind_from_lang_item(did).is_some() {
|
||||
if cx.tcx.fn_trait_kind_from_def_id(did).is_some() {
|
||||
let inputs =
|
||||
// The trait's first substitution is the one after self, if there is one.
|
||||
match substs.iter().nth(if has_self { 1 } else { 0 }).unwrap().expect_ty().kind() {
|
||||
|
Loading…
Reference in New Issue
Block a user