summary refs log tree commit diff
path: root/compiler/rustc_lint/src/levels.rs
AgeCommit message (Collapse)AuthorLines
2022-07-05lint: `LintDiagnosticBuilder` into `rustc_errors`David Wood-3/+3
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30middle: translation in `LintDiagnosticBuilder`David Wood-2/+2
Accept `DiagnosticMessage` in `LintDiagnosticBuilder::build` so that lints can be built with translatable diagnostic messages. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-16Rollup merge of #97757 - xFrednet:rfc-2383-expect-with-force-warn, ↵Matthias Krüger-6/+16
r=wesleywiser,flip1995 Support lint expectations for `--force-warn` lints (RFC 2383) Rustc has a `--force-warn` flag, which overrides lint level attributes and forces the diagnostics to always be warn. This means, that for lint expectations, the diagnostic can't be suppressed as usual. This also means that the expectation would not be fulfilled, even if a lint had been triggered in the expected scope. This PR now also tracks the expectation ID in the `ForceWarn` level. I've also made some minor adjustments, to possibly catch more bugs and make the whole implementation more robust. This will probably conflict with https://github.com/rust-lang/rust/pull/97718. That PR should ideally be reviewed and merged first. The conflict itself will be trivial to fix. --- r? `@wesleywiser` cc: `@flip1995` since you've helped with the initial review and also discussed this topic with me. :upside_down_face: Follow-up of: https://github.com/rust-lang/rust/pull/87835 Issue: https://github.com/rust-lang/rust/issues/85549 Yeah, and that's it.
2022-06-16Support lint expectations for `--force-warn` lints (RFC 2383)xFrednet-6/+16
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-3/+3
2022-05-20Lint single-use-lifetimes on the AST.Camille GILLOT-1/+9
2022-05-08Move lint expectation checking into a separate query (RFC 2383)xFrednet-7/+18
2022-04-05span: move `MultiSpan`David Wood-2/+2
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-16rustc_error: make ErrorReported impossible to constructmark-1/+1
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-15Rollup merge of #94947 - Dylan-DPC:fix/typos, r=oli-obkMatthias Krüger-2/+2
fix typos Rework of #94603 which got closed as I was trying to unmerge and repush. This is a subset of changes from the original pr as I sed'd whatever typos I remembered from the original PR thanks to `@cuishuang` for the original PR
2022-03-15fix typosDylan DPC-2/+2
2022-03-14Rollup merge of #94670 - xFrednet:rfc-2383-expect-impl-after-party, ↵Matthias Krüger-8/+28
r=flip1995,wesleywiser Improve `expect` impl and handle `#[expect(unfulfilled_lint_expectations)]` (RFC 2383) This PR updates unstable `ExpectationIds` in stashed diagnostics and adds some asserts to ensure that the stored expectations are really empty in the end. Additionally, it handles the `#[expect(unfulfilled_lint_expectations)]` case. According to the [Errors and lints docs](https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-levels) the `error` level should only be used _"when the compiler detects a problem that makes it unable to compile the program"_. As this isn't the case with `#[expect(unfulfilled_lint_expectations)]` I decided to only create a warning. To avoid adding a new lint only for this case, I simply emit a `unfulfilled_lint_expectations` diagnostic with an additional note. --- r? `@wesleywiser` I'm requesting a review from you since you reviewed the previous PR https://github.com/rust-lang/rust/pull/87835. You are welcome to reassign it if you're busy :upside_down_face: rfc: [RFC-2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html) tracking issue: https://github.com/rust-lang/rust/issues/85549 cc: `@flip1995` In case you're also interested in this :)
2022-03-09Add comment about `unfulfilled_lint_expectation` not being in a group (RFC 2383)xFrednet-0/+2
2022-03-08Fix docs, fix incorrect lint source in noteDavid Koloski-2/+3
2022-03-08Switch the primary diagnostic to `unknown_lints`David Koloski-31/+36
This also affects the `non_exhaustive_omitted_patterns` and `must_not_suspend` lints as they are not stable. This also changes the diagnostic level to pull from `unknown_lints` instead of always being allow or deny.
2022-03-08Treat unstable lints as unknownDavid Koloski-35/+57
This change causes unstable lints to be ignored if the `unknown_lints` lint is allowed. To achieve this, it also changes lints to apply as soon as they are processed. Previously, lints in the same set were processed as a batch and then all simultaneously applied. Implementation of https://github.com/rust-lang/compiler-team/issues/469
2022-03-07Handle `#[expect(unfulfilled_lint_expectations)]` with a lint messagexFrednet-8/+26
2022-03-03Emit `unused_attributes` if a level attr only has a reasonxFrednet-3/+1
2022-03-02Use Vec for expectations to have a constant order (RFC-2383)xFrednet-5/+5
2022-03-02Emit `unfullfilled_lint_expectation` using a `HirId` for performance (RFC-2383)xFrednet-45/+11
2022-03-02Reduced the size of `LintExpectationId` by 12 bytes (RFC-2383)xFrednet-2/+3
2022-03-02Expect each lint in attribute individually (RFC-2383)xFrednet-26/+62
2022-03-02Make `LintExpectationId` stable between compilation sessions (RFC-2383)xFrednet-6/+44
2022-03-02Set `LintExpectationId` in level and collect fulfilled ones (RFC-2383)xFrednet-7/+31
* Collect lint expectations and set expectation ID in level (RFC-2383) * Collect IDs of fulfilled lint expectations from diagnostics (RFC 2383)
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-12/+13
2022-02-19Adopt let else in more placesest31-3/+3
2022-01-23rustc_lint: Stop creating a fake `ast::Crate` for running early lintsVadim Petrochenkov-1/+1
Add a trait generalizing over the crate root and freshly loaded modules instead This also makes node IDs used for pre-expansion linting more precise
2022-01-23rustc_lint: Reuse the set of registered tools from resolverVadim Petrochenkov-23/+9
2022-01-23rustc_lint: Remove some redundant fields from `EarlyContext`Vadim Petrochenkov-15/+18
Use consistent function parameter order for early context construction and early linting Rename some functions to make it clear that they do not necessarily work on the whole crate
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-4/+4
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-1/+1
2021-12-03Use let_else in some more places in rustc_lintest31-9/+6
2021-10-08remove unwrap_or! macroklensy-2/+4
2021-09-02Rename walk_crate.Camille GILLOT-1/+1
2021-09-02Stop using walk_crate.Camille GILLOT-1/+1
2021-08-28Treat macros as HIR itemsinquisitivecrystal-3/+0
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-2/+0
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-01Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisabors-1/+1
more clippy::complexity fixes (also a couple of clippy::perf fixes)
2021-07-25clippy::flat_map_identityMatthias Krüger-1/+1
2021-07-25Merge the BTreeMap in hir::Crate.Camille GILLOT-2/+2
2021-07-17Make `--force-warns` a normal lint level optioninquisitivecrystal-19/+5
2021-07-08Rollup merge of #86639 - eholk:lint-tool, r=petrochenkovYuki Okushi-30/+34
Support lint tool names in rustc command line options When rustc is running without a lint tool such as clippy enabled, options for lints such as `clippy::foo` are meant to be ignored. This was already working for those specified by attrs, such as `#![allow(clippy::foo)]`, but this did not work for command line arguments like `-A clippy::foo`. This PR fixes that issue. Note that we discovered this issue while discussing https://github.com/rust-lang/cargo/issues/5034. Fixes #86628.
2021-07-07Cleanup: unify lint name checkingEric Holk-3/+4
This change merges `check_lint_and_tool_name` into `check_lint_name` in order to avoid having two very similar functions. Also adds the `.stderr` file back for the test case, since apparently it is still needed.
2021-07-06Unify lint tool and lint name checkingEric Holk-29/+32
This shares a little more code between checking command line and attribute lint specifications.
2021-06-29Encode CommandLine in the index only.Camille GILLOT-2/+2
2021-06-29Use a newtype_index instead of a u32.Camille GILLOT-8/+8
2021-06-26Make ForceWarn a lint level.Camille GILLOT-15/+16
2021-06-02Force warn on lint groups as wellRyan Levick-3/+8
2021-06-01Fix issues and add testRyan Levick-1/+1
2021-05-28Initial support for force-warnsRyan Levick-0/+9