summary refs log tree commit diff
path: root/compiler/rustc_lint/src/context.rs
AgeCommit message (Collapse)AuthorLines
2024-06-03Tweak `CheckLintNameResult::Tool`.Nicholas Nethercote-18/+21
It has a clumsy type, with repeated `&'a [LintId]`, and sometimes requires an empty string that isn't used in the `Err`+`None` case. This commit splits it into two variants.
2024-06-03Fix up comments.Nicholas Nethercote-1/+2
Wrap overly long ones, etc.
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-21/+14
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_lint`.Nicholas Nethercote-1/+1
2024-05-23Delay the construction of early lint diag structsLeón Orell Valerian Liehr-1/+3
Fixes a slew of perf regressions.
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-20/+11
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-21Make early lints translatableXiretza-13/+8
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-2/+1
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
2024-05-10Lift `TraitRef` into `rustc_type_ir`Michael Goulet-1/+1
2024-04-30Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-deadMatthias Krüger-0/+1
Remove many `#[macro_use] extern crate foo` items This requires the addition of more `use` items, which often make the code more verbose. But they also make the code easier to read, because `#[macro_use]` obscures where macros are defined. r? `@fee1-dead`
2024-04-29[Refactor] Rename Lint and LintGroup\'s is_loaded to is_externally_loadedblyxyas-8/+10
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+1
2024-04-17has_typeck_results doesnt need to be a queryMichael Goulet-1/+1
2024-03-22Rename `hir::Node::Local` into `hir::Node::LetStmt`Guillaume Gomez-2/+2
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-2/+2
2024-03-11Rename `DecorateLint` as `LintDiagnostic`.Nicholas Nethercote-5/+5
To match `derive(LintDiagnostic)`.
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-3/+4
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`.
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-2/+2
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-7/+7
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-8/+8
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-14clean up potential_query_instability with FxIndexMap and UnordMapyukang-12/+10
2024-02-10hir: Remove `hir::Map::{opt_parent_id,parent_id,get_parent,find_parent}`Vadim Petrochenkov-2/+2
2024-01-30add missing potential_query_instability for keys and values in hashmapyukang-6/+8
2024-01-23Rename `struct_lint_level` as `lint_level`.Nicholas Nethercote-4/+4
2024-01-23Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `TyCtxt::struct_lint_node` as `TyCtxt::node_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `LintLevelsBuilder::struct_lint` as `LintLevelsBuilder::opt_span_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `LintContext::emit_spanned_lint` as `LintContext::emit_span_lint`.Nicholas Nethercote-1/+1
2024-01-23Rename `LintContext::lookup_with_diagnostics` as ↵Nicholas Nethercote-1/+1
`LintContext::span_lint_with_diagnostics`.
2024-01-23Rename `LintContext::lookup` as `LintContext::opt_span_lint`.Nicholas Nethercote-8/+8
2024-01-23Rename `LintContext::struct_span_lint` as `LintContext::span_lint`.Nicholas Nethercote-1/+1
2024-01-12check rust lints when an unknown lint is detectedyukang-7/+17
2023-12-31rustc_lint: Enforce `rustc::potential_query_instability` lintMartin Nordholts-0/+2
Stop allowing `rustc::potential_query_instability` on all of `rustc_lint` and instead allow it on a case-by-case basis if it is safe to do so. In this particular crate, all lints were safe to allow.
2023-12-30Move around the code responsible for decorating builtin diagnosticsUrgau-444/+6
2023-12-30Rollup merge of #119425 - Urgau:check-cfg-fix-cargo-diag-bug, r=NilstriebMatthias Krüger-2/+0
Fix invalid check-cfg Cargo feature diagnostic help #118213 added specialized diagnostic for Cargo `feature` cfg. However when providing an empty `#[cfg(feature)]` condition the suggestion would suggest adding `feature` as a feature in `Cargo.toml` (wtf!). This PR removes the invalid logic, which even brings a nice improvement. ```diff --> $DIR/cargo-feature.rs:18:7 | LL | #[cfg(feature)] - | ^^^^^^^ + | ^^^^^^^- help: specify a config value: `= "bitcode"` | = note: expected values for `feature` are: `bitcode` - = help: consider defining `feature` as feature in `Cargo.toml` ``` The first commit add a test showing the bug and the second commit fixes the bug. `@rustbot` label +F-check-cfg
2023-12-30Fix invalid check-cfg Cargo feature diagnostic helpUrgau-2/+0
2023-12-28rustc_lint: Rename `warn_about_weird_lints` to `lint_added_lints`Martin Nordholts-2/+2
So we can apply more kinds of lints to added lints without having to add another parameter.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-0/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-15Fix commentsMichael Goulet-9/+0
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-20/+10
2023-12-13Add more suggestion to unexpected cfg names and valuesUrgau-3/+48
2023-12-10Revert "Don't print host effect param in pretty path_generic_args"Deadbeef-1/+0
This reverts commit f1bf874fb13703d706fc8184407c6df12555d8e9.
2023-12-09Don't print host effect param in pretty path_generic_argsMichael Goulet-0/+1
2023-12-01vis note for no pub reexports glob importbohan-0/+4
2023-11-22rustc_session: implement latent TODOTamir Duberstein-1/+3
2023-11-22Auto merge of #118071 - Urgau:check-cfg-cargo-feature, r=petrochenkovbors-0/+2
Remove `feature` from the list of well known check-cfg name This PR removes `feature` from the list of well known check-cfg. This is done for multiple reasons: - Cargo is the source of truth, rustc shouldn't have any knowledge of it - It creates a conflict between Cargo and rustc when there are no features defined. In this case Cargo won't pass any `--check-cfg` for `feature` since no feature will ever be passed, but rustc by having in it's list adds a implicit `cfg(feature, values(any()))` which is completely wrong. Having any cfg `feature` is unexpected not allow any `feature` value. While doing this, I took the opportunity to specialise the diagnostic a bit for the case above. r? `@petrochenkov`
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-10/+10
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-21Improve diagnostic for unexpected feature config name from CargoUrgau-0/+2
2023-11-17Rollup merge of #117549 - DaniPopes:more-copied, r=b-naberMatthias Krüger-1/+1
Use `copied` instead of manual `map`
2023-11-17Remove dead lint code.Nicholas Nethercote-27/+5