Commit graph

19486 commits

Author SHA1 Message Date
bors
eb4a441c09 Auto merge of #12419 - smoelius:plural-acronyms, r=dswij
Handle plural acronyms in `doc_markdown`

Prevent `doc_markdown` from triggering on words like `OSes` and `UXes`.

changelog: handle plural acronyms in `doc_markdown`
2024-03-05 10:47:40 +00:00
bors
193456e0a5 Auto merge of #12288 - PartiallyTyped:trait-type-checking-documentation, r=flip1995
Add documentation on trait checking and type construction

Changes:

Added documentation on how to create types via `Ty` and how to check specific trait implementations.

changelog: none

r? `@blyxyas`
2024-03-05 09:38:45 +00:00
bors
ae710de635 Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwco
Diagnostic renaming 2

A sequel to #121489.

r? `@davidtwco`
2024-03-05 02:58:34 +00:00
Nicholas Nethercote
ec920ce096 Rename DiagnosticExt as DiagExt. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
dc37dddeb5 Rename DiagnosticMessage as DiagMessage. 2024-03-05 12:14:49 +11:00
bors
415b1f1fa7 Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelix
Add a scheme for moving away from `extern "rust-intrinsic"` entirely

All `rust-intrinsic`s can become free functions now, either with a fallback body, or with a dummy body and an attribute, requiring backends to actually implement the intrinsic.

This PR demonstrates the dummy-body scheme with the `vtable_size` intrinsic.

cc https://github.com/rust-lang/rust/issues/63585

follow-up to #120500

MCP at https://github.com/rust-lang/compiler-team/issues/720
2024-03-05 00:13:01 +00:00
Samuel Moelius
cc4c8db0fd Handle plural acronyms in doc_markdown 2024-03-04 22:00:24 +00:00
Nicholas Nethercote
b74b4b09d1 Rename all ParseSess variables/fields/lifetimes as psess.
Existing names for values of this type are `sess`, `parse_sess`,
`parse_session`, and `ps`. `sess` is particularly annoying because
that's also used for `Session` values, which are often co-located, and
it can be difficult to know which type a value named `sess` refers to.
(That annoyance is the main motivation for this change.) `psess` is nice
and short, which is good for a name used this much.

The commit also renames some `parse_sess_created` values as
`psess_created`.
2024-03-05 08:11:45 +11:00
Alex Macleod
301d293ef6 Move iter_nth to style, add machine applicable suggestion 2024-03-04 16:39:15 +00:00
bors
5214ab557f Auto merge of #12416 - Veykril:patch-2, r=blyxyas
Add missing header for `manual_is_variant_and`

