fix incorrect suggestion for `!(a >= b) as i32 == c`
fixes#12761
The expression `!(a >= b) as i32 == c` got simplified to `a < b as i32 == c`, but this is a syntax error.
The result we want is `(a < b) as i32 == c`.
This is fixed by adding a parenthesis to the suggestion given in `check_simplify_not` when the boolean expression is casted.
changelog: [`nonminimal_bool`]: fix incorrect suggestion for `!(a >= b) as i32 == c`
Optimise Msrv for common one item case
Currently, `Msrv` is cloned around a lot in order to handle the `#[clippy::msrv]` attribute. This attribute, however, means `RustcVersion` will be heap allocated if there is only one source of an msrv (eg: `rust-version` in `Cargo.toml`).
This PR optimizes for said case, while keeping the external interface the same by swapping the internal representation to `SmallVec<[RustcVersion; 2]>`.
changelog: none
Add test case for `missing_errors_doc` at tests with option `check-private-item=true`
Add test case for `missing_errors_doc` at tests with option `check-private-item=true` to proof that rust-lang/rust-clippy#13391 is not an issue anymore
changelog: none
Closes: rust-lang/rust-clippy#13391
Fix indentation of website code snippets
Fixes#13568
Follow up to #13359, I didn't catch that it swapped the `strip_prefix` out for a `trim` but they aren't interchangeable here
changelog: none
docs: Fix too_long_first_doc_paragraph: line -> paragraph
The documentation for too_long_first_doc_paragraph incorrectly says "line" where it should say "paragraph".
Fix a minor typo: doscstring -> docstring.
Also do a few tiny edits to attempt to make the wording slightly shorter and clearer.
changelog: [`too_long_first_doc_paragraph`]: Edit documentation
Add units/unit prefixes of frequency to doc-valid-idents
These units/unit prefixes often come up in the embedded world.
Should this PR also modify the `test_units` test? It seems only concerned with data units currently; should it also test frequency units?
changelog: [`doc_markdown`]: Add MHz, GHz, and THz to `doc-valid-idents`.
Fix not working lint anchor (generation and filtering)
As spotted by `@flip1995,` the anchor button is currently not working. Problem was the JS that was preventing the web browser from adding the hash at the end of the URL.
For the second bug fixed, the JS was stripping two characters instead of just stripping the `#` at the beginning.
changelog: Fix clippy page lint anchor (generation and filtering)
r? `@flip1995`
The documentation for too_long_first_doc_paragraph incorrectly says
"line" where it should say "paragraph".
Fix a minor typo: doscstring -> docstring.
Also do a few tiny edits to attempt to make the wording slightly
shorter and clearer.
changelog: Edit documentation for [`too_long_first_doc_paragraph`]
Add debug assertions for empty replacements and overlapping spans
rustc has debug assertions [^1] [^2] that check that a substitution doesn't have an empty suggestion string and an empty span at the same time, as well as that spans in multipart suggestions don't overlap.
However, since we link to the rustc-dev distributed compiler, these debug assertions are always disabled and so we never actually run them.
This leads to the problem that the debug ICE is not necessarily caught in the PR and only triggered in the rust repo sync, and in one of the last syncs this was a blocker and delayed the sync by several weeks because the fix was not obvious.
So this PR essentially copies the checks over and runs them in clippy debug builds as well, so that we can catch these errors in PRs directly.
-----
As for the second commit, this also *did* cause an ICE in a sync before and was fixed in the sync PR (see https://github.com/rust-lang/rust/pull/120345#issuecomment-1911005554), but it seems like that commit didn't make it back into the clippy repo (cc `@flip1995),` so the fixed code is in the rust repo but not in the clippy repo.
changelog: none
[^1]: https://doc.rust-lang.org/1.82.0/nightly-rustc/src/rustc_errors/diagnostic.rs.html#1019
[^2]: https://doc.rust-lang.org/1.82.0/nightly-rustc/src/rustc_errors/diagnostic.rs.html#932
The expansion of `asm!()` and `line!()` is not marked as from an expansion, in which case `SourceMap::stmt_span` returns the input span unchanged. So instead of using `stmt_span`, use `mac_call_stmt_semi_span` directly
Allow to go through clippy lints page without javascript
Fixes#13536.
This is the follow-up of https://github.com/rust-lang/rust-clippy/pull/13269.
This PR makes it possible to expand/collapse lints (individually) without JS. To achieve this result, there are two ways:
1. Use `details` and `summary` tags. Problem with this approach is that the web browser search may open the `details` tags automatically if content matching it is inside. From a previous discussion with `@Alexendoo,` it seems to not be a desired behaviour.
2. Use a little trick where you use a `label` and a checkbox where the checkbox is in fact hidden. Then it's just a matter of CSS.
r? `@Alexendoo`
changelog: Allow to go through clippy lints page without JS