Guillaume Gomez
1f94d55a18
Fix new tests updates
2025-02-15 13:38:42 +01:00
Guillaume Gomez
f666fd6417
Update UI tests
2025-02-15 13:38:16 +01:00
Samuel Tardieu
342ac8ee28
New lint: mem_replace_option_with_some
...
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.
2025-02-12 19:57:14 +01:00
Esteban Küber
39d73d5bbb
Use MIR body to identify more "default equivalent" calls
...
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-11 02:59:06 +00:00
Samuel Moelius
877585089e
Fix non-lifetime tests
2024-09-25 13:52:12 -04:00
Alex Macleod
1d107ab2be
Remove $DIR replacement in test output
2024-02-17 12:34:54 +00:00
Gabriel Fernandes
83555914ed
[mem_replace_with_default] No longer triggers on unused expression
2024-02-11 21:11:13 -03:00
Urgau
a86e758228
Adjust clippy tests with new rustc help suggestion for lints
2023-09-04 14:22:02 +02:00
Philipp Krones
cc61aeea54
Merge commit '080b587854a73f2a8cbaecff1884860a78e2ff37' into clippyup
2023-08-24 21:32:12 +02:00
Philipp Krones
6b95029f17
Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup
2023-04-11 15:31:08 +02:00
Philipp Krones
d05e2865a0
Merge commit 'd822110d3b5625b9dc80ccc442e06fc3cc851d76' into clippyup
2022-12-01 18:29:38 +01:00
flip1995
cd0bb7de01
Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup
2022-10-23 15:18:45 +02:00
flip1995
091ed44b50
Merge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyup
2021-09-08 16:31:47 +02:00
flip1995
9f6b5de7de
Merge commit '0e87918536b9833bbc6c683d1f9d51ee2bf03ef1' into clippyup
2021-03-25 19:29:11 +01:00
flip1995
fb989d3215
Remove remaining license header in test file
2020-02-20 12:06:45 +01:00
Krishna Veera Reddy
c09e79e226
Lint within internal macros without a suggestion
2019-12-31 09:22:35 -08:00
Krishna Veera Reddy
26812f733d
Prevent mem_replace_with_default lint within macros
...
Also added test cases for internal and external macros.
2019-12-31 09:22:34 -08:00
Krishna Veera Reddy
2a75241c1a
Add test cases for replace with Default::default()
2019-12-31 09:22:34 -08:00
Krishna Veera Reddy
8db319f957
Use mem::take instead of mem::replace when applicable
...
`std::mem::take` can be used to replace a value of type `T`
with `T::default()` instead of `std::mem::replace`.
2019-12-31 09:22:34 -08:00
Wilco Kusee
95f2a9dbfc
Add run-rustfix to mem_replace test
2019-01-13 13:55:26 +01:00
flip1995
d2dbd0b8a5
Update *.stderr files
2018-12-28 12:41:12 +01:00
Matthias Krüger
7bcc2cd9c8
update test stderr
2018-12-10 08:22:07 +01:00
Manish Goregaokar
e9c025ea70
Add license header to Rust files
2018-10-06 09:43:08 -07:00
Jay Kickliter
2f53aaa5bd
mem_replace: match on path.
2018-09-19 14:41:22 -07:00
Jay Kickliter
598df08d88
Add lint for mem::replace(.., None).
...
Suggest `Option::take()` as an alternative.
2018-09-19 14:38:34 -07:00