Commit graph

3680 commits

Author SHA1 Message Date
Matthias Krüger
a417366d58 Rollup merge of #119710 - Nilstrieb:let-_-=-oops, r=TaKO8Ki
Improve `let_underscore_lock`

- lint if the lock was in a nested pattern
- lint if the lock is inside a `Result<Lock, _>`

addresses https://github.com/rust-lang/rust/pull/119704#discussion_r1444044745
2024-01-22 07:56:41 +01:00
Michael Goulet
f7376a0f8c Deal with additional wrapping of async closure body in clippy 2024-01-16 17:12:10 +00:00
Nilstrieb
3b7ba1d10a Improve let_underscore_lock
- lint if the lock was in a nested pattern
- lint if the lock is inside a `Result<Lock, _>`
2024-01-12 23:18:58 +01:00
Guillaume Gomez
e9f87132a1 Rollup merge of #119819 - chenyukang:yukang-fix-118183-lint, r=davidtwco
Check rust lints when an unknown lint is detected

Fixes #118183
2024-01-12 15:16:56 +01:00
yukang
1485e5c4da check rust lints when an unknown lint is detected 2024-01-12 18:50:36 +08:00
Philipp Krones
aa220c7ee7 Merge commit '26ac6aab023393c94edf42f38f6ad31196009643' 2024-01-11 17:27:03 +01:00
Matthias Krüger
b418117277 Rollup merge of #119151 - Jules-Bertholet:no-foreign-doc-hidden-suggest, r=davidtwco
Hide foreign `#[doc(hidden)]` paths in import suggestions

Stops the compiler from suggesting to import foreign `#[doc(hidden)]` paths.

```@rustbot``` label A-suggestion-diagnostics
2024-01-05 20:39:50 +01:00
Michael Goulet
3a683f696d Rollup merge of #119148 - estebank:bare-traits, r=davidtwco
Tweak suggestions for bare trait used as a type

```
error[E0782]: trait objects must include the `dyn` keyword
  --> $DIR/not-on-bare-trait-2021.rs:11:11
   |
LL | fn bar(x: Foo) -> Foo {
   |           ^^^
   |
help: use a generic type parameter, constrained by the trait `Foo`
   |
LL | fn bar<T: Foo>(x: T) -> Foo {
   |       ++++++++    ~
help: you can also use `impl Foo`, but users won't be able to specify the type paramer when calling the `fn`, having to rely exclusively on type inference
   |
LL | fn bar(x: impl Foo) -> Foo {
   |           ++++
help: alternatively, use a trait object to accept any type that implements `Foo`, accessing its methods at runtime using dynamic dispatch
   |
LL | fn bar(x: &dyn Foo) -> Foo {
   |           ++++

error[E0782]: trait objects must include the `dyn` keyword
  --> $DIR/not-on-bare-trait-2021.rs:11:19
   |
LL | fn bar(x: Foo) -> Foo {
   |                   ^^^
   |
help: use `impl Foo` to return an opaque type, as long as you return a single underlying type
   |
LL | fn bar(x: Foo) -> impl Foo {
   |                   ++++
help: alternatively, you can return an owned trait object
   |
LL | fn bar(x: Foo) -> Box<dyn Foo> {
   |                   +++++++    +
```

Fix #119525:

```

error[E0038]: the trait `Ord` cannot be made into an object
  --> $DIR/bare-trait-dont-suggest-dyn.rs:3:33
   |
LL | fn ord_prefer_dot(s: String) -> Ord {
   |                                 ^^^ `Ord` cannot be made into an object
   |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
  --> $SRC_DIR/core/src/cmp.rs:LL:COL
   |
   = note: the trait cannot be made into an object because it uses `Self` as a type parameter
  ::: $SRC_DIR/core/src/cmp.rs:LL:COL
   |
   = note: the trait cannot be made into an object because it uses `Self` as a type parameter
help: consider using an opaque type instead
   |
LL | fn ord_prefer_dot(s: String) -> impl Ord {
   |                                 ++++
```
2024-01-05 10:57:20 -05:00
Esteban Küber
ca83a98e66 Track HirId instead of Span in ObligationCauseCode::SizedArgumentType
This gets us more accurate suggestions.
2024-01-03 18:59:42 +00:00
Jake Goulding
04ebf3c8c9 Remove #[allow(unused_tuple_struct_fields)] from Clippy tests 2024-01-02 15:34:37 -05:00
Philipp Krones
15b1edb209 Merge commit 'ac4c2094a6030530661bee3876e0228ddfeb6b8b' into clippy-subtree-sync 2023-12-28 19:33:07 +01:00
Michael Goulet
2230add36e Rollup merge of #119240 - compiler-errors:lang-item-more, r=petrochenkov
Make some non-diagnostic-affecting `QPath::LangItem` into regular `QPath`s

