Commit Graph

8839 Commits

Author SHA1 Message Date
Tyler Weaver
4d266d31de
needless_range_loop: improve documentation 2023-01-29 11:41:53 -07:00
bors
96c28d1f69 Auto merge of #10231 - Alexendoo:regex-spans, r=llogiq
`invalid_regex`: Show full error when string value doesn't match source

changelog: [`invalid_regex`]: Show full error when parsing non-literals or regular strings containing escape sequences

Fixes #4170, the escape sequence there causes the span to be incorrect which will have caused most of the confusion
2023-01-29 14:13:58 +00:00
Philipp Krones
6f9c70a201
Bump Clippy version -> 0.1.69 2023-01-27 20:27:00 +01:00
Philipp Krones
2bc2431fd1
Merge remote-tracking branch 'upstream/master' into rustup 2023-01-27 20:26:35 +01:00
Collin Styles
a1a01c19f1 Fix docs for suspicious_xor_used_as_pow lint
There was a tab after the three leading slashes which caused the
contents of the "Why is this bad?" section to be rendered as a code
block.
2023-01-26 16:52:39 -08:00
Alex Macleod
986f40fab0 invalid_regex: Show full error when string value doesn't match source 2023-01-26 15:33:40 +00:00
bors
a64940f948 Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk
Move format_args!() into AST (and expand it during AST lowering)

Implements https://github.com/rust-lang/compiler-team/issues/541

This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier.

