Commit Graph

13357 Commits

Author SHA1 Message Date
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
bors
083697014c Auto merge of #8429 - nsunderland1:master, r=llogiq
Document `pub` requirement for `new_without_default` lint

fixes #8415

Also adds some UI tests that ensure that `pub` is required on both the struct _and_ the field. The only thing I'm not sure about is that the lint actually [checks](https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/new_without_default.rs#L102) if `new` is _reachable_, not _public_. To the best of my understanding, both the struct and the method need to be public for the method to be reachable for external crates (I certainly didn't manage to craft a counterexample).

changelog: Document `pub` requirement for ``[`new_without_default`]`` lint.
2022-02-14 05:55:34 +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
bors
c37d6eed06 Auto merge of #8421 - Alexendoo:paths, r=llogiq
Replace a few paths with diagnostic items

A fairly small change towards #5393

changelog: none
2022-02-12 17:24:57 +00:00
Alex Macleod
e2dc8ca080 Replace a few paths with diagnostic items 2022-02-12 11:44:28 +00:00
bors
5707491b18 Auto merge of #8418 - dtolnay-contrib:transmuteundefinedrepr, r=llogiq
Downgrade transmute_undefined_repr to nursery

Reason: #8417. I am skeptical of this lint but maybe there is a narrower subset of types on which it is useful, so keeping it for now but moving to nursery for further development.

---

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

changelog: Remove [`transmute_undefined_repr`] from default set of enabled lints
2022-02-12 07:22:13 +00:00
David Tolnay
79644069f0
Downgrade transmute_undefined_repr lint to nursery 2022-02-11 19:40:07 -08:00
bors
96c73c5923 Auto merge of #8411 - Alexendoo:dbg_macro, r=flip1995
Migrate `dbg_macro` to late pass

changelog: Make `dbg_macro` work with crate level attributes and inside macro calls

One down for #6610, fixes #7275

Also fixes #7274, and adds parenthesis around the suggestion for `dbg!(1, 2, 3)` as it expands to a tuple
2022-02-11 16:39:00 +00:00
Alex Macleod
41d7c7e059 Migrate dbg_macro to late pass 2022-02-11 15:56:10 +00:00
bors
57b3c4b90f Auto merge of #8409 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-02-10 17:14:39 +00:00
flip1995
49b9f9247b
Bump nightly version -> 2022-02-10 2022-02-10 18:11:49 +01:00
flip1995
0775c06d32
Merge remote-tracking branch 'upstream/master' into rustup 2022-02-10 18:11:27 +01:00
bors
6966a42c1a Auto merge of #8404 - camsteffen:rm-ui-test, r=flip1995
Factor out ui_test suite

changelog: none
2022-02-09 09:09:58 +00: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
Cameron Steffen
88fd090531 Factor out ui_test suite 2022-02-08 15:11:48 -06:00
bors
caeebd6b09 Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
Support `cargo dev bless` for tests with revisions

changelog: internal: Support `cargo dev bless` for tests with revisions

Previously bless wouldn't pick up the saved stderr from `target/debug/tests/manual_assert.stage-id.edition2021.stderr` or `target/debug/tests/manual_assert.stage-id.edition2018.stderr` due to there being multiple revisions of the test output

This tweaks compile-test so the built files end up in e.g. `target/debug/tests/ui`, `target/debug/tests/ui-cargo` rather than share the `tests` dir. `cargo dev bless` then uses that to update all the `.stdout/stdout/fixed` files it can find

Also removes an empty file I found, and the logic to remove empty outputs as compiletest doesn't produce empty `.stdout/stderr` files
2022-02-08 20:50:41 +00:00
bors
2590701b2a Auto merge of #8400 - Jarcho:split_matches, r=Manishearth
Split matches

Part of #6680

changelog: None
2022-02-07 20:10:07 +00: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
Matthias Krüger
aae64e93b7 ignore test on windows since I don't know why compiletest does not hand paths properly there 2022-02-06 17:21:32 +01: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
Alex Macleod
04dce4aed4 Support cargo dev bless for tests with revisions 2022-02-06 13:00:17 +00: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
Alex Macleod
4bae06d73c Use source callsite in FormatArgsExpn::inputs_span 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
Oli Scherer
69872175ee Lazily resolve type-alias-impl-trait defining uses
by using an opaque type obligation to bubble up comparisons between opaque types and other types

Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-02 15:40:11 +00:00