cl-ast: Add filename to File
- Better error reporting - Better pizza - Papa Cow's
This commit is contained in:
@@ -34,6 +34,7 @@ pub enum Visibility {
|
||||
/// A list of [Item]s
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||
pub struct File {
|
||||
pub name: &'static str,
|
||||
pub items: Vec<Item>,
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ pub trait WeightOf {
|
||||
|
||||
impl WeightOf for File {
|
||||
fn weight_of(&self) -> usize {
|
||||
let Self { items } = self;
|
||||
items.weight_of()
|
||||
let Self { name, items } = self;
|
||||
name.weight_of() + items.weight_of()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ pub trait Fold {
|
||||
s
|
||||
}
|
||||
fn fold_file(&mut self, f: File) -> File {
|
||||
let File { items } = f;
|
||||
File { items: items.into_iter().map(|i| self.fold_item(i)).collect() }
|
||||
let File { name, items } = f;
|
||||
File { name, items: items.into_iter().map(|i| self.fold_item(i)).collect() }
|
||||
}
|
||||
fn fold_attrs(&mut self, a: Attrs) -> Attrs {
|
||||
let Attrs { meta } = a;
|
||||
|
||||
@@ -26,7 +26,7 @@ pub trait Visit<'a>: Sized {
|
||||
fn visit_smuggled_float(&mut self, _f: &'a u64) {}
|
||||
fn visit_string(&mut self, _s: &'a str) {}
|
||||
fn visit_file(&mut self, f: &'a File) {
|
||||
let File { items } = f;
|
||||
let File { name: _, items } = f;
|
||||
items.iter().for_each(|i| self.visit_item(i));
|
||||
}
|
||||
fn visit_attrs(&mut self, a: &'a Attrs) {
|
||||
|
||||
Reference in New Issue
Block a user