The rest of 'em affect diagnostics, so leave them alone... for now.

cc #115178
2023-12-26 13:29:13 -05:00
Michael Goulet
90a59d4990 Make some non-diagnostic-affecting QPath::LangItem into regular qpaths 2023-12-26 04:07:38 +00:00
Michael Goulet
e0097f5323 Fix clippy's usage of Body's coroutine_kind
Also fixes a bug where we weren't peeling blocks from async bodies
2023-12-25 21:13:41 +00:00
Jules Bertholet
4ab8cdd5b9 Hide foreign #[doc(hidden)] paths in import suggestions 2023-12-20 00:19:45 -05:00
Philipp Krones
3596d44988 Merge commit 'a859e5cc1ce100df22346a1005da30532d04de59' into clippyup 2023-12-16 14:12:50 +01:00
Urgau
a2ea760b88 Drop clippy::vtable_address_comparisons 2023-12-06 09:03:48 +01:00
bors
c586717cfb Auto merge of #118507 - flip1995:clippy-subtree-sync, r=matthiaskrgr
Clippy subtree sync

r? `@Manishearth`
2023-12-02 11:41:55 +00:00
bors
30f8e871a3 Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errors
Cleanup error handlers

Mostly by making function naming more consistent. More to do after this, but this is enough for one PR.

r? compiler-errors
2023-12-02 02:48:34 +00:00
Nicholas Nethercote
8dab7387f2 Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug.
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug`
follows the pattern used everywhere else: `span_err`, `span_warning`,
etc.
2023-12-02 09:01:19 +11:00
Philipp Krones
c9a43b18f1 Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-subtree-sync 2023-12-01 18:21:58 +01:00
bors
3a760909fa Auto merge of #117472 - jmillikin:stable-c-str-literals, r=Nilstrieb
Stabilize C string literals

RFC: https://rust-lang.github.io/rfcs/3348-c-str-literal.html

Tracking issue: https://github.com/rust-lang/rust/issues/105723

Documentation PR (reference manual): https://github.com/rust-lang/reference/pull/1423

# Stabilization report

Stabilizes C string and raw C string literals (`c"..."` and `cr#"..."#`), which are expressions of type [`&CStr`](https://doc.rust-lang.org/stable/core/ffi/struct.CStr.html). Both new literals require Rust edition 2021 or later.

```rust
const HELLO: &core::ffi::CStr = c"Hello, world!";
```

C strings may contain any byte other than `NUL` (`b'\x00'`), and their in-memory representation is guaranteed to end with `NUL`.

## Implementation

Originally implemented by PR https://github.com/rust-lang/rust/pull/108801, which was reverted due to unintentional changes to lexer behavior in Rust editions < 2021.

The current implementation landed in PR https://github.com/rust-lang/rust/pull/113476, which restricts C string literals to Rust edition >= 2021.

## Resolutions to open questions from the RFC

* Adding C character literals (`c'.'`) of type `c_char` is not part of this feature.
  * Support for `c"..."` literals does not prevent `c'.'` literals from being added in the future.
