summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_monomorphize/src/polymorphize.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_monomorphize/src/polymorphize.rs')
-rw-r--r--compiler/rustc_monomorphize/src/polymorphize.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/compiler/rustc_monomorphize/src/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs
index 88a3e0285..a8b7a0dbb 100644
--- a/compiler/rustc_monomorphize/src/polymorphize.rs
+++ b/compiler/rustc_monomorphize/src/polymorphize.rs
@@ -14,9 +14,8 @@ use rustc_middle::mir::{
use rustc_middle::query::Providers;
use rustc_middle::ty::{
self,
- subst::SubstsRef,
visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor},
- Const, Ty, TyCtxt, UnusedGenericParams,
+ Const, GenericArgsRef, Ty, TyCtxt, UnusedGenericParams,
};
use rustc_span::symbol::sym;
use std::ops::ControlFlow;
@@ -144,7 +143,7 @@ fn mark_used_by_default_parameters<'tcx>(
| DefKind::Enum
| DefKind::Variant
| DefKind::Trait
- | DefKind::TyAlias
+ | DefKind::TyAlias { .. }
| DefKind::ForeignTy
| DefKind::TraitAlias
| DefKind::AssocTy
@@ -163,7 +162,6 @@ fn mark_used_by_default_parameters<'tcx>(
| DefKind::AnonConst
| DefKind::InlineConst
| DefKind::OpaqueTy
- | DefKind::ImplTraitPlaceholder
| DefKind::Field
| DefKind::LifetimeParam
| DefKind::GlobalAsm
@@ -230,12 +228,12 @@ struct MarkUsedGenericParams<'a, 'tcx> {
impl<'a, 'tcx> MarkUsedGenericParams<'a, 'tcx> {
/// Invoke `unused_generic_params` on a body contained within the current item (e.g.
/// a closure, generator or constant).
- #[instrument(level = "debug", skip(self, def_id, substs))]
- fn visit_child_body(&mut self, def_id: DefId, substs: SubstsRef<'tcx>) {
+ #[instrument(level = "debug", skip(self, def_id, args))]
+ fn visit_child_body(&mut self, def_id: DefId, args: GenericArgsRef<'tcx>) {
let instance = ty::InstanceDef::Item(def_id);
let unused = self.tcx.unused_generic_params(instance);
debug!(?self.unused_parameters, ?unused);
- for (i, arg) in substs.iter().enumerate() {
+ for (i, arg) in args.iter().enumerate() {
let i = i.try_into().unwrap();
if unused.is_used(i) {
arg.visit_with(self);
@@ -253,9 +251,9 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
if matches!(def_kind, DefKind::Closure | DefKind::Generator) {
// Skip visiting the closure/generator that is currently being processed. This only
// happens because the first argument to the closure is a reference to itself and
- // that will call `visit_substs`, resulting in each generic parameter captured being
+ // that will call `visit_args`, resulting in each generic parameter captured being
// considered used by default.
- debug!("skipping closure substs");
+ debug!("skipping closure args");
return;
}
}
@@ -268,12 +266,12 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
ConstantKind::Ty(c) => {
c.visit_with(self);
}
- ConstantKind::Unevaluated(mir::UnevaluatedConst { def, substs: _, promoted }, ty) => {
+ ConstantKind::Unevaluated(mir::UnevaluatedConst { def, args: _, promoted }, ty) => {
// Avoid considering `T` unused when constants are of the form:
// `<Self as Foo<T>>::foo::promoted[p]`
if let Some(p) = promoted {
if self.def_id == def && !self.tcx.generics_of(def).has_self {
- // If there is a promoted, don't look at the substs - since it will always contain
+ // If there is a promoted, don't look at the args - since it will always contain
// the generic parameters, instead, traverse the promoted MIR.
let promoted = self.tcx.promoted_mir(def);
self.visit_body(&promoted[p]);
@@ -304,10 +302,10 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for MarkUsedGenericParams<'a, 'tcx> {
self.unused_parameters.mark_used(param.index);
ControlFlow::Continue(())
}
- ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs })
+ ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args })
if matches!(self.tcx.def_kind(def), DefKind::AnonConst) =>
{
- self.visit_child_body(def, substs);
+ self.visit_child_body(def, args);
ControlFlow::Continue(())
}
_ => c.super_visit_with(self),
@@ -321,7 +319,7 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for MarkUsedGenericParams<'a, 'tcx> {
}
match *ty.kind() {
- ty::Closure(def_id, substs) | ty::Generator(def_id, substs, ..) => {
+ ty::Closure(def_id, args) | ty::Generator(def_id, args, ..) => {
debug!(?def_id);
// Avoid cycle errors with generators.
if def_id == self.def_id {
@@ -330,7 +328,7 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for MarkUsedGenericParams<'a, 'tcx> {
// Consider any generic parameters used by any closures/generators as used in the
// parent.
- self.visit_child_body(def_id, substs);
+ self.visit_child_body(def_id, args);
ControlFlow::Continue(())
}
ty::Param(param) => {