Derive Default on ItemTree

This commit is contained in:
Laurențiu Nicola 2021-01-25 14:12:53 +02:00
parent a6a5b02f4c
commit 5ed5a542fb
2 changed files with 3 additions and 12 deletions

View file

@ -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 {

View file

@ -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),