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

Add lint for wrong attributes #10316

Merged
merged 8 commits into from
Nov 26, 2013
Merged

Add lint for wrong attributes #10316

merged 8 commits into from
Nov 26, 2013

Conversation

klutzy
Copy link
Contributor

@klutzy klutzy commented Nov 6, 2013

This patchset makes warning if crate-level attribute is used at other places, obsolete attributed is used, or unknown attribute is used, since they are usually from mistakes.

Closes #3348

// since it is usually caused by mistake of semicolon omission.
// also make error on obsolete attributes for less confusion.
fn check_item_attribute_usage(cx: &Context, it: &ast::item) {
let crate_attrs = ["crate_type", "link", "feature", "no_uv", "no_main", "no_std"];
Copy link
Member

Choose a reason for hiding this comment

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

This may also want to include

  • no_implicit_prelude
  • license

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no_implicit_prelude can be used on items:

#[no_implicit_prelude]
mod x {
  fn f() -> Option<int> { None } // error: use of undeclared type name `Option`
}

I initially included license, copyright and comment but I've found we don't use them at all, so I don't know how good including them is.

Copy link
Member

Choose a reason for hiding this comment

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

They're not explicitly used anywhere currently, but all crate attributes contribute to the crate hash currently (but that may not stick around very long).

Copy link
Member

Choose a reason for hiding this comment

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

It's probably fine to leave them out for now.

@emberian
Copy link
Member

@klutzy any progress on this?

@klutzy
Copy link
Contributor Author

klutzy commented Nov 25, 2013

I've completely forgot this! I've implemented unknown-attr lint but haven't added tests yet. It also needs update to reflect current attributes.

@klutzy
Copy link
Contributor Author

klutzy commented Nov 25, 2013

I think it's done. r?

@emberian
Copy link
Member

@klutzy needs rebase

@klutzy
Copy link
Contributor Author

klutzy commented Nov 26, 2013

rebase done.
It may be worth to note that unknown-attr lint can be improved later (I'm not going to do it now): it might be good if it makes warning for #[deriving(Eq)] on function or #[packed]; on crate.

bors added a commit that referenced this pull request Nov 26, 2013
This patchset makes warning if crate-level attribute is used at other places, obsolete attributed is used, or unknown attribute is used, since they are usually from mistakes.

Closes #3348
@bors bors closed this Nov 26, 2013
@bors bors merged commit fa2077a into rust-lang:master Nov 26, 2013
@klutzy klutzy deleted the attr-lint branch November 26, 2013 06:58
zargony added a commit to zargony/fuse-rs that referenced this pull request Nov 26, 2013
…lang/rust#10316. Also moved comment attr to desc which seems more appropriate.
Jarcho pushed a commit to Jarcho/rust that referenced this pull request Feb 26, 2023
… r=Manishearth

Add `suspicious_command_arg_space` lint

Fixes rust-lang#10316

---

changelog: New lint: [`suspicious_command_arg_space`]
[rust-lang#10317](rust-lang/rust-clippy#10317)
<!-- changelog_checked -->
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.

ignored link and crate_type attributes
6 participants