Skip to content

Commit 5fdc0de

Browse files
committed
Eliminate unnecessary parameter
1 parent 1d9d30f commit 5fdc0de

File tree

5 files changed

+12
-21
lines changed

5 files changed

+12
-21
lines changed

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ hir_analysis_assoc_kind_mismatch = expected {$expected}, found {$got}
3737
3838
hir_analysis_assoc_kind_mismatch_wrap_in_braces_sugg = consider adding braces here
3939
40-
hir_analysis_associated_type_trait_uninferred_generic_params = cannot use the associated {$what} of a trait with uninferred generic parameters
40+
hir_analysis_associated_type_trait_uninferred_generic_params = cannot use the {$what} of a trait with uninferred generic parameters
4141
.suggestion = use a fully qualified path with inferred lifetimes
4242
4343
hir_analysis_associated_type_trait_uninferred_generic_params_multipart_suggestion = use a fully qualified path with explicit lifetimes

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use rustc_trait_selection::traits::ObligationCtxt;
4444
use tracing::{debug, instrument};
4545

4646
use crate::errors;
47-
use crate::hir_ty_lowering::errors::assoc_tag_str;
4847
use crate::hir_ty_lowering::{FeedConstTy, HirTyLowerer, RegionInferReason};
4948

5049
pub(crate) mod dump;
@@ -450,7 +449,6 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
450449
item_def_id: DefId,
451450
item_segment: &rustc_hir::PathSegment<'tcx>,
452451
poly_trait_ref: ty::PolyTraitRef<'tcx>,
453-
assoc_tag: ty::AssocTag,
454452
) -> Result<(DefId, ty::GenericArgsRef<'tcx>), ErrorGuaranteed> {
455453
if let Some(trait_ref) = poly_trait_ref.no_bound_vars() {
456454
let item_args = self.lowerer().lower_generic_args_of_assoc_item(
@@ -525,7 +523,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
525523
inferred_sugg,
526524
bound,
527525
mpart_sugg,
528-
what: assoc_tag_str(assoc_tag),
526+
what: self.tcx.def_descr(item_def_id),
529527
}))
530528
}
531529
}

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
803803
}
804804
};
805805

806+
let trait_def_id = bound.def_id();
807+
let assoc_fn = self
808+
.probe_assoc_item(assoc_ident, ty::AssocTag::Fn, qpath_hir_id, span, trait_def_id)
809+
.expect("failed to find associated fn");
810+
806811
// Don't let `T::method` resolve to some `for<'a> <T as Tr<'a>>::method`,
807812
// which may happen via a higher-ranked where clause or supertrait.
808813
// This is the same restrictions as associated types; even though we could
@@ -815,16 +820,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
815820
inferred_sugg: Some(span.with_hi(item_segment.ident.span.lo())),
816821
bound: format!("{}::", tcx.anonymize_bound_vars(bound).skip_binder(),),
817822
mpart_sugg: None,
818-
what: "function",
823+
what: assoc_fn.descr(),
819824
}));
820825
}
821826

822-
let trait_def_id = bound.def_id();
823-
let assoc_ty = self
824-
.probe_assoc_item(assoc_ident, ty::AssocTag::Fn, qpath_hir_id, span, trait_def_id)
825-
.expect("failed to find associated type");
826-
827-
Ok((bound, assoc_ty.def_id))
827+
Ok((bound, assoc_fn.def_id))
828828
}
829829

830830
/// Do the common parts of lowering an RTN type. This involves extending the

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ pub trait HirTyLowerer<'tcx> {
168168
item_def_id: DefId,
169169
item_segment: &hir::PathSegment<'tcx>,
170170
poly_trait_ref: ty::PolyTraitRef<'tcx>,
171-
assoc_tag: ty::AssocTag,
172171
) -> Result<(DefId, GenericArgsRef<'tcx>), ErrorGuaranteed>;
173172

174173
fn lower_fn_sig(
@@ -1433,13 +1432,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
14331432
let assoc_item = self
14341433
.probe_assoc_item(assoc_ident, mode.assoc_tag(), hir_ref_id, span, trait_did)
14351434
.expect("failed to find associated item");
1436-
let (def_id, args) = self.lower_assoc_shared(
1437-
span,
1438-
assoc_item.def_id,
1439-
assoc_segment,
1440-
bound,
1441-
mode.assoc_tag(),
1442-
)?;
1435+
let (def_id, args) =
1436+
self.lower_assoc_shared(span, assoc_item.def_id, assoc_segment, bound)?;
14431437
let result = LoweredAssoc::Term(def_id, args);
14441438

14451439
if let Some(variant_def_id) = variant_resolution {

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,10 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
314314
item_def_id: DefId,
315315
item_segment: &rustc_hir::PathSegment<'tcx>,
316316
poly_trait_ref: ty::PolyTraitRef<'tcx>,
317-
_assoc_tag: ty::AssocTag,
318317
) -> Result<(DefId, ty::GenericArgsRef<'tcx>), ErrorGuaranteed> {
319318
let trait_ref = self.instantiate_binder_with_fresh_vars(
320319
span,
321-
// FIXME(mgca): this should be assoc const if that is the `kind`
320+
// FIXME(mgca): `item_def_id` can be an AssocConst; rename this variant.
322321
infer::BoundRegionConversionTime::AssocTypeProjection(item_def_id),
323322
poly_trait_ref,
324323
);

0 commit comments

Comments
 (0)