Commit graph

19882 commits

Author SHA1 Message Date
schvv31n
3629372723 Lint on closure calls, suppress on callable constants calls 2024-05-20 08:05:49 +01:00
bors
298f38c06e Auto merge of #125294 - matthiaskrgr:rollup-w42c829, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #124948 (chore: Remove repeated words (extension of #124924))
 - #124992 (Add example to IsTerminal::is_terminal)
 - #125279 (make `Debug` impl for `Term` simpler)
 - #125286 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-19 21:30:43 +00:00
Matthias Krüger
647f222885 Rollup merge of #124948 - blyxyas:remove-repeated-words, r=compiler-errors
chore: Remove repeated words (extension of #124924)

When I saw #124924 I thought "Hey, I'm sure that there are far more than just two typos of this nature in the codebase". So here's some more typo-fixing.

Some found with regex, some found with a spellchecker. Every single one manually reviewed by me (along with hundreds of false negatives by the tools)
2024-05-19 22:50:55 +02:00
schvv31n
9d311b5c2b initial fix 2024-05-19 21:41:13 +01: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
0b1bf37722 Auto merge of #12818 - notriddle:master, r=y21
doc_lazy_continuation: do not warn on End events

```
changelog: none
```

This avoids event spans that would otherwise cause crashes, since an
End's span covers the range of the tag (which will be earlier than the
line break within the tag).
2024-05-18 23:46:57 +00:00
Michael Howell
b5cf8b8277 doc_lazy_continuation: do not warn on End events
This avoids event spans that would otherwise cause crashes, since an
End's span covers the range of the tag (which will be earlier than the
line break within the tag).
2024-05-18 16:19:41 -07: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
blyxyas
ae547e3000 Fix typos (taking into account review comments) 2024-05-18 18:12:18 +02: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
bors
680256f3ce Auto merge of #12813 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: None
2024-05-16 21:28:33 +00:00
Philipp Krones
9f6280b1e7
Bump nightly version -> 2024-05-16 2024-05-16 14:21:11 -07:00
Philipp Krones
c200dad300
Merge remote-tracking branch 'upstream/master' into rustup 2024-05-16 14:20:56 -07:00
bors
5459429f92 Auto merge of #12803 - wutchzone:panic-in-tests, r=y21
Add configuration option for ignoring `panic!()` in tests

```
changelog: [`panic`]: Now can be disabled in tests with the `allow-panic-in-tests` option
```

I often find myself using `panic!(…)` in tests a lot, where I often do something like:

```rust
match enam {
  Enam::A => …,
  Enam::B => …,
  _ => panic!("This should not happen at all."),
}
```
I think this patch should go nicely with already existing `allow-unwrap-in-tests` and `allow-expect-in-tests`.
2024-05-16 21:13:34 +00:00
bors
6c8ff3f894 Auto merge of #12812 - Alexendoo:driver-integration, r=flip1995
Manually set library paths in .github/driver.sh

Fixes https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Windows.20CI.20failing

Rustup 1.27.1 no longer adds `[SYSROOT]/bin` to `PATH` by default - https://github.com/rust-lang/rustup/issues/3825. This is fine for the packaged binaries since windows loads `dll`s from the folder the executable is in, but our built one is in a different folder

There's an environment variable to get the old behaviour back, but as it's deprecated and not much code I think returning to setting it manually is fine

changelog: none
2024-05-16 20:54:33 +00:00
Alex Macleod
821dc871af Manually set library paths in .github/driver.sh 2024-05-16 21:11:58 +01: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
Jakob Schwarz
1b6c91628e
add test for #[expect]ing unsafe_derive_deserialize
Adding `#![feature(lint_reasons)]` to the top of the file
also changed the line numbers in the expected error output.
2024-05-16 19:54:43 +02:00
Jakob Schwarz
fc2f7035c6
fulfill expectations in check_unsafe_derive_deserialize
The utility function `clippy_utils::fulfill_or_allowed` is not used because
using it would require to move the check for allowed after the check
iterating over all inherent impls of the type, doing possibly
unnecessary work.
Instead, `is_lint_allowed` is called as before, but additionally, once
certain that the lint should be emitted, `span_lint_hir_and_then` is called
instead of `span_lint_and_help` to also fulfill expectations.