* C string literals should not be blocked on making `&CStr` a thin pointer.
  * It's possible to declare constant expressions of type `&'static CStr` in stable Rust (as of v1.59), so C string literals are not adding additional coupling on the internal representation of `CStr`.
* The unstable `concat_bytes!` macro should not accept `c"..."` literals.
  * C strings have two equally valid `&[u8]` representations (with or without terminal `NUL`), so allowing them to be used in `concat_bytes!` would be ambiguous.
* Adding a type to represent C strings containing valid UTF-8 is not part of this feature.
  * Support for a hypothetical `&Utf8CStr` may be explored in the future, should such a type be added to Rust.
2023-12-01 13:33:55 +00:00
Nilstrieb
191e1bc299 Manual find replace updates 2023-11-24 21:04:51 +01:00
Nilstrieb
c2c73189c8 Bless clippy tests
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Nicholas Nethercote
aec4e8115b Move lint_store from GlobalCtxt to Session.
This was made possible by the removal of plugin support, which
simplified lint store creation.

This simplifies the places in rustc and rustdoc that call
`describe_lints`, which are early on. The lint store is now built before
those places, so they don't have to create their own lint store for
temporary use, they can just use the main one.
2023-11-17 10:39:18 +11:00
Philipp Krones
6246f0446a Merge commit 'edb720b199083f4107b858a8761648065bf38d86' into clippyup 2023-11-16 19:13:24 +01:00
Dinu Blanovschi
67cc4b0cad fix clippy author and failing test 2023-11-04 21:43:18 +01:00
Nadrieril
17c7d21650 Warn when lint level is set on a match arm 2023-11-04 14:44:00 +01:00
Philipp Krones
77c1e3aaa1 Merge commit '09ac14c901abc43bd0d617ae4a44e8a4fed98d9c' into clippyup 2023-11-02 17:35:56 +01:00
John Millikin
e3a1555648 Stabilize C string literals 2023-11-01 09:16:34 +09:00
Oli Scherer
ffc741965e Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
bors
cd6ec97f0d Auto merge of #116773 - dtolnay:validatestable, r=compiler-errors
Validate `feature` and `since` values inside `#[stable(…)]`

Previously the string passed to `#[unstable(feature = "...")]` would be validated as an identifier, but not `#[stable(feature = "...")]`. In the standard library there were `stable` attributes containing the empty string, and kebab-case string, neither of which should be allowed.

Pre-existing validation of `unstable`:

```rust
// src/lib.rs

#![allow(internal_features)]
#![feature(staged_api)]
#![unstable(feature = "kebab-case", issue = "none")]

#[unstable(feature = "kebab-case", issue = "none")]
pub struct Struct;
```

```console
error[E0546]: 'feature' is not an identifier
 --> src/lib.rs:5:1
  |
5 | #![unstable(feature = "kebab-case", issue = "none")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

For an `unstable` attribute, the need for an identifier is obvious because the downstream code needs to write a `#![feature(...)]` attribute containing that identifier. `#![feature(kebab-case)]` is not valid syntax and `#![feature(kebab_case)]` would not work if that is not the name of the feature.

Having a valid identifier even in `stable` is less essential but still useful because it allows for informative diagnostic about the stabilization of a feature. Compare:

```rust
// src/lib.rs

#![allow(internal_features)]
#![feature(staged_api)]
#![stable(feature = "kebab-case", since = "1.0.0")]

#[stable(feature = "kebab-case", since = "1.0.0")]
pub struct Struct;
```

```rust
// src/main.rs

#![feature(kebab_case)]

use repro::Struct;

fn main() {}
```

```console
error[E0635]: unknown feature `kebab_case`
 --> src/main.rs:3:12
  |
3 | #![feature(kebab_case)]
  |            ^^^^^^^^^^
```

vs the situation if we correctly use `feature = "snake_case"` and `#![feature(snake_case)]`, as enforced by this PR:

```console
warning: the feature `snake_case` has been stable since 1.0.0 and no longer requires an attribute to enable
 --> src/main.rs:3:12
  |
3 | #![feature(snake_case)]
  |            ^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default
```
2023-10-24 15:06:20 +00:00
bors
330d7fafb8 Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkov
report `unused_import` for empty reexports even it is pub

Fixes #116032

An easy fix. r? `@petrochenkov`

(Discovered this issue while reviewing #115993.)
2023-10-23 20:24:09 +00:00
David Tolnay
7ade24e824 Fix stable feature names in tests 2023-10-23 13:03:11 -07:00
bors
350a6827a8 Auto merge of #116849 - oli-obk:error_shenanigans, r=cjgillot
Avoid a `track_errors` by bubbling up most errors from `check_well_formed`

I believe `track_errors` is mostly papering over issues that a sufficiently convoluted query graph can hit. I made this change, while the actual change I want to do is to stop bailing out early on errors, and instead use this new `ErrorGuaranteed` to invoke `check_well_formed` for individual items before doing all the `typeck` logic on them.

This works towards resolving https://github.com/rust-lang/rust/issues/97477 and various other ICEs, as well as allowing us to use parallel rustc more (which is currently rather limited/bottlenecked due to the very sequential nature in which we do `rustc_hir_analysis::check_crate`)

cc `@SparrowLii` `@Zoxc` for the new `try_par_for_each_in` function
2023-10-23 09:59:40 +00:00
bohan
87d0ace9ac use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
Philipp Krones
8e7d1678c4 Merge commit '2b030eb03d9e5837440b1ee0b98c50b97c0c5889' into clippyup 2023-10-21 14:16:11 +02:00
Oli Scherer
d9259fdedd s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
4fc503ee37 Avoid a track_errors by bubbling up most errors from check_well_formed 2023-10-20 08:46:27 +00:00
Esteban Küber
a07c032e96 Tweak wording of type errors involving type params
Fix #78206.
2023-10-18 23:53:18 +00:00
Michael Goulet
1ffd09af29 Stabilize AFIT and RPITIT 2023-10-13 21:01:36 +00:00
Michael Goulet
70b8d15a85 Extend impl's def_span to include where clauses 2023-10-09 11:47:02 +00:00
Philipp Krones
8ebed4cc1a Merge commit 'b105fb4c39bc1a010807a6c076193cef8d93c109' into clippyup 2023-10-06 17:35:45 +02:00
Jason Newcomb
9de3e6c928 Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
Michael Goulet
c5c6d703de Point to closure return instead of output if defaulted 2023-10-04 21:09:54 +00:00
Michael Goulet
56794fa5f1 Fix clippy 2023-10-04 21:09:54 +00:00
Michael Goulet
2c525fd758 Point to full async fn for future 2023-10-03 02:25:32 +00:00
bors
3169423ce9 Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum
Partially outline code inside the panic! macro

This outlines code inside the panic! macro in some cases. This is split out from https://github.com/rust-lang/rust/pull/115562 to exclude changes to rustc.
2023-10-01 05:56:47 +00:00
Philipp Krones
772296c50e Merge commit '7671c283a50b5d1168841f3014b14000f01dd204' into clippyup 2023-09-25 11:28:58 +02:00
Camille GILLOT
19e160fe2f Bless clippy. 2023-09-23 13:47:30 +00:00
Ralf Jung
1fac304bf5 adjust how closure/generator types and rvalues are printed 2023-09-21 22:20:58 +02:00
bors
e9dc753b7b Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
move required_consts check to general post-mono-check function

This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants.

Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized.

I didn't expect this to change diagnostics, but it's just cycle errors that change.

r? `@oli-obk`
2023-09-18 19:41:21 +00:00
Dylan DPC
66aa7f7cac Rollup merge of #115477 - kellerkindt:stabilized_int_impl, r=dtolnay
Stabilize the `Saturating` type

Closes #87920
Closes #92354

Stabilization report https://github.com/rust-lang/rust/issues/87920#issuecomment-1652346124
FCP https://github.com/rust-lang/rust/issues/87920#issuecomment-1676438885
2023-09-17 11:23:24 +00:00
Ralf Jung
3226e4b010 don't point at const usage site for resolution-time errors
also share the code that emits the actual error
2023-09-14 22:34:05 +02:00
Alex Macleod
da4244e79c Ignore #[doc(hidden)] functions in clippy doc lints 2023-09-14 17:52:36 +00:00
Philipp Krones
471469d30f Merge commit '98363cbf6a7c3f8b571a7d92a3c645bb4376e4a6' into clippyup 2023-09-12 18:44:06 +02:00
bors
b643f20f46 Auto merge of #115689 - Alexendoo:clippy-doc-comments, r=notriddle,Manishearth,flip1995
Reuse rustdoc's doc comment handling in Clippy

Moves `source_span_for_markdown_range` and `span_of_attrs` (renamed to `span_of_fragments`) to `rustc_resolve::rustdoc` so it can be used in Clippy

Fixes https://github.com/rust-lang/rust-clippy/issues/10277
Fixes https://github.com/rust-lang/rust-clippy/issues/5593
Fixes https://github.com/rust-lang/rust-clippy/issues/10263
Fixes https://github.com/rust-lang/rust-clippy/issues/2581
2023-09-12 01:45:24 +00:00
Alex Macleod
54f3ddb84a Call LateLintPass::check_attribute from with_lint_attrs 2023-09-10 18:56:39 +00:00
Alex Macleod
e88a556124 Reuse rustdoc's doc comment handling in Clippy 2023-09-08 23:42:57 +00:00
John Kåre Alsaker
b5941a2fd5 Partially outline code inside the panic! macro 2023-09-08 14:05:57 +02:00
Urgau
a86e758228 Adjust clippy tests with new rustc help suggestion for lints 2023-09-04 14:22:02 +02:00
Michael Watzko
1c27ba931b Stabilize the Saturating type (saturating_int_impl, gh-87920)
Also stabilizes saturating_int_assign_impl, gh-92354.

And also make pub fns const where the underlying saturating_*
fns became const in the meantime since the Saturating type was
created.
2023-09-03 01:22:46 +02:00
Caio
b3136a874d [clippy] Use symbols intended for arithmetic_side_effects 2023-09-01 10:28:55 +02:00
Oli Scherer
6a876f236c Bump ui_test 2023-08-29 13:47:06 +00:00
Philipp Krones
cc61aeea54 Merge commit '080b587854a73f2a8cbaecff1884860a78e2ff37' into clippyup 2023-08-24 21:32:12 +02:00
Esteban Küber
32eecd4b88 Fix clippy lint for identical if/else contraining ? expressions
Follow up to #114819.
2023-08-23 00:58:09 +00:00
bors
5638860ff8 Auto merge of #11314 - GuillaumeGomez:needless_ref_mut_async_block, r=Centri3
Correctly handle async blocks for NEEDLESS_PASS_BY_REF_MUT

Fixes https://github.com/rust-lang/rust-clippy/issues/11299.

The problem was that the `async block`s are popping a closure which we didn't go into, making it miss the mutable access to the variables.

cc `@Centri3`

changelog: none
2023-08-17 18:06:36 +02:00
bors
d068043891 Auto merge of #11070 - y21:issue11065, r=flip1995
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro

Fixes #11065 (which is actually two issues: an ICE and a false positive)

It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes https://github.com/rust-lang/rust-clippy/issues/11065#issuecomment-1616836099).
It *also* makes sure that the expression is not part of a macro call (fixes https://github.com/rust-lang/rust-clippy/issues/11065#issuecomment-1616919639). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore)

changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item
changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP)

r? `@llogiq` (reviewed #10814, which introduced these issues)
2023-08-17 18:06:36 +02:00
Esteban Küber
d0a26f1c9c bless clippy test 2023-08-14 22:00:46 +00:00
Philipp Krones
f730a2655a Merge commit '1e8fdf492808a25d78a97e1242b835ace9924e4d' into clippyup 2023-08-11 14:05:13 +02:00
Catherine Flores
1ec0501bca Revert "New lint [filter_map_bool_then]"
This reverts commits 978b1daf99 and 3235d9d612.
2023-08-10 17:28:01 -05:00
bors
d412b91fd1 Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obk
Add `internal_features` lint

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

Also requires some more test blessing for codegen tests etc

`@jyn514` had the idea of just `allow`ing the lint by default in the test suite. I'm not sure whether this is a good idea, but it's definitely one worth considering. Additional input encouraged.
2023-08-03 22:58:02 +00:00
Nilstrieb
85b5e98ea2 Add internal_features lint
It lints against features that are inteded to be internal to the
compiler and standard library. Implements MCP #596.

We allow `internal_features` in the standard library and compiler as those
use many features and this _is_ the standard library from the "internal to the compiler and
standard library" after all.

Marking some features as internal wasn't exactly the most scientific approach, I just marked some
mostly obvious features. While there is a categorization in the macro,
it's not very well upheld (should probably be fixed in another PR).

We always pass `-Ainternal_features` in the testsuite
About 400 UI tests and several other tests use internal features.
Instead of throwing the attribute on each one, just always allow them.
There's nothing wrong with testing internal features^^
2023-08-03 14:50:50 +02:00
Urgau
7ef1a54ffe Rename incorrect_fn_null_checks to useless_ptr_null_checks (clippy side) 2023-08-01 20:04:01 +02:00
Philipp Krones
b0e64a9c09 Merge commit '5436dba826191964ac1d0dab534b7eb6d4c878f6' into clippyup 2023-07-31 23:53:53 +02:00
Matthias Krüger
f54263af58 Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee
Mark `map_or` as `#[must_use]`

I don't know what else to say.

r? libs
2023-07-30 14:25:08 +02:00
Maybe Waffle
0c93e30956 Mark map_or as #[must_use] 2023-07-30 10:22:23 +00:00
bors
436060f637 Auto merge of #113422 - Urgau:cast_ref_to_mut-pre-beta, r=Nilstrieb
Rename and allow `cast_ref_to_mut` lint

This PR is a small subset of https://github.com/rust-lang/rust/pull/112431, that is the renaming of the lint (`cast_ref_to_mut` -> `invalid_reference_casting`).

BUT also temporarily change the default level of the lint from deny-by-default to allow-by-default until https://github.com/rust-lang/rust/pull/112431 is merged.

r? `@Nilstrieb`
2023-07-29 07:48:44 +00:00
bors
0c0026e380 Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, r=compiler-errors
make `noop_method_call` warn by default

r? `@compiler-errors`
2023-07-29 01:40:50 +00:00
bors
e97a770bf1 Auto merge of #114134 - fee1-dead-contrib:rm-constness-from-param-env, r=oli-obk
Remove `constness` from `ParamEnv`

This should be replaced by keyword generics/effects. cc #110395

r? `@oli-obk`
2023-07-28 08:53:12 +00:00
Deadbeef
39fb315396 bless clippy 2023-07-27 17:56:25 +00:00
Trevor Gross
6ca6be6f2b Unite bless environment variables under RUSTC_BLESS
Currently, Clippy, Miri, Rustfmt, and rustc all use an environment variable to
indicate that output should be blessed, but they use different variable names.
In order to improve consistency, this patch applies the following changes:

- Emit `RUSTC_BLESS` within `prepare_cargo_test` so it is always
  available
- Change usage of `MIRI_BLESS` in the Miri subtree to use `RUSTC_BLESS`
- Change usage of `BLESS` in the Clippy subtree to `RUSTC_BLESS`
- Change usage of `BLESS` in the Rustfmt subtree to `RUSTC_BLESS`
- Adjust the blessable test in `rustc_errors` to use this same
  convention
- Update documentation where applicable

Any tools that uses `RUSTC_BLESS` should check that it is set to any value
other than `"0"`.
2023-07-26 16:54:02 -04:00
Ralf Jung
2b16c37b65 bless more 2023-07-25 14:30:58 +02:00
Deadbeef
1662fdb2d0 fix 2023-07-23 09:58:31 +00:00
Philipp Krones
d6d530fd0b Merge commit 'd9c24d1b1ee61f276e550b967409c9f155eac4e3' into clippyup 2023-07-17 10:22:32 +02:00
Mahdi Dibaiee
fdb2e363d3 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Urgau
50da77521e Rename cast_ref_to_mut to invalid_reference_casting (clippy side) 2023-07-13 23:01:24 +02:00
Eric Huss
660ef4ffe8 Ignore flaky clippy tests. 2023-07-12 06:59:57 -07:00
bors
a8939e5eae Auto merge of #111717 - Urgau:uplift_fn_null_check, r=oli-obk
Uplift `clippy::fn_null_check` lint

This PR aims at uplifting the `clippy::fn_null_check` lint into rustc.

## `incorrect_fn_null_checks`

(warn-by-default)

The `incorrect_fn_null_checks` lint checks for expression that checks if a function pointer is null.

### Example

```rust
let fn_ptr: fn() = /* somehow obtained nullable function pointer */

if (fn_ptr as *const ()).is_null() { /* ... */ }
```

### Explanation

Function pointers are assumed to be non-null, checking for their nullity is incorrect.

-----

Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler
2023-07-11 09:34:48 +00:00
Urgau
103949b241 Drop uplifted clippy::fn_null_check 2023-07-10 18:12:41 +02:00
Nilstrieb
31d50a6e21 Delete to_string_in_format_args_incremental.rs
It fails CI and passes locally. It passes random directores in
`-Cincremental` so maybe something's up. It shouldn't block us here.
2023-07-08 17:17:40 +02:00
Alex Macleod
87373d7f52 Fix failing clippy tests
Comments out the C string literals due to https://github.com/rust-lang/rust/pull/113334

Fixes https://github.com/rust-lang/rust-clippy/issues/11121
2023-07-07 18:19:08 +00:00
Philipp Krones
4aa4fecf89 Fix compile-test tests to work with the new ui_test crate 2023-07-02 15:07:39 +02:00
Philipp Krones
cb3ecf7b79 Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup 2023-07-02 14:59:02 +02:00
Oli Scherer
7bd8ab77e5 Make simd_shuffle_indices use valtrees 2023-06-26 09:34:52 +00:00
yukang
23d7a07e86 Do not offer any of the suggestions in emit_coerce_suggestions for expr from destructuring assignment desugaring 2023-06-25 09:26:17 +08:00
bors
70c2d0cfe5 Auto merge of #106450 - albertlarsan68:fix-arc-ptr-eq, r=Amanieu
Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata

FCP completed in https://github.com/rust-lang/rust/issues/103763#issuecomment-1362267967

Closes #103763
2023-06-21 05:13:39 +00:00
Michael Goulet
f711c7e1f6 Treat TAIT equation as always ambiguous in coherence 2023-06-18 22:52:30 +00:00
Oli Scherer
5777494f99 Add AliasKind::Weak for type aliases.
Only use it when the type alias contains an opaque type.

Also does wf-checking on such type aliases.
2023-06-16 19:39:48 +00:00
许杰友 Jieyou Xu (Joe)
a35c78fa70 Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
Urgau
edb3266b91 Drop uplifted clippy:cmp_nan 2023-06-10 11:13:01 +02:00
Urgau
f47e9156a4 Drop uplifted clippy::undropped_manually_drops 2023-06-08 11:41:34 +02:00
bors
6a5e3de812 Auto merge of #112203 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2023-06-02 10:55:54 +00:00
Philipp Krones
e6dc0efc00 Merge commit '30448e8cf98d4754350db0c959644564f317bc0f' into clippyup 2023-06-02 11:41:57 +02:00
bors
427a4538db Auto merge of #112198 - compiler-errors:rollup-o2xe4of, r=compiler-errors
Rollup of 7 pull requests

Successful merges:

 - #111670 (Require that const param tys implement `ConstParamTy`)
 - #111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…)
 - #112030 (Migrate `item_trait_alias` to Askama)
 - #112150 (Support 128-bit atomics on all x86_64 Apple targets)
 - #112174 (Fix broken link)
 - #112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.)
 - #112193 (Check tuple elements are `Sized` in `offset_of`)

Failed merges:

 - #112071 (Group rfcs tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-02 07:57:21 +00:00
Michael Goulet
b4f074c588 Implement custom diagnostic for ConstParamTy 2023-06-01 18:21:42 +00:00
Deadbeef
ec2c6155aa Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
Urgau
1a5db18b11 Drop uplifted clippy::cast_ref_to_mut 2023-05-31 13:42:53 +02:00
Urgau
5a2094319b Drop uplifted clippy::invalid_utf8_in_unchecked 2023-05-27 00:16:47 +02:00
Urgau
915ff71b7c Rename forget_ref lint to forgetting_references 2023-05-21 14:28:09 +02:00
Urgau
fdbfe0e249 Rename drop_ref lint to dropping_references 2023-05-21 14:16:41 +02:00
Urgau
234f2b67cb Rename forget_copy lint to forgetting_copy_types 2023-05-21 14:09:03 +02:00
Urgau
9b97ae98f8 Rename drop_copy lint to dropping_copy_types 2023-05-21 13:37:32 +02:00
Philipp Krones
b76b0aeb63 Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup 2023-05-20 15:39:26 +02:00
León Orell Valerian Liehr
0eb364b8d6 Exclude inherent projections from some alias ty matches 2023-05-17 23:53:58 +02:00
David Tolnay
fcb132765c Exposes false negative in clippy's diverging_sub_expression 2023-05-14 07:58:45 -07:00
Urgau
35e5aac5c8 Drop uplifted clippy::forget_copy 2023-05-10 19:36:02 +02:00
Urgau
22688fc91f Drop uplifted clippy::forget_ref 2023-05-10 19:36:01 +02:00
Urgau
551f6e6154 Drop uplifted clippy::drop_copy 2023-05-10 19:36:01 +02:00
Urgau
6af0359f2a Drop uplifted clippy::drop_ref 2023-05-10 19:36:01 +02:00
Philipp Krones
7e9abb311d Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup 2023-05-05 17:45:49 +02:00
Dylan DPC
eac589b4e4 Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errors
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`

Split from #109842.

r? ``@compiler-errors``
2023-05-02 11:44:52 +05:30
Deadbeef
81a614145f uplift clippy::clone_double_ref as suspicious_double_ref_op 2023-04-28 17:24:48 +00:00
Michael Goulet
83504fa763 Make clippy happy 2023-04-27 17:18:12 +00:00
Albert Larsan
9a61550e78 Make {Arc,Rc,Weak}::ptr_eq ignore pointer metadata 2023-04-26 15:27:32 +00:00
Philipp Krones
a1b75c5108 Merge commit 'a3ed905928a03b6e433d0b429190bf3a847128b3' into clippyup 2023-04-23 13:28:56 +02:00
Camille GILLOT
cb3e0fbb59 Evaluate place expression in PlaceMention. 2023-04-21 21:34:59 +00:00
Matthias Krüger
1dfc231b10 clippy: add test for https://github.com/rust-lang/rust-clippy/issues/10645 2023-04-18 18:46:41 +00:00
bors
d61570ceb6 Auto merge of #110160 - petrochenkov:notagain2, r=cjgillot
resolve: Pre-compute non-reexport module children

Instead of repeating the same logic by walking HIR during metadata encoding.

The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list. They can be encoded separately if this need ever arises.

`module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-14 01:14:36 +00:00
Esteban Küber
4680aa2fd0 Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
Esteban Küber
7a0fb902bc Tweak output for 'add line' suggestion 2023-04-12 22:50:10 +00:00
Vadim Petrochenkov
5989400e2e resolve: Pre-compute non-reexport module children
Instead of repeating the same logic by walking HIR during metadata encoding.

The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list.
They can be encoded separately if this need ever arises.

`module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-12 15:22:03 +03:00
Philipp Krones
6b95029f17 Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup 2023-04-11 15:31:08 +02:00
Trevor Gross
4cf5bdc60c Stabilize a portion of 'once_cell'
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29 18:04:44 -04:00
Jamen Marz
28b80059ed Add notes to non-structural const in pattern error message 2023-03-27 11:08:11 -04:00
Philipp Krones
8df896c076 Merge commit 'd5e2a7aca55ed49fc943b7a07a8eba05ab5a0079' into clippyup 2023-03-24 14:26:19 +01:00
bors
491f63214a Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors
Remove `identity_future` indirection

This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation.

Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14 10:12:58 +00:00
bors
ff23e48c30 Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31
Remove `box_syntax`

r? `@Nilstrieb`

This removes the feature `box_syntax`, which allows the use of `box <expr>` to create a Box, and finalises removing use of the feature from the compiler. `box_patterns` (allowing the use of `box <pat>` in a pattern) is unaffected.
It also removes `ast::ExprKind::Box` - the only way to create a 'box' expression now is with the rustc-internal `#[rustc_box]` attribute.
As a temporary measure to help users move away, `box <expr>` now parses the inner expression, and emits a `MachineApplicable` lint to replace it with `Box::new`

Closes #49733
2023-03-13 10:41:50 +00:00
bors
e07c6b4899 Auto merge of #108872 - cjgillot:simp-const-prop, r=oli-obk
Strengthen state tracking in const-prop

Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization.

Behaviour changes:
- const-prop opt does not give a span to propagated values. This was useless as that span's primary purpose is to diagnose evaluation failure in codegen.
- we remove the `OnlyPropagateInto` mode. It was only used for function arguments, which are better modeled by a write before entry.
- the tracking of assignments and discriminants make clearer that we do nothing in `NoPropagation` mode or on indirect places.
2023-03-12 23:27:52 +00:00
clubby789
213a22efb9 Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
Philipp Krones
cf8a67d9ad Merge commit '3c06e0b1ce003912f8fe0536d3a7fe22558e38cf' into clippyup 2023-03-10 10:53:50 +01:00
Camille GILLOT
e66e918bd3 Fortify clippy tests. 2023-03-08 14:40:38 +00:00
Arpad Borsos
90afb207eb Remove identity_future indirection
This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]` annotation.
2023-03-08 15:37:14 +01:00
Pietro Albini
aff9b72375 move clippy tests back to their intended directory 2023-03-08 14:17:16 +01:00
Alex Macleod
64b54ef950 Fix array-size-threshold config deserialization error 2023-03-02 21:42:11 +01:00
Jason Newcomb
0413fb35ba Merge commit '149392b0baa4730c68f3c3eadf5c6ed7b16b85a4' into clippyup 2023-02-25 19:28:50 -05:00
Michael Howell
d254516be1 clippy: update clippy to use new TyCtxt::def_descr 2023-02-22 08:40:47 -07:00
Philipp Krones
e7fe1f9c14 Merge commit '0f7558148c22e53cd4608773b56cdfa50dcdeac3' into clippyup 2023-02-10 14:01:19 +01:00
Esteban Küber
821199c885 Modify primary span label for E0308
The previous output was unintuitive to users.
2023-01-30 20:12:19 +00:00
Philipp Krones
5c7a65251a Merge commit '1480cea393d0cee195e59949eabdfbcf1230f7f9' into clippyup 2023-01-27 21:09:08 +01:00