Skip to content

Commit fafacf3

Browse files
committed
Auto merge of #17555 - Veykril:grammar-inline, r=Veykril
internal: Inline generated syntax methods
2 parents 9a04253 + 0ee4ff2 commit fafacf3

26 files changed

+1115
-41
lines changed

src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use span::AstIdMap;
1515
use stdx::never;
1616
use syntax::{
1717
ast::{
18-
self, ArrayExprKind, AstChildren, BlockExpr, HasArgList, HasAttrs, HasLoopBody, HasName,
19-
RangeItem, SlicePatComponents,
18+
self, ArrayExprKind, AstChildren, BlockExpr, HasArgList, HasAttrs, HasGenericArgs,
19+
HasLoopBody, HasName, RangeItem, SlicePatComponents,
2020
},
2121
AstNode, AstPtr, AstToken as _, SyntaxNodePtr,
2222
};

src/tools/rust-analyzer/crates/hir-def/src/hir/type_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use hir_expand::{
1010
AstId,
1111
};
1212
use intern::Interned;
13-
use syntax::ast::{self, HasName, IsString};
13+
use syntax::ast::{self, HasGenericArgs, HasName, IsString};
1414

1515
use crate::{
1616
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},

src/tools/rust-analyzer/crates/hir-def/src/path/lower.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use hir_expand::{
99
name::{name, AsName},
1010
};
1111
use intern::Interned;
12-
use syntax::ast::{self, AstNode, HasTypeBounds};
12+
use syntax::ast::{self, AstNode, HasGenericArgs, HasTypeBounds};
1313

