Skip to content

Commit

Permalink
Remove P<> from visit_ty
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcabrajac committed Oct 26, 2024
1 parent 67c0c66 commit aa35221
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub trait MutVisitor: Sized {
walk_generic_arg(self, arg);
}

fn visit_ty(&mut self, t: &mut P<Ty>) {
fn visit_ty(&mut self, t: &mut Ty) {
walk_ty(self, t);
}

Expand Down Expand Up @@ -476,8 +476,8 @@ fn walk_assoc_item_constraint<T: MutVisitor>(
vis.visit_span(span);
}

pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) {
let Ty { id, kind, span, tokens } = ty.deref_mut();
pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut Ty) {
let Ty { id, kind, span, tokens } = ty;
vis.visit_id(id);
match kind {
TyKind::Err(_guar) => {}
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_builtin_macros/src/deriving/smart_ptr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ast::HasAttrs;
use ast::ptr::P;
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::visit::BoundKind;
use rustc_ast::{
Expand Down Expand Up @@ -373,11 +372,11 @@ struct TypeSubstitution<'a> {
}

impl<'a> ast::mut_visit::MutVisitor for TypeSubstitution<'a> {
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
fn visit_ty(&mut self, ty: &mut ast::Ty) {
if let Some(name) = ty.kind.is_simple_path()
&& name == self.from_name
{
**ty = self.to_ty.clone();
*ty = self.to_ty.clone();
self.rewritten = true;
} else {
ast::mut_visit::walk_ty(self, ty);
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1586,14 +1586,14 @@ impl InvocationCollectorNode for ast::Crate {
}
}

impl InvocationCollectorNode for P<ast::Ty> {
type OutputTy = P<ast::Ty>;
impl InvocationCollectorNode for ast::Ty {
type OutputTy = ast::Ty;
const KIND: AstFragmentKind = AstFragmentKind::Ty;
fn to_annotatable(self) -> Annotatable {
unreachable!()
}
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_ty()
fragment.make_ty().into_inner()
}
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
walk_ty(visitor, self)
Expand All @@ -1602,8 +1602,7 @@ impl InvocationCollectorNode for P<ast::Ty> {
matches!(self.kind, ast::TyKind::MacCall(..))
}
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
let node = self.into_inner();
match node.kind {
match self.kind {
TyKind::MacCall(mac) => (mac, AttrVec::new(), AddSemicolon::No),
_ => unreachable!(),
}
Expand Down Expand Up @@ -2168,7 +2167,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
self.visit_node(node)
}

fn visit_ty(&mut self, node: &mut P<ast::Ty>) {
fn visit_ty(&mut self, node: &mut ast::Ty) {
self.visit_node(node)
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ impl MutVisitor for PlaceholderExpander {
}
}

fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
fn visit_ty(&mut self, ty: &mut ast::Ty) {
match ty.kind {
ast::TyKind::MacCall(_) => *ty = self.remove(ty.id).make_ty(),
ast::TyKind::MacCall(_) => *ty = self.remove(ty.id).make_ty().into_inner(),
_ => walk_ty(self, ty),
}
}
Expand Down

0 comments on commit aa35221

Please sign in to comment.