Skip to content

Commit 9697d23

Browse files
committed
Rename UseItem -> Use
1 parent 35e7966 commit 9697d23

File tree

18 files changed

+43
-42
lines changed

18 files changed

+43
-42
lines changed

crates/ra_assists/src/handlers/auto_import.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl AutoImportAssets {
9292

9393
fn for_regular_path(path_under_caret: ast::Path, ctx: &AssistContext) -> Option<Self> {
9494
let syntax_under_caret = path_under_caret.syntax().to_owned();
95-
if syntax_under_caret.ancestors().find_map(ast::UseItem::cast).is_some() {
95+
if syntax_under_caret.ancestors().find_map(ast::Use::cast).is_some() {
9696
return None;
9797
}
9898

crates/ra_assists/src/handlers/merge_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<()
2828
let mut rewriter = SyntaxRewriter::default();
2929
let mut offset = ctx.offset();
3030

31-
if let Some(use_item) = tree.syntax().parent().and_then(ast::UseItem::cast) {
31+
if let Some(use_item) = tree.syntax().parent().and_then(ast::Use::cast) {
3232
let (merged, to_delete) = next_prev()
3333
.filter_map(|dir| neighbor(&use_item, dir))
3434
.filter_map(|it| Some((it.clone(), it.use_tree()?)))

crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) fn replace_qualified_name_with_use(
2525
) -> Option<()> {
2626
let path: ast::Path = ctx.find_node_at_offset()?;
2727
// We don't want to mess with use statements
28-
if path.syntax().ancestors().find_map(ast::UseItem::cast).is_some() {
28+
if path.syntax().ancestors().find_map(ast::Use::cast).is_some() {
2929
return None;
3030
}
3131

@@ -85,7 +85,7 @@ fn shorten_paths(rewriter: &mut SyntaxRewriter<'static>, node: SyntaxNode, path:
8585
match child {
8686
// Don't modify `use` items, as this can break the `use` item when injecting a new
8787
// import into the use tree.
88-
ast::UseItem(_it) => continue,
88+
ast::Use(_it) => continue,
8989
// Don't descend into submodules, they don't have the same `use` items in scope.
9090
ast::Module(_it) => continue,
9191

crates/ra_assists/src/utils/insert_use.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn walk_use_tree_for_best_action(
225225
current_use_tree
226226
.syntax()
227227
.ancestors()
228-
.find_map(ast::UseItem::cast)
228+
.find_map(ast::Use::cast)
229229
.map(|it| it.syntax().clone()),
230230
true,
231231
);
@@ -254,7 +254,7 @@ fn walk_use_tree_for_best_action(
254254
current_use_tree
255255
.syntax()
256256
.ancestors()
257-
.find_map(ast::UseItem::cast)
257+
.find_map(ast::Use::cast)
258258
.map(|it| it.syntax().clone()),
259259
true,
260260
),
@@ -304,7 +304,7 @@ fn walk_use_tree_for_best_action(
304304
current_use_tree
305305
.syntax()
306306
.ancestors()
307-
.find_map(ast::UseItem::cast)
307+
.find_map(ast::Use::cast)
308308
.map(|it| it.syntax().clone()),
309309
true,
310310
);
@@ -377,7 +377,7 @@ fn best_action_for_target(
377377
let mut storage = Vec::with_capacity(16); // this should be the only allocation
378378
let best_action = container
379379
.children()
380-
.filter_map(ast::UseItem::cast)
380+
.filter_map(ast::Use::cast)
381381
.filter_map(|it| it.use_tree())
382382
.map(|u| walk_use_tree_for_best_action(&mut storage, None, u, target))
383383
.fold(None, |best, a| match best {

crates/ra_hir_def/src/body/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ impl ExprCollector<'_> {
670670
}
671671
ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks
672672
ast::Item::ImplDef(_)
673-
| ast::Item::UseItem(_)
673+
| ast::Item::Use(_)
674674
| ast::Item::ExternCrate(_)
675675
| ast::Item::Module(_)
676676
| ast::Item::MacroCall(_) => return None,

crates/ra_hir_def/src/item_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ macro_rules! mod_items {
411411
}
412412

413413
mod_items! {
414-
Import in imports -> ast::UseItem,
414+
Import in imports -> ast::Use,
415415
ExternCrate in extern_crates -> ast::ExternCrate,
416416
Function in functions -> ast::FnDef,
417417
Struct in structs -> ast::StructDef,
@@ -482,7 +482,7 @@ pub struct Import {
482482
pub is_prelude: bool,
483483
/// AST ID of the `use` or `extern crate` item this import was derived from. Note that many
484484
/// `Import`s can map to the same `use` item.
485-
pub ast_id: FileAstId<ast::UseItem>,
485+
pub ast_id: FileAstId<ast::Use>,
486486
}
487487

488488
#[derive(Debug, Clone, Eq, PartialEq)]

crates/ra_hir_def/src/item_tree/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Ctx {
9595
ast::Item::TraitDef(_) | ast::Item::ImplDef(_) | ast::Item::ExternBlock(_) => {}
9696

9797
// These don't have inner items.
98-
ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::UseItem(_) => {}
98+
ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::Use(_) => {}
9999
};
100100

101101
let attrs = Attrs::new(item, &self.hygiene);
@@ -110,7 +110,7 @@ impl Ctx {
110110
ast::Item::Module(ast) => self.lower_module(ast).map(Into::into),
111111
ast::Item::TraitDef(ast) => self.lower_trait(ast).map(Into::into),
112112
ast::Item::ImplDef(ast) => self.lower_impl(ast).map(Into::into),
113-
ast::Item::UseItem(ast) => Some(ModItems(
113+
ast::Item::Use(ast) => Some(ModItems(
114114
self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(),
115115
)),
116116
ast::Item::ExternCrate(ast) => self.lower_extern_crate(ast).map(Into::into),
@@ -469,7 +469,7 @@ impl Ctx {
469469
Some(id(self.data().impls.alloc(res)))
470470
}
471471

472-
fn lower_use(&mut self, use_item: &ast::UseItem) -> Vec<FileItemTreeId<Import>> {
472+
fn lower_use(&mut self, use_item: &ast::Use) -> Vec<FileItemTreeId<Import>> {
473473
// FIXME: cfg_attr
474474
let is_prelude = use_item.has_atom_attr("prelude_import");
475475
let visibility = self.lower_visibility(use_item);

crates/ra_hir_def/src/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl ModPath {
6767

6868
/// Calls `cb` with all paths, represented by this use item.
6969
pub(crate) fn expand_use_item(
70-
item_src: InFile<ast::UseItem>,
70+
item_src: InFile<ast::Use>,
7171
hygiene: &Hygiene,
7272
mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option<ImportAlias>),
7373
) {

crates/ra_ide/src/completion/completion_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(crate) struct CompletionContext<'a> {
3636
pub(super) expected_type: Option<Type>,
3737
pub(super) name_ref_syntax: Option<ast::NameRef>,
3838
pub(super) function_syntax: Option<ast::FnDef>,
39-
pub(super) use_item_syntax: Option<ast::UseItem>,
39+
pub(super) use_item_syntax: Option<ast::Use>,
4040
pub(super) record_lit_syntax: Option<ast::RecordLit>,
4141
pub(super) record_pat_syntax: Option<ast::RecordPat>,
4242
pub(super) record_field_syntax: Option<ast::RecordField>,
@@ -343,7 +343,7 @@ impl<'a> CompletionContext<'a> {
343343
}
344344

345345
self.use_item_syntax =
346-
self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::UseItem::cast);
346+
self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::Use::cast);
347347

348348
self.function_syntax = self
349349
.sema

crates/ra_ide/src/folding_ranges.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
5858
}
5959
NodeOrToken::Node(node) => {
6060
// Fold groups of imports
61-
if node.kind() == USE_ITEM && !visited_imports.contains(&node) {
61+
if node.kind() == USE && !visited_imports.contains(&node) {
6262
if let Some(range) = contiguous_range_for_group(&node, &mut visited_imports) {
6363
res.push(Fold { range, kind: FoldKind::Imports })
6464
}
@@ -83,7 +83,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
8383
fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
8484
match kind {
8585
COMMENT => Some(FoldKind::Comment),
86-
USE_ITEM => Some(FoldKind::Imports),
86+
USE => Some(FoldKind::Imports),
8787
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
8888
RECORD_FIELD_DEF_LIST
8989
| RECORD_FIELD_PAT_LIST

crates/ra_parser/src/grammar/items/use_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub(super) fn use_item(p: &mut Parser, m: Marker) {
77
p.bump(T![use]);
88
use_tree(p, true);
99
p.expect(T![;]);
10-
m.complete(p, USE_ITEM);
10+
m.complete(p, USE);
1111
}
1212

1313
/// Parse a use 'tree', such as `some::path` in `use some::path;`

crates/ra_parser/src/syntax_kind/generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub enum SyntaxKind {
130130
RET_TYPE,
131131
EXTERN_CRATE,
132132
MODULE,
133-
USE_ITEM,
133+
USE,
134134
STATIC_DEF,
135135
CONST_DEF,
136136
TRAIT_DEF,

crates/ra_ssr/src/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ fn is_search_permitted(node: &SyntaxNode) -> bool {
237237
// and the code is `use foo::{baz, bar}`, we'll match `bar`, since it resolves to `foo::bar`.
238238
// However we'll then replace just the part we matched `bar`. We probably need to instead remove
239239
// `bar` and insert a new use declaration.
240-
node.kind() != SyntaxKind::USE_ITEM
240+
node.kind() != SyntaxKind::USE
241241
}
242242

243243
impl UsageCache {

crates/ra_syntax/src/ast/edit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ impl ast::PathSegment {
262262
}
263263
}
264264

265-
impl ast::UseItem {
265+
impl ast::Use {
266266
#[must_use]
267-
pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem {
267+
pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::Use {
268268
if let Some(old) = self.use_tree() {
269269
return self.replace_descendant(old, use_tree);
270270
}

crates/ra_syntax/src/ast/generated/nodes.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ impl UnionDef {
213213
}
214214
}
215215
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
216-
pub struct UseItem {
216+
pub struct Use {
217217
pub(crate) syntax: SyntaxNode,
218218
}
219-
impl ast::AttrsOwner for UseItem {}
220-
impl ast::VisibilityOwner for UseItem {}
221-
impl UseItem {
219+
impl ast::AttrsOwner for Use {}
220+
impl ast::VisibilityOwner for Use {}
221+
impl Use {
222222
pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
223223
pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
224224
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
@@ -1283,7 +1283,7 @@ pub enum Item {
12831283
TraitDef(TraitDef),
12841284
TypeAliasDef(TypeAliasDef),
12851285
UnionDef(UnionDef),
1286-
UseItem(UseItem),
1286+
Use(Use),
12871287
}
12881288
impl ast::AttrsOwner for Item {}
12891289
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1562,8 +1562,8 @@ impl AstNode for UnionDef {
15621562
}
15631563
fn syntax(&self) -> &SyntaxNode { &self.syntax }
15641564
}
1565-
impl AstNode for UseItem {
1566-
fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM }
1565+
impl AstNode for Use {
1566+
fn can_cast(kind: SyntaxKind) -> bool { kind == USE }
15671567
fn cast(syntax: SyntaxNode) -> Option<Self> {
15681568
if Self::can_cast(syntax.kind()) {
15691569
Some(Self { syntax })
@@ -2811,15 +2811,16 @@ impl From<TypeAliasDef> for Item {
28112811
impl From<UnionDef> for Item {
28122812
fn from(node: UnionDef) -> Item { Item::UnionDef(node) }
28132813
}
2814-
impl From<UseItem> for Item {
2815-
fn from(node: UseItem) -> Item { Item::UseItem(node) }
2814+
impl From<Use> for Item {
2815+
fn from(node: Use) -> Item { Item::Use(node) }
28162816
}
28172817
impl AstNode for Item {
28182818
fn can_cast(kind: SyntaxKind) -> bool {
28192819
match kind {
28202820
CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL
2821-
| MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF
2822-
| USE_ITEM => true,
2821+
| MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => {
2822+
true
2823+
}
28232824
_ => false,
28242825
}
28252826
}
@@ -2838,7 +2839,7 @@ impl AstNode for Item {
28382839
TRAIT_DEF => Item::TraitDef(TraitDef { syntax }),
28392840
TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }),
28402841
UNION_DEF => Item::UnionDef(UnionDef { syntax }),
2841-
USE_ITEM => Item::UseItem(UseItem { syntax }),
2842+
USE => Item::Use(Use { syntax }),
28422843
_ => return None,
28432844
};
28442845
Some(res)
@@ -2858,7 +2859,7 @@ impl AstNode for Item {
28582859
Item::TraitDef(it) => &it.syntax,
28592860
Item::TypeAliasDef(it) => &it.syntax,
28602861
Item::UnionDef(it) => &it.syntax,
2861-
Item::UseItem(it) => &it.syntax,
2862+
Item::Use(it) => &it.syntax,
28622863
}
28632864
}
28642865
}
@@ -3531,7 +3532,7 @@ impl std::fmt::Display for UnionDef {
35313532
std::fmt::Display::fmt(self.syntax(), f)
35323533
}
35333534
}
3534-
impl std::fmt::Display for UseItem {
3535+
impl std::fmt::Display for Use {
35353536
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35363537
std::fmt::Display::fmt(self.syntax(), f)
35373538
}

crates/ra_syntax/src/ast/make.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn use_tree_list(use_trees: impl IntoIterator<Item = ast::UseTree>) -> ast::
6060
ast_from_text(&format!("use {{{}}};", use_trees))
6161
}
6262

63-
pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem {
63+
pub fn use_item(use_tree: ast::UseTree) -> ast::Use {
6464
ast_from_text(&format!("use {};", use_tree))
6565
}
6666

xtask/src/ast_src.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
100100
"RET_TYPE",
101101
"EXTERN_CRATE",
102102
"MODULE",
103-
"USE_ITEM",
103+
"USE",
104104
"STATIC_DEF",
105105
"CONST_DEF",
106106
"TRAIT_DEF",

xtask/src/codegen/rust.ungram

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Item =
1717
| TraitDef
1818
| TypeAliasDef
1919
| UnionDef
20-
| UseItem
20+
| Use
2121

2222
Module =
2323
Attr* Visibility? 'mod' Name
@@ -32,7 +32,7 @@ ExternCrate =
3232
Rename =
3333
'as' (Name | '_')
3434

35-
UseItem =
35+
Use =
3636
Attr* Visibility? 'use' UseTree ';'
3737

3838
UseTree =

0 commit comments

Comments
 (0)