Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visit statement and expression attributes in the AST visitor #34199

Merged
merged 2 commits into from
Jun 10, 2016
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
6 changes: 6 additions & 0 deletions src/libsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod) {
}

pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
for attr in local.attrs.as_attr_slice() {
visitor.visit_attribute(attr);
}
visitor.visit_pat(&local.pat);
walk_list!(visitor, visit_ty, &local.ty);
walk_list!(visitor, visit_expr, &local.init);
Expand Down Expand Up @@ -635,6 +638,9 @@ pub fn walk_mac<'v, V: Visitor<'v>>(_: &mut V, _: &'v Mac) {
}

pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
for attr in expression.attrs.as_attr_slice() {
visitor.visit_attribute(attr);
}
match expression.node {
ExprKind::Box(ref subexpression) => {
visitor.visit_expr(subexpression)
Expand Down
7 changes: 6 additions & 1 deletion src/test/compile-fail/custom_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(stmt_expr_attributes)]

#[foo] //~ ERROR The attribute `foo`
fn main() {

#[foo] //~ ERROR The attribute `foo`
let x = ();
#[foo] //~ ERROR The attribute `foo`
x
}