1414
use crate::{
1515
path::{AssociatedTypeBinding, GenericArg, GenericArgs, ModPath, Path, PathKind},

src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_turbo_fish.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use either::Either;
22
use ide_db::defs::{Definition, NameRefClass};
33
use syntax::{
4-
ast::{self, make, HasArgList},
4+
ast::{self, make, HasArgList, HasGenericArgs},
55
ted, AstNode,
66
};
77

src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use ide_db::{famous_defs::FamousDefs, traits::resolve_target_trait};
22
use itertools::Itertools;
33
use syntax::{
4-
ast::{self, make, AstNode, HasName},
4+
ast::{self, make, AstNode, HasGenericArgs, HasName},
55
ted,
66
};
77

src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_into_to_from.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use hir::ImportPathConfig;
22
use ide_db::{famous_defs::FamousDefs, helpers::mod_path_to_ast, traits::resolve_target_trait};
3-
use syntax::ast::{self, AstNode, HasName};
3+
use syntax::ast::{self, AstNode, HasGenericArgs, HasName};
44

55
use crate::{AssistContext, AssistId, AssistKind, Assists};
66

src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_type_alias.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use either::Either;
22
use ide_db::syntax_helpers::node_ext::walk_ty;
33
use syntax::{
4-
ast::{self, edit::IndentLevel, make, AstNode, HasGenericParams, HasName},
4+
ast::{self, edit::IndentLevel, make, AstNode, HasGenericArgs, HasGenericParams, HasName},
55
ted,
66
};
77

src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_delegate_trait.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use syntax::{
1717
self,
1818
edit::{self, AstNodeEdit},
1919
edit_in_place::AttrsOwnerEdit,
20-
make, AssocItem, GenericArgList, GenericParamList, HasAttrs, HasGenericParams, HasName,
21-
HasTypeBounds, HasVisibility as astHasVisibility, Path, WherePred,
20+
make, AssocItem, GenericArgList, GenericParamList, HasAttrs, HasGenericArgs,
21+
HasGenericParams, HasName, HasTypeBounds, HasVisibility as astHasVisibility, Path,
22+
WherePred,
2223
},
2324
ted::{self, Position},
2425
AstNode, NodeOrToken, SmolStr, SyntaxKind,

src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_documentation_template.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use itertools::Itertools;
44
use stdx::{format_to, to_lower_snake_case};
55
use syntax::{
66
algo::skip_whitespace_token,
7-
ast::{self, edit::IndentLevel, HasDocComments, HasName},
7+
ast::{self, edit::IndentLevel, HasDocComments, HasGenericArgs, HasName},
88
match_ast, AstNode, AstToken,
99
};
1010

src/tools/rust-analyzer/crates/ide-assists/src/handlers/inline_call.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use ide_db::{
1515
};
1616
use itertools::{izip, Itertools};
1717
use syntax::{
18-
ast::{self, edit::IndentLevel, edit_in_place::Indent, HasArgList, Pat, PathExpr},
18+
ast::{
19+
self, edit::IndentLevel, edit_in_place::Indent, HasArgList, HasGenericArgs, Pat, PathExpr,
20+
},
1921
ted, AstNode, NodeOrToken, SyntaxKind,
2022
};
2123

src/tools/rust-analyzer/crates/ide-assists/src/handlers/qualify_path.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use ide_db::{
66
helpers::mod_path_to_ast,
77
imports::import_assets::{ImportCandidate, LocatedImport},
88
};
9+
use syntax::ast::HasGenericArgs;
910
use syntax::{
1011
ast,
1112
ast::{make, HasArgList},

src/tools/rust-analyzer/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use ide_db::{
44
imports::insert_use::{insert_use, ImportScope},
55
};
66
use syntax::{
7-
ast::{self, make},
7+
ast::{self, make, HasGenericArgs},
88
match_ast, ted, AstNode, SyntaxNode,
99
};
1010

src/tools/rust-analyzer/crates/ide-assists/src/handlers/replace_turbofish_with_explicit_type.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use hir::HirDisplay;
22
use syntax::{
3-
ast::{Expr, GenericArg, GenericArgList},
4-
ast::{LetStmt, Type::InferType},
3+
ast::{Expr, GenericArg, GenericArgList, HasGenericArgs, LetStmt, Type::InferType},
54
AstNode, TextRange,
65
};
76

src/tools/rust-analyzer/crates/ide-assists/src/handlers/toggle_async_sugar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use ide_db::{
44
famous_defs::FamousDefs,
55
};
66
use syntax::{
7-
ast::{self, HasVisibility},
7+
ast::{self, HasGenericArgs, HasVisibility},
88
AstNode, NodeOrToken, SyntaxKind, SyntaxNode, SyntaxToken, TextRange,
99
};
1010

src/tools/rust-analyzer/crates/ide-assists/src/handlers/unwrap_result_return_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use ide_db::{
44
};
55
use itertools::Itertools;
66
use syntax::{
7-
ast::{self, Expr},
7+
ast::{self, Expr, HasGenericArgs},
88
match_ast, AstNode, NodeOrToken, SyntaxKind, TextRange,
99
};
1010

src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use ide_db::{active_parameter::ActiveParameter, RootDatabase};
66
use itertools::Either;
77
use syntax::{
88
algo::{ancestors_at_offset, find_node_at_offset, non_trivia_sibling},
9-
ast::{self, AttrKind, HasArgList, HasGenericParams, HasLoopBody, HasName, NameOrNameRef},
9+
ast::{
10+
self, AttrKind, HasArgList, HasGenericArgs, HasGenericParams, HasLoopBody, HasName,
11+
NameOrNameRef,
12+
},
1013
match_ast, AstNode, AstToken, Direction, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode,
1114
SyntaxToken, TextRange, TextSize, T,
1215
};

src/tools/rust-analyzer/crates/ide-db/src/path_transform.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use hir::{AsAssocItem, HirDisplay, ImportPathConfig, ModuleDef, SemanticsScope};
66
use itertools::Itertools;
77
use rustc_hash::FxHashMap;
88
use syntax::{
9-
ast::{self, make, AstNode},
9+
ast::{self, make, AstNode, HasGenericArgs},
1010
ted, SyntaxNode,
1111
};
1212

src/tools/rust-analyzer/crates/ide-ssr/src/matching.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use hir::{ImportPathConfig, Semantics};
1010
use ide_db::{base_db::FileRange, FxHashMap};
1111
use std::{cell::Cell, iter::Peekable};
1212
use syntax::{
13-
ast::{self, AstNode, AstToken},
13+
ast::{self, AstNode, AstToken, HasGenericArgs},
1414
SmolStr, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken,
1515
};
1616

src/tools/rust-analyzer/crates/ide-ssr/src/resolving.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
use hir::AsAssocItem;
44
use ide_db::{base_db::FilePosition, FxHashMap};
55
use parsing::Placeholder;
6-
use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken};
6+
use syntax::{
7+
ast::{self, HasGenericArgs},
8+
SmolStr, SyntaxKind, SyntaxNode, SyntaxToken,
9+
};
710

811
use crate::{errors::error, parsing, SsrError};
912

src/tools/rust-analyzer/crates/ide/src/inlay_hints/bind_pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ide_db::{base_db::FileId, famous_defs::FamousDefs, RootDatabase};
88

99
use itertools::Itertools;
1010
use syntax::{
11-
ast::{self, AstNode, HasName},
11+
ast::{self, AstNode, HasGenericArgs, HasName},
1212
match_ast,
1313
};
1414

src/tools/rust-analyzer/crates/syntax/src/ast.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ pub use self::{
3131
operators::{ArithOp, BinaryOp, CmpOp, LogicOp, Ordering, RangeOp, UnaryOp},
3232
token_ext::{CommentKind, CommentPlacement, CommentShape, IsString, QuoteOffsets, Radix},
3333
traits::{
34-
AttrDocCommentIter, DocCommentIter, HasArgList, HasAttrs, HasDocComments, HasGenericParams,
35-
HasLoopBody, HasModuleItem, HasName, HasTypeBounds, HasVisibility,
34+
AttrDocCommentIter, DocCommentIter, HasArgList, HasAttrs, HasDocComments, HasGenericArgs,
35+
HasGenericParams, HasLoopBody, HasModuleItem, HasName, HasTypeBounds, HasVisibility,
3636
},
3737
};
3838

@@ -149,14 +149,17 @@ pub trait RangeItem {
149149
mod support {
150150
use super::{AstChildren, AstNode, SyntaxKind, SyntaxNode, SyntaxToken};
151151

152+
#[inline]
152153
pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
153154
parent.children().find_map(N::cast)
154155
}
155156

157+
#[inline]
156158
pub(super) fn children<N: AstNode>(parent: &SyntaxNode) -> AstChildren<N> {
157159
AstChildren::new(parent)
158160
}
159161

162+
#[inline]
160163
pub(super) fn token(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> {
161164
parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind)
162165
}

src/tools/rust-analyzer/crates/syntax/src/ast/edit_in_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use parser::{SyntaxKind, T};
66

77
use crate::{
88
algo::{self, neighbor},
9-
ast::{self, edit::IndentLevel, make, HasGenericParams},
9+
ast::{self, edit::IndentLevel, make, HasGenericArgs, HasGenericParams},
1010
ted::{self, Position},
1111
AstNode, AstToken, Direction, SyntaxElement,
1212
SyntaxKind::{ATTR, COMMENT, WHITESPACE},

0 commit comments

Comments
 (0)