Commit Graph

7035 Commits

Author SHA1 Message Date
Jason Newcomb
78345b4d09 Clarify cfg detection process in matches.rs 2022-02-18 15:41:46 -05:00
Jason Newcomb
8912d659cd Remove hack testing for cfg attribute in match_single_binding 2022-02-17 14:16:21 -05:00
Jason Newcomb
8ce2d46cac Check for cfg attrubutes before linting match expressions 2022-02-17 14:04:10 -05:00
Jason Newcomb
9bfcbf4f02 Remove some redundant checks in various matches lints 2022-02-17 10:48:24 -05:00
bors
a4cf91b9c8 Auto merge of #8433 - hellow554:update_default_trait, r=flip1995
Don't lint Default::default if it is the udpate syntax base

changelog: Don't lint `Default::default` it is part of the update syntax

Current clippy warns about this:

```
warning: calling `Foo::default()` is more clear than this expression
  --> src/main.rs:12:11
   |
12 |         ..Default::default()
   |           ^^^^^^^^^^^^^^^^^^ help: try: `Foo::default()`
   |
```

With these changes, it will not lint that particular expression anymore.
2022-02-17 09:13:30 +00:00
Marcel Hellwig
504f3af70e Don't lint Default::default if it is the udpate syntax base
An Update Syntax looks like this:

   Foo {
      a: 3,
      ..Default::default()
    }

Don't lint `Default::default` here
2022-02-17 10:04:25 +01:00
James McMurray
b162b11abc Add recursive_format_impl lint
The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug
inside any format string in the same impl
The to_string_in_display check is kept as is - like in the
format_in_format_args lint

For now only Display and Debug are checked
This could also be extended to other Format traits (Binary, etc.)
2022-02-14 18:49:51 +01:00
bors
4931cab709 Auto merge of #8425 - Jarcho:transmute_8417, r=giraffate
Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs

Fixes: #8417

The description has also been made more precise.

changelog: Fix `transmute_undefined_repr` with single field `#[repr(C)]` structs
changelog: Move `transmute_undefined_repr` back to `correctness`
2022-02-14 06:58:51 +00:00
bors
41c7004cea Auto merge of #8427 - Jarcho:merge_cargo_passes, r=llogiq
Merge cargo lints

changelog: None
2022-02-14 06:14:02 +00:00
nsunderland1
78c2e0bfe9 Document pub requirement for new_without_default lint 2022-02-13 17:07:14 -08:00
Jason Newcomb
eed7e9f618 Merge cargo lints 2022-02-13 17:36:33 -05:00
Jason Newcomb
662df33e97 Fix transmute_undefined_repr with single field #[repr(C)] structs 2022-02-13 13:22:17 -05:00
Alex Macleod
e2dc8ca080 Replace a few paths with diagnostic items 2022-02-12 11:44:28 +00:00
David Tolnay
79644069f0
Downgrade transmute_undefined_repr lint to nursery 2022-02-11 19:40:07 -08:00
Alex Macleod
41d7c7e059 Migrate dbg_macro to late pass 2022-02-11 15:56:10 +00:00
flip1995
0775c06d32
Merge remote-tracking branch 'upstream/master' into rustup 2022-02-10 18:11:27 +01:00
Yuki Okushi
5044e3769e Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis
Remove defaultness from ImplItem.

This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-09 14:12:22 +09:00
Jason Newcomb
c65894cf1a Split out wild_in_or_pats 2022-02-07 13:00:19 -05:00
Jason Newcomb
aa3af30dee Split out rest_pat_in_fully_bound_struct 2022-02-07 12:57:02 -05:00
Jason Newcomb
6477923323 Split out infalliable_detructuring_match 2022-02-07 12:28:57 -05:00
Jason Newcomb
fb1093c561 Split out match_ref_pats 2022-02-07 12:22:27 -05:00
Jason Newcomb
1da26c8a70 Split out match_single_binding 2022-02-07 12:22:27 -05:00
Jason Newcomb
bccf06f601 Split out match_as_ref 2022-02-07 12:22:26 -05:00
Jason Newcomb
75923dff5b Split out wildcard_enum_match_arm and match_wildcard_for_single_variants 2022-02-07 12:22:26 -05:00
Jason Newcomb
dc75695e97 Split out match_wild_err_arm 2022-02-07 12:22:26 -05:00
Jason Newcomb
2a70439ef0 Split out overlapping_arms 2022-02-07 12:22:26 -05:00
Jason Newcomb
f3dd909e0f Split out match_bool 2022-02-07 12:22:26 -05:00
Jason Newcomb
f23dc16e1d Split out single_match 2022-02-07 12:22:26 -05:00
Jason Newcomb
f2b6ed7cb2 Split out redundant_pattern_match 2022-02-07 12:22:24 -05:00
Jason Newcomb
64548250e7 Split out match_same_arms 2022-02-07 12:20:18 -05:00
Jason Newcomb
e41a6fc042 Split out match_like_matches_macro 2022-02-07 12:20:18 -05:00
Jason Newcomb
f7be9564e5 Move matches.rs to mod.rs 2022-02-07 12:20:17 -05:00
bors
3d43826e32 Auto merge of #8305 - camsteffen:util-cleanup, r=flip1995
Factor out several utils, add `path_def_id`

