// Consider all generic params in a predicate as used if any other parameter in the
// predicate is used.
let any_param_used = {
- let mut vis = HasUsedGenericParams { unused_parameters };
+ let mut vis = HasUsedGenericParams { tcx, unused_parameters };
predicate.visit_with(&mut vis).is_break()
};
unused_parameters: &FiniteBitSet<u32>,
) {
let base_def_id = tcx.closure_base_def_id(def_id);
- if !tcx
- .get_attrs(base_def_id)
- .iter()
- .any(|a| tcx.sess.check_name(a, sym::rustc_polymorphize_error))
- {
+ if !tcx.get_attrs(base_def_id).iter().any(|a| a.has_name(sym::rustc_polymorphize_error)) {
return;
}
}
impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
+ fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
+ Some(self.tcx)
+ }
#[instrument(skip(self))]
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> {
- if !c.has_param_types_or_consts() {
+ if !c.potentially_has_param_types_or_consts() {
return ControlFlow::CONTINUE;
}
self.unused_parameters.clear(param.index);
ControlFlow::CONTINUE
}
- ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted: Some(p)})
+ ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs_: _, promoted: Some(p)})
// Avoid considering `T` unused when constants are of the form:
// `<Self as Foo<T>>::foo::promoted[p]`
if self.def_id == def.did && !self.tcx.generics_of(def.did).has_self =>
self.visit_body(&promoted[p]);
ControlFlow::CONTINUE
}
- ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted: None })
- if self.tcx.def_kind(def.did) == DefKind::AnonConst =>
+ ty::ConstKind::Unevaluated(uv)
+ if self.tcx.def_kind(uv.def.did) == DefKind::AnonConst =>
{
- self.visit_child_body(def.did, substs);
+ self.visit_child_body(uv.def.did, uv.substs(self.tcx));
ControlFlow::CONTINUE
}
_ => c.super_visit_with(self),
#[instrument(skip(self))]
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
- if !ty.has_param_types_or_consts() {
+ if !ty.potentially_has_param_types_or_consts() {
return ControlFlow::CONTINUE;
}
}
/// Visitor used to check if a generic parameter is used.
-struct HasUsedGenericParams<'a> {
+struct HasUsedGenericParams<'a, 'tcx> {
+ tcx: TyCtxt<'tcx>,
unused_parameters: &'a FiniteBitSet<u32>,
}
-impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> {
+impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a, 'tcx> {
type BreakTy = ();
+ fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
+ Some(self.tcx)
+ }
+
#[instrument(skip(self))]
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> {
- if !c.has_param_types_or_consts() {
+ if !c.potentially_has_param_types_or_consts() {
return ControlFlow::CONTINUE;
}
#[instrument(skip(self))]
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
- if !ty.has_param_types_or_consts() {
+ if !ty.potentially_has_param_types_or_consts() {
return ControlFlow::CONTINUE;
}