Skip to content

Commit b0eaaca

Browse files
Remove redundant InferCtxtExt::fresh_item_substs
1 parent bbc536d commit b0eaaca

File tree

4 files changed

+3
-41
lines changed

4 files changed

+3
-41
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-36
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
2626
use rustc_hir::def_id::{DefId, LocalDefId};
2727
use rustc_hir::intravisit::{walk_generics, Visitor as _};
2828
use rustc_hir::{GenericArg, GenericArgs, OpaqueTyOrigin};
29-
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
3029
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
3130
use rustc_infer::traits::ObligationCause;
32-
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
3331
use rustc_middle::middle::stability::AllowUnstable;
3432
use rustc_middle::ty::fold::FnMutDelegate;
3533
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
@@ -2488,7 +2486,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24882486
infcx.probe(|_| {
24892487
let ocx = ObligationCtxt::new_in_snapshot(&infcx);
24902488

2491-
let impl_substs = infcx.fresh_item_substs(impl_);
2489+
let impl_substs = infcx.fresh_substs_for_item(span, impl_);
24922490
let impl_ty = tcx.type_of(impl_).subst(tcx, impl_substs);
24932491
let impl_ty = ocx.normalize(&cause, param_env, impl_ty);
24942492

@@ -3775,36 +3773,3 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
37753773
}
37763774
}
37773775
}
3778-
3779-
pub trait InferCtxtExt<'tcx> {
3780-
fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx>;
3781-
}
3782-
3783-
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
3784-
fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> {
3785-
InternalSubsts::for_item(self.tcx, def_id, |param, _| match param.kind {
3786-
GenericParamDefKind::Lifetime => self.tcx.lifetimes.re_erased.into(),
3787-
GenericParamDefKind::Type { .. } => self
3788-
.next_ty_var(TypeVariableOrigin {
3789-
kind: TypeVariableOriginKind::SubstitutionPlaceholder,
3790-
span: self.tcx.def_span(def_id),
3791-
})
3792-
.into(),
3793-
GenericParamDefKind::Const { .. } => {
3794-
let span = self.tcx.def_span(def_id);
3795-
let origin = ConstVariableOrigin {
3796-
kind: ConstVariableOriginKind::SubstitutionPlaceholder,
3797-
span,
3798-
};
3799-
self.next_const_var(
3800-
self.tcx
3801-
.type_of(param.def_id)
3802-
.no_bound_vars()
3803-
.expect("const parameter types cannot be generic"),
3804-
origin,
3805-
)
3806-
.into()
3807-
}
3808-
})
3809-
}
3810-
}

compiler/rustc_hir_typeck/src/method/probe.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_data_structures::fx::FxHashSet;
99
use rustc_errors::Applicability;
1010
use rustc_hir as hir;
1111
use rustc_hir::def::DefKind;
12-
use rustc_hir_analysis::astconv::InferCtxtExt as _;
1312
use rustc_hir_analysis::autoderef::{self, Autoderef};
1413
use rustc_infer::infer::canonical::OriginalQueryValues;
1514
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
@@ -954,7 +953,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
954953
trait_def_id: DefId,
955954
) {
956955
debug!("assemble_extension_candidates_for_trait(trait_def_id={:?})", trait_def_id);
957-
let trait_substs = self.fresh_item_substs(trait_def_id);
956+
let trait_substs = self.fresh_substs_for_item(self.span, trait_def_id);
958957
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, trait_substs);
959958

960959
if self.tcx.is_trait_alias(trait_def_id) {
@@ -1899,7 +1898,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
18991898
&self,
19001899
impl_def_id: DefId,
19011900
) -> (ty::EarlyBinder<Ty<'tcx>>, SubstsRef<'tcx>) {
1902-
(self.tcx.type_of(impl_def_id), self.fresh_item_substs(impl_def_id))
1901+
(self.tcx.type_of(impl_def_id), self.fresh_substs_for_item(self.span, impl_def_id))
19031902
}
19041903

19051904
/// Replaces late-bound-regions bound by `value` with `'static` using

compiler/rustc_infer/src/infer/type_variable.rs

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ pub enum TypeVariableOriginKind {
129129
/// (before it has been determined).
130130
// FIXME(eddyb) distinguish upvar inference variables from the rest.
131131
ClosureSynthetic,
132-
SubstitutionPlaceholder,
133132
AutoDeref,
134133
AdjustmentType,
135134

compiler/rustc_middle/src/infer/unify_key.rs

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ pub enum ConstVariableOriginKind {
116116
MiscVariable,
117117
ConstInference,
118118
ConstParameterDefinition(Symbol, DefId),
119-
SubstitutionPlaceholder,
120119
}
121120

122121
#[derive(Copy, Clone, Debug)]

0 commit comments

Comments
 (0)