diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs index 5722dea3ab9..d2e09dbb6d9 100644 --- a/crates/ide/src/syntax_highlighting/inject.rs +++ b/crates/ide/src/syntax_highlighting/inject.rs @@ -6,7 +6,7 @@ use either::Either; use hir::{HasAttrs, InFile, Semantics}; use ide_db::{call_info::ActiveParameter, defs::Definition, SymbolKind}; use syntax::{ - ast::{self, AstNode, AttrsOwner, DocCommentsOwner}, + ast::{self, AstNode, AttrsOwner, AttrsOwnerNode, DocCommentsOwner}, match_ast, AstToken, NodeOrToken, SyntaxNode, SyntaxToken, TextRange, TextSize, }; @@ -89,36 +89,6 @@ const RUSTDOC_FENCE_TOKENS: &[&'static str] = &[ "edition2021", ]; -// Basically an owned dyn AttrsOwner without extra Boxing -struct AttrsOwnerNode { - node: SyntaxNode, -} - -impl AttrsOwnerNode { - fn new(node: N) -> Self { - AttrsOwnerNode { node: node.syntax().clone() } - } -} - -impl AttrsOwner for AttrsOwnerNode {} -impl AstNode for AttrsOwnerNode { - fn can_cast(_: syntax::SyntaxKind) -> bool - where - Self: Sized, - { - false - } - fn cast(_: SyntaxNode) -> Option - where - Self: Sized, - { - None - } - fn syntax(&self) -> &SyntaxNode { - &self.node - } -} - fn doc_attributes<'node>( sema: &Semantics, node: &'node SyntaxNode, diff --git a/crates/syntax/src/ast.rs b/crates/syntax/src/ast.rs index 38e0b04efbe..7f472d4dbed 100644 --- a/crates/syntax/src/ast.rs +++ b/crates/syntax/src/ast.rs @@ -20,8 +20,8 @@ pub use self::{ expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, generated::{nodes::*, tokens::*}, node_ext::{ - AttrKind, FieldKind, Macro, NameLike, NameOrNameRef, PathSegmentKind, SelfParamKind, - SlicePatComponents, StructKind, TypeBoundKind, VisibilityKind, + AttrKind, AttrsOwnerNode, FieldKind, Macro, NameLike, NameOrNameRef, PathSegmentKind, + SelfParamKind, SlicePatComponents, StructKind, TypeBoundKind, VisibilityKind, }, token_ext::*, traits::*, diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 5a9834cbb85..01f580a4094 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -90,6 +90,36 @@ impl NameOwner for Macro { impl AttrsOwner for Macro {} +/// Basically an owned `dyn AttrsOwner` without extra boxing. +pub struct AttrsOwnerNode { + node: SyntaxNode, +} + +impl AttrsOwnerNode { + pub fn new(node: N) -> Self { + AttrsOwnerNode { node: node.syntax().clone() } + } +} + +impl AttrsOwner for AttrsOwnerNode {} +impl AstNode for AttrsOwnerNode { + fn can_cast(_: SyntaxKind) -> bool + where + Self: Sized, + { + false + } + fn cast(_: SyntaxNode) -> Option + where + Self: Sized, + { + None + } + fn syntax(&self) -> &SyntaxNode { + &self.node + } +} + #[derive(Debug, Clone, PartialEq, Eq)] pub enum AttrKind { Inner,