don't link to the nightly version of the Edition Guide in stable lints
As reported in rust-lang/rust#143557 for `rust_2024_incompatible_pat`, most future-Edition-incompatibility lints link to the nightly version of the Edition Guide; the lints were written before their respective Editions (and their guides) stabilized. But now that Rusts 2021 and 2024 are stable, these lints are emitted on stable versions of the compiler, where it makes more sense to present users with links that don't say "nightly" in them.
This does not change the link for `rust_2024_incompatible_pat`. That's handled in rust-lang/rust#144006.
clippy: make tests work in stage 1
This finally fixes https://github.com/rust-lang/rust/issues/78717 :)
Similar to what Miri already does, the clippy test step needs to carefully consider which compiler is used to build clippy and which compiler is linked into clippy (and thus must be used to build the test dependencies). On top of that we have some extra complications that Miri avoided by using `cargo-miri` for building its test dependencies: we need cargo to use the right rustc and the right sysroot, but https://github.com/rust-lang/cargo/issues/4423 makes this quite hard to do. See the long comment in `src/tools/clippy/tests/compile-test.rs` for details.
Some clippy tests tried to import rustc crates; that fundamentally requires a full bootstrap loop so it cannot work in stage 1. I had to kind of guess what those tests were doing so I don't know if my changes there make any sense.
Cc ```@flip1995``` ```@Kobzol```
Fix false positive in `useless_attribute` with `redundant_imports`
Add `redundant_imports` to the list of allowed lints on use items to
prevent
`useless_attribute` from triggering false positives when
`#[expect(redundant_imports)]`
or similar attributes are used on use statements.
fixesrust-lang/rust-clippy#15316
---
changelog: [`useless_attribute`]: fix false positive when using
`#[expect(redundant_imports)]` and similar lint attributes on `use`
statements
The useless_attribute lint was incorrectly flagging #[expect(redundant_imports)]
as useless when applied to macro re-exports. This occurred because the lint
didn't recognize 'redundant_imports' as a valid rustc lint name.
This commit:
- Adds 'redundant_imports' to the list of known rustc lints in sym.rs
- Updates the useless_attribute lint to properly handle this case
- Adds a regression test to prevent future false positives
Fixesrust-lang/rust-clippy#15192 by adding checks for no_std while
giving out Box recommendation
```
changelog: [`large_enum_variant`]: Dont suggest `Box` in `no_std` mode
```
- Updated the `help:` text to include a more general suggestion
- Ensures compatibility with `#[no_std]` environments where boxing is
still possible via `alloc`.
Closesrust-lang/rust-clippy#15007
Removes the `break` stmt and the dead code after it when appropriate.
changelog: [`never_loop`] Make sure to remove `break` in suggestions
This makes `const` contexts use the `const`-stability version
information instead of the regular stability one, as `const`-stability
may happen much later than stability in non-`const` contexts.
~~It includes the content of PR rust-lang/rust-clippy#15296 as its first
commit. I separated them because this one is more complex, and
rust-lang/rust-clippy#15296 may be merged more rapidly.~~
changelog: [`incompatible_msrv`]: check the right MSRV when in a `const`
context
r? Jarcho @rustbot label +C-bug +I-false-negative
This makes `const` contexts use the `const`-stability version information
instead of the regular stability one, as `const`-stability may happen
much later than stability in non-`const` contexts.
For example, the `Duration` type from the standard library was only
introduced in Rust 1.3.0.
changelog: [`incompatible_msrv`]: recognize types exceeding MSRV as well
r? Jarcho @rustbot label +C-bug +I-false-negative
Reword mismatched-lifetime-syntaxes text based on feedback
Key changes include:
- Removal of the word "syntax" from the lint message. More accurately, it could have been something like "syntax group" or "syntax category", but avoiding it completely is easier.
- The primary lint message now reflects exactly which mismatch is occurring, instead of trying to be general. A new `help` line is general across the mismatch kinds.
- Suggestions have been reduced to be more minimal, no longer also changing non-idiomatic but unrelated aspects.
- Suggestion text no longer mentions changes when those changes don't occur in that specific suggestion.
r? ``@jieyouxu``
There are many places that join path segments with `::` to produce a
string. A lot of these use `join("::")`. Many in rustdoc use
`join_with_double_colon`, and a few use `.joined("..")`. One in Clippy
uses `itertools::join`. A couple of them look for `kw::PathRoot` in the
first segment, which can be important.
This commit introduces `rustc_ast::join_path_{syms,ident}` to do the
joining for everyone. `rustc_ast` is as good a location for these as
any, being the earliest-running of the several crates with a `Path`
type. Two functions are needed because `Ident` printing is more complex
than simple `Symbol` printing.
The commit also removes `join_with_double_colon`, and
`estimate_item_path_byte_length` with it.
There are still a handful of places that join strings with "::" that are
unchanged. They are not that important: some of them are in tests, and
some of them first split a path around "::" and then rejoin with "::".
This fixes one test case where `{{root}}` shows up in an error message.