Commit graph

474 commits

Author SHA1 Message Date
xFrednet b124b3666e
sudo CI=green && Review changes <3 2024-06-25 18:06:22 +02:00
xFrednet 8b14e23dce
RFC 2383: Stabilize lint_reasons 🎉 2024-06-25 17:22:22 +02:00
Vadim Petrochenkov c4c7859e40 resolve: Implement a lint for out-of-scope use of macro_rules 2024-06-24 17:12:08 +03:00
carbotaniuman a23917cfd0 Add hard error and migration lint for unsafe attrs 2024-06-23 19:02:14 -05:00
Nicholas Nethercote 9981d61cdb Remove useless tidy-alphabetical markers.
rustfmt already sorts `use` declarations within the same group.
2024-06-20 09:23:20 +10:00
Michael Goulet 4f97ab54c4 Resolve elided lifetimes in assoc const to static if no other lifetimes are in scope 2024-06-14 11:05:35 -04:00
Waffle Lapkin 8400cd0b34 Fixup links in lint docs
looks like prim@ stuff does not work here (is it possibly not handled by rustdoc at all?)
2024-06-13 12:24:31 +02:00
Waffle Lapkin 83f8f9f85d Implement lint for obligations broken by never type fallback change 2024-06-13 12:24:31 +02:00
Jubilee 9d946a3f6f
Rollup merge of #126356 - epage:check-cfg, r=Urgau
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-12 20:03:22 -07:00
Ed Page 9232bd2e83 docs(rustc): Link unexpected_cfgs to the Cargo.toml docs
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-12 15:27:27 -05:00
Nicholas Nethercote 75b164d836 Use tidy to sort crate attributes for all compiler crates.
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-12 15:49:10 +10:00
许杰友 Jieyou Xu (Joe) 81ff9b5770
Rollup merge of #125913 - fmease:early-lints-spruce-up-some-diags, r=Nadrieril
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-11 09:14:34 +01:00
bors 2d28b6384e Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obk
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-06 08:14:58 +00:00
Santiago Pastorino 1afc7d716c
Make MISSING_UNSAFE_ON_EXTERN lint emit future compat info with suggestion to prepend unsafe 2024-06-05 09:36:01 -03:00
Santiago Pastorino 0380321e78
Add unsafe_extern_blocks feature flag 2024-06-05 09:35:57 -03:00
Guillaume Gomez fa96e2cb4f
Rollup merge of #125596 - nnethercote:rental-hard-error, r=estebank
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-04 21:41:33 +02:00
Santiago Pastorino 3ba8de0b60
Make extern blocks without unsafe warn in edition 2024 2024-06-04 14:19:42 -03:00
Michael Goulet de6b219803 Make WHERE_CLAUSES_OBJECT_SAFETY a regular object safety violation 2024-06-03 09:49:04 -04:00
León Orell Valerian Liehr b2949ff911
Spruce up the diagnostics of some early lints 2024-06-03 07:25:32 +02:00
Tobias Bucher 44f9f8bc33 Add deprecated_safe lint
It warns about usages of `std::env::{set_var, remove_var}` with an
automatic fix wrapping the call in an `unsafe` block.
2024-05-30 00:20:48 +02:00
Nicholas Nethercote cf0c2c7333 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.
2024-05-28 08:15:15 +10:00
Guillaume Gomez ad37f40355
Rollup merge of #125522 - spastorino:fix-lint-docs-edition-handling, r=Urgau,michaelwoerister
Add "better" edition handling on lint-docs tool

r? `@Urgau`
2024-05-27 13:10:34 +02:00
bors b582f807fa Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote
[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 (06bc4fc671, *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-27 08:44:12 +00:00
bors 5fe5543502 Auto merge of #124661 - RalfJung:only-structural-consts-in-patterns, r=pnkfelix
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-26 07:55:47 +00:00
Santiago Pastorino 41d4a95fca
Add "better" edition handling on lint-docs tool 2024-05-24 23:58:27 -03:00
León Orell Valerian Liehr 366ef95407
Slightly clean up some lint infra code
* 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-23 03:21:12 +02:00
Xiretza 98dd6c7e8f Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
Xiretza 8004e6a379 Make early lints translatable 2024-05-21 20:16:39 +00:00
Xiretza b7abf014ec Convert uses of BuiltinLintDiag::Normal to custom variants
This ensures all diagnostic messages are created at diagnostic emission
time, making them translatable.
2024-05-21 20:16:39 +00:00
Xiretza 41a20b4c56 Port DeprecatedMacro to diag structs 2024-05-21 20:16:39 +00:00
Xiretza c227f35a9c Generate lint diagnostic message from BuiltinLintDiag
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-21 20:16:39 +00:00
Xiretza bac6b6248b Convert NAMED_ASM_LABELS lint to diag struct 2024-05-21 20:11:42 +00:00
bors b92758a9ae Auto merge of #125219 - Urgau:check-cfg-cargo-config, r=fmease
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-20 20:14:09 +00:00
Urgau bc8e034c39 Link to the check-cfg doc section in the unexpected_cfgs lint doc 2024-05-19 20:15:01 +02:00
Waffle Lapkin a02db8660c Make NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE into an FCW and report it ext macros 2024-05-18 00:08:52 +02:00
Waffle Lapkin 83acddc766 Remove fixme
(libs team decided not to add `absurd` to std)
2024-05-18 00:08:11 +02:00
mejrs 18d7411719 Add `on_unimplemented" typo suggestions 2024-05-15 00:49:33 +02:00
Jules Bertholet 9d92a7f355
Match ergonomics 2024: migration lint
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-12 11:13:33 -04:00
Ralf Jung cbd682beeb turn pointer_structural_match into a hard error 2024-05-03 15:56:59 +02:00
Ralf Jung 179a6a08b1 remove IndirectStructuralMatch lint, emit the usual hard error instead 2024-05-03 15:56:59 +02:00
Ross Smyth 6967d1c0fc Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
Maybe Waffle b63cb6fd81 Add an explanation about never type fallback 2024-05-02 03:47:32 +02:00
Maybe Waffle aa0a916c81 Add a lint against never type fallback affecting unsafe code 2024-05-02 03:47:32 +02:00
bors f705de5962 Auto merge of #117164 - fmease:orphan-norm, r=lcnr
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-30 20:51:46 +00:00
León Orell Valerian Liehr 951e902562
Normalize trait ref before orphan check & consider ty params in alias types to be uncovered 2024-04-30 21:54:54 +02:00
Matthias Krüger 784316eadc
Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-dead
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-30 15:04:08 +02:00
blyxyas d31b7db8e4 [Refactor] Rename Lint and LintGroup\'s is_loaded to is_externally_loaded 2024-04-29 15:57:09 +02:00
Nicholas Nethercote 4814fd0a4b Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
Jules Bertholet e13911e6e8
Rename feature gate 2024-04-15 23:27:21 -04:00
Jules Bertholet 1b2e471b43
Fix typo
Co-authored-by: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
2024-04-15 23:27:21 -04:00