changelog: none

This is generally an effort to reduce the total number of utils. `path_def_id` is added which I believe is more "cross-cutting" and also complements `path_to_local`. Best reviewed one commit at a time.

Added:
* `path_def_id`
* `path_res`

Removed:
 * `is_qpath_def_path`
 * `match_any_diagnostic_items`
 * `expr_path_res`
 * `single_segment_path`
 * `differing_macro_contexts`
 * `is_ty_param_lang_item`
 * `is_ty_param_diagnostic_item`
 * `get_qpath_generics`

Renamed:
* `path_to_res` to `def_path_res`
* `get_qpath_generic_tys` to `qpath_generic_tys`

CC `@Jarcho` since this relates to some of your work and you may have input.
2022-02-07 15:23:23 +00:00
bors
8dc719cb39 Auto merge of #8326 - matthiaskrgr:warn_on_multi_configs, r=xFrednet
warn if we find multiple clippy configs

Fixes #8323

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: warn if we find multiple clippy configs
2022-02-06 17:19:11 +00:00
bors
093e32052e Auto merge of #8398 - Jarcho:unordered_transmute, r=llogiq
Add lint `transmute_undefined_repr`

Partially implements #3999 and #546

This doesn't consider `enum`s at all right now as those are going to be a pain to deal with. This also allows `#[repr(Rust)]` structs with only one non-zero sized fields. I think those are technically undefined when transmuted.

changelog: Add lint `transmute_undefined_repr`
2022-02-06 16:05:00 +00:00
Jason Newcomb
68993b1f6c Small transmute_float_to_int cleanup 2022-02-06 09:42:10 -05:00
Jason Newcomb
3403b3e717 Add lint transumte_undefined_repr 2022-02-05 16:28:25 -05:00
bors
68b44986de Auto merge of #8365 - Alexendoo:explicit-write-suggestion, r=camsteffen
Add `explicit_write` suggestions for `write!`s with format args

changelog: Add [`explicit_write`] suggestions for `write!`s with format args

Fixes #4542

```rust
writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
```

Now suggests:

```
error: use of `writeln!(stderr(), ...).unwrap()`
  --> $DIR/explicit_write.rs:36:9
   |
LL |         writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("macro arg {}", one!())`
```

---------

r? `@camsteffen` (again, sorry 😛) for the `FormatArgsExpn` change

Before this change `inputs_span` returned a span pointing to just `1` in

```rust
macro_rules! one {
    () => { 1 };
}

`writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap();`
```

And the `source_callsite` of that span didn't include the format string, it was just `one!()`
2022-02-05 17:44:37 +00:00
bors
29cc0d8e59 Auto merge of #8372 - tamaroning:unwrap_used, r=llogiq
make unwrap_used also trigger on .get().unwrap()

fixes #8124
changelog: make the [unwrap_used] lint trigger for code of the form such as `.get(i).unwrap()` and `.get_mut(i).unwrap()`
2022-02-05 14:56:42 +00:00
Alex Macleod
144b4a59c7 Add explicit_write suggestions for write!s with format args 2022-02-05 13:05:08 +00:00
bors
699ee5e31c Auto merge of #8376 - dswij:8373, r=camsteffen
[`chars_next_cmp`] Fix unescaped suggestion

closes #8373

changelog: [`chars_next_cmp`] Fix unescaped suggestion
2022-02-05 00:32:10 +00:00
Camille GILLOT
3edfd5ec3d Remove defaultness from ImplItem. 2022-02-03 18:56:08 +01:00
bors
bef92b864d Auto merge of #8382 - tamaroning:suggest_iter_instead_of_into_iter, r=giraffate
[explicit_counter_loop] suggests `.into_iter()`, despite that triggering [into_iter_on_ref] in some cases

I have modified `fn make_iterator_snippet` in clippy_lints/src/loops/utils.rs ,so this change has some little influence on another lint [manual_flatten] .

fixes #8155

---
changelog: Fix that [`explicit_counter_loop`] suggests `into_iter()` despite that triggering [`into_iter_on_ref`] in some cases
2022-02-02 12:37:18 +00:00
tamaron
f5fd9ded00 chore 2022-02-02 11:25:15 +09:00
Jason Newcomb
e4f45c22e2 Fix ICE in ptr_arg 2022-02-01 15:05:20 -05:00
Jason Newcomb
8ef87455b0 Minor cleanup on transmute lints 2022-02-01 10:58:01 -05:00
lcnr
99af4c8971 remove TyS::same_type
it ignored regions and constants in adts,
but didn't do so for references or any other types.
This seemed quite weird
2022-02-01 11:21:26 +01:00
tamaron
0e1cbc5cd1 fix code 2022-02-01 13:43:39 +09:00
Matthias Krüger
1193abe4c8 multiple configs: add tests 2022-01-31 18:36:15 +01:00
Matthias Krüger
97e5a70f47 warn if we find multiple clippy configs
Fixes #8323
2022-01-31 18:36:15 +01:00