fixes: #12802

changelog: fulfill expectations in `check_unsafe_derive_deserialize`
2024-05-16 19:54:42 +02:00
Daniel Sedlak
c342a61564 Add configuration option for ignoring panic!() in tests 2024-05-16 05:45:56 +00: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
bors
e669d97494 Auto merge of #12706 - pacak:less-aggressive-needless-borrows, r=dswij
less aggressive needless_borrows_for_generic_args

Current implementation looks for significant drops, that can change the behavior, but that's not enough - value might not have a `Drop` itself but one of its children might have it.

A good example is passing a reference to `PathBuf` to `std::fs::File::open`. There's no benefits to pass `PathBuf` by value, but since `clippy` can't see `Drop` on `Vec` several layers down it complains forcing pass by value and making it impossible to use the same name later.

New implementation only looks at copy values or values created in place     so existing variable will never be moved but things that take a string reference created and value is created inplace `&"".to_owned()` will make it to suggest to use `"".to_owned()` still.

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

changelog: [`needless_borrows_for_generic_args`]: avoid moving variables
2024-05-15 15:51:27 +00:00
bors
a9b5c8ca81 Auto merge of #12790 - c410-f3r:blah, r=dswij
Fix #12760

Fix #12760

```
changelog: [missing_panics_doc]: Ignore panics in compile time
```
2024-05-15 15:40:36 +00:00
bors
a7f326574c Auto merge of #12779 - de-vri-es:move-assigng-clones-to-pedantic, r=y21
`assigning_clones`: move to `pedantic` so it is allow by default

In a nutshell, the `assigning_clones` lint suggests to make your code less readable for a small performance gain. See #12778 for more motivation.

fixes #12778

changelog: [`assigning_clones`]: move to the `pedantic` group
2024-05-15 14:50:29 +00:00
J-ZhengLi
1b7fc5f5aa add some msrv checks in is_min_const_fn 2024-05-15 16:38:57 +08:00
bors
c58b6e66fd Auto merge of #12798 - Alexendoo:no-effect-path-statements, r=y21
Don't lint path statements in no_effect

The rustc lint `path_statements` covers this case

Fixes #11547

changelog: none
2024-05-14 17:44:51 +00:00
Alex Macleod
9d790d6407 Don't lint path statements in no_effect 2024-05-14 17:22:56 +00:00
bors
a86378086b Auto merge of #12794 - J-ZhengLi:issue9251, r=blyxyas
improve [`match_same_arms`] messages, enable rustfix test

closes: #9251

don't worry about the commit size, most of them are generated

---

changelog: improve [`match_same_arms`] lint messages
2024-05-14 08:42:23 +00:00
J-ZhengLi
dc5b99b3b6 improve [match_same_arms] messages, enable rustfix test 2024-05-14 00:10:45 +02:00
Michael Goulet
2701a4175f Apply nits 2024-05-13 16:55:58 -04:00
Michael Goulet
760fbdf64e split out AliasTy -> AliasTerm 2024-05-13 11:59:42 -04:00
bors
d6991abc5a Auto merge of #12764 - lrh2000:ignore-place, r=blyxyas
`significant_drop_in_scrutinee`: Fix false positives due to false drops of place expressions

