Commit Graph

1587 Commits

Author SHA1 Message Date
Jacherr
93b39d8910 disable indexing_slicing for custom Index impls 2024-05-30 11:45:43 +00:00
Philipp Krones
89037ea18f
Merge remote-tracking branch 'upstream/master' into rustup 2024-05-30 09:44:14 +02:00
Oli Scherer
e3e27ba3dd Create const block DefIds in typeck instead of ast lowering 2024-05-28 13:38:43 +00:00
bors
4dd07f4e4e Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote
[perf] Delay the construction of early lint diag structs

Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666.

See individual commits for details. The first three commits are not strictly necessary.
However, the 2nd one (06bc4fc671, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement.
It's also pretty sweet on its own if I may say so myself.
2024-05-27 08:44:12 +00:00
J-ZhengLi
03306b6ab6 suggest adding parentheses when linting [let_and_return] and [needless_return] 2024-05-27 11:49:10 +08:00
León Orell Valerian Liehr
0c653d9f91 Remove LintDiagnostic::msg
* instead simply set the primary message inside the lint decorator functions
* it used to be this way before [#]101986 which introduced `msg` to prevent
  good path delayed bugs (which no longer exist) from firing under certain
  circumstances when lints were suppressed / silenced
* this is no longer necessary for various reasons I presume
* it shaves off complexity and makes further changes easier to implement
2024-05-23 04:08:35 +02:00
Philipp Krones
4363278c73 Merge commit '2efebd2f0c03dabbe5c3ad7b4ebfbd99238d1fb2' into clippy-subtree-update 2024-05-21 10:39:30 -07:00
Matthias Krüger
acf38f8466 Rollup merge of #125173 - scottmcm:never-checked, r=davidtwco
Remove `Rvalue::CheckedBinaryOp`

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996>
cc `@RalfJung`

While it's a draft,
r? ghost
2024-05-20 18:13:48 +02:00
Santiago Pastorino
23e8b03f00 Add and use generics.is_empty() and generics.is_own_empty, rather than using generics' attributes 2024-05-19 11:10:56 -03:00
bors
37dfd973b7 Auto merge of #125077 - spastorino:add-new-fnsafety-enum2, r=jackh726
Rename Unsafe to Safety

Alternative to #124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks.

This leaves us today with:

```rust
enum ast::Safety {
    Unsafe(Span),
    Default,
    // Safe (going to be added for unsafe extern blocks)
}

enum hir::Safety {
    Unsafe,
    Safe,
}
```

We would convert from `ast::Safety::Default` into the right Safety level according the context.
2024-05-18 19:35:24 +00:00
Scott McMurray
0cd64b5756 Fix clippy 2024-05-17 20:33:02 -07:00
Santiago Pastorino
0590d71ce2 Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
Philipp Krones
c200dad300
Merge remote-tracking branch 'upstream/master' into rustup 2024-05-16 14:20:56 -07:00
Michael Goulet
4f589e322d Remove trivial Binder::dummy calls 2024-05-16 14:24:23 -04:00
Michael Goulet
6b371469bf Fix tools 2024-05-16 14:24:23 -04:00
bors
caad063933 Auto merge of #12713 - J-ZhengLi:issue8864, r=y21
make sure the msrv for `const_raw_ptr_deref` is met when linting [`missing_const_for_fn`]

fixes: #8864

---

changelog: make sure the msrv for `const_ptr_deref` is met when linting [`missing_const_for_fn`]
2024-05-15 21:29:34 +00:00
J-ZhengLi
1b7fc5f5aa add some msrv checks in is_min_const_fn 2024-05-15 16:38:57 +08:00
Michael Goulet
760fbdf64e split out AliasTy -> AliasTerm 2024-05-13 11:59:42 -04:00
Michael Goulet
e65cefcf6f Propagate errors rather than using return_if_err 2024-05-12 12:50:18 -04:00
Michael Goulet
db193c1c9d Make LateCtxt be a type info delegate for EUV for clippy 2024-05-12 12:11:25 -04:00
Michael Goulet
2baeb9be54 Lift TraitRef into rustc_type_ir 2024-05-10 15:44:03 -04:00
Matthias Krüger
44c29bd7d1 Rollup merge of #124957 - compiler-errors:builtin-deref, r=michaelwoerister
Make `Ty::builtin_deref` just return a `Ty`

Nowhere in the compiler are we using the mutability part of the `TyAndMut` that we used to return.
2024-05-10 16:10:47 +02:00
bors
ff931a7af8 Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124551 (Add benchmarks for `impl Debug for str`)
 - #124915 (`rustc_target` cleanups)
 - #124918 (Eliminate some `FIXME(lcnr)` comments)
 - #124927 (opt-dist: use xz2 instead of xz crate)
 - #124936 (analyse visitor: build proof tree in probe)
 - #124943 (always use `GenericArgsRef`)
 - #124955 (Use fewer origins when creating type variables.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-10 06:50:46 +00:00
Matthias Krüger
b8997e30f0 Rollup merge of #124955 - nnethercote:next_ty_var, r=lcnr
Use fewer origins when creating type variables.

To reduce lots of repetitive boilerplate code. Details in the individual commit messages.

r? ``@lcnr``
2024-05-10 07:30:22 +02:00
Michael Goulet
51145a20bf Make builtin_deref just return a Ty 2024-05-09 22:55:00 -04:00
Michael Goulet
9523b3fbf0 Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
Nicholas Nethercote
dbeae8da78 Use fewer origins when creating type variables.
`InferCtxt::next_{ty,const}_var*` all take an origin, but the
`param_def_id` is almost always `None`. This commit changes them to just
take a `Span` and build the origin within the method, and adds new
methods for the rare cases where `param_def_id` might not be `None`.
This avoids a lot of tedious origin building.

Specifically:
- next_ty_var{,_id_in_universe,_in_universe}: now take `Span` instead of
  `TypeVariableOrigin`
- next_ty_var_with_origin: added

- next_const_var{,_in_universe}: takes Span instead of ConstVariableOrigin
- next_const_var_with_origin: added

- next_region_var, next_region_var_in_universe: these are unchanged,
  still take RegionVariableOrigin

The API inconsistency (ty/const vs region) seems worth it for the
large conciseness improvements.
2024-05-10 09:47:46 +10:00
lcnr
9b4ad016ec always use GenericArgsRef 2024-05-09 19:52:02 +00:00
Matthias Krüger
eef082899d Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=Nilstrieb
Remove braces when fixing a nested use tree into a single item

[Back in 2019](https://github.com/rust-lang/rust/pull/56645) I added rustfix support for the `unused_imports` lint, to automatically remove them when running `cargo fix`. For the most part this worked great, but when removing all but one childs of a nested use tree it turned `use foo::{Unused, Used}` into `use foo::{Used}`. This is slightly annoying, because it then requires you to run `rustfmt` to get `use foo::Used`.

This PR automatically removes braces and the surrouding whitespace when all but one child of a nested use tree are unused. To get it done I had to add the span of the nested use tree to the AST, and refactor a bit the code I wrote back then.

A thing I noticed is, there doesn't seem to be any `//@ run-rustfix` test for fixing the `unused_imports` lint. I created a test in `tests/suggestions` (is that the right directory?) that for now tests just what I added in the PR. I can followup in a separate PR to add more tests for fixing `unused_lints`.

This PR is best reviewed commit-by-commit.
2024-05-08 23:33:24 +02:00
Michael Howell
afedaf6a26 Update doc comments to avoid lazy continuations 2024-05-06 16:31:23 -07:00
bors
28002514d5 Auto merge of #12742 - Alexendoo:assigning-clones-nested-late-init, r=dswij
Don't lint assigning_clones on nested late init locals

Fixes #12741

changelog: none
2024-05-04 19:36:06 +00:00
bors
3cdc951b0b Auto merge of #124401 - oli-obk:some_hir_cleanups, r=cjgillot
Some hir cleanups

It seemed odd to not put `AnonConst` in the arena, compared with the other types that we did put into an arena. This way we can also give it a `Span` without growing a lot of other HIR data structures because of the extra field.

r? compiler
2024-05-04 00:32:27 +00:00
bors
993d8ae2a7 Auto merge of #12567 - Alexendoo:format-args-storage, r=flip1995
Fix `FormatArgs` storage when `-Zthreads` > 1

Fixes #11886

The initial way I thought of was a little gross so I never opened a PR for it, I thought of a nicer way today that no longer involves any `thread_local`s or `static`s

`rustc_data_strucutres::sync::{Lrc, OnceLock}` implement `DynSend` + `DynSync` so we can pass them to the lint passes that need the storage

changelog: none

r? `@flip1995`
2024-05-03 09:21:22 +00:00
Philipp Krones
80c6f8ff7b Merge commit '20b085d500dfba5afe0869707bf357af3afe20be' into clippy-subtree-update 2024-05-02 17:26:44 +02:00
bors
c36918329f Auto merge of #12743 - CBSpeir:remove-paths-vec_resize, r=y21
Remove `dead_code` paths

The following paths are `dead_code` and can be removed:

### `clippy_utils::paths::VEC_RESIZE`
* Introduced when `vec_resize_to_zero` lint added in PR https://github.com/rust-lang/rust-clippy/pull/5637
* No longer used after commit 8acc4d2f1e
### `clippy_utils::paths::SLICE_GET`
* Introduced when `get_first` lint added in PR https://github.com/rust-lang/rust-clippy/pull/8882
* No longer used after commit a8d80d531f
### `clippy_utils::paths::STR_BYTES`
* Introduced when `bytes_count_to_len` lint added in PR https://github.com/rust-lang/rust-clippy/pull/8711
* No longer used after commit ba6a459528

When the lints were moved into the `Methods` lint pass, they switched from using paths to diagnostic items.  However, the paths were never removed.  This occurred in PR https://github.com/rust-lang/rust-clippy/pull/8957.

This relates to issue https://github.com/rust-lang/rust-clippy/issues/5393

changelog: none
2024-05-02 12:47:40 +00:00
Philipp Krones
76b95fd249
Bump Clippy version -> 0.1.80 2024-05-02 14:21:19 +02:00
Philipp Krones
e8492355a3
Merge remote-tracking branch 'upstream/master' into rustup 2024-05-02 14:21:00 +02:00
Christopher B. Speir
5e05821af3 Remove clippy_utils::paths::{SLICE_GET, STR_BYTES}
Both clippy_utils::paths::SLICE_GET and clippy_utils::paths::STR_BYTES
are dead_code and can therefore be removed.
2024-05-01 22:23:31 -05:00
Christopher B. Speir
fed9940e57 Remove clippy_utils::paths::VEC_RESIZE
This path is no longer used and can be removed.
2024-05-01 08:45:45 -05:00
Alex Macleod
c313ef51df Don't lint assigning_clones on nested late init locals 2024-05-01 12:22:50 +00:00
Alex Macleod
c187bff864 Fix FormatArgs storage when -Zthreads > 1 2024-05-01 11:35:04 +00:00
Santiago Pastorino
9276ce1cf3 Add StaticForeignItem and use it on ForeignItemKind 2024-04-29 13:15:51 -03:00
Andre Bogus
87efce4fa2 configurably allow useless_vec in tests
This adds a `àllow-useless-vec-in-test` configuration which, when set
to `true` will allow the `useless_vec` lint in `#[test]` functions and
code within `#[cfg(test)]`. It also moves a `is_in_test` helper to
`clippy_utils`.
2024-04-28 22:07:56 +02:00
bors
c6bf9548d5 Auto merge of #12624 - J-ZhengLi:issue12586, r=xFrednet
fix [`large_stack_arrays`] linting in `vec` macro

fixes: #12586

this PR also adds a wrapper function `matching_root_macro_call` to `clippy_utils::macros`, considering how often that same pattern appears in the codebase.

(I'm always very indecisive towards naming, so, if anyone have better idea of how that function should be named, feel free to suggest it)

---

changelog: fix [`large_stack_arrays`] linting in `vec` macro; add `matching_root_macro_call` to clippy_utils
2024-04-27 09:30:20 +00:00
Oli Scherer
b1a4f87257 put hir::AnonConst on the hir arena 2024-04-26 12:57:02 +00:00
bors
c642d0cab6 Auto merge of #12696 - smoelius:fix-is_test_module_or_function, r=Alexendoo
Fix `is_test_module_or_function`

The rustdoc comment for `is_test_module_or_function` states: 2795a60189/clippy_utils/src/lib.rs (L2561-L2566)

Given `item`, the function calls `is_in_test_function` with `item.hir_id()`. However, `is_in_test_function` considers only `item`'s parents, not `item` itself. This PR fixes the problem.

The `test_with_disallowed_name` test fails without the fix, but passes once applied.

changelog: none
2024-04-20 15:06:02 +00:00
Samuel Moelius
de258cc6be Fix is_test_module_or_function 2024-04-20 01:20:03 +00:00
Alex Macleod
f7aef635c1 Rework interior mutability detection 2024-04-18 17:33:39 +00:00
Philipp Krones
a5aaf33422 Merge commit 'ca3b393750ee8d870bf3215dcf6509cafa5c0445' into clippy-subtree-update 2024-04-18 17:48:52 +02:00
Philipp Krones
846f6e7e00
Merge remote-tracking branch 'upstream/master' into rustup 2024-04-18 17:29:59 +02:00