Commit Graph

930 Commits

Author SHA1 Message Date
Alex Macleod
136c2cdb91 Add unused_format_specs lint 2022-10-17 11:36:05 +00:00
bors
4eaf543b69 Auto merge of #9609 - kraktus:hexa_f32, r=giraffate
[`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as floats

fix https://github.com/rust-lang/rust-clippy/issues/9603

changelog: [`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as floats
2022-10-17 00:46:36 +00:00
Samuel Moelius
2e5e3560e9 Fix adjacent code 2022-10-15 07:03:29 -04:00
Samuel Moelius
524ec2e125 Fix bug in referent_used_exactly_once 2022-10-12 09:21:08 -04:00
Jason Newcomb
0cc749296f Use the correct type when comparing nested constants. 2022-10-10 15:33:49 -04:00
Guillaume Gomez
c3f077c7ad Fix unclosed HTML tag in clippy doc 2022-10-10 20:45:04 +02:00
bors
cf72565a12 Auto merge of #9610 - Jarcho:fix-9608, r=Alexendoo
Don't suggest moving tuple structs with a significant drop to late evaluation

fixes #9608

changelog: Don't suggest moving tuple structs with a significant drop to late evaluation
2022-10-10 12:29:15 +00:00
Michael Goulet
7a42219e37 Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
Yuki Okushi
5ccf727344 Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki
rename `ImplItemKind::TyAlias` to `ImplItemKind::Type`

The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.
2022-10-10 00:09:42 +09:00
Michael Goulet
8e76d6687e ImplItemKind::TyAlias => ImplItemKind::Type 2022-10-09 07:09:57 +00:00
bors
272bbfb857 Auto merge of #9386 - smoelius:further-enhance-needless-borrow, r=Jarcho
Further enhance `needless_borrow`, mildly refactor `redundant_clone`

This PR does the following:
* Moves some code from `redundant_clone` into a new `clippy_utils` module called `mir`, and wraps that code in a function called `dropped_without_further_use`.
* Relaxes the "is copyable" condition condition from #9136 by also suggesting to remove borrows from values dropped without further use. The changes involve the just mentioned function.
* Separates `redundant_clone` into modules.

Strictly speaking, the last bullet is independent of the others. `redundant_clone` is somewhat hairy, IMO. Separating it into modules makes it slightly less so, by helping to delineate what depends upon what.

I've tried to break everything up into digestible commits.

r? `@Jarcho`

(`@Jarcho` I hope you don't mind.)

changelog: continuation of #9136
2022-10-08 21:24:54 +00:00
bors
292e313259 Auto merge of #9451 - kraktus:manual_filter2, r=dswij
Add `manual_filter` lint for `Option`

Share much of its implementation with `manual_map` and should greatly benefit from its previous feedback.
I'm sure it's possible to even more refactor both and would gladly take input on that as well as any clippy idiomatic usage, since this is my first lint addition.

I've added the lint to the complexity section for now, I don't know if every new lint needs to go in nursery first.

The matching could be expanded to more than `Some(<value>)` to lint on arbitrary struct matching inside the `Some` but I've left it like it was for `manual_map` for now. `needless_match::pat_same_as_expr` provides a more generic match example.

close https://github.com/rust-lang/rust-clippy/issues/8822

changelog: Add lint [`manual_filter`] for `Option`
2022-10-08 15:58:51 +00:00
Jason Newcomb
39a7d000b6 Don't suggest moving tuple structs with a significant drop to late evaluation. 2022-10-08 11:23:05 -04:00
kraktus
6f4546a4be [unnecessary_cast] Do not lint negative hexadecimal literals when cast as float
Floats cannot be expressed as hexadecimal literals
2022-10-08 16:15:18 +02:00
Matthias Krüger
4013d367fe Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk
Remove `mir::CastKind::Misc`

As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast.

r? ````@oli-obk````
2022-10-08 14:38:18 +02:00
bors
2c8e473ffe Auto merge of #9585 - rust-lang:extend-box-default, r=Alexendoo
extend `box-default` lint, add suggestion

This extends the recently added `box-default` lint to also cover `Box::new(vec![])`, `Box::new(String::from(""))` and `Box::new(Vec::from([]))`. Also the lint now suggests a suitable replacement. I did not find a simple way to check whether the type is fully determined by the outside, so I at least checked for some variations to remove the turbofish in those cases.

---

changelog: none
2022-10-07 14:49:54 +00:00
Cameron Steffen
6819e85501 Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
Samuel Moelius
9cc8da222b Fix adjacent code 2022-10-07 05:07:44 -04:00
Samuel Moelius
037f698147 needless_borrow uses used_exactly_once 2022-10-07 05:07:44 -04:00
Philipp Krones
09a554db25 Merge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyup 2022-10-06 17:41:53 +02:00
Andre Bogus
d3c041a086 extend box-default lint, add suggestion 2022-10-06 16:00:45 +02:00
Yuri Astrakhan
c251f8d8dd lint: fix a few comments 2022-10-06 08:54:07 -04:00
ouz-a
13dbc33d8f Remove mir::CastKind::Misc 2022-10-06 15:32:41 +03:00
Philipp Krones
d75b25faab Merge commit 'ac0e10aa68325235069a842f47499852b2dee79e' into clippyup 2022-10-06 09:44:38 +02:00
Philipp Krones
e2808afd60
Merge remote-tracking branch 'upstream/master' into rustup 2022-10-06 09:19:29 +02:00
bors
887ba0c5a4 Auto merge of #9586 - Alexendoo:format-args-commas, r=Manishearth
FormatArgsExpn: Find comma spans and ignore weird proc macro spans

Fixes the following cases:

A missing `, 1` from the `expect_fun_call` suggestion:

```rust
Some(()).expect(&format!("{x} {}", 1));
```
```
warning: use of `expect` followed by a function call
 --> t.rs:7:14
  |
7 |     Some(()).expect(&format!("{x} {}", 1));
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{x} {}"))`
```

The suggestion removing from the comma in the comment rather than the one after the format string:

```rust
println!(
    "{}",
    // a comment, with a comma in it
    x
);
```
```
warning: variables can be used directly in the `format!` string
  --> t.rs:9:5
   |
9  | /     println!(
10 | |         "{}",
11 | |         // a comment, with a comma in it
12 | |         x
13 | |     );
   | |_____^
   |
help: change this to
   |
10 ~         "{x}",
11 ~         // a comment
   |
```

It also no longer accepts expansions where a format string or argument has a "weird" proc macro span, that is one where the literal/expression it outputs has the span of one of its inputs. Kind of like a `format_args` specific `clippy_utils::is_from_proc_macro`, e.g. `format!(indoc! {" ... "})`

changelog: [`expect_fun_call`]: Fix suggestion for `format!` using captured variables
changelog: [`print_literal`], [`write_literal`], [`uninlined_format_args`]: Fix suggestion when following a comment including a comma
2022-10-05 16:27:03 +00:00
Alex Macleod
9226066bcb FormatArgsExpn: Find comma spans and ignore weird proc macro spans 2022-10-05 16:10:52 +00:00
Alex Macleod
86c86c3742 Add disallowed_macros lint 2022-10-05 13:44:06 +00:00
Jason Newcomb
26bb36636c Workaround rustc bug 2022-10-02 17:54:44 -04:00
Jason Newcomb
649d443646 Replace expr_visitor with for_each_expr 2022-10-02 17:04:22 -04:00
Jason Newcomb
162aa19793 Fix and improve internal lint checking for match_type usages
* Check for `const`s and `static`s from external crates
* Check for `LangItem`s
* Handle inherent functions which have the same name as a field
* Also check the following functions:
    * `match_trait_method`
    * `match_def_path`
    * `is_expr_path_def_path`
    * `is_qpath_def_path`
* Handle checking for a constructor to a diagnostic item or `LangItem`
2022-10-02 15:02:55 -04:00
Jason Newcomb
8e7af6b429 Replace is_lang_ctor with is_res_lang_ctor 2022-10-02 14:50:37 -04:00
kraktus
b89ac0cefc refactor manual_filter
Move common functions to `manual_utils.rs`, better arm matching, use clippy utils `contains_unsafe_block`
2022-10-03 14:13:15 +02:00
kraktus
2c04c1a188 [manual_assert]: Preserve comments in the suggestion 2022-10-02 15:03:48 +02:00
Jacob Kiesel
b221184572 Implement manual_clamp lint 2022-10-01 13:58:41 -06:00
bors
9e8f53d09a Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebank
Move lint level source explanation to the bottom

So, uhhhhh

r? `@estebank`

## User-facing change

"note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic:
```diff
-   = note: `#[warn(unsupported_calling_conventions)]` on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
+   = note: `#[warn(unsupported_calling_conventions)]` on by default
```

Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO.

## Developer-facing change

`struct_span_lint` and similar methods have a different signature.

Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)`
After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>`

The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion.

Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere.

## Subtle problem

By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings...

I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate.

## P.S.

I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01 10:44:25 +00:00
Maybe Waffle
0867c64a54 clippy: adopt to the new lint API 2022-10-01 10:03:06 +00:00
bors
e43f5a17d4 Auto merge of #9516 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-09-29 10:04:13 +00:00
Philipp Krones
67af127f24
Fix dogfood 2022-09-29 12:02:58 +02:00
Nicholas Nethercote
8b59fe4981 Shrink hir::def::Res.
`Res::SelfTy` currently has two `Option`s. When the second one is `Some`
the first one is never consulted. So we can split it into two variants,
`Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res`
from 24 bytes to 12. This then shrinks `hir::Path` and
`hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-29 08:44:52 +10:00
kraktus
314d57a790 [unnecessary_lazy_evaluations] Do not suggest switching to early evaluation when type has custom Drop 2022-09-28 22:46:05 +02:00
Philipp Krones
458e83291d
Bump Clippy version -> 0.1.66 2022-09-28 14:27:50 +02:00
Philipp Krones
bbcde66685
Merge remote-tracking branch 'upstream/master' into rustup 2022-09-28 14:27:32 +02:00
lcnr
e5ce6d18df rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
Pietro Albini
06568fd6c7 remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
fee1-dead
c69edba515 Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
Stabilize const `BTree{Map,Set}::new`

The FCP was completed in #71835.

Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.
2022-09-26 13:09:42 +08:00
Yuri Astrakhan
5a71bbdf3f new uninlined_format_args lint to inline explicit arguments
Implement https://github.com/rust-lang/rust-clippy/issues/8368 - a new
lint to inline format arguments such as `print!("{}", var)` into
`print!("{var}")`.

code | suggestion | comment
---|---|---
`print!("{}", var)` | `print!("{var}")` |  simple variables
`print!("{0}", var)` | `print!("{var}")` |  positional variables
`print!("{v}", v=var)` | `print!("{var}")` |  named variables
`print!("{0} {0}", var)` | `print!("{var} {var}")` |  aliased variables
`print!("{0:1$}", var, width)` | `print!("{var:width$}")` |  width
support
`print!("{0:.1$}", var, prec)` | `print!("{var:.prec$}")` |  precision
support
`print!("{:.*}", prec, var)` | `print!("{var:.prec$}")` |  asterisk
support

code | suggestion | comment
---|---|---
`print!("{0}={1}", var, 1+2)` | `print!("{var}={0}", 1+2)` | Format
string uses an indexed argument that cannot be inlined.  Supporting this
case requires re-indexing of the format string.

changelog: [`uninlined_format_args`]: A new lint to inline format
arguments, i.e. `print!("{}", var)` into `print!("{var}")`
2022-09-25 19:53:03 -04:00
Takayuki Maeda
ea75178219 separate definitions and HIR owners
fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-24 23:21:19 +09:00
Nilstrieb
e30b37b84b Fix clippy's const fn stability check for CURRENT_RUSTC_VERSION
Since clippy can use a projects MSRV for its lints, it might not want
to consider functions as const stable if they have been added lately.

Functions that have been stabilized this version use
CURRENT_RUSTC_VERSION as their version, which gets then turned into the
current version, which might be something like `1.66.0-dev`. The version
parser cannot deal with this version, so it has to be stripped off.
2022-09-23 21:04:54 +02:00
Yuri Astrakhan
59d0e8caba and a few more from other dirs 2022-09-23 14:25:03 -04:00
b-naber
26861fbd7f rename Unevaluated to UnevaluatedConst 2022-09-23 14:27:34 +02:00
b-naber
adc7e3e679 introduce mir::Unevaluated 2022-09-22 12:35:28 +02:00
David Koloski
4d015293d1 Merge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy 2022-09-21 13:13:27 -04:00
bors
0dc24ca376 Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
Allow patterns to constrain the hidden type of opaque types

fixes #96572

reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864)

TODO:

* check if https://github.com/rust-lang/rust/issues/99685 is avoided
2022-09-20 12:09:52 +00:00
lcnr
70f4c712c5 remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
Oli Scherer
c2e9c991d5 Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
This reverts commit 4a742a691e.
2022-09-16 11:36:39 +00:00
est31
2be8b73328 Fix clippy 2022-09-15 21:21:18 +02:00
Jacob Kiesel
dd97c1ed20 fix: clippy_utils::Sugg should treat hir::ExprKind::DropTemps as transparent 2022-09-14 13:35:35 -06:00
bors
f6a07d1d36 Auto merge of #101212 - eholk:dyn-star, r=compiler-errors
Initial implementation of dyn*

This PR adds extremely basic and incomplete support for [dyn*](https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/). The goal is to get something in tree behind a flag to make collaboration easier, and also to make sure the implementation so far is not unreasonable. This PR does quite a few things:

* Introduce `dyn_star` feature flag
* Adds parsing for `dyn* Trait` types
* Defines `dyn* Trait` as a sized type
* Adds support for explicit casts, like `42usize as dyn* Debug`
  * Including const evaluation of such casts
* Adds codegen for drop glue so things are cleaned up properly when a `dyn* Trait` object goes out of scope
* Adds codegen for method calls, at least for methods that take `&self`

Quite a bit is still missing, but this gives us a starting point. Note that this is never intended to become stable surface syntax for Rust, but rather `dyn*` is planned to be used as an implementation detail for async functions in dyn traits.

Joint work with `@nikomatsakis` and `@compiler-errors.`

r? `@bjorn3`
2022-09-14 18:10:51 +00: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
cf043f6a16 Auto merge of #101709 - nnethercote:simplify-visitors-more, r=cjgillot
Simplify visitors more

A successor to #100392.

r? `@cjgillot`
2022-09-14 05:21:14 +00:00
Eric Holk
27e91b65d5 Address code review comments 2022-09-13 14:50:12 -07:00
Eric Holk
b95b285ef4 Make x.py check work 2022-09-12 17:29:11 -07:00
Markus Reiter
64a42db51a Simplify clippy fix. 2022-09-12 19:46:51 +02: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
Nicholas Nethercote
308153563b Remove unused span argument from visit_name. 2022-09-12 13:44:29 +10: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
0958f9486b Add manual_filter lint for Option
Share much of its implementation with `manual_map` and should greatly benefit from its previous feedback.
2022-09-10 10:41:55 +02:00
kraktus
bdb13cd887 refactor: move has_debug_impl to clippy_utils::ty 2022-09-10 10:39:51 +02:00
Philipp Krones
98bf99e2f8 Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup 2022-09-09 13:36:26 +02:00
Michael Goulet
854f751b26 Appease clippy again 2022-09-09 01:31:46 +00:00
Michael Goulet
ac1c68a5e6 Make clippy happy 2022-09-09 01:31:45 +00: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
Nicholas Nethercote
c86a9c077c Introduce DotDotPos.
This shrinks `hir::Pat` from 88 to 72 bytes.
2022-09-08 15:25:50 +10:00
Nicholas Nethercote
977b6e29a3 Arena-allocate hir::Lifetime.
This shrinks `hir::Ty` from 72 to 48 bytes.

`visit_lifetime` is added to the HIR stats collector because these types
are now stored in memory on their own, instead of being within other
types.
2022-09-08 15:07:19 +10: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
bors
0ee702514e Auto merge of #9303 - Jarcho:ice_9297, r=Alexendoo
Fix ICE when reading literals with weird proc-macro spans

fixes #9297
changelog: Fix ICE when reading literals with weird proc-macro spans
2022-08-08 11:36:27 +00:00
Jason Newcomb
99abd4a9f6 Fix ICE when reading literals with weird proc-macro spans 2022-08-07 22:22:17 -04:00
Jason Newcomb
745b194292 Small cleanup for check_proc_macro.rs 2022-08-07 21:55:10 -04:00
Jason Newcomb
8dda974a27 Add note to the docs on is_from_proc_macro 2022-08-07 21:55:10 -04:00
Jason Newcomb
670efd5720 Don't lint default_trait_access in proc-macro expansions 2022-08-07 21:55:08 -04:00
Jason Newcomb
4ae582ef88 Don't lint missing_docs_in_private_items on proc-macro output 2022-08-07 21:53:51 -04:00
Jason Newcomb
37e838f759 Use new util function in suspicious_else_formatting 2022-08-07 21:52:27 -04:00
Jason Newcomb
2ae8b300a7 Don't lint unit_arg when expanded from a proc-macro 2022-08-07 21:52:25 -04:00
bors
05e7d5481b Auto merge of #9053 - AaronC81:fix-9052, r=flip1995
Fix suggestions for `async` closures in redundant_closure_call

Fixes #9052

changelog: Fix suggestions given by [`redundant_closure_call`] for async closures
2022-08-02 12:39:37 +00:00
Federico Guerinoni
0696624ba7 Add elapsed_instant lint
Closes #8603

Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>
2022-08-01 23:39:00 +02:00
bors
80a56878cf Auto merge of #99884 - nnethercote:lexer-improvements, r=matklad
Lexer improvements

Some cleanups and small speed improvements.

r? `@matklad`
2022-08-01 12:52:49 +00:00
Nicholas Nethercote
09f9acea0a Shrink Token.
From 72 bytes to 12 bytes (on x86-64).

There are two parts to this:
- Changing various source code offsets from 64-bit to 32-bit. This is
  not a problem because the rest of rustc also uses 32-bit source code
  offsets. This means `Token` is no longer `Copy` but this causes no
  problems.
- Removing the `RawStrError` from `LiteralKind`. Raw string literal
  invalidity is now indicated by a `None` value within
  `RawStr`/`RawByteStr`, and the new `validate_raw_str` function can be
  used to re-lex an invalid raw string literal to get the `RawStrError`.

There is one very small change in behaviour. Previously, if a raw string
literal matched both the `InvalidStarter` and `TooManyHashes` cases,
the latter would override the former. This has now changed, because
`raw_double_quoted_string` now uses `?` and so returns immediately upon
detecting the `InvalidStarter` case. I think this is a slight
improvement to report the earlier-detected error, and it explains the
change in the `test_too_many_hashes` test.

The commit also removes a couple of comments that refer to #77629 and
say that the size of these types don't affect performance. These
comments are wrong, though the performance effect is small.
2022-08-01 08:53:04 +10:00
Dylan DPC
72649cf2a6 Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot
Use LocalDefId for closures more
2022-07-31 17:36:40 +05:30
Cameron Steffen
62907727af Use LocalDefId for closures more 2022-07-30 15:59:17 -05:00
Miguel Guarniz
ce5fa10cce Change enclosing_body_owner to return LocalDefId
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Philipp Krones
67c405cc1d Merge commit '3c7e7dbc1583a0b06df5bd7623dd354a4debd23d' into clippyup 2022-07-28 19:08:22 +02:00
Philipp Krones
0905ec465d
Merge remote-tracking branch 'upstream/master' into rustup 2022-07-28 18:55:32 +02:00
Jason Newcomb
ab6463e9d9 Fix ICE in miri_to_const 2022-07-24 18:23:33 -04:00
Oli Scherer
bcd2241c9a Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank"
This reverts commit 6f8fb911ad, reversing
changes made to 7210e46dc6.
2022-07-20 07:55:58 +00:00
Jason Newcomb
95c759157c Check for todo! on every expression in SpanlessEq 2022-07-19 09:57:18 -04:00
Philipp Krones
7d4daaa8fa Merge commit 'fdb84cbfd25908df5683f8f62388f663d9260e39' into clippyup 2022-07-18 09:39:37 +02:00
Jason Newcomb
84e03b6215 Don't lint explicit_auto_deref on dyn Trait return 2022-07-17 11:14:07 -04:00
Caio
f88a1399bb Stabilize let_chains 2022-07-16 20:17:58 -03:00
Oli Scherer
417a600c30 Introduce opaque type to hidden type projection 2022-07-15 15:49:22 +00:00
Aaron Christiansen
4c43aa7053 Fix suggestion for async in redundant_closure_call
Fix redundant_closure_call for single-expression async closures

Add Sugg::asyncify

Use Sugg for redundant_closure_call implementation
2022-07-15 15:49:04 +01:00
Philipp Krones
f074034590
Merge remote-tracking branch 'upstream/master' into rustup 2022-07-15 09:49:15 +02:00
bors
6dc9746147 Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot
Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of https://github.com/rust-lang/rust/pull/90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
2022-07-14 13:42:09 +00:00
Dylan DPC
e275abf92e Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
bors
5b7a2d5037 Auto merge of #99210 - Dylan-DPC:rollup-879cp1t, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #98574 (Lower let-else in MIR)
 - #99011 (`UnsafeCell` blocks niches inside its nested type from being available outside)
 - #99030 (diagnostics: error messages when struct literals fail to parse)
 - #99155 (Keep unstable target features for asm feature checking)
 - #99199 (Refactor: remove an unnecessary `span_to_snippet`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-13 17:13:27 +00:00
bors
a7162f29b4 Auto merge of #9134 - Jarcho:while_let_iter_closure, r=dswij
Improve `while_let_on_iterator` suggestion inside an `FnOnce` closure

changelog: Improve `while_let_on_iterator` suggestion inside an `FnOnce` closure
2022-07-13 16:20:14 +00:00
bors
0930ac91b9 Fix typos
changelog: none
2022-07-13 14:48:32 +00:00