mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 09:48:10 +00:00
Derive Default on ItemTree
This commit is contained in:
parent
a6a5b02f4c
commit
5ed5a542fb
2 changed files with 3 additions and 12 deletions
|
@ -66,7 +66,7 @@ impl GenericParamsId {
|
|||
}
|
||||
|
||||
/// The item tree of a source file.
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
#[derive(Debug, Default, Eq, PartialEq)]
|
||||
pub struct ItemTree {
|
||||
_c: Count<Self>,
|
||||
|
||||
|
@ -82,7 +82,7 @@ impl ItemTree {
|
|||
let syntax = if let Some(node) = db.parse_or_expand(file_id) {
|
||||
node
|
||||
} else {
|
||||
return Arc::new(Self::empty());
|
||||
return Default::default();
|
||||
};
|
||||
|
||||
let hygiene = Hygiene::new(db.upcast(), file_id);
|
||||
|
@ -118,15 +118,6 @@ impl ItemTree {
|
|||
Arc::new(item_tree)
|
||||
}
|
||||
|
||||
fn empty() -> Self {
|
||||
Self {
|
||||
_c: Count::new(),
|
||||
top_level: Default::default(),
|
||||
attrs: Default::default(),
|
||||
data: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn shrink_to_fit(&mut self) {
|
||||
if let Some(data) = &mut self.data {
|
||||
let ItemTreeData {
|
||||
|
|
|
@ -43,7 +43,7 @@ pub(super) struct Ctx {
|
|||
impl Ctx {
|
||||
pub(super) fn new(db: &dyn DefDatabase, hygiene: Hygiene, file: HirFileId) -> Self {
|
||||
Self {
|
||||
tree: ItemTree::empty(),
|
||||
tree: ItemTree::default(),
|
||||
hygiene,
|
||||
file,
|
||||
source_ast_id_map: db.ast_id_map(file),
|
||||
|
|
Loading…
Reference in a new issue