Skip to content

Commit

Permalink
refactor(ast_tools): remove support for #[scope(if(...))] attr (#5113)
Browse files Browse the repository at this point in the history
There are no longer any nodes with conditional scopes. Remove support for `#[scope(if(...))]` attr from `ast_tools` - it's no longer needed.
  • Loading branch information
overlookmotel committed Aug 23, 2024
1 parent 1ba11a3 commit 8650d3e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
20 changes: 2 additions & 18 deletions tasks/ast_tools/src/generators/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,21 +438,6 @@ impl<'a> VisitBuilder<'a> {
let ident = visit_as.unwrap_or_else(|| struct_.ident());
let scope_events =
struct_.markers.scope.as_ref().map_or_else(Default::default, |markers| {
let cond = markers.r#if.as_ref().map(|cond| {
let cond = cond.to_token_stream().replace_ident("self", &format_ident!("it"));
quote!(let scope_events_cond = #cond;)
});
let maybe_conditional = |tk: TokenStream| {
if cond.is_some() {
quote! {
if scope_events_cond {
#tk
}
}
} else {
tk
}
};
let flags = markers
.flags
.as_ref()
Expand All @@ -470,9 +455,8 @@ impl<'a> VisitBuilder<'a> {
} else {
flags
};
let mut enter = cond.as_ref().into_token_stream();
enter.extend(maybe_conditional(quote!(visitor.enter_scope(#flags, &it.scope_id);)));
let leave = maybe_conditional(quote!(visitor.leave_scope();));
let enter = quote!(visitor.enter_scope(#flags, &it.scope_id););
let leave = quote!(visitor.leave_scope(););
(enter, leave)
});

Expand Down
2 changes: 0 additions & 2 deletions tasks/ast_tools/src/markers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ impl From<&Ident> for CloneInAttribute {
/// A struct representing the `#[scope(...)]` attribute.
#[derive(Debug, Default)]
pub struct ScopeAttribute {
pub r#if: Option<Expr>,
pub flags: Option<Expr>,
pub strict_if: Option<Expr>,
}
Expand All @@ -104,7 +103,6 @@ impl Parse for ScopeAttribute {
Ok(parsed.into_iter().fold(Self::default(), |mut acc, CommonAttribute { ident, args }| {
let expr = parse2(args).expect("Invalid `#[scope]` input.");
match ident.to_string().as_str() {
"if" => acc.r#if = Some(expr),
"flags" => acc.flags = Some(expr),
"strict_if" => acc.strict_if = Some(expr),
_ => {}
Expand Down

0 comments on commit 8650d3e

Please sign in to comment.