Noticed this while generating our lint completions failed in rust-analyzer (separate PR from https://github.com/rust-lang/rust-clippy/pull/12415 as I made these via the github interface quickly)
changelog: none
2024-03-04 16:27:23 +00:00
bors
1cb39050bf Auto merge of #12415 - Veykril:patch-1, r=blyxyas
Add missing header for `manual_c_str_literals`

Noticed this while generating our lint completions failed in rust-analyzer
changelog: none
2024-03-04 16:16:46 +00:00
Oli Scherer
ea92548c56 Add is_intrinsic helper 2024-03-04 16:13:50 +00:00
Lukas Wirth
7322fa0235
Add missing header for manual_is_variant_and 2024-03-04 17:09:49 +01:00
Lukas Wirth
c5c14773fd
Add missing header for manual_c_str_literals 2024-03-04 17:07:31 +01:00
bors
c0939b18b8 Auto merge of #12409 - cookie-s:fix-identityop-duplicate-errors, r=Alexendoo
[`identity_op`]: Fix duplicate diagnostics

Relates to #12379

In the `identity_op` lint, the following diagnostic was emitted two times

```
  --> tests/ui/identity_op.rs:156:5
   |
LL |     1 * 1;
   |     ^^^^^ help: consider reducing it to: `1`
   |
```

because both of the left operand and the right operand are the identity element of the multiplication.

This PR fixes the issue so that if a diagnostic is created for an operand, the check of the other operand will be skipped. It's fine because the result is always the same in the affected operators.

---

changelog: [`identity_op`]: Fix duplicate diagnostics
2024-03-04 14:43:38 +00:00
bors
e970fa52e7 Auto merge of #12341 - y21:issue12337, r=dswij
Check for try blocks in `question_mark` more consistently

Fixes #12337

I split this PR up into two commits since this moves a method out of an `impl`, which makes for a pretty bad diff (the `&self` parameter is now unused, and there isn't a reason for that function to be part of the `impl` now).

The first commit is the actual relevant change and the 2nd commit just moves stuff (github's "hide whitespace" makes the diff easier to look at)

------------
Now for the actual issue:

`?` within `try {}` blocks desugars to a `break` to the block, rather than a `return`, so that changes behavior in those cases.

The lint has multiple patterns to look for and in *some* of them it already does correctly check whether we're in a try block, but this isn't done for all of its patterns.

We could add another `self.inside_try_block()` check to the function that looks for `let-else-return`, but I chose to actually just move those checks out and instead have them in `LintPass::check_{stmt,expr}`. This has the advantage that we can't (easily) accidentally forget to add that check in new patterns that might be added in the future.

(There's also a bit of a subtle interaction between two lints, where `question_mark`'s LintPass calls into `manual_let_else`, so I added a check to make sure we don't avoid linting for something that doesn't have anything to do with `?`)

changelog: [`question_mark`]: avoid linting on try blocks in more cases
2024-03-04 14:34:56 +00:00
bors
f75d8c7f1b Auto merge of #12393 - J-ZhengLi:issue9413, r=dswij
fix [`derive_partial_eq_without_eq`] FP on trait projection

fixes: #9413 #9319

---

changelog: fix [`derive_partial_eq_without_eq`] FP on trait projection

Well, this is awkward, it works but I don't understand why, why `clippy_utils::ty::implements_trait` couldn't detects the existance of `Eq` trait, even thought it's obviously present in the derive attribute.
2024-03-04 06:43:59 +00:00
kcz
3b9939e83b
[identity_op]: Fix duplicate errors 2024-03-03 19:25:51 -05:00
bors
c2dd413c79 Auto merge of #12403 - samueltardieu:issue-12402, r=blyxyas
Pointers cannot be converted to integers at compile time

Fix #12402

changelog: [`transmutes_expressible_as_ptr_casts`]: do not suggest invalid const casts
2024-03-03 23:09:54 +00:00
bors
aceeb54b75 Auto merge of #12405 - PartiallyTyped:12404, r=blyxyas
Added msrv to threadlocal initializer check

closes: #12404
changelog:[`thread_local_initializer_can_be_made_const`]: Check for MSRV (>= 1.59) before processing.
2024-03-03 23:01:37 +00:00
Samuel Tardieu
6e5332cd9c Pointers cannot be converted to integers at compile time 2024-03-03 23:55:01 +01:00
bors
30642113b2 Auto merge of #12406 - MarcusGrass:fix-duplicate-std-instead-of-core, r=Alexendoo
Dedup std_instead_of_core by using first segment span for uniqueness

Relates to #12379.

Instead of checking that the paths have an identical span, it checks that the relevant `std` part of the path segment's span is identical. Added a multiline test, because my first implementation was worse and failed that, then I realized that you could grab the span off the first_segment `Ident`.

I did find another bug that isn't addressed by this, and that exists on master as well.

The path:
```Rust
use std::{io::Write, fmt::Display};
```

Will get fixed into:
```Rust
use core::{io::Write, fmt::Display};
```

Which doesn't compile since `io::Write` isn't in `core`, if any of those paths are present in `core` it'll do the replace and cause a miscompilation. Do you think I should file a separate bug for that? Since `rustfmt` default splits those up it isn't that big of a deal.

Rustfmt:
```Rust
// Pre
use std::{io::Write, fmt::Display};
// Post
use std::fmt::Display;
use std::io::Write;
```
---

changelog: [`std_instead_of_core`]: Fix duplicated output on multiple imports
2024-03-03 18:22:40 +00:00
Quinn Sinclair
19c2aba3e9 address review comments 2024-03-03 18:12:41 +01:00
Quinn Sinclair
8c5afd496b address review comments 2024-03-03 18:12:41 +01:00
Quinn Sinclair
ca8f03fb93 Update trait_checking.md
Co-authored-by: Philipp Krones <hello@philkrones.com>
2024-03-03 18:12:41 +01:00
Quinn Sinclair
58d9c4707e formatting 2024-03-03 18:12:41 +01:00
Quinn Sinclair
a6fc64bb7b Trait checking and type construction 2024-03-03 18:12:41 +01:00
MarcusGrass
3735bf93ff
Working but not with mixed imports 2024-03-03 17:23:11 +01:00
MarcusGrass
a2e4ef294c
dump bugged fix 2024-03-03 17:17:58 +01:00
Quinn Sinclair
08459b4dae Added msrv to threadlocal initializer 2024-03-03 15:43:09 +01:00
MarcusGrass
74cba639e9
Dedup std_instead_of_core by using first segment span for uniqueness 2024-03-03 15:30:49 +01:00
bors
28e11b31de Auto merge of #12400 - samueltardieu:issue-12395, r=Alexendoo
[`let_underscore_untyped`]: fix false positive on async function

changelog: [`let_underscore_untyped`]: fix false positive on async function

Fix #12395
2024-03-03 13:20:11 +00:00
Samuel Tardieu
1df2854ac3 [let_underscore_untyped]: fix false positive on async function 2024-03-03 14:03:02 +01:00
MarcusGrass
8e3ad2e545
Remove double expr lint 2024-03-03 08:32:30 +01:00
Guillaume Boisseau
550b276109 Rollup merge of #121841 - tgross35:f16-f128-step2-intrinsics, r=compiler-errors
`f16` and `f128` step 2: intrinsics

Continuation of https://github.com/rust-lang/rust/pull/121728, another portion of https://github.com/rust-lang/rust/pull/114607.

This PR adds `f16` and `f128` intrinsics, and hooks them up to both HIR and LLVM. This is all still unexposed to the frontend, which will probably be the next step. Also update itanium mangling per `@rcvalle's` in https://github.com/rust-lang/rust/pull/121728/files#r1506570300, and fix a typo from step 1.

Once these types are usable in code, I will add the codegen tests from #114607 (codegen is passing on that branch)

This does add more `unimplemented!`s to Clippy, but I still don't think we can do better until library support is added.

r? `@compiler-errors`
cc `@Nilstrieb`
`@rustbot` label +T-compiler +F-f16_and_f128
2024-03-02 20:13:24 +01:00
bors
5e0afee334 Auto merge of #12394 - CBSpeir:issue-12390-refactor, r=Alexendoo
Refactor lints in clippy_lints::attrs into separate submodules/files

This pull request contains the changes requested in issue #12390.

changelog: none
2024-03-02 14:32:43 +00:00
Christopher B. Speir
1580af6b55 Refactor lints in clippy_lints::attrs into separate submodules/files 2024-03-02 07:20:25 -06:00
Trevor Gross
2c8f47105a Propegate HIR and AST f16 and f128 types to clippy 2024-03-01 13:59:06 -05:00
J-ZhengLi
dde2552b11 add test cases for #9319 2024-03-02 01:06:59 +08:00
J-ZhengLi
1a97d1460b fix [derive_partial_eq_without_eq] FP on trait projection 2024-03-02 00:37:35 +08:00
Jakub Beránek
24de0be29b
Fix tests 2024-03-01 16:37:23 +01:00
Jakub Beránek
bc551b9a70
Do not run the lint on macro-generated code 2024-03-01 16:36:05 +01:00
Jakub Beránek
f7356f2a8f
Fix lint errors 2024-03-01 16:36:05 +01:00
Jakub Beránek
41f5ee1189
React to review 2024-03-01 16:36:05 +01:00
Jakub Beránek
0fcc33e29c
Fix tests 2024-03-01 16:36:04 +01:00
Jakub Beránek
e3cda2a399
Update lints 2024-03-01 16:35:28 +01:00
Jakub Beránek
0656d28f6b
Add assigning_clones lint 2024-03-01 16:35:28 +01:00
clubby789
aa1c9a5993 If suggestion would leave an empty line, delete it 2024-03-01 13:48:20 +00:00
bors
346b094a11 Auto merge of #12218 - jhpratt:manifest-options-doc, r=blyxyas
Document manifest options

All built-in cargo commands have this output included when run with `cargo foo --help`. Clippy is the only exception, so I have copied the text here. As far as I can tell, the flags come from Cargo itself and not clippy, but the user almost certainly does not care about that.

```text
Manifest Options:
      --manifest-path <PATH>  Path to Cargo.toml
      --frozen                Require Cargo.lock and cache are up to date
      --locked                Require Cargo.lock is up to date
      --offline               Run without accessing the network
```

changelog: Add the standard Manifest Options section to the `--help` output
2024-03-01 12:13:24 +00:00
bors
e865dca4d7 Auto merge of #12010 - granddaifuku:fix/manual-memcpy-indexing-for-multi-dimension-arrays, r=Alexendoo
fix: `manual_memcpy` wrong indexing for multi dimensional arrays

fixes: #9334

This PR fixes an invalid suggestion for multi-dimensional arrays.

For example,
```rust
let src = vec![vec![0; 5]; 5];
let mut dst = vec![0; 5];

for i in 0..5 {
    dst[i] = src[i][i];
}
```

For the above code, Clippy suggests `dst.copy_from_slice(&src[i]);`, but it is not compilable because `i` is only used to loop the array.
I adjusted it so that Clippy `manual_memcpy` works properly for multi-dimensional arrays.

changelog: [`manual_memcpy`]: Fixes invalid indexing suggestions for multi-dimensional arrays
2024-03-01 12:05:03 +00:00