Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions tasks/ast_tools/src/derives/content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@ use crate::{
util::ToIdent,
};

use super::{define_derive, Derive};
use super::{content_hash::IGNORE_FIELD_TYPES, define_derive, Derive};

pub struct DeriveContentEq;

define_derive!(DeriveContentEq);

const IGNORE_FIELDS: [(/* field name */ &str, /* field type */ &str); 6] = [
("span", "Span"),
("trailing_comma", "Span"),
("this_span", "Span"),
("scope_id", "ScopeId"),
("symbol_id", "SymbolId"),
("reference_id", "ReferenceId"),
];

impl Derive for DeriveContentEq {
fn trait_name() -> &'static str {
"ContentEq"
Expand Down Expand Up @@ -86,10 +77,7 @@ fn derive_struct(def: &StructDef) -> (&str, TokenStream) {
.fields
.iter()
.filter(|field| {
let Some(name) = field.name.as_ref() else { return false };
!IGNORE_FIELDS
.iter()
.any(|it| name == it.0 && field.typ.name().inner_name() == it.1)
!IGNORE_FIELD_TYPES.iter().any(|it| field.typ.name().inner_name() == *it)
})
.map(|field| {
let ident = field.ident();
Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/derives/content_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct DeriveContentHash;

define_derive!(DeriveContentHash);

const IGNORE_FIELD_TYPES: [/* type name */ &str; 4] = [
pub const IGNORE_FIELD_TYPES: [/* type name */ &str; 4] = [
"Span",
"ScopeId",
"SymbolId",
Expand Down
Loading