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
|
@ -810,7 +810,9 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
intravisit::walk_ty(this, ty);
|
||||
});
|
||||
}
|
||||
hir::TyKind::TraitObject(bounds, lifetime, _) => {
|
||||
hir::TyKind::TraitObject(bounds, lifetime) => {
|
||||
let lifetime = lifetime.pointer();
|
||||
|
||||
debug!(?bounds, ?lifetime, "TraitObject");
|
||||
let scope = Scope::TraitRefBoundary { s: self.scope };
|
||||
self.with(scope, |this| {
|
||||
|
@ -827,7 +829,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
// use the object lifetime defaulting
|
||||
// rules. So e.g., `Box<dyn Debug>` becomes
|
||||
// `Box<dyn Debug + 'static>`.
|
||||
self.resolve_object_lifetime_default(lifetime)
|
||||
self.resolve_object_lifetime_default(&*lifetime)
|
||||
}
|
||||
LifetimeName::Infer => {
|
||||
// If the user writes `'_`, we use the *ordinary* elision
|
||||
|
@ -838,7 +840,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
}
|
||||
LifetimeName::Param(..) | LifetimeName::Static => {
|
||||
// If the user wrote an explicit name, use that.
|
||||
self.visit_lifetime(lifetime);
|
||||
self.visit_lifetime(&*lifetime);
|
||||
}
|
||||
LifetimeName::Error => {}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
) -> Option<ErrorGuaranteed> {
|
||||
let tcx = self.tcx();
|
||||
|
||||
let hir::TyKind::TraitObject([poly_trait_ref, ..], _, TraitObjectSyntax::None) =
|
||||
let poly_trait_ref = if let hir::TyKind::TraitObject([poly_trait_ref, ..], tagged_ptr) =
|
||||
self_ty.kind
|
||||
else {
|
||||
&& let TraitObjectSyntax::None = tagged_ptr.tag()
|
||||
{
|
||||
poly_trait_ref
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
|
||||
|
@ -294,7 +297,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
let (dyn_str, paren_dyn_str) =
|
||||
if borrowed { ("dyn ", "(dyn ") } else { ("&dyn ", "&(dyn ") };
|
||||
|
||||
let sugg = if let hir::TyKind::TraitObject([_, _, ..], _, _) = self_ty.kind {
|
||||
let sugg = if let hir::TyKind::TraitObject([_, _, ..], _) = self_ty.kind {
|
||||
// There are more than one trait bound, we need surrounding parentheses.
|
||||
vec![
|
||||
(self_ty.span.shrink_to_lo(), paren_dyn_str.to_string()),
|
||||
|
|
|
@ -2311,7 +2311,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
tcx.late_bound_vars(hir_ty.hir_id),
|
||||
),
|
||||
),
|
||||
hir::TyKind::TraitObject(bounds, lifetime, repr) => {
|
||||
hir::TyKind::TraitObject(bounds, tagged_ptr) => {
|
||||
let lifetime = tagged_ptr.pointer();
|
||||
let repr = tagged_ptr.tag();
|
||||
|
||||
if let Some(guar) = self.prohibit_or_lint_bare_trait_object_ty(hir_ty) {
|
||||
// Don't continue with type analysis if the `dyn` keyword is missing
|
||||
// It generates confusing errors, especially if the user meant to use another
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue