1
Fork 0

Add sugar for &pin (const|mut) types

This commit is contained in:
Eric Holk 2024-09-20 12:09:18 -07:00
parent 7caad69253
commit ae698f8199
No known key found for this signature in database
GPG key ID: F1A772BB658A63E1
23 changed files with 284 additions and 63 deletions

View file

@ -779,7 +779,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
let prev = self.diag_metadata.current_trait_object;
let prev_ty = self.diag_metadata.current_type_path;
match &ty.kind {
TyKind::Ref(None, _) => {
TyKind::Ref(None, _) | TyKind::PinnedRef(None, _) => {
// Elided lifetime in reference: we resolve as if there was some lifetime `'_` with
// NodeId `ty.id`.
// This span will be used in case of elision failure.
@ -2326,7 +2326,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
impl<'ra> Visitor<'ra> for FindReferenceVisitor<'_, '_, '_> {
fn visit_ty(&mut self, ty: &'ra Ty) {
trace!("FindReferenceVisitor considering ty={:?}", ty);
if let TyKind::Ref(lt, _) = ty.kind {
if let TyKind::Ref(lt, _) | TyKind::PinnedRef(lt, _) = ty.kind {
// See if anything inside the &thing contains Self
let mut visitor =
SelfVisitor { r: self.r, impl_self: self.impl_self, self_found: false };

View file

@ -3482,7 +3482,7 @@ struct LifetimeFinder<'ast> {
impl<'ast> Visitor<'ast> for LifetimeFinder<'ast> {
fn visit_ty(&mut self, t: &'ast Ty) {
if let TyKind::Ref(_, mut_ty) = &t.kind {
if let TyKind::Ref(_, mut_ty) | TyKind::PinnedRef(_, mut_ty) = &t.kind {
self.seen.push(t);
if t.span.lo() == self.lifetime.lo() {
self.found = Some(&mut_ty.ty);