about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/internal.rs
AgeCommit message (Collapse)AuthorLines
2025-02-08Rustfmtbjorn3-20/+30
2025-01-29Eliminate PatKind::PathOli Scherer-6/+4
2025-01-23Split hir `TyKind` and `ConstArgKind` in two and update `hir::Visitor`Boxy-3/+3
2024-12-18Merge some patterns togetherOli Scherer-21/+5
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-17Remove `rustc::existing_doc_keyword` lint.Nicholas Nethercote-42/+2
`CheckAttrVisitor::check_doc_keyword` checks `#[doc(keyword = "..")]` attributes to ensure they are on an empty module, and that the value is a non-empty identifier. The `rustc::existing_doc_keyword` lint checks these attributes to ensure that the value is the name of a keyword. It's silly to have two different checking mechanisms for these attributes. This commit does the following. - Changes `check_doc_keyword` to check that the value is the name of a keyword (avoiding the need for the identifier check, which removes a dependency on `rustc_lexer`). - Removes the lint. - Updates tests accordingly. There is one hack: the `SelfTy` FIXME case used to used to be handled by disabling the lint, but now is handled with a special case in `is_doc_keyword`. That hack will go away if/when the FIXME is fixed. Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2024-12-03Rollup merge of #133545 - clubby789:symbol-intern-lit, r=jieyouxuMatthias Krüger-2/+33
Lint against Symbol::intern on a string literal Disabled in tests where this doesn't make much sense
2024-12-02remove outdated commentlcnr-11/+4
2024-11-28Implement lint against `Symbol::intern` on a string literalclubby789-2/+33
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-2/+3
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-10-26Auto merge of #132190 - matthiaskrgr:rollup-rsocfiz, r=matthiaskrgrbors-2/+2
Rollup of 3 pull requests Successful merges: - #131875 (Add WASM | WASI | Emscripten groups to triagebot.toml) - #132019 (Document `PartialEq` impl for `OnceLock`) - #132182 (Downgrade `untranslatable_diagnostic` and `diagnostic_outside_of_impl` to `allow`) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-26Downgrade `untranslatable_diagnostic` and `diagnostic_outside_of_impl` to ↵Jieyou Xu-2/+2
`allow` See <https://github.com/rust-lang/rust/issues/132181> for more context.
2024-10-19Unify syntax (all to @eval_always)blyxyas-2/+2
2024-10-19Remove module passes filteringblyxyas-2/+2
2024-10-19Do not run lints that cannot emitblyxyas-2/+4
Before this change, adding a lint was a difficult matter because it always had some overhead involved. This was because all lints would run, no matter their default level, or if the user had #![allow]ed them. This PR changes that
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-37/+25
2024-09-03Add an internal lint that warns when accessing untracked dataNadrieril-3/+21
2024-09-01Deny imports of rustc_type_ir::inherent outside of type ir + new trait solverMichael Goulet-2/+28
2024-08-10Refactor: `diagnostic_outside_of_impl`, `untranslatable_diagnostic`Pavel Grigorenko-60/+74
1. Decouple them. 2. Make logic around `diagnostic_outside_of_impl`'s early exits simpler. 3. Make `untranslatable_diagnostic` run one loop instead of two and not allocate an intermediate vec. 4. Overall, reduce the amount of code executed when the lints do not end up firing.
2024-08-10`untranslatable_diagnostic` lint: point at the untranslated thingPavel Grigorenko-10/+12
and not the function/method call
2024-07-29Reformat `use` declarations.Nicholas Nethercote-8/+12
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-18Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent`León Orell Valerian Liehr-1/+45
2024-07-02Instance::resolve -> Instance::try_resolve, and other nitsMichael Goulet-2/+2
2024-06-03Fix up comments.Nicholas Nethercote-7/+7
Wrap overly long ones, etc.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_lint`.Nicholas Nethercote-0/+1
2024-03-11Allow multiple `impl Into<{D,Subd}iagMessage>` parameters in a function.Nicholas Nethercote-12/+5
The internal diagnostic lint currently only allows one, because that was all that occurred in practice. But rust-lang/rust-clippy/pull/12453 wants to introduce functions with more than one, and this limitation is getting in the way.
2024-03-11Rename diagnostic derive things.Nicholas Nethercote-2/+1
For increased consistency. - session_diagnostic_derive -> diagnostic_derive - session_subdiagnostic_derive -> subdiagnostic_derive - SubdiagnosticDeriveBuilder -> SubdiagnosticDerive
2024-03-11Rename `DecorateLint` as `LintDiagnostic`.Nicholas Nethercote-5/+5
To match `derive(LintDiagnostic)`.
2024-03-11Rename `AddToDiagnostic` as `Subdiagnostic`.Nicholas Nethercote-4/+4
To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-7/+4
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-08Fix crash in late internal checkingyukang-4/+6
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-43/+122
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 `SubdiagnosticMessage` as `SubdiagMessage`.Nicholas Nethercote-1/+1
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-1/+1
2024-02-28Remove the `UntranslatableDiagnosticTrivial` lint.Nicholas Nethercote-82/+1
It's a specialized form of the `UntranslatableDiagnostic` lint that is deny-by-default. Now that `UntranslatableDiagnostic` has been changed from allow-by-default to deny-by-default, the trivial variant is no longer needed.
2024-02-10hir: Remove `hir::Map::{opt_parent_id,parent_id,get_parent,find_parent}`Vadim Petrochenkov-6/+5
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+2
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-01-23Rename `LintContext::emit_spanned_lint` as `LintContext::emit_span_lint`.Nicholas Nethercote-13/+13
2024-01-06rustc_span: Optimize syntax context comparisonsVadim Petrochenkov-1/+3
Including comparisons with root context
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-1/+1
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`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-10-16tweak pass description and fix lint fail post-rebaseArthur Lafrance-1/+1
2023-10-16debug Span::ctxt() call detectionArthur Lafrance-17/+6
2023-10-16basic lint v2 implementedArthur Lafrance-2/+43
2023-10-13Format all the let chains in compilerMichael Goulet-50/+49
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-12/+12
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-3/+2
2023-05-06Check arguments length in trivial diagnostic lintclubby789-2/+4
2023-04-25Add deny lint to prevent untranslatable diagnostics using static stringsclubby789-1/+79
2023-04-10Fix typos in compilerDaniPopes-3/+3