summary refs log tree commit diff
path: root/compiler/rustc_lint_defs/src
AgeCommit message (Collapse)AuthorLines
2024-03-14Rollup merge of #122373 - surechen:fix_121331, r=petrochenkovMatthias Krüger-0/+1
Fix the conflict problem between the diagnostics fixes of lint `unnecessary_qualification` and `unused_imports` fixes #121331 For an `item` that triggers lint unnecessary_qualification, if the `use item` which imports this item is also trigger unused import, fixing the two lints at the same time may lead to the problem that the `item` cannot be found. This PR will avoid reporting lint unnecessary_qualification when conflict occurs. r? ``@petrochenkov``
2024-03-14Rollup merge of #122482 - weiznich:fix/122446, r=compiler-errorsMatthias Krüger-1/+0
Ungate the `UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES` lint This was missed during stablisation of the `#[diagnostic]` attribute namespace. Fixes #122446
2024-03-14Rollup merge of #121899 - shepmaster:dead-code-docs, r=wesleywiserMatthias Krüger-0/+14
Document how removing a type's field can be bad and what to do instead Related to #119645
2024-03-14Ungate the `UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES` lintGeorg Semmler-1/+0
This was missed during stablisation of the `#[diagnostic]` attribute namespace. Fixes #122446
2024-03-14fixes #121331surechen-0/+1
2024-03-13Add produces as tidy requiresWesley Wiser-0/+2
2024-03-13Added an "Explanation" header and expanded that section for the newly added ↵Felix S. Klock II-0/+8
lint.
2024-03-13downgrade mutable-ptr-in-final-value from hard-error to future-incompat lint ↵Felix S. Klock II-0/+36
to address issue 121610.
2024-03-09Declare new lintNadrieril-0/+31
2024-03-06Document how removing a type's field can be bad and what to do insteadJake Goulding-0/+14
Related to #119645
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-5/+5
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-5/+5
2024-03-01Rollup merge of #111505 - GuillaumeGomez:turn-invalid-doc-attr-into-err, ↵Matthias Krüger-10/+1
r=rustdoc Made `INVALID_DOC_ATTRIBUTES` lint deny by default Fixes https://github.com/rust-lang/rust/issues/82730. # Explanations The `INVALID_DOC_ATTRIBUTES` lint was marked as "will become a hard error into the future" for quite some time so making it `deny` by default. <del>Waiting on https://github.com/rust-lang/backtrace-rs/pull/524 for now.</del>
2024-02-29Detect empty leading where-clauses on type aliasesLeón Orell Valerian Liehr-1/+1
2024-02-29Make `invalid_doc_attributes` deny by defaultGuillaume Gomez-10/+1
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-1/+1
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-28Rename `Diagnostic` as `DiagInner`.Nicholas Nethercote-1/+1
I started by changing it to `DiagData`, but that didn't feel right. `DiagInner` felt much better.
2024-02-25make non-PartialEq-typed consts as patterns a hard errorRalf Jung-52/+0
2024-02-20Rollup merge of #120716 - spastorino:change-some-lint-msgs, r=lcnrNilstrieb-36/+1
Change leak check and suspicious auto trait lint warning messages The leak check lint message "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" is misleading as some cases may not be phased out and could end being accepted. This is under discussion still. The suspicious auto trait lint the change in behavior already happened, so the new message is probably more accurate. r? `@lcnr` Closes #93367
2024-02-19Remove suspicious auto trait lintSantiago Pastorino-35/+0
2024-02-19Rollup merge of #121230 - GuillaumeGomez:extend-level-api, r=NadrierilMatthias Krüger-13/+17
Extend Level API I need this API for https://github.com/rust-lang/rust-clippy/pull/12303: I have a nested `cfg` attribute (so a `MetaItem`) and I'd like to still be able to match against all possible kind of `Level`s.
2024-02-18Change leak check lint message to behavior is likely to change in the futureSantiago Pastorino-1/+1
2024-02-18Improve wording of static_mut_refObei Sideg-4/+4
Rename `static_mut_ref` lint to `static_mut_refs`.
2024-02-18Extend Level APIGuillaume Gomez-13/+17
2024-02-13Bump `indexmap`clubby789-1/+2
`swap` has been deprecated in favour of `swap_remove` - the behaviour is the same though.
2024-02-10Remove unnecessary `#![feature(min_specialization)]`Zalathar-2/+0
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-2/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
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-02-05update the tracking issue for structural match violationsRalf Jung-2/+2
and bless a test I missed
2024-02-05show indirect_structural_match and pointer_structural_match in future compat ↵Ralf Jung-2/+2
reports
2024-02-05get rid of nontrivial_structural_match lint and custom_eq const qualifRalf Jung-40/+3
2024-01-26remove illegal_floating_point_literal_pattern lintRalf Jung-50/+0
2024-01-22Rollup merge of #119948 - asquared31415:unsafe_op_in_unsafe_fn_fix, r=TaKO8KiMatthias Krüger-0/+5
Make `unsafe_op_in_unsafe_fn` migrated in edition 2024 fixes rust-lang/rust#119823
2024-01-21exclude unexported macro bindings from extern cratebohan-0/+47
2024-01-15make unsafe_op_in_unsafe_fn MachineApplicable and add it to 2024 compatibilityasquared31415-0/+5
2024-01-09Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwcoGuillaume Gomez-0/+52
Disallow reference to `static mut` and adding `static_mut_ref` lint Closes #114447 r? `@scottmcm`
2024-01-08Make inductive cycles in coherence ambiguous alwaysMichael Goulet-40/+0
2024-01-06Disallow reference to `static mut` for expressionsObei Sideg-0/+52
Add `E0796` error code. Add `static_mut_ref` lint. This is the idea for the 2024 edition.
2024-01-05Auto merge of #119192 - michaelwoerister:mcp533-push, r=cjgillotbors-1/+11
Replace a number of FxHashMaps/Sets with stable-iteration-order alternatives This PR replaces almost all of the remaining `FxHashMap`s in query results with either `FxIndexMap` or `UnordMap`. The only case that is missing is the `EffectiveVisibilities` struct which turned out to not be straightforward to transform. Once that is done too, we can remove the `HashStable` implementation from `HashMap`. The first commit adds the `StableCompare` trait which is a companion trait to `StableOrd`. Some types like `Symbol` can be compared in a cross-session stable way, but their `Ord` implementation is not stable. In such cases, a `StableCompare` implementation can be provided to offer a lightweight way for stable sorting. The more heavyweight option is to sort via `ToStableHashKey`, but then sorting needs to have access to a stable hashing context and `ToStableHashKey` can also be expensive as in the case of `Symbol` where it has to allocate a `String`. The rest of the commits are rather mechanical and don't overlap, so they are best reviewed individually. Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-01-05Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkinbors-29/+7
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-04Split StableCompare trait out of StableOrd trait.Michael Woerister-1/+11
StableCompare is a companion trait to `StableOrd`. Some types like `Symbol` can be compared in a cross-session stable way, but their `Ord` implementation is not stable. In such cases, a `StableOrd` implementation can be provided to offer a lightweight way for stable sorting. (The more heavyweight option is to sort via `ToStableHashKey`, but then sorting needs to have access to a stable hashing context and `ToStableHashKey` can also be expensive as in the case of `Symbol` where it has to allocate a `String`.)
2024-01-02Merge `unused_tuple_struct_fields` into `dead_code`Jake Goulding-29/+7
This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group.
2024-01-01Update deadlinks of `strict_provenance` lintsLieselotte-4/+4
2023-12-25Auto merge of #116274 - RalfJung:soft_unstable, r=cjgillotbors-1/+1
make soft_unstable show up in future breakage reports If we want to break these in the future, let's warn users of affected crates.
2023-12-16Remove the lint outrightMichael Goulet-8/+0
2023-12-16Make IMPLIED_BOUNDS_ENTAILMENT into a hard error from a lintMichael Goulet-35/+1
2023-12-12Rollup merge of #117927 - ehuss:future-incompat-docs, r=wesleywiserMatthias Krüger-0/+67
Clarify how to choose a FutureIncompatibilityReason variant. There has been some confusion about how to choose these variants, or what the procedure is for handling future-incompatible errors. Hopefully this helps provide some more information on how these work.
2023-12-07Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlinbors-128/+163
compile-time evaluation: detect writes through immutable pointers This has two motivations: - it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable" - it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already. The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers. I just hope perf works out.
2023-12-07compile-time evaluation: emit a lint when a write through an immutable ↵Ralf Jung-128/+163
pointer occurs
2023-12-05Update unexpected_cfgs lint definition with new syntax and diagnosticsUrgau-5/+6