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

Use scoped attributes for skip attribute #2703

Merged
merged 5 commits into from
May 15, 2018
Merged

Use scoped attributes for skip attribute #2703

merged 5 commits into from
May 15, 2018

Conversation

nrc
Copy link
Member

@nrc nrc commented May 14, 2018

@@ -584,6 +596,33 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {

// Returns true if we should skip the following item.
pub fn visit_attrs(&mut self, attrs: &[ast::Attribute], style: ast::AttrStyle) -> bool {
for attr in attrs {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for deprecated rustfmt_skip or invalid scoped attributes inside visit_attrs means that we cannot emit warnings for attributes on expressions (we use contains_skip for expressions).

It would be nice if we can perform this check inside contains_skip. I think we can do so by adding RefCell<FormatReport> field to RewriteContext and pass &RewriteContext to contains_skip.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hesitant to do this because there is no guarantee that contains_skip will be called only once per attribute and so we potentially end up having to deduplicate errors. Attributes on expressions are also unstable and not widely used, so I don't think it matters too much.

Copy link
Contributor

@topecongiro topecongiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! We cannot emit warnings for attributes on expressions, but if implementing this is too time-consuming, I am fine merging this PR and leaving it as an open issue (I think most of #[rustfmt_skip]s are used on statements or items anyway).

@nrc nrc merged commit 45c0b47 into rust-lang:master May 15, 2018
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

2 participants