This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`.

This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-26 12:44:47 +00:00
Martin Fischer
20cc72e8a8 Improve span for module_name_repetitions 2023-01-25 07:07:10 +01:00
Vincenzo Palazzo
2d8ede2335 fix: use LocalDefId instead of HirId in trait res
use LocalDefId instead of HirId in trait resolution to simplify
the obligation clause resolution

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-23 11:42:18 +00:00
bors
a9c251f11d Auto merge of #10106 - koka831:fix/10084, r=Alexendoo
Fix FP in `unnecessary_safety_comment`

Fix https://github.com/rust-lang/rust-clippy/issues/10084

changelog: FP: [`unnecessary_safety_comment`]: No longer lints code inside macros
[#10106](https://github.com/rust-lang/rust-clippy/pull/10106)
<!-- changelog_checked -->
2023-01-22 14:10:16 +00:00
Alex Macleod
5f49808bde Add machine applicable suggestion for bool_assert_comparison 2023-01-21 17:33:39 +00:00
bors
298a78277e Auto merge of #106977 - michaelwoerister:unord_id_collections, r=oli-obk
Use UnordMap and UnordSet for id collections (DefIdMap, LocalDefIdMap, etc)

This PR changes the `rustc_data_structures::define_id_collections!` macro to use `UnordMap` and `UnordSet` instead of `FxHashMap` and `FxHashSet`. This should account for a large portion of hash-maps being used in places where they can cause trouble.

The changes required are moderate but non-zero:
- In some places the collections are extracted into sorted vecs.
- There are a few instances where for-loops have been changed to extends.

~~Let's see what the performance impact is. With a bit more refactoring, we might be able to get rid of some of the additional sorting -- but the change set is already big enough. Unless there's a performance impact, I'd like to do further changes in subsequent PRs.~~

Performance does not seem to be negatively affected ([perf-run here](https://github.com/rust-lang/rust/pull/106977#issuecomment-1396776699)).

Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).

r? `@ghost`
2023-01-21 14:18:17 +00:00
bors
ce460dcd14 Auto merge of #105102 - compiler-errors:copy-impl-considering-regions, r=lcnr
Check ADT fields for copy implementations considering regions

Fixes #88901
r? `@ghost`
2023-01-20 21:29:52 +00:00
xFrednet
e3a09eca6d
Update version attribute for 1.67 lints 2023-01-19 21:58:08 +01:00
bors
aa0eb7fb1c Auto merge of #10206 - Niki4tap:one_unsafe_op_per_block, r=Alexendoo
Add `multiple_unsafe_ops_per_block` lint

Adds a lint, which restricts an `unsafe` block to only one unsafe operation.

Closes #10064

---

changelog: New lint: [`multiple_unsafe_ops_per_block`]
[#10206](https://github.com/rust-lang/rust-clippy/pull/10206)
<!-- changelog_checked -->
2023-01-19 13:58:09 +00:00
Alex Macleod
11611b0440 Move unchecked_duration_subtraction to pedantic 2023-01-19 11:18:47 +01:00
Michael Woerister
c1b358945a Allow for more efficient sorting when exporting Unord collections. 2023-01-19 10:40:54 +01:00
Michael Woerister
465ed5bd46 Use UnordMap instead of FxHashMap in define_id_collections!(). 2023-01-19 10:40:47 +01:00
Michael Woerister
31a053059e Use UnordSet instead of FxHashSet in define_id_collections!(). 2023-01-19 10:19:07 +01:00
Niki4tap
875e36f7e4 Add multiple_unsafe_ops_per_block lint 2023-01-18 10:00:31 +03:00
bors
89d443a4c3 Auto merge of #10193 - Jarcho:issue_9894, r=Manishearth
Fix suggestion in `transmutes_expressible_as_ptr_casts` when the source type is a borrow.

fixes #9894

changelog: `transmutes_expressible_as_ptr_casts`: Fix suggestion when the source type is a borrow.
2023-01-17 14:58:39 +00:00
bors
07a7603994 Auto merge of #10187 - dswij:issue-10182-semicolon, r=Jarcho
[needless_return]: Remove all semicolons on suggestion

Closes #10182

Multiple semicolons currently breaks autofix for `needless_return` suggestions. Any semicolons left after removing return means that the return type will always be `()`, and thus fail to compile.

This PR allows `needless_return` to remove multiple semicolons.

The change won't cover the case where there is multiple line yet.

i.e.

```rust
fn needless_return() -> bool {
    return true;
;;
}
```

---

changelog: Sugg: [`needless_return`]: Now removes all semicolons on the same line
[#10187](https://github.com/rust-lang/rust-clippy/pull/10187)
<!-- changelog_checked -->
2023-01-15 15:49:40 +00:00
bors
aceb4439d6 Auto merge of #10199 - tylerjw:document-extending-list-configs, r=xFrednet
Document lint configuration values in Clippy's book

changelog: document lint configuration values in Clippy's book

fixes #9991

r? `@xFrednet`
2023-01-14 18:14:31 +00:00
Tyler Weaver
c0da8acb72
Comment that lint_configuration.md is machine generated 2023-01-14 11:10:40 -07:00
bors
483b7ac918 Auto merge of #10038 - xFrednet:9231-sugg-try-from, r=Jarcho
`cast_possible_truncation` Suggest TryFrom when truncation possible

This fixes the last issues from https://github.com/rust-lang/rust-clippy/pull/9664 as the author seems to be inactive. The PR author was sadly kept during the rebase, due to the conflict resolution.

IDK if it's worth it do to a full review, I only added the last commit, everything else remained the same, besides a rebase.

---

changelog: Sugg: [`cast_possible_truncation`]: Now suggests using `try_from` or allowing the lint
[#10038](https://github.com/rust-lang/rust-clippy/pull/10038)
<!-- changelog_checked -->

closes: https://github.com/rust-lang/rust-clippy/issues/9231
2023-01-14 16:04:51 +00:00
Kyle Matsuda
b92d90211e change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata 2023-01-14 00:29:56 -07:00
Kyle Matsuda
a160ce3a48 change usages of impl_trait_ref to bound_impl_trait_ref 2023-01-14 00:23:32 -07:00
Tyler Weaver
7d1609dce3
Document configurations in table and paragraphs
Signed-off-by: Tyler Weaver <maybe@tylerjw.dev>
2023-01-13 16:26:46 -07:00
Michael Goulet
93d0f47064 Check ADT fields for copy implementations considering regions 2023-01-13 23:06:29 +00:00
Tyler Weaver
2e2ae68d5a
Document lint configuration values in Clippy's book
Signed-off-by: Tyler Weaver <maybe@tylerjw.dev>
2023-01-13 11:48:51 -07:00
bors
efb631a09c Auto merge of #106776 - oli-obk:om_nom_nom_nom_nom, r=cjgillot
Feed a bunch of queries instead of tracking fields on TyCtxt

r? `@cjgillot`

pulled out of https://github.com/rust-lang/rust/pull/105462
2023-01-13 13:57:21 +00:00
Alex Macleod
295225e9cd Move unchecked_duration_subtraction to pedantic 2023-01-13 00:04:28 +00:00
Jason Newcomb
b38848d8f7 Fix suggestion in transmutes_expressible_as_ptr_casts when the source type is a borrow. 2023-01-12 16:01:24 -05:00
Philipp Krones
d21616737b Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup 2023-01-12 19:48:13 +01:00
bors
7f27e2e74e Auto merge of #10192 - Jarcho:revert_9701, r=flip1995
Partially revert #9701

This partially reverts #9701 due to #10134

r? `@flip1995`

changelog: None
2023-01-12 18:47:17 +00:00
Jason Newcomb
5eed9c69ca Revert 4dbd8ad34e, c7dc961558, ed519ad746 and c6477eb711 2023-01-12 13:28:22 -05:00
Philipp Krones
631481ffb3
Merge remote-tracking branch 'upstream/master' into rustup 2023-01-12 18:59:59 +01:00
Oli Scherer
0c48b5a223 Feed the features_query instead of grabbing it from the session lazily 2023-01-12 17:14:17 +00:00
bors
decaba97cc Auto merge of #10184 - robertbastian:master, r=xFrednet
Allow implementing `Hash` with derived `PartialEq` (`derive_hash_xor_eq`

This is a common pattern and is totally allowed by the `Hash` trait.

Fixes #2627

changelog: Move: Renamed `derive_hash_xor_eq` to [`derived_hash_with_manual_eq`]
[#10184](https://github.com/rust-lang/rust-clippy/pull/10184)
changelog: Enhancement: [`derived_hash_with_manual_eq`]: Now allows `#[derive(PartialEq)]` with custom `Hash` implementations
[#10184](https://github.com/rust-lang/rust-clippy/pull/10184)
<!-- changelog_checked -->
2023-01-12 14:59:41 +00:00
bors
7c01721434 Auto merge of #10179 - llogiq:trim-suspicious-to-owned-paths, r=xFrednet
trim paths in `suspicious_to_owned`

This continues my path trimming spree. I'm not going to add yet another changelog entry, we should have one "trim paths in some applicable lints" entry instead.

---

changelog: none
2023-01-12 12:10:56 +00:00
xFrednet
5cb6246c3e
Address PR reivew 2023-01-12 12:37:56 +01:00
xFrednet
e6948c4117
Last PR adjustments 2023-01-12 12:16:08 +01:00
navh
fcdd08badf
update cast_possible_truncation documentation 2023-01-12 12:16:07 +01:00
navh
51aaba6e8c
cast_possible_truncation Suggest TryFrom when truncation possible 2023-01-12 12:16:06 +01:00
Mara Bos
2bcd697e2d Update clippy for new format_args!() lang items. 2023-01-12 00:25:46 +01:00
Alex Macleod
34024adc88 expl_impl_clone_on_copy: ignore packed structs with type/const params 2023-01-11 17:37:19 +00:00
Andre Bogus
bd76d9133b trim paths in suspicious_to_owned 2023-01-11 16:39:34 +01:00
bors
15226f91bb Auto merge of #10166 - sulami:master, r=giraffate
unused_self: Don't trigger if the method body contains todo!()

If the author is using todo!(), presumably they intend to use self at some point later, so we don't have a good basis to recommend factoring out to an associated function.

Fixes #10117.

---

changelog: Enhancement: [`unused_self`]: No longer lints, if the method body contains a `todo!()` call
[#10166](https://github.com/rust-lang/rust-clippy/pull/10166)
<!-- changelog_checked -->
2023-01-11 00:30:19 +00:00
dswij
d73adea465 needless_return: remove multiple semis on suggestion 2023-01-11 07:09:57 +08:00
Robert Bastian
8ca900b01c rename 2023-01-10 11:12:54 +01:00