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

Lints could have error codes #24900

Closed
huonw opened this issue Apr 28, 2015 · 6 comments
Closed

Lints could have error codes #24900

huonw opened this issue Apr 28, 2015 · 6 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@huonw
Copy link
Member

huonw commented Apr 28, 2015

Lint messages don't always explain the error in much detail, and so would often benefit from a detailed --explain explanation just like normal errors, e.g. this will hit a dead_code warning, but that doesn't really help diagnose the problem (that mod foo; is private), a detailed explanation could include discussion of the privacy/modules aspect of the lint.

#![crate_type = "lib"]
mod foo;
// foo.rs
pub fn bar() {}
foo.rs:2:1: 2:12 warning: function is never used: `bar`, #[warn(dead_code)] on by default
foo.rs:2 fn bar() {}
         ^~~~~~~~~~~

It might also make sense to have a generic "lints" detailed explanation, that (a) lints that don't have their own error message point to, and (b) that any specific lint explanation also points to ("see also [E...] for more on lints"). This could include the common details of how the allow/etc. attributes work.

On the other hand, lints may change too fast for this to make sense.

cc @michaelsproul #24407

@huonw huonw added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints labels Apr 28, 2015
@michaelsproul
Copy link
Contributor

I like it. We could even namespace lints differently, like L0001.

@huonw
Copy link
Member Author

huonw commented Apr 28, 2015

Interesting.

Namespacing has the downside of exposing implementation details that may not hold true in future, e.g. if a lint moves around/uses some different infrastructure it may no longer make sense to be classed as L..., but changing numbers isn't really possible. However, it seems likely to me that there is a hard distinction between lints and compiler errors that will always be true: the former has levels (including 'disabled').

@steveklabnik steveklabnik added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Apr 28, 2015
@caspark
Copy link
Contributor

caspark commented Apr 29, 2015

I want to emphasize that the most useful portion of such lints would be an explanation of how to turn them off or suppress them, both globally or in the specific case.

As such, perhaps it would make sense to have a generic reusable explanation of #[blah] vs #![blah] (perhaps as L0000).

For the extended message for the dead_code case specifically, it might also make sense to have a pointer to cfg, cfg_attr and the associated possible logic options, as those things (particularly cfg_attr and the logic options) are not easy to stumble upon in my experience - even if that's only a pointer to the relevant section of the official docs. I only found out about cfg_attr when Huon mentioned it to me (context: wrote about 2-3,000 lines of Rust over the last 3-4 months before that).

@llogiq
Copy link
Contributor

llogiq commented May 26, 2015

How would this work with external lints? Should they have their own namespace? What happens if two plugins accidentially use the same error codes? Do we need a central registry?

"What could go wrong?" — famous last quotes...

@steveklabnik
Copy link
Member

Triage: no change

@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@estebank
Copy link
Contributor

Lints now have DiagnosticIds: #45484.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants