Commit Graph

761 Commits

Author SHA1 Message Date
Jacob Kiesel
dd97c1ed20 fix: clippy_utils::Sugg should treat hir::ExprKind::DropTemps as transparent 2022-09-14 13:35:35 -06:00
bors
2ddbc86bef Auto merge of #8518 - Alexendoo:write-late-pass, r=flip1995
Migrate write.rs to a late pass

changelog: Migrates write.rs from a pre expansion pass to a late pass
changelog: [`positional_named_format_parameters`] is renamed in favour of the rustc lint `named_arguments_used_positionally`

- Macros are now identified by diagnostic items, so will no longer lint user defined macros named, e.g. a custom `print!`
- `print_literal`/`write_literal` no longer lint no longer lint literals that come from macro expansions, e.g. `env!("FOO")`
- `print_with_newline`/`write_with_newline` no longer lint strings with any internal `\r` or `\n`s

~~A false negative, `print_literal`/`write_literal` don't lint format strings that produce `FormatSpec`s, e.g. ones containing pretty print/width/align specifiers~~

Suggestion changes:
- ~~`print_literal`/`write_literal` no longer have suggestions, as the spans for the `{}`s were not easily obtainable~~
-  `print_with_newline`/`write_with_newline` has a better suggestion for a sole literal newline, but no longer has suggestions for len > 1 strings that end in a literal newline
- ~~`use_debug` spans are less precise, now point to the whole format string~~

The diff for write.rs is pretty unwieldy, other than for the `declare_clippy_lint!`s I think you'd be better off viewing it as a brand new file rather than looking at the diff, as it's mostly written from scratch

cc #6610, fixes #5721, fixes #7195, fixes #8615
2022-09-14 15:58:21 +00:00
bors
7b8c4a9e83 Auto merge of #9464 - lukaslueg:issue9463, r=dswij
Don't panic on invalid shift while constfolding

Instead of panicking on invalid shifts while folding constants we simply give up. Fixes #9463

Notice the "attempt to shift right by `1316134912_u32`", which seems weird. AFAICS it comes from rustc itself.

changelog: none
2022-09-12 16:56:53 +00:00
bors
5e0663e25c Auto merge of #9469 - Alexendoo:expr-field-visitor, r=giraffate
Fix FormatArgsExpn parsing of FormatSpec positions

Woops, forgot visitors don't walk themselves

Fixes #9468

r? `@giraffate`

changelog: none
2022-09-12 13:58:53 +00:00
Alex Macleod
bd9d375c6b Fix FormatArgsExpn parsing of FormatSpec positions 2022-09-12 11:39:54 +00:00
bors
018b54b33b Auto merge of #9458 - Alexendoo:expr-field-visitor, r=giraffate
Use `visit_expr_field` for `ParamPosition`

A small change to make it a little simpler

changelog: none
2022-09-12 00:21:28 +00:00
bors
69f6009f85 Auto merge of #9410 - dswij:issue-9375, r=xFrednet
Use macro callsite when creating `Sugg` helper

Closes #9375

changelog: Improvement: [`collapsible_if`]: Suggestions now work with macros, by taking the call site into account.
2022-09-11 15:10:00 +00:00
Lukas Lueg
1e23c65d5e Don't panic on invalid shift while constfolding
Fixes #9463
2022-09-11 12:26:13 +02:00
Alex Macleod
1b245e7e0e Use visit_expr_field for ParamPosition 2022-09-10 18:33:04 +00:00
kraktus
bdb13cd887 refactor: move has_debug_impl to clippy_utils::ty 2022-09-10 10:39:51 +02:00
Alex Macleod
6fc6d87fd0 Migrate write.rs to a late pass 2022-09-08 20:18:02 +00:00
Philipp Krones
4ee55c5528
Merge remote-tracking branch 'upstream/auto' into rustup 2022-09-08 21:27:09 +02:00
Oli Scherer
9cbbd4a80e Generalize the Assume intrinsic statement to a general Intrinsic statement 2022-09-06 14:18:32 +00:00
Oli Scherer
e1b3483ee8 Lower the assume intrinsic to a MIR statement 2022-09-06 14:18:32 +00:00
bors
ce339b219a Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
`BindingAnnotation` refactor

* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`

One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.

I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-06 03:16:29 +00:00
Takayuki Maeda
4bcaddeeb2 separate the receiver from arguments in HIR under /clippy 2022-09-05 22:25:57 +09:00
Dylan DPC
9ae329232b Rollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwco
Improve HIR stats

#100398 improve the AST stats collection done by `-Zhir-stats`. This PR does the same for HIR stats collection.

r? `@davidtwco`
2022-09-05 14:15:51 +05:30
Cameron Steffen
e5f30f4dfa clippy: BindingAnnotation change 2022-09-02 13:03:11 -05:00
dswij
f0d642ea38 Use macro source when creating Sugg helper 2022-09-01 18:46:53 +08:00
Jason Newcomb
d4a0785464 Correctly handle unescape warnings 2022-09-01 00:00:37 -04:00
Jason Newcomb
7bd5b012c7 Use CountIsStart in clippy 2022-08-31 09:45:51 -04:00
Jason Newcomb
fb41bfa774 Merge commit 'f51aade56f93175dde89177a92e3669ebd8e7592' into clippyup 2022-08-31 09:24:45 -04:00
Lukas Lueg
66a97055b2 Initial implementation of result_large_err 2022-08-30 17:39:40 +02:00
Nilstrieb
ce847beb47 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Nicholas Nethercote
3ce109e12d Use &'hir Ty everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Nicholas Nethercote
3b80e994d5 Use &'hir Expr everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Jason Newcomb
3ad398d9b0 Merge branch 'master' into rustup 2022-08-28 06:44:13 -04:00
dswij
51e9113c60 Add span_contains_comments util 2022-08-28 00:07:00 +08:00
Tomasz Miąsko
e4eddc611a Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
Michael Wright
a0afbdfbec Replace contains_ty(..) with Ty::contains(..)
This removes some code we don't need and the method syntax is
also more readable IMO.
2022-08-24 08:11:29 +02:00
Nicholas Nethercote
06d7119f40 Remove the symbol from ast::LitKind::Err.
Because it's never used meaningfully.
2022-08-23 16:56:24 +10:00
alex-semenyuk
2781ad0e9e Fix typos 2022-08-20 12:31:29 +03:00
bors
2091142f5d Auto merge of #9258 - Serial-ATA:unused-peekable, r=Alexendoo
Add [`unused_peekable`] lint

changelog: Add [`unused_peekable`] lint
closes: #854
2022-08-19 18:30:13 +00:00
Alex Macleod
4f049f5a69 Refactor FormatArgsExpn 2022-08-19 15:35:26 +00:00
Serial
2666c38acb Add [unused_peekable] lint 2022-08-19 08:05:59 -04:00
bors
868dba9f65 Auto merge of #9295 - Guilherme-Vasconcelos:manual-empty-string-creation, r=dswij
Add `manual_empty_string_creations` lint

Closes #2972

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`

changelog: [`manual_empty_string_creations`]: Add lint for empty String not being created with `String::new()`
2022-08-19 11:19:06 +00:00
Samuel E. Moelius III
a05cb74d30 Enhance needless_borrow to consider trait implementations 2022-08-16 18:34:51 -04:00
Nicholas Nethercote
6e5f90ae46 Shrink ast::Attribute. 2022-08-16 11:10:13 +10:00
Guilherme-Vasconcelos
80826c3944 Implement clippy::manual_empty_string_creations lint 2022-08-14 12:45:24 -03:00
Mark Rousskov
1a3192a331 Adjust cfgs 2022-08-12 16:28:15 -04:00
bors
9ac237dce5 Auto merge of #100419 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2022-08-12 00:12:51 +00:00
Philipp Krones
dc29cfb8d5 Merge commit '2b2190cb5667cdd276a24ef8b9f3692209c54a89' into clippyup 2022-08-11 19:42:16 +02:00
Philipp Krones
280b527821
Bump Clippy version -> 0.1.65 2022-08-11 19:26:38 +02:00
Philipp Krones
879855bbaf
Merge remote-tracking branch 'upstream/master' into rustup 2022-08-11 19:26:04 +02:00
Camille GILLOT
cf3f71d2a2 Do not consider method call receiver as an argument in AST. 2022-08-10 18:34:54 +02:00
dAxpeDDa
fd60581628
Address review take 2 2022-08-09 05:14:03 +02:00
dAxpeDDa
6f5d64842b
Address review 2022-08-09 04:56:04 +02:00
dAxpeDDa
8d4f2ac381
Use check_proc_macro for missing_const_for_fn 2022-08-09 03:41:59 +02:00
bors
4912c0ece4 Auto merge of #9126 - Jarcho:auto_deref_sugg, r=Manishearth
`explicit_auto_deref` changes

fixes #9123
fixes #9109
fixes #9143
fixes #9101

This avoid suggesting code which hits a rustc bug. Basically `&{x}` won't use auto-deref if the target type is `Sized`.

changelog: Don't suggest using auto deref for block expressions when the target type is `Sized`
changelog: Include the borrow in the suggestion for `explicit_auto_deref`
changelog: Don't lint `explicit_auto_deref` on `dyn Trait` return
changelog: Don't lint `explicit_auto_deref` when other adjustments are required
changelog: Lint `explicit_auto_deref` in implicit return positions for closures
2022-08-08 15:20:24 +00:00
Jason Newcomb
ecb51fe6a5 Lint explicit_auto_deref in implicit return positions for closures 2022-08-08 10:25:05 -04:00