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

Refactor inner attribute parsing #1021

Merged
merged 4 commits into from Apr 22, 2021
Merged

Refactor inner attribute parsing #1021

merged 4 commits into from Apr 22, 2021

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Apr 21, 2021

Appending inner attrs onto an existing attributes vector, instead of into a separate vector which the caller is responsible for combining together, is more amenable for an upcoming refactor -- it's more convenient to pass &mut attrs as an argument to various helpers, rather than trying to pass back inner attrs as a tuple element in return position, which is always clumsy.

// easy
let thing = parse_thing(input, x, y, attrs)?;

// clumsy
let (thing, inner_attrs) = parse_thing(input, x, y)?;
attrs.extend(inner_attrs);

The rustc parser follows the same strategy, such as in https://github.com/rust-lang/rust/blob/b849326744a8eec939e592f0ab13bff85cc865d3/compiler/rustc_parse/src/parser/item.rs#L33-L48.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant