Skip to content

Implement #507 #508

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

Merged
merged 2 commits into from
Dec 21, 2015
Merged

Conversation

devonhollowood
Copy link
Contributor

Make used_underscore_binding lint compatible with MacroAttributes
expansions. TODO: Add a good test for this.

Fixes #507

Make `used_underscore_binding` lint compatible with MacroAttributes
expansions. TODO: Add a good test for this.
@Manishearth
Copy link
Member

Did you check that this works with rustc-serialize?

(You can add a regular test similar to mut_mut_macro that does this)

Besides the test, looks good to me!

println!("{}", _foo); //~ ERROR used binding which is prefixed with an underscore
}

// TODO: This doesn't actually correctly test this. Need to find a #[derive(...)] which sets off
Copy link
Member

Choose a reason for hiding this comment

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

#[derive(RustcEncodable)] should work. However, you need to include rustc_serialize, which is a Crates.io crate, so it will not work directly in a compile-fail test. Instead, add a small test, similar to mut_mut_macro, directly in tests/ (which uses RustcEncodable on a non-empty struct and has #[deny(this lint)]), and a dev-dependency on rustc-serialize in Cargo.toml. The test should always pass since this lint will not trigger there.

(Ensure the test fails when you use it for an earlier clippy version)

Copy link
Member

Choose a reason for hiding this comment

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

@devonhollowood
Copy link
Contributor Author

Done. I checked, and it does not compile (because of the deny) for the current HEAD on master (4a32445) if I delete the early return that you added for the lint.

@Manishearth
Copy link
Member

Awesome, thanks!

Manishearth added a commit that referenced this pull request Dec 21, 2015
@Manishearth Manishearth merged commit cd3c649 into rust-lang:master Dec 21, 2015
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.

2 participants