mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Reduce memory usage a bit
This commit is contained in:
parent
356dd3d909
commit
fe910c7bc4
2 changed files with 14 additions and 9 deletions
|
@ -543,18 +543,18 @@ pub enum UseTreeKind {
|
|||
/// use path::to::Item as Renamed;
|
||||
/// use path::to::Trait as _;
|
||||
/// ```
|
||||
Single { path: ModPath, alias: Option<ImportAlias> },
|
||||
Single { path: Interned<ModPath>, alias: Option<ImportAlias> },
|
||||
|
||||
/// ```ignore
|
||||
/// use *; // (invalid, but can occur in nested tree)
|
||||
/// use path::*;
|
||||
/// ```
|
||||
Glob { path: Option<ModPath> },
|
||||
Glob { path: Option<Interned<ModPath>> },
|
||||
|
||||
/// ```ignore
|
||||
/// use prefix::{self, Item, ...};
|
||||
/// ```
|
||||
Prefixed { prefix: Option<ModPath>, list: Vec<UseTree> },
|
||||
Prefixed { prefix: Option<Interned<ModPath>>, list: Box<[UseTree]> },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
|
@ -811,7 +811,7 @@ impl UseTree {
|
|||
},
|
||||
None => prefix,
|
||||
};
|
||||
for tree in list {
|
||||
for tree in &**list {
|
||||
tree.expand_impl(prefix.clone(), cb);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -864,7 +864,12 @@ impl UseTreeLowering<'_> {
|
|||
let list =
|
||||
use_tree_list.use_trees().filter_map(|tree| self.lower_use_tree(tree)).collect();
|
||||
|
||||
Some(self.use_tree(UseTreeKind::Prefixed { prefix, list }, tree))
|
||||
Some(
|
||||
self.use_tree(
|
||||
UseTreeKind::Prefixed { prefix: prefix.map(Interned::new), list },
|
||||
tree,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
let is_glob = tree.star_token().is_some();
|
||||
let path = match tree.path() {
|
||||
|
@ -883,15 +888,15 @@ impl UseTreeLowering<'_> {
|
|||
if path.is_none() {
|
||||
cov_mark::hit!(glob_enum_group);
|
||||
}
|
||||
Some(self.use_tree(UseTreeKind::Glob { path }, tree))
|
||||
Some(self.use_tree(UseTreeKind::Glob { path: path.map(Interned::new) }, tree))
|
||||
}
|
||||
// Globs can't be renamed
|
||||
(_, Some(_), true) | (None, None, false) => None,
|
||||
// `bla::{ as Name}` is invalid
|
||||
(None, Some(_), false) => None,
|
||||
(Some(path), alias, false) => {
|
||||
Some(self.use_tree(UseTreeKind::Single { path, alias }, tree))
|
||||
}
|
||||
(Some(path), alias, false) => Some(
|
||||
self.use_tree(UseTreeKind::Single { path: Interned::new(path), alias }, tree),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue