about summary refs log tree commit diff
path: root/tests/ui
AgeCommit message (Collapse)AuthorLines
2025-03-10make `never_loop` applicability more flexiblelapla-cogito-1/+172
2025-02-20Rustup (#14262)Philipp Krones-1579/+2523
r? @ghost changelog: none
2025-02-20Rustup: fix 32bit testsPhilipp Krones-48/+72
2025-02-20Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-13029/+29172
2025-02-19add `owned_cow` lintAndre Bogus-95/+184
2025-02-19fix: `map_entry` FP on struct member (#14151)Catherine Flores-0/+46
fixes #13934 I modified the part for checking if the map is used so that it can check field and index exprs. changelog: [`map_entry`]: fix FP on struct member
2025-02-19`.last()` to `.next_back()` requires a mutable receiver (#14140)Catherine Flores-13/+208
In the case where `iter` is a `DoubleEndedIterator`, replacing a call to `iter.last()` (which consumes `iter`) by `iter.next_back()` (which requires a mutable reference to `iter`) cannot be done when `iter` is a non-mutable binding which is not a mutable reference. When possible, a local immutable binding is made into a mutable one. Also, the applicability is switched to `MaybeIncorrect` and a note is added to the output when the element types have a significant drop, because the drop order will potentially be modified because `.next_back()` does not consume the iterator nor the elements before the last one. Fix #14139 changelog: [`double_ended_iterator_last`]: do not trigger on non-reference immutable receiver, and warn about possible drop order change
2025-02-19`double_ended_iterator_last`: note when drop order is changedSamuel Tardieu-2/+75
`iter.last()` will drop all elements of `iter` in order, while `iter.next_back()` will drop the non-last elements of `iter` when `iter` goes out of scope since `.next_back()` does not consume its argument. When the transformation proposed by `double_ended_iterator_last` would concern an iterator whose element type has a significant drop, a note is added to warn about the possible drop order change, and the suggestion is switched from `MachineApplicable` to `MaybeIncorrect`.
2025-02-19fix: `map_entry` FP on struct memberyanglsh-0/+46
2025-02-18`.last()` to `.next_back()` requires a mutable receiverSamuel Tardieu-13/+135
In the case where `iter` is a `DoubleEndedIterator`, replacing a call to `iter.last()` (which consumes `iter`) by `iter.next_back()` (which requires a mutable reference to `iter`) cannot be done when `iter` Is not a mutable binding or a mutable reference. When `iter` is a local binding, it can be made mutable by fixing its definition site.
2025-02-17fix: `needless_option_as_deref` FP in trait (#14210)Alejandra González-0/+26
fixes #14148 Another case of #13077 and #8646 changelog: [`needless_option_as_deref`]: fix FP in trait
2025-02-17`manual_ok_err`: blockify the replacement of an `else if …`Samuel Tardieu-1/+39
If the part being replaced is an `if` expression following an `else`, the replacement expression must be blockified.
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-4/+4
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-02-16`ui_test` annotation cleanup (#14232)Alex Macleod-355/+340
Cleans up some changes from https://github.com/rust-lang/rust-clippy/pull/11421 I searched for any `.stderr` files where the number of errors changed and reverted + manually added the annotations for them Also fixes `tests/ui/asm_syntax_not_x86.rs` r? @flip1995 changelog: none
2025-02-16`ui_test` annotation cleanupAlex Macleod-355/+340
2025-02-16add `manual_contains` lintlapla-cogito-25/+310
2025-02-15fGuillaume Gomez-2/+2
2025-02-15Better handle 32bit/64bit-specific ui testsGuillaume Gomez-143/+155
2025-02-15Fix `tests/ui/transmute_32bit.rs` annotationsGuillaume Gomez-4/+4
2025-02-15Fix 32 bits testsSamuel Tardieu-63/+81
2025-02-15Add missing ui annotations to new ui testsGuillaume Gomez-2/+8
2025-02-15Make fmt (weirdly) happyGuillaume Gomez-548/+1647
2025-02-15Fix new tests updatesGuillaume Gomez-7822/+5989
2025-02-15Make `if_let_mutex` test pass on both 2021 and 2024 editionsGuillaume Gomez-8/+6
2025-02-15Add manual annotationsGuillaume Gomez-6/+9
2025-02-15Handle compilation error in `builtin_type_shadow.rs`Guillaume Gomez-2/+1
2025-02-15Allowed `clippy::tests/ui/attrs.2.fixed` in `tests/ui/attr.rs` because when ↵Guillaume Gomez-44/+2
adding annotations, it doesn't work anymore
2025-02-15Update UI testsGuillaume Gomez-15122/+28709
2025-02-15Fix `used_underscore_items` lint uses of foreign functions (#14205)Jason Newcomb-0/+10
Fixed #14156 changelog: none
2025-02-15`unnecessary_map_or`: do not consume the comparison value if it does not ↵Jason Newcomb-1/+37
implement `Copy` (#14207) Fix #14201 changelog: [`unnecessary_map_or`]: do not consume the comparison value if it does not implement `Copy`
2025-02-14doc_link_code: add check for links with code spans that render weird (#14121)Catherine Flores-0/+228
This is the lint described at https://github.com/rust-lang/rust/pull/136308#issuecomment-2625485331 that recommends using HTML to nest links inside code. changelog: [`doc_link_code`]: warn when a link with code and a code span are back-to-back
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-29/+18
2025-02-13Fix `literal_string_with_formatting_args` lint emitted when it should not ↵Timo-14/+98
(#13953) Fixes #13885. Fixes https://github.com/rust-lang/rust-clippy/issues/14007. Problem was that I forgot to check whether or not the `span` was a "real" one. Because if not, then it starts pointing to pretty much only wrong content, hence the problems we saw with clippy linting on `clippy.toml`. changelog: Fix `literal_string_with_formatting_args` lint emitted when it should not r? @samueltardieu
2025-02-13`unnecessary_map_or`: do not consume the non-`Copy` comparison valueSamuel Tardieu-1/+37
2025-02-13fix: `needless_option_as_deref` FP in traityanglsh-0/+26
2025-02-12New lint: `mem_replace_option_with_some` (#14197)llogiq-1/+66
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`. Close #14195 changelog: [`mem_replace_option_with_some`]: new lint
2025-02-12New lint: `mem_replace_option_with_some`Samuel Tardieu-1/+66
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.
2025-02-13Fix `used_underscore_items` lint uses of foreign functionsWeiTheShinobi-0/+10
2025-02-12New lint: `unbuffered_bytes` (#14089)Jason Newcomb-6/+79
Checks for `Read::bytes()` on an unbuffered Read type. The default implementation calls `read` for each byte, which can be very inefficient for data that’s not in memory, such as `File`. Considerations which I'd like to have feedback on: * Currently this lint triggers when `.bytes()` is called on any type that implements `std::io::Read` but not `std::io::BufRead`. This is quite aggressive and in and may result in false positives. Alternatives: * Only trigger on concrete types, not generic types. This does mean that cases where a function is generic over a `R: Read` and calls `.bytes()` are not caught by the lint, which could be quite a nasty case of this bug. * Only trigger on an allowlist of stdlib types * Compromise: Is it possible to make this lint `pedantic` on types that are not on a allowlist? * Theoretically, a trait implementation of `Read` could override `.bytes()` with an efficient implementation. I'm not sure how to add this check to the lint, and I can't find any cases of this being done in practice. * I don't think an automatic fix for this lint is possible, but I'd love to be proven wrong * This is my first time contributing to clippy, please let me know if I did anything wrong Fixes #14087 ``` changelog: [`unbuffered_bytes`]: new lint ```
2025-02-12add index checks for the slice in `manual_slice_fill` (#14193)Jason Newcomb-2/+34
fix #14192 changelog: [`manual_slice_fill`]: resolve FP caused by missing index checks for the slice
2025-02-12New lint: `unbuffered_bytes`jonathan-6/+79
2025-02-11`{expect,unwrap}_used`: add options to lint at compilation timeSamuel Tardieu-0/+11
By default, do not lint `.unwrap()` and `.expect(…)` in always const contexts, as a failure would be detected at compile time anyway. New options `allow_expect_in_consts` and `allow_unwrap_in_consts`, defaulting to `true`, can be turned unset to still lint in always const contexts.
2025-02-11just_underscores_and_digits: fix false positive in error recovery scenario ↵Alejandra González-0/+29
(#14168) Fixes #12302 changelog: [`just_underscores_and_digits`]: fix false positive in error recovery scenario
2025-02-11just_underscores_and_digits: ignore empty identMichael Howell-0/+29
Empty idents come from error recovery, and should imply that a better error has already been emitted.
2025-02-11`declare_interior_mutable_const`, `borrow_interior_mutable_const`: resolve ↵Alejandra González-0/+86
`<T as Trait>::AssocT` projections (#14125) changelog: [`declare_interior_mutable_const`, `borrow_interior_mutable_const`]: resolve `<T as Trait>::AssocT` projections --- This came up during https://github.com/rust-lang/rust/pull/130543 where we have `<T as AtomicPrimitive>::Assoc = AtomicT` instead of just `AtomicT` and clippy failed to resolve that properly. This really needs a review, because - I don't know if `try_normalize_erasing_regions` is the right thing to call here. - I'm not sure if I peel off the correct amount of `ValTree::Branch` layers (I think I do). Also, shouldn't this lint's infrastructure rely on `Freeze` trait (https://github.com/rust-lang/rust/issues/121675) instead of hardcoding a list of known-to-be-interior-mutable types? --- Previously filed this in the main rust repo (https://github.com/rust-lang/rust/pull/136369), was asked to do it here instead (https://github.com/rust-lang/rust/pull/136369#issuecomment-2628527774).
2025-02-11add index checks for the slice in `manual_slice_fill`lapla-cogito-2/+34
2025-02-11Use MIR body to identify more "default equivalent" callsEsteban Küber-25/+175
When looking for `Default` impls that could be derived, we look at the body of their `fn default()` and if it is an fn call or literal we check if they are equivalent to what `#[derive(Default)]` would have used. Now, when checking those fn calls in the `fn default()` body, we also compare against the corresponding type's `Default::default` body to see if our call is equivalent to that one. For example, given ```rust struct S; impl S { fn new() -> S { S } } impl Default for S { fn default() -> S { S::new() } } ``` `<S as Default>::default()` and `S::new()` are considered equivalent. Given that, if the user also writes ```rust struct R { s: S, } impl Default for R { fn default() -> R { R { s: S::new() } } } ``` the `derivable_impls` lint will now trigger.
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-1444/+2207
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-10Use parentheses when needed in `nonminimal_bool` lintSamuel Tardieu-1/+13
Since comparisons on types not implementing `Ord` (such as `f32`) are not inverted, they must be enclosed in parentheses when they are negated.
2025-02-09Fix `let_and_return` with temporary variables, and distinguish between Rust ↵llogiq-0/+938
editions (#14180) The first commit fixes #14164 by making sure that temporaries with non-static references are also looked for in expressions coming from expansion. The shortcut that was done skipped those parts and reported an absence of short-lived temporaries, which was incorrect. The second commit distinguishes between edition 2024 and earlier ones. Starting from edition 2024, the problematic drop order has been fixed, and block variables, which might be referenced in a block expression, are freed after the block expression itself. This allows more `let_and_return` cases to be reported starting with edition 2024, whereas in earlier editions an intermediary variable was necessary to reorder the drops. Incidentally, since Clippy is compiled in edition 2024 mode, the second commit has led to a fix in `clippy_lints/src/matches/significant_drop_in_scrutinee.rs`. changelog: [`let_and_return`]: lint more cases in edition 2024, and fix a false positive involving short-lived block temporary variables in earlier editions.