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

Pluggable lints (and attributes) #12372

Closed
lilyball opened this issue Feb 18, 2014 · 4 comments
Closed

Pluggable lints (and attributes) #12372

lilyball opened this issue Feb 18, 2014 · 4 comments

Comments

@lilyball
Copy link
Contributor

Just as we now support pluggable macros, I would love to see pluggable lints (with associated pluggable attributes). I'm thinking these lints/attributes could be scoped by the crate name, so something like

#[attribute_registrar]
pub fn attribute_registrar(registrar: |Name, Type|) {
    // register attribute names with whatever info is used
    // to determine if and how arguments are specified
    register(token::intern("myattr"), ...);
}

#[lint_registrar]
pub fn lint_registrar(register: |Name, LintExtension|) {
    register(token::intern("mylint"), ...);
}

when loaded as

#[feature(phase)];
#[phase(syntax)]
extern mod foo;

would add the attribute #[foo::myattr] and the lint foo::mylint.

The motivating reason here for me is that I believe for my rust-lua project to be safe I need to have a lint to ensure that the functions exposed to Lua do not make any Lua calls when there is a value with a destructor on the stack. To that end I want to annotate my Lua methods with #[lua::longjmp] and have a lint that disallows calling any #[lua::longjmp] method with destructors on the stack.

@huonw
Copy link
Member

huonw commented Feb 18, 2014

associated pluggable attributes

This is kinda-meaningless, since attributes are already arbitrary, and having truly "pluggable attributes" would essentially require being able to modify any part of the compilation process (since attributes can be read anywhere). Unless you just mean adding attribute to the list of known attributes for the attribute_usage lint.

👍 to pluggable lints though.

@lilyball
Copy link
Contributor Author

Yes, I basically just mean adding an attribute to the list of known attributes for attribute_usage. Also, I wanted to scope the attribute so that way two pluggable lints don't accidentally conflict.

@ghost
Copy link

ghost commented Sep 30, 2014

This is now done, I think?

@steveklabnik
Copy link
Member

Yes: #14067

bors pushed a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
…eykril

Generate variant: insert code in file with enum definition

Closes rust-lang#12372
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
…, r=Veykril

Add test for rust-lang#12372 (generate enum variant in different file)

The test currently fails but I'm not sure why.

The "Right" output seems to contain only the contents of `foo.rs`, without the magic comments:

<img width="967" alt="image" src="https://user-images.githubusercontent.com/7998310/170310707-e69b21eb-d4f8-46c1-8a0a-9b4071289e26.png">

cc `@Veykril`
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 7, 2024
…gression, r=flip1995

Fix `nonminimal_bool` lint regression

Fixes rust-lang#12371.
Fixes rust-lang#12369.

cc `@RalfJung`

The problem was an invalid condition. Shame on me...

changelog: Fix `nonminimal_bool` lint regression
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

No branches or pull requests

3 participants