Place expressions do not really create temporaries, so they will not create significant drops. For example, the following code snippet is quite good (#8963):
```rust
fn main() {
    let x = std::sync::Mutex::new(vec![1, 2, 3]);
    let x_guard = x.lock().unwrap();
    match x_guard[0] {
        1 => println!("1!"),
        x => println!("{x}"),
    }
    drop(x_guard); // Some "usage"
}
```

Also, the previous logic thinks that references like `&MutexGuard<_>`/`Ref<'_, MutexGuard<'_, _>>` have significant drops, which is simply not true, so it is fixed together in this PR.

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

changelog: [`significant_drop_in_scrutinee`]: Fix false positives due to false drops of place expressions.

r? `@blyxyas`
2024-05-13 13:19:48 +00:00
Caio
12ec009f5a Fix #12760 2024-05-12 21:59:45 -03:00
Michael Goulet
e65cefcf6f Propagate errors rather than using return_if_err 2024-05-12 12:50:18 -04:00
bors
a4a1a7365d Auto merge of #12107 - y21:expr_metavars_in_unsafe, r=xFrednet
new lint: `macro_metavars_in_unsafe`

This implements a lint that I've been meaning to write for a while: a macro with an `expr` metavariable that is then expanded in an unsafe context. It's bad because it lets the user write unsafe code without an unsafe block.

Note: this has gone through some major rewrites, so any comment before https://github.com/rust-lang/rust-clippy/pull/12107#issuecomment-2029503545 is outdated and was based on an older version that has since been completely rewritten.

changelog: new lint: [`macro_metavars_in_unsafe`]
2024-05-12 16:32:41 +00: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
dfc9c9132b Inline MemCategorization into ExprUseVisitor 2024-05-12 11:52:13 -04:00
y21
9747c80644 new lint: macro_metavars_in_unsafe 2024-05-12 17:03:30 +02:00
bors
7cfb9a0d6f Auto merge of #11540 - J-ZhengLi:issue11443, r=xFrednet
add new lint that disallow renaming parameters in trait functions

fixes: #11443
fixes: #486

changelog: add new lint [`renamed_function_params`]

Note that the lint name is not final, because I have a bad reputation in naming things, and I don't trust myself.
2024-05-12 14:21:22 +00:00
J-ZhengLi
46659acdbd add configuration to allow skipping on some certain traits & collect metadata 2024-05-12 22:13:17 +08:00
bors
9b446c7ff8 Auto merge of #12787 - J-ZhengLi:issue127311, r=blyxyas
make [`from_str_radix_10`] skip constant context

fixes: #12731

---

changelog: make [`from_str_radix_10`] skip constant context
2024-05-12 14:03:55 +00:00
bors
2b34abc887 Auto merge of #12730 - Alexendoo:lint-groups-workspace-priority, r=xFrednet
Lint direct priority conflicts in `[workspace.lints]`

Partially addresses #12729

This still doesn't do any workspace resolution stuff, so it will not catch any virtual workspaces or conflicts from inherited definitions. But while we're parsing the `Cargo.toml` we might as well check the workspace definitions if we find them

changelog: none
2024-05-12 13:45:47 +00:00
bors
412b69158b Auto merge of #12620 - Nilstrieb:dupattr, r=xFrednet
Handle `rustc_on_unimplemented` in duplicated_attributes

```rust
#[rustc_on_unimplemented(
    on(
        _Self = "&str",
        label = "`a"
    ),
    on(
        _Self = "alloc::string::String",
        label = "a"
    ),
)]
```

The lint treats this as a repetition because `rustc_on_unimplemented:🔛:label` appears twice, but that's ok.

Fixes #12619

changelog: [`duplicated_attributes`]: fix handling of `rustc_on_unimplemented`
2024-05-12 13:35:02 +00:00
Yusuf Raji
cb3fcbbcfe
Improve clippy_lints/src/loops/mod.rs doc
Co-authored-by: llogiq <bogusandre@gmail.com>
2024-05-11 17:06:12 +02:00
bors
0e5bded17e Auto merge of #12770 - notriddle:notriddle/doc-lazy-continuation, r=llogiq
Add new lint `doc_lazy_continuation`

changelog: [`doc_lazy_continuation`]: add lint that warns on so-called "lazy paragraph continuations"

This is a follow-up for https://github.com/rust-lang/rust/pull/121659, since most cases of unintended block quotes are lazy continuations. The lint is designed to be more generally useful than that, though, because it will also catch unintended list items and unintended block quotes that didn't coincidentally hit a pulldown-cmark bug.

The second commit is the result of running `cargo dev dogfood --fix`, and manually fixing anything that seems wrong. NOTE: this lint's suggestions should never change the parser's interpretation of the markdown, but in many cases, it seems that doc comments in clippy were written without regard for this feature of Markdown (which, I suppose, is why this lint should exist).
2024-05-11 10:55:25 +00:00
J-ZhengLi
904c99c163 make [from_str_radix_10] skip constant context 2024-05-11 15:37:31 +08:00
Michael Goulet
2baeb9be54 Lift TraitRef into rustc_type_ir 2024-05-10 15:44:03 -04:00
Michael Howell
133549c61a doc_lazy_continuation: change applicability to MaybeIncorrect 2024-05-10 08:41:11 -07:00