about summary refs log tree commit diff
path: root/compiler/rustc_lint_defs/src
AgeCommit message (Collapse)AuthorLines
2024-06-28Only require symbol name for @feature_gateMichael Goulet-13/+12
2024-06-28Make `NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE` deny-by-default in e2024Maybe Lapkin-0/+1
2024-06-28Bump elided_lifetimes_in_associated_constantMichael Goulet-1/+1
2024-06-25`sudo CI=green` && Review changes <3xFrednet-1/+1
2024-06-25RFC 2383: Stabilize `lint_reasons` :tada:xFrednet-18/+8
2024-06-24resolve: Implement a lint for out-of-scope use of `macro_rules`Vadim Petrochenkov-0/+42
2024-06-23Add hard error and migration lint for unsafe attrscarbotaniuman-0/+47
2024-06-20Remove useless `tidy-alphabetical` markers.Nicholas Nethercote-2/+0
rustfmt already sorts `use` declarations within the same group.
2024-06-14Resolve elided lifetimes in assoc const to static if no other lifetimes are ↵Michael Goulet-3/+6
in scope
2024-06-13Fixup links in lint docsWaffle Lapkin-6/+3
looks like prim@ stuff does not work here (is it possibly not handled by rustdoc at all?)
2024-06-13Implement lint for obligations broken by never type fallback changeWaffle Lapkin-0/+57
2024-06-12Rollup merge of #126356 - epage:check-cfg, r=UrgauJubilee-0/+4
docs(rustc): Improve discoverable of Cargo docs In preparing Cargo's blog post for 1.80, I tried to find the documentation for the lint configuration and I couldn't. The link is only visible from the lint itself, which isn't where I started, and the side bar, which was collapsed for me. The first place I went was the docs for `unexpected_cfgs` because this is configuration for that lint. If using lint configuration were a one off, I could see skipping it here. However, when we discussed this with at least one T-compiler member, there was interest in using this for other lints in the future. To that end, it seems like we should be exposing this with the lint itself. The second place I checked was the `check-cfg` documentation. This now has a call out for the sub-page.
2024-06-12docs(rustc): Link unexpected_cfgs to the Cargo.toml docsEd Page-0/+4
This is the first time we have a lint with configuration exposed in `Cargo.toml`. When this was done, interest was expressed in using this for other cases in the future. To this end, we need to make the documentation for the lint configuration discoverable from the documentation for that lint.
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-0/+2
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-11Rollup merge of #125913 - fmease:early-lints-spruce-up-some-diags, r=Nadrieril许杰友 Jieyou Xu (Joe)-5/+9
Spruce up the diagnostics of some early lints Implement the various "*(note to myself) in a follow-up PR we should turn parts of this message into a subdiagnostic (help msg or even struct sugg)*" drive-by comments I left in #124417 during my review. For context, before #124417, only a few early lints touched/decorated/customized their diagnostic because the former API made it a bit awkward. Likely because of that, things that should've been subdiagnostics were just crammed into the primary message. This PR rectifies this.
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-0/+41
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-05Make MISSING_UNSAFE_ON_EXTERN lint emit future compat info with suggestion ↵Santiago Pastorino-3/+9
to prepend unsafe
2024-06-05Add unsafe_extern_blocks feature flagSantiago Pastorino-2/+5
2024-06-04Rollup merge of #125596 - nnethercote:rental-hard-error, r=estebankGuillaume Gomez-52/+0
Convert `proc_macro_back_compat` lint to an unconditional error. We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in #73345. The lint was added in #83127. The tracking issue is #83125. The direct motivation for the change is that providing the alternative behaviour is interfering with #125174 and follow-on work. r? ``@estebank``
2024-06-04Make extern blocks without unsafe warn in edition 2024Santiago Pastorino-0/+32
2024-06-03Make WHERE_CLAUSES_OBJECT_SAFETY a regular object safety violationMichael Goulet-42/+0
2024-06-03Spruce up the diagnostics of some early lintsLeón Orell Valerian Liehr-5/+9
2024-05-30Add `deprecated_safe` lintTobias Bucher-0/+49
It warns about usages of `std::env::{set_var, remove_var}` with an automatic fix wrapping the call in an `unsafe` block.
2024-05-28Convert `proc_macro_back_compat` lint to an unconditional error.Nicholas Nethercote-52/+0
We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in #73345. The lint was added in #83127. The tracking issue is #83125. The direct motivation for the change is that providing the alternative behaviour is interfering with #125174 and follow-on work.
2024-05-27Rollup merge of #125522 - spastorino:fix-lint-docs-edition-handling, ↵Guillaume Gomez-2/+2
r=Urgau,michaelwoerister Add "better" edition handling on lint-docs tool r? `@Urgau`
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-16/+9
[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-26Auto merge of #124661 - RalfJung:only-structural-consts-in-patterns, r=pnkfelixbors-87/+0
Turn remaining non-structural-const-in-pattern lints into hard errors This completes the implementation of https://github.com/rust-lang/rust/issues/120362 by turning our remaining future-compat lints into hard errors: indirect_structural_match and pointer_structural_match. They have been future-compat lints for a while (indirect_structural_match for many years, pointer_structural_match since Rust 1.75 (released Dec 28, 2023)), and have shown up in dependency breakage reports since Rust 1.78 (just released on May 2, 2024). I don't expect a lot of code will still depend on them, but we will of course do a crater run. A lot of cleanup is now possible in const_to_pat, but that is deferred to a later PR. Fixes https://github.com/rust-lang/rust/issues/70861
2024-05-24Add "better" edition handling on lint-docs toolSantiago Pastorino-2/+2
2024-05-23Slightly clean up some lint infra codeLeón Orell Valerian Liehr-16/+9
* inline `LintBuffer::add_lint`, it only had a single use * update a lint infra example code snippet * it used the wrong API (the snippet isn't tested) * presumably the arguments were updated from builder to diag struct style at some point without updating the method
2024-05-21Rename buffer_lint_with_diagnostic to buffer_lintXiretza-1/+1
2024-05-21Make early lints translatableXiretza-8/+11
2024-05-21Convert uses of BuiltinLintDiag::Normal to custom variantsXiretza-15/+41
This ensures all diagnostic messages are created at diagnostic emission time, making them translatable.
2024-05-21Port DeprecatedMacro to diag structsXiretza-2/+11
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-16/+33
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-21Convert NAMED_ASM_LABELS lint to diag structXiretza-1/+0
2024-05-20Auto merge of #125219 - Urgau:check-cfg-cargo-config, r=fmeasebors-4/+7
Update `unexpected_cfgs` lint for Cargo new `check-cfg` config This PR updates the diagnostics output of the `unexpected_cfgs` lint for Cargo new `check-cfg` config. It's a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction. ```toml [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] } ``` This PR also adds a Cargo specific section regarding check-cfg and Cargo inside rustc's book (motivation is described inside the file, but mainly check-cfg is a rustc feature not a Cargo one, Cargo only enabled the feature, it does not own it; T-cargo even considers the `check-cfg` lint config to be an implementation detail). This PR also updates the links to refer to that sub-page when using Cargo from rustc. As well as updating the lint doc to refer to the check-cfg docs. ~**Not to be merged before https://github.com/rust-lang/cargo/pull/13913 reaches master!**~ (EDIT: merged in https://github.com/rust-lang/rust/pull/125237) `@rustbot` label +F-check-cfg r? `@fmease` *(feel free to roll)* Fixes https://github.com/rust-lang/rust/issues/124800 cc `@epage` `@weihanglo`
2024-05-19Link to the check-cfg doc section in the `unexpected_cfgs` lint docUrgau-4/+7
2024-05-18Make `NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE` into an FCW and report it ext ↵Waffle Lapkin-1/+6
macros
2024-05-18Remove fixmeWaffle Lapkin-2/+1
(libs team decided not to add `absurd` to std)
2024-05-15Add `on_unimplemented" typo suggestionsmejrs-0/+4
2024-05-12Match ergonomics 2024: migration lintJules Bertholet-19/+19
Unfortunately, we can't always offer a machine-applicable suggestion when there are subpatterns from macro expansion. Co-Authored-By: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
2024-05-03turn pointer_structural_match into a hard errorRalf Jung-40/+0
2024-05-03remove IndirectStructuralMatch lint, emit the usual hard error insteadRalf Jung-47/+0
2024-05-02Stabilize exclusive_rangeRoss Smyth-1/+0
2024-05-02Add an explanation about never type fallbackMaybe Waffle-2/+38
2024-05-02Add a lint against never type fallback affecting unsafe codeMaybe Waffle-0/+44
2024-04-30Auto merge of #117164 - fmease:orphan-norm, r=lcnrbors-0/+66
Lazily normalize inside trait ref during orphan check & consider ty params in rigid alias types to be uncovered Fixes #99554, fixes rust-lang/types-team#104. Fixes #114061. Supersedes #100555. Tracking issue for the future compatibility lint: #124559. r? lcnr
2024-04-30Normalize trait ref before orphan check & consider ty params in alias types ↵León Orell Valerian Liehr-0/+66
to be uncovered
2024-04-30Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-deadMatthias Krüger-3/+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-4/+5