Skip to content

Commit ec41bc6

Browse files
committed
Rename fn_trait_kind_from_{from_lang=>def_id} to better convey meaning
1 parent 0f7d817 commit ec41bc6

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
@@ -1073,7 +1073,7 @@ pub trait PrettyPrinter<'tcx>:
10731073
let mut resugared = false;
10741074

10751075
// Special-case `Fn(...) -> ...` and re-sugar it.
1076-
let fn_trait_kind = cx.tcx().fn_trait_kind_from_lang_item(principal.def_id);
1076+
let fn_trait_kind = cx.tcx().fn_trait_kind_from_def_id(principal.def_id);
10771077
if !cx.should_print_verbose() && fn_trait_kind.is_some() {
10781078
if let ty::Tuple(tys) = principal.substs.type_at(0).kind() {
10791079
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
@@ -2152,7 +2152,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
21522152
if generics.params.iter().any(|p| p.name != kw::SelfUpper)
21532153
&& !snippet.ends_with('>')
21542154
&& !generics.has_impl_trait()
2155-
&& !self.tcx.fn_trait_kind_from_lang_item(def_id).is_some()
2155+
&& !self.tcx.fn_trait_kind_from_def_id(def_id).is_some()
21562156
{
21572157
// FIXME: To avoid spurious suggestions in functions where type arguments
21582158
// 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
@@ -1685,7 +1685,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
16851685
let inputs = trait_ref.skip_binder().substs.type_at(1);
16861686
let sig = match inputs.kind() {
16871687
ty::Tuple(inputs)
1688-
if infcx.tcx.fn_trait_kind_from_lang_item(trait_ref.def_id()).is_some() =>
1688+
if infcx.tcx.fn_trait_kind_from_def_id(trait_ref.def_id()).is_some() =>
16891689
{
16901690
infcx.tcx.mk_fn_sig(
16911691
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
@@ -435,7 +435,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
435435
obligation: &TraitObligation<'tcx>,
436436
candidates: &mut SelectionCandidateSet<'tcx>,
437437
) {
438-
let Some(kind) = self.tcx().fn_trait_kind_from_lang_item(obligation.predicate.def_id()) else {
438+
let Some(kind) = self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()) else {
439439
return;
440440
};
441441

@@ -473,7 +473,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
473473
candidates: &mut SelectionCandidateSet<'tcx>,
474474
) {
475475
// We provide impl of all fn traits for fn pointers.
476-
if self.tcx().fn_trait_kind_from_lang_item(obligation.predicate.def_id()).is_none() {
476+
if self.tcx().fn_trait_kind_from_def_id(obligation.predicate.def_id()).is_none() {
477477
return;
478478
}
479479

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
700700
) -> Result<ImplSourceClosureData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
701701
let kind = self
702702
.tcx()
703-
.fn_trait_kind_from_lang_item(obligation.predicate.def_id())
703+
.fn_trait_kind_from_def_id(obligation.predicate.def_id())
704704
.unwrap_or_else(|| bug!("closure candidate for non-fn trait {:?}", obligation));
705705

706706
// 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
@@ -203,7 +203,7 @@ fn resolve_associated_item<'tcx>(
203203
substs: generator_data.substs,
204204
}),
205205
traits::ImplSource::Closure(closure_data) => {
206-
let trait_closure_kind = tcx.fn_trait_kind_from_lang_item(trait_id).unwrap();
206+
let trait_closure_kind = tcx.fn_trait_kind_from_def_id(trait_id).unwrap();
207207
Instance::resolve_closure(
208208
tcx,
209209
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)