Add the generic_associated_types_extended feature
This commit is contained in:
parent
5e1d19d307
commit
4e570a68a1
14 changed files with 261 additions and 33 deletions
|
@ -1383,3 +1383,50 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
|||
ControlFlow::CONTINUE
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds the max universe present
|
||||
pub struct MaxUniverse {
|
||||
max_universe: ty::UniverseIndex,
|
||||
}
|
||||
|
||||
impl MaxUniverse {
|
||||
pub fn new() -> Self {
|
||||
MaxUniverse { max_universe: ty::UniverseIndex::ROOT }
|
||||
}
|
||||
|
||||
pub fn max_universe(self) -> ty::UniverseIndex {
|
||||
self.max_universe
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for MaxUniverse {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::Placeholder(placeholder) = t.kind() {
|
||||
self.max_universe = ty::UniverseIndex::from_u32(
|
||||
self.max_universe.as_u32().max(placeholder.universe.as_u32()),
|
||||
);
|
||||
}
|
||||
|
||||
t.super_visit_with(self)
|
||||
}
|
||||
|
||||
fn visit_const(&mut self, c: ty::consts::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::ConstKind::Placeholder(placeholder) = c.val() {
|
||||
self.max_universe = ty::UniverseIndex::from_u32(
|
||||
self.max_universe.as_u32().max(placeholder.universe.as_u32()),
|
||||
);
|
||||
}
|
||||
|
||||
c.super_visit_with(self)
|
||||
}
|
||||
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::RePlaceholder(placeholder) = *r {
|
||||
self.max_universe = ty::UniverseIndex::from_u32(
|
||||
self.max_universe.as_u32().max(placeholder.universe.as_u32()),
|
||||
);
|
||||
}
|
||||
|
||||
ControlFlow::CONTINUE
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue