about summary refs log tree commit diff
path: root/src/tools/clippy/tests
AgeCommit message (Collapse)AuthorLines
2024-05-30Merge commit 'c9139bd546d9cd69df817faeab62c5f9b1a51337' into ↵Philipp Krones-147/+686
clippy-subtree-update
2024-05-29ast: Revert a breaking attribute visiting order changeVadim Petrochenkov-24/+24
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-4/+28
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-6/+6
[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-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-6/+6
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-21Merge commit '2efebd2f0c03dabbe5c3ad7b4ebfbd99238d1fb2' into ↵Philipp Krones-396/+2422
clippy-subtree-update
2024-05-20Remove a clippy test that doesn't apply anymoreMichael Goulet-34/+26
2024-05-18Fix typos (taking into account review comments)blyxyas-1/+1
2024-05-08Use generic `NonZero`.Markus Reiter-33/+33
2024-05-08Simplify `clippy` lint.Markus Reiter-102/+102
2024-05-02Update clippy tests for stable exclusive_rangeRoss Smyth-72/+66
2024-05-02Merge commit '20b085d500dfba5afe0869707bf357af3afe20be' into ↵Philipp Krones-324/+991
clippy-subtree-update
2024-04-30Auto merge of #124398 - klensy:trailing-ws, r=compiler-errorsbors-6/+6
tests: remove some trailing ws Cleans one more case of trailing whitespace in tests.
2024-04-27clippy: bless testsklensy-6/+6
2024-04-25ast: Generalize item kind visitingVadim Petrochenkov-24/+24
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-24Fix and bless clippy testsGary Guo-79/+74
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-15/+13
And suggest adding the `#[coroutine]` to the closure
2024-04-23Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, r=davidtwcoMatthias Krüger-6/+6
Disallow ambiguous attributes on expressions This implements the suggestion in [#15701](https://github.com/rust-lang/rust/issues/15701#issuecomment-2033124217) to disallow ambiguous outer attributes on expressions. This should resolve one of the concerns blocking the stabilization of `stmt_expr_attributes`.
2024-04-18Disallow ambiguous attributes on expressionsDominik Stolz-6/+6
2024-04-18Merge commit 'ca3b393750ee8d870bf3215dcf6509cafa5c0445' into ↵Philipp Krones-140/+579
clippy-subtree-update
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-10/+10
2024-04-12Rollup merge of #123204 - notriddle:notriddle/include-str-span, r=pnkfelixMatthias Krüger-7/+6
rustdoc: point at span in `include_str!`-ed md file Fixes #118549
2024-04-08Rollup merge of #122807 - danielhuang:fix-1, r=davidtwcoMatthias Krüger-1/+1
Add consistency with phrases "meantime" and "mean time" "mean time" is used in a few places while "meantime" is used everywhere else; this would make usage consistent throughout the codebase.
2024-04-04Merge commit '9725c4a162502a02c1c67fdca6b797fe09b2b73c' into ↵Philipp Krones-930/+3260
clippy-subtree-update
2024-04-03update messagesDan-1/+1
2024-03-29clippy: fix up `include_str!` spans in diagnosticsMichael Howell-7/+6
2024-03-23Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlinbors-0/+59
Replace visibility test with reachability test in dead code detection Fixes https://github.com/rust-lang/rust/issues/119545 Also included is a fix for an error now flagged by the lint
2024-03-22Rollup merge of #122195 - jieyouxu:impl-return-note, r=fmeaseMatthias Krüger-0/+1
Note that the caller chooses a type for type param ``` error[E0308]: mismatched types --> $DIR/return-impl-trait.rs:23:5 | LL | fn other_bounds<T>() -> T | - - | | | | | expected `T` because of return type | | help: consider using an impl return type: `impl Trait` | expected this type parameter ... LL | () | ^^ expected type parameter `T`, found `()` | = note: expected type parameter `T` found unit type `()` = note: the caller chooses the type of T which can be different from () ``` Tried to see if "expected this type parameter" can be replaced, but that goes all the way to `rustc_infer` so seems not worth the effort and can affect other diagnostics. Revives #112088 and #104755.
2024-03-22Update (doc) commentsLeón Orell Valerian Liehr-1/+1
Several (doc) comments were super outdated or didn't provide enough context. Some doc comments shoved everything in a single paragraph without respecting the fact that the first paragraph should be a single sentence because rustdoc treats these as item descriptions / synopses on module pages.
2024-03-21Merge commit '9d6f41691ed9dbfaec2a2df2661c42451f2fe0d3' into ↵Philipp Krones-655/+2554
clippy-subtree-update
2024-03-18When displaying multispans, ignore empty lines adjacent to `...`Esteban Küber-4/+2
``` error[E0308]: `match` arms have incompatible types --> tests/ui/codemap_tests/huge_multispan_highlight.rs:98:18 | 6 | let _ = match true { | ---------- `match` arms have incompatible types 7 | true => ( | _________________- 8 | | // last line shown in multispan header ... | 96 | | 97 | | ), | |_________- this is found to be of type `()` 98 | false => " | __________________^ ... | 119 | | 120 | | ", | |_________^ expected `()`, found `&str` error[E0308]: `match` arms have incompatible types --> tests/ui/codemap_tests/huge_multispan_highlight.rs:215:18 | 122 | let _ = match true { | ---------- `match` arms have incompatible types 123 | true => ( | _________________- 124 | | 125 | | 1 // last line shown in multispan header ... | 213 | | 214 | | ), | |_________- this is found to be of type `{integer}` 215 | false => " | __________________^ 216 | | 217 | | 218 | | 1 last line shown in multispan ... | 237 | | 238 | | ", | |_________^ expected integer, found `&str` ```
2024-03-16Note that type param is chosen by caller when suggesting return impl Trait许杰友 Jieyou Xu (Joe)-0/+1
2024-03-12fix: allow-one-hash-in-raw-strings option of needless_raw_string_hashes was ↵Arthur Carcano-0/+59
ignored Fixes: https://github.com/rust-lang/rust-clippy/issues/11481 changelog: Fix `allow-one-hash-in-raw-strings` option of [`needless_raw_string_hashes`] was ignored
2024-03-09Allow lint where we don't careNadrieril-19/+21
2024-03-07Merge commit '93f0a9a91f58c9b2153868f458402155fb6265bb' into ↵Philipp Krones-457/+1550
clippy-subtree-update
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-3/+8
2024-03-01If suggestion would leave an empty line, delete itclubby789-14/+0
2024-02-29Rollup merge of #121669 - nnethercote:count-stashed-errs-again, r=estebankGuillaume Gomez-0/+17
Count stashed errors again Stashed diagnostics are such a pain. Their "might be emitted, might not" semantics messes with lots of things. #120828 and #121206 made some big changes to how they work, improving some things, but still leaving some problems, as seen by the issues caused by #121206. This PR aims to fix all of them by restricting them in a way that eliminates the "might be emitted, might not" semantics while still allowing 98% of their benefit. Details in the individual commit logs. r? `@oli-obk`
2024-02-29Overhaul how stashed diagnostics work, again.Nicholas Nethercote-0/+17
Stashed errors used to be counted as errors, but could then be cancelled, leading to `ErrorGuaranteed` soundness holes. #120828 changed that, closing the soundness hole. But it introduced other difficulties because you sometimes have to account for pending stashed errors when making decisions about whether errors have occured/will occur and it's easy to overlook these. This commit aims for a middle ground. - Stashed errors (not warnings) are counted immediately as emitted errors, avoiding the possibility of forgetting to consider them. - The ability to cancel (or downgrade) stashed errors is eliminated, by disallowing the use of `steal_diagnostic` with errors, and introducing the more restrictive methods `try_steal_{modify,replace}_and_emit_err` that can be used instead. Other things: - `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both return `Option<ErrorGuaranteed>`, which enables the removal of two `delayed_bug` calls and one `Ty::new_error_with_message` call. This is possible because we store error guarantees in `DiagCtxt::stashed_diagnostics`. - Storing the guarantees also saves us having to maintain a counter. - Calls to the `stashed_err_count` method are no longer necessary alongside calls to `has_errors`, which is a nice simplification, and eliminates two more `span_delayed_bug` calls and one FIXME comment. - Tests are added for three of the four fixed PRs mentioned below. - `issue-121108.rs`'s output improved slightly, omitting a non-useful error message. Fixes #121451. Fixes #121477. Fixes #121504. Fixes #121508.
2024-02-28Use `LitKind::Err` for floats with empty exponents.Nicholas Nethercote-12/+1
This prevents a follow-up type error in a test, which seems fine.
2024-02-27Merge commit '10136170fe9ed01e46aeb4f4479175b79eb0e3c7' into ↵Philipp Krones-9416/+11604
clippy-subtree-update
2024-02-25Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkinbors-73/+86
Implement RFC 3373: Avoid non-local definitions in functions This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-5/+0
2024-02-20Auto merge of #121087 - oli-obk:eager_const_failures, r=lcnrbors-64/+23
Always evaluate free constants and statics, even if previous errors occurred work towards https://github.com/rust-lang/rust/issues/79738 We will need to evaluate static items before the `definitions.freeze()` below, as we will start creating new `DefId`s (for nested allocations) within the `eval_static_initializer` query. But even without that motivation, this is a good change. Hard errors should always be reported and not silenced if other errors happened earlier.
2024-02-19Always evaluate free constants and statics, even if previous errors occurredOli Scherer-64/+23
2024-02-19Remove suspicious auto trait lintSantiago Pastorino-27/+26
2024-02-17Allow newly added non_local_definitions lint in clippyUrgau-73/+86
2024-02-14Fix msg for verbose suggestions with confusable capitalizationEsteban Küber-1/+1
When encountering a verbose/multipart suggestion that has changes that are only caused by different capitalization of ASCII letters that have little differenciation, expand the message to highlight that fact (like we already do for inline suggestions). The logic to do this was already present, but implemented incorrectly.
2024-02-12Rollup merge of #118983 - Urgau:invalid_ref_casting-bigger-layout, r=oli-obkMatthias Krüger-11/+11
Warn on references casting to bigger memory layout This PR extends the [`invalid_reference_casting`](https://doc.rust-lang.org/rustc/lints/listing/deny-by-default.html#invalid-reference-casting) lint (*deny-by-default*) which currently lint on `&T -> &mut T` casting to also lint on `&(mut) A -> &(mut) B` where `size_of::<B>() > size_of::<A>()` (bigger memory layout requirement). The goal is to detect such cases: ```rust let u8_ref: &u8 = &0u8; let u64_ref: &u64 = unsafe { &*(u8_ref as *const u8 as *const u64) }; //~^ ERROR casting references to a bigger memory layout is undefined behavior let mat3 = Mat3 { a: Vec3(0i32, 0, 0), b: Vec3(0, 0, 0), c: Vec3(0, 0, 0) }; let mat3 = unsafe { &*(&mat3 as *const _ as *const [[i64; 3]; 3]) }; //~^ ERROR casting references to a bigger memory layout is undefined behavior ``` This is added to help people who write unsafe code, especially when people have matrix struct that they cast to simple array of arrays. EDIT: One caveat, due to the [`&Header`](https://github.com/rust-lang/unsafe-code-guidelines/issues/256) uncertainty the lint only fires when it can find the underline allocation. ~~I have manually tested all the new expressions that warn against Miri, and they all report immediate UB.~~ r? ``@est31``
2024-02-12Avoid UB in clippy transmute_ptr_to_ptr UI testUrgau-11/+11