diff options
| author | bors <bors@rust-lang.org> | 2022-01-16 11:19:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-01-16 11:19:21 +0000 |
| commit | 7be8693984d32d2f65ce9ded4f65b6b7340bddce (patch) | |
| tree | 5f9cec2bbb5a4332ab6d80c61dbcc2afb8c8eb23 /compiler/rustc_monomorphize/src/polymorphize.rs | |
| parent | 42852d7857d2955f19ec333bec1ed107964db200 (diff) | |
| parent | 3f3a10fa64278173718b1fb9ee9ae85b14380af0 (diff) | |
| download | rust-7be8693984d32d2f65ce9ded4f65b6b7340bddce.tar.gz rust-7be8693984d32d2f65ce9ded4f65b6b7340bddce.zip | |
Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnr
partially revertish `lazily "compute" anon const default substs` reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049> r? `@lcnr`
Diffstat (limited to 'compiler/rustc_monomorphize/src/polymorphize.rs')
| -rw-r--r-- | compiler/rustc_monomorphize/src/polymorphize.rs | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/compiler/rustc_monomorphize/src/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs index 595080619da..4b17c22a68c 100644 --- a/compiler/rustc_monomorphize/src/polymorphize.rs +++ b/compiler/rustc_monomorphize/src/polymorphize.rs @@ -277,12 +277,9 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> { } impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> { - fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> { - Some(self.tcx) - } #[instrument(level = "debug", skip(self))] fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> { - if !c.potentially_has_param_types_or_consts() { + if !c.has_param_types_or_consts() { return ControlFlow::CONTINUE; } @@ -292,7 +289,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> { 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 => @@ -306,7 +303,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> { ty::ConstKind::Unevaluated(uv) if matches!(self.tcx.def_kind(uv.def.did), DefKind::AnonConst | DefKind::InlineConst) => { - self.visit_child_body(uv.def.did, uv.substs(self.tcx)); + self.visit_child_body(uv.def.did, uv.substs); ControlFlow::CONTINUE } _ => c.super_visit_with(self), @@ -315,7 +312,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> { #[instrument(level = "debug", skip(self))] fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> { - if !ty.potentially_has_param_types_or_consts() { + if !ty.has_param_types_or_consts() { return ControlFlow::CONTINUE; } @@ -343,21 +340,16 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> { } /// Visitor used to check if a generic parameter is used. -struct HasUsedGenericParams<'a, 'tcx> { - tcx: TyCtxt<'tcx>, +struct HasUsedGenericParams<'a> { unused_parameters: &'a FiniteBitSet<u32>, } -impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a, 'tcx> { +impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> { type BreakTy = (); - fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> { - Some(self.tcx) - } - #[instrument(level = "debug", skip(self))] fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> { - if !c.potentially_has_param_types_or_consts() { + if !c.has_param_types_or_consts() { return ControlFlow::CONTINUE; } @@ -375,7 +367,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a, 'tcx> { #[instrument(level = "debug", skip(self))] fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> { - if !ty.potentially_has_param_types_or_consts() { + if !ty.has_param_types_or_consts() { return ControlFlow::CONTINUE; } |
