Eliminate unnecessary parameter
This commit is contained in:
parent
1d9d30f35a
commit
5fdc0de28c
5 changed files with 12 additions and 21 deletions
|
|
@ -37,7 +37,7 @@ hir_analysis_assoc_kind_mismatch = expected {$expected}, found {$got}
|
|||
|
||||
hir_analysis_assoc_kind_mismatch_wrap_in_braces_sugg = consider adding braces here
|
||||
|
||||
hir_analysis_associated_type_trait_uninferred_generic_params = cannot use the associated {$what} of a trait with uninferred generic parameters
|
||||
hir_analysis_associated_type_trait_uninferred_generic_params = cannot use the {$what} of a trait with uninferred generic parameters
|
||||
.suggestion = use a fully qualified path with inferred lifetimes
|
||||
|
||||
hir_analysis_associated_type_trait_uninferred_generic_params_multipart_suggestion = use a fully qualified path with explicit lifetimes
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ use rustc_trait_selection::traits::ObligationCtxt;
|
|||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::errors;
|
||||
use crate::hir_ty_lowering::errors::assoc_tag_str;
|
||||
use crate::hir_ty_lowering::{FeedConstTy, HirTyLowerer, RegionInferReason};
|
||||
|
||||
pub(crate) mod dump;
|
||||
|
|
@ -450,7 +449,6 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
|
|||
item_def_id: DefId,
|
||||
item_segment: &rustc_hir::PathSegment<'tcx>,
|
||||
poly_trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
assoc_tag: ty::AssocTag,
|
||||
) -> Result<(DefId, ty::GenericArgsRef<'tcx>), ErrorGuaranteed> {
|
||||
if let Some(trait_ref) = poly_trait_ref.no_bound_vars() {
|
||||
let item_args = self.lowerer().lower_generic_args_of_assoc_item(
|
||||
|
|
@ -525,7 +523,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
|
|||
inferred_sugg,
|
||||
bound,
|
||||
mpart_sugg,
|
||||
what: assoc_tag_str(assoc_tag),
|
||||
what: self.tcx.def_descr(item_def_id),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -803,6 +803,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
}
|
||||
};
|
||||
|
||||
let trait_def_id = bound.def_id();
|
||||
let assoc_fn = self
|
||||
.probe_assoc_item(assoc_ident, ty::AssocTag::Fn, qpath_hir_id, span, trait_def_id)
|
||||
.expect("failed to find associated fn");
|
||||
|
||||
// Don't let `T::method` resolve to some `for<'a> <T as Tr<'a>>::method`,
|
||||
// which may happen via a higher-ranked where clause or supertrait.
|
||||
// This is the same restrictions as associated types; even though we could
|
||||
|
|
@ -815,16 +820,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
inferred_sugg: Some(span.with_hi(item_segment.ident.span.lo())),
|
||||
bound: format!("{}::", tcx.anonymize_bound_vars(bound).skip_binder(),),
|
||||
mpart_sugg: None,
|
||||
what: "function",
|
||||
what: assoc_fn.descr(),
|
||||
}));
|
||||
}
|
||||
|
||||
let trait_def_id = bound.def_id();
|
||||
let assoc_ty = self
|
||||
.probe_assoc_item(assoc_ident, ty::AssocTag::Fn, qpath_hir_id, span, trait_def_id)
|
||||
.expect("failed to find associated type");
|
||||
|
||||
Ok((bound, assoc_ty.def_id))
|
||||
Ok((bound, assoc_fn.def_id))
|
||||
}
|
||||
|
||||
/// Do the common parts of lowering an RTN type. This involves extending the
|
||||
|
|
|
|||
|
|
@ -168,7 +168,6 @@ pub trait HirTyLowerer<'tcx> {
|
|||
item_def_id: DefId,
|
||||
item_segment: &hir::PathSegment<'tcx>,
|
||||
poly_trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
assoc_tag: ty::AssocTag,
|
||||
) -> Result<(DefId, GenericArgsRef<'tcx>), ErrorGuaranteed>;
|
||||
|
||||
fn lower_fn_sig(
|
||||
|
|
@ -1433,13 +1432,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
let assoc_item = self
|
||||
.probe_assoc_item(assoc_ident, mode.assoc_tag(), hir_ref_id, span, trait_did)
|
||||
.expect("failed to find associated item");
|
||||
let (def_id, args) = self.lower_assoc_shared(
|
||||
span,
|
||||
assoc_item.def_id,
|
||||
assoc_segment,
|
||||
bound,
|
||||
mode.assoc_tag(),
|
||||
)?;
|
||||
let (def_id, args) =
|
||||
self.lower_assoc_shared(span, assoc_item.def_id, assoc_segment, bound)?;
|
||||
let result = LoweredAssoc::Term(def_id, args);
|
||||
|
||||
if let Some(variant_def_id) = variant_resolution {
|
||||
|
|
|
|||
|
|
@ -314,11 +314,10 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
|
|||
item_def_id: DefId,
|
||||
item_segment: &rustc_hir::PathSegment<'tcx>,
|
||||
poly_trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
_assoc_tag: ty::AssocTag,
|
||||
) -> Result<(DefId, ty::GenericArgsRef<'tcx>), ErrorGuaranteed> {
|
||||
let trait_ref = self.instantiate_binder_with_fresh_vars(
|
||||
span,
|
||||
// FIXME(mgca): this should be assoc const if that is the `kind`
|
||||
// FIXME(mgca): `item_def_id` can be an AssocConst; rename this variant.
|
||||
infer::BoundRegionConversionTime::AssocTypeProjection(item_def_id),
|
||||
poly_trait_ref,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue