Skip to content

Commit 881862e

Browse files
committed
Rename fn_trait_kind_from_{from_lang=>def_id} to better convey meaning
1 parent 0e9eee6 commit 881862e

File tree

11 files changed

+14
-14
lines changed

11 files changed

+14
-14
lines changed

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
178178
});
179179
let kind = object_type
180180
.principal_def_id()
181-
.and_then(|did| self.tcx.fn_trait_kind_from_lang_item(did));
181+
.and_then(|did| self.tcx.fn_trait_kind_from_def_id(did));
182182
(sig, kind)
183183
}
184184
ty::Infer(ty::TyVar(vid)) => self.deduce_signature_from_predicates(
@@ -235,7 +235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
235235
_ => None,
236236
};
237237
if let Some(closure_kind) =
238-
trait_def_id.and_then(|def_id| self.tcx.fn_trait_kind_from_lang_item(def_id))
238+
trait_def_id.and_then(|def_id| self.tcx.fn_trait_kind_from_def_id(def_id))
239239
{
240240
expected_kind = Some(
241241
expected_kind
@@ -263,7 +263,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263263

264264
let trait_def_id = projection.trait_def_id(tcx);
265265

266-
let is_fn = tcx.fn_trait_kind_from_lang_item(trait_def_id).is_some();
266+
let is_fn = tcx.fn_trait_kind_from_def_id(trait_def_id).is_some();
267267
let gen_trait = tcx.require_lang_item(LangItem::Generator, cause_span);
268268
let is_gen = gen_trait == trait_def_id;
269269
if !is_fn && !is_gen {

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
401401
if self_ty.value.is_closure()
402402
&& self
403403
.tcx()
404-
.fn_trait_kind_from_lang_item(expected_trait_ref.value.def_id)
404+
.fn_trait_kind_from_def_id(expected_trait_ref.value.def_id)
405405
.is_some()
406406
{
407407
let closure_sig = self_ty.map(|closure| {

compiler/rustc_middle/src/middle/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'tcx> TyCtxt<'tcx> {
2727
})
2828
}
2929

30-
pub fn fn_trait_kind_from_lang_item(self, id: DefId) -> Option<ty::ClosureKind> {
30+
pub fn fn_trait_kind_from_def_id(self, id: DefId) -> Option<ty::ClosureKind> {
3131
let items = self.lang_items();
3232
match Some(id) {
3333
x if x == items.fn_trait() => Some(ty::ClosureKind::Fn),

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ pub trait PrettyPrinter<'tcx>:
10851085
let mut resugared = false;
10861086

10871087
// Special-case `Fn(...) -> ...` and re-sugar it.
1088-
let fn_trait_kind = cx.tcx().fn_trait_kind_from_lang_item(principal.def_id);
1088+
let fn_trait_kind = cx.tcx().fn_trait_kind_from_def_id(principal.def_id);
10891089
if !cx.should_print_verbose() && fn_trait_kind.is_some() {
10901090
if let ty::Tuple(tys) = principal.substs.type_at(0).kind() {
10911091
let mut projections = predicates.projection_bounds();

compiler/rustc_mir_transform/src/shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
3737
}
3838
ty::InstanceDef::FnPtrShim(def_id, ty) => {
3939
let trait_ = tcx.trait_of_item(def_id).unwrap();
40-
let adjustment = match tcx.fn_trait_kind_from_lang_item(trait_) {
40+
let adjustment = match tcx.fn_trait_kind_from_def_id(trait_) {
4141
Some(ty::ClosureKind::FnOnce) => Adjustment::Identity,
4242
Some(ty::ClosureKind::FnMut | ty::ClosureKind::Fn) => Adjustment::Deref,
4343
None => bug!("fn pointer {:?} is not an fn", ty),

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
21552155
if generics.params.iter().any(|p| p.name != kw::SelfUpper)
21562156
&& !snippet.ends_with('>')
21572157
&& !generics.has_impl_trait()
2158-
&& !self.tcx.fn_trait_kind_from_lang_item(def_id).is_some()
2158+
&& !self.tcx.fn_trait_kind_from_def_id(def_id).is_some()
21592159
{
21602160
// FIXME: To avoid spurious suggestions in functions where type arguments
21612161
// where already supplied, we check the snippet to make sure it doesn't

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
16801680
let inputs = trait_ref.skip_binder().substs.type_at(1);
16811681
let sig = match inputs.kind() {
16821682
ty::Tuple(inputs)
1683-
if infcx.tcx.fn_trait_kind_from_lang_item(trait_ref.def_id()).is_some() =>
1683+
if infcx.tcx.fn_trait_kind_from_def_id(trait_ref.def_id()).is_some() =>
16841684
{
16851685
infcx.tcx.mk_fn_sig(
16861686
inputs.iter(),

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
451451
obligation: &TraitObligation<'tcx>,
452452
candidates: &mut SelectionCandidateSet<'tcx>,
453453
) {
454-
let Some(kind) = self.tcx().fn_trait_kind_from_lang_item(obligation.predicate.def_id()) else {
454+
let Some(kind) = self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()) else {
455455
return;
456456
};
457457

@@ -489,7 +489,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
489489
candidates: &mut SelectionCandidateSet<'tcx>,
490490
) {
491491
// We provide impl of all fn traits for fn pointers.
492-
if self.tcx().fn_trait_kind_from_lang_item(obligation.predicate.def_id()).is_none() {
492+
if self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()).is_none() {
493493
return;
494494
}
495495

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
735735
) -> Result<ImplSourceClosureData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
736736
let kind = self
737737
.tcx()
738-
.fn_trait_kind_from_lang_item(obligation.predicate.def_id())
738+
.fn_trait_kind_from_def_id(obligation.predicate.def_id())
739739
.unwrap_or_else(|| bug!("closure candidate for non-fn trait {:?}", obligation));
740740

741741
// Okay to skip binder because the substs on closure types never

compiler/rustc_ty_utils/src/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn resolve_associated_item<'tcx>(
209209
substs: future_data.substs,
210210
}),
211211
traits::ImplSource::Closure(closure_data) => {
212-
let trait_closure_kind = tcx.fn_trait_kind_from_lang_item(trait_id).unwrap();
212+
let trait_closure_kind = tcx.fn_trait_kind_from_def_id(trait_id).unwrap();
213213
Instance::resolve_closure(
214214
tcx,
215215
closure_data.closure_def_id,

src/librustdoc/clean/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn external_generic_args<'tcx>(
106106
) -> GenericArgs {
107107
let args = substs_to_args(cx, substs, has_self);
108108

109-
if cx.tcx.fn_trait_kind_from_lang_item(did).is_some() {
109+
if cx.tcx.fn_trait_kind_from_def_id(did).is_some() {
110110
let inputs =
111111
// The trait's first substitution is the one after self, if there is one.
112112
match substs.iter().nth(if has_self { 1 } else { 0 }).unwrap().expect_ty().kind() {

0 commit comments

Comments
 (0)