Make hir::TyKind::TraitObject
use tagged ptr
This commit is contained in:
parent
3cd8fcbf87
commit
0f10ba60ff
20 changed files with 84 additions and 48 deletions
|
@ -15,6 +15,7 @@ pub use rustc_ast::{
|
|||
};
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::sorted_map::SortedMap;
|
||||
use rustc_data_structures::tagged_ptr::TaggedRef;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
|
@ -764,11 +765,8 @@ impl<'hir> Generics<'hir> {
|
|||
&& let [.., segment] = trait_ref.path.segments
|
||||
&& let Some(ret_ty) = segment.args().paren_sugar_output()
|
||||
&& let ret_ty = ret_ty.peel_refs()
|
||||
&& let TyKind::TraitObject(
|
||||
_,
|
||||
_,
|
||||
TraitObjectSyntax::Dyn | TraitObjectSyntax::DynStar,
|
||||
) = ret_ty.kind
|
||||
&& let TyKind::TraitObject(_, tagged_ptr) = ret_ty.kind
|
||||
&& let TraitObjectSyntax::Dyn | TraitObjectSyntax::DynStar = tagged_ptr.tag()
|
||||
&& ret_ty.span.can_be_used_for_suggestions()
|
||||
{
|
||||
Some(ret_ty.span)
|
||||
|
@ -3230,7 +3228,10 @@ pub enum TyKind<'hir> {
|
|||
TraitAscription(GenericBounds<'hir>),
|
||||
/// A trait object type `Bound1 + Bound2 + Bound3`
|
||||
/// where `Bound` is a trait or a lifetime.
|
||||
TraitObject(&'hir [PolyTraitRef<'hir>], &'hir Lifetime, TraitObjectSyntax),
|
||||
///
|
||||
/// We use pointer tagging to represent a `&'hir Lifetime` and `TraitObjectSyntax` pair
|
||||
/// as otherwise this type being `repr(C)` would result in `TyKind` increasing in size.
|
||||
TraitObject(&'hir [PolyTraitRef<'hir>], TaggedRef<'hir, Lifetime, TraitObjectSyntax>),
|
||||
/// Unused for now.
|
||||
Typeof(&'hir AnonConst),
|
||||
/// `TyKind::Infer` means the type should be inferred instead of it having been
|
||||
|
|
|
@ -922,7 +922,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) -> V::Resul
|
|||
try_visit!(visitor.visit_ty(ty));
|
||||
try_visit!(visitor.visit_const_arg(length));
|
||||
}
|
||||
TyKind::TraitObject(bounds, ref lifetime, _syntax) => {
|
||||
TyKind::TraitObject(bounds, ref lifetime) => {
|
||||
for bound in bounds {
|
||||
try_visit!(visitor.visit_poly_trait_ref(bound));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue