about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/lint.rs
AgeCommit message (Collapse)AuthorLines
2023-12-23Streamline `struct_lint_level`.Nicholas Nethercote-23/+13
We can just get the error level in the `match` and then use `DiagnosticBuilder::new`. This then means a number of `DiagCtxt` functions are no longer needed, because this was the one place that used them. Note: the commit changes the treatment of spans for `Expect`, which was different to all the other cases, but this has no apparent effect.
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-2/+2
2023-12-18Rename `HandlerInner` as `DiagCtxtInner`.Nicholas Nethercote-1/+1
2023-12-15Fix commentsMichael Goulet-22/+3
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-9/+2
2023-11-04Remove support for compiler plugins.Nicholas Nethercote-2/+1
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes #29597.
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-3/+2
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-09-22give FutureIncompatibilityReason variants more explicit namesRalf Jung-3/+6
2023-09-04Add help to allow lint for the implied by suggestionUrgau-0/+3
2023-08-02fix RedundantLocals clippy caused by async and awaityukang-0/+9
2023-08-02Fix #107113, avoid suggest for macro attributesyukang-1/+5
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-9/+5
2023-07-18Add `#[track_caller]` to lint related diagnostic functionsMaybe Waffle-0/+2
2023-07-12Move `maybe_lint_level_root_bounded`.Nicholas Nethercote-20/+0
From `TyCtxt` to the MIR `Builder`. This will allow us to add a cache to `Builder` and use it from `maybe_lint_level_root_bounded`.
2023-06-27Simplify some conditionsMaybe Waffle-3/+4
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-05-25Remove ExpnKind::Inlined.Camille GILLOT-2/+1
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-6/+6
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-01-10create helper function for `rustc_lint_defs::Level` and remove it's ↵ozkanonur-10/+1
duplicated code r=ozkanonur Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-01-04rename get_parent_node to parent_idMichael Goulet-1/+1
2022-11-06fix: typoRejyr-1/+1
2022-10-16fix typoRalf Jung-1/+1
2022-10-12Apply suggestions from code reviewWaffle Maybe-9/+4
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-10-12Improve docs for `struct_lint_level` function.Maybe Waffle-0/+38
2022-10-04Rollup merge of #102568 - compiler-errors:lint-unsatisfied-opaques, r=oli-obkDylan DPC-1/+3
Lint against nested opaque types that don't satisfy associated type bounds See the test failures for examples of places where this lint would fire. r? `@oli-obk`
2022-10-04Rollup merge of #102567 - compiler-errors:issue-102561, r=davidtwcoMatthias Krüger-1/+4
Delay evaluating lint primary message until after it would be suppressed Fixes #102561 Fixes #102572
2022-10-02Lint for unsatisfied nested opaquesMichael Goulet-1/+3
2022-10-02Remove a couple lifetimes that could be inferedMaybe Waffle-7/+6
2022-10-02Delay evaluating lint primary message until after it would be suppressedMichael Goulet-1/+4
2022-10-01Use a SortedMap instead of a VecMap.Camille GILLOT-2/+2
2022-10-01Compute by owner instead of HirId.Camille GILLOT-6/+19
2022-10-01Do not fetch HIR node when iterating to find lint.Camille GILLOT-7/+3
2022-10-01Move lint level computation to rustc_middle::lint.Camille GILLOT-36/+64
2022-10-01Move code to rustc_lint.Camille GILLOT-149/+38
2022-10-01Remove unused tool_name.Camille GILLOT-2/+0
2022-10-01Compute `lint_levels` by definitionDeadbeef-19/+92
2022-10-01Move lint level source explanation to the bottomMaybe Waffle-2/+1
2022-10-01Refactor rustc lint APIMaybe Waffle-8/+24
2022-09-22Revert "Auto merge of #101620 - cjgillot:compute_lint_levels_by_def, r=oli-obk"Camille GILLOT-98/+124
This reverts commit 2cb9a65684dba47c52de8fa938febf97a73e70a9, reversing changes made to 750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c.
2022-09-22Revert "Auto merge of #101862 - cjgillot:lint-regression, r=oli-obk"Camille GILLOT-1/+1
This reverts commit bc7b17cfe3bf08b618d1c7b64838053faeb1f590, reversing changes made to 5253b0a0a1f366fad0ebed57597fcf2703b9e893.
2022-09-15Do not fetch HIR node when iterating to find lint.Camille GILLOT-1/+1
2022-09-14Remove unused tool_name.Camille GILLOT-2/+0
2022-09-14Move some code and add comments.Camille GILLOT-180/+83
2022-09-14Compute `lint_levels` by definitionDeadbeef-19/+92
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-1/+1
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-05lint: `LintDiagnosticBuilder` into `rustc_errors`David Wood-26/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30middle: translation in `LintDiagnosticBuilder`David Wood-2/+3
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-16Support lint expectations for `--force-warn` lints (RFC 2383)xFrednet-5/+11
2022-05-08Move lint expectation checking into a separate query (RFC 2383)xFrednet-1/+6
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>