Commit graph

19816 commits

Author SHA1 Message Date
Guillaume Gomez
4f98cc6d55 Correctly handle closing parens in missing_backticks doc lint 2024-05-21 14:55:30 +02: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
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
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
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
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
bors
68dbc84ec4 Auto merge of #12780 - future-highway:str-to-string-expansions, r=Manishearth
Ignore `_to_string` lints in code `from_expansion`

Includes the `string_to_string` and `str_to_string` lints.

changelog: [`str_to_string`]: Ignore code from expansion
changelog: [`string_to_string`]: Ignore code from expansion
2024-05-09 21:53:57 +00:00
bors
baf2a23840 Auto merge of #12783 - shanretoo:fix-assigning-clones, r=blyxyas
fix: use hir_with_context to produce correct snippets for assigning_clones

The `assigning_clones` lint is producing wrong output when the assignment is a macro call.
Since Applicability level `Unspecified` will never be changed inside `hir_with_applicability`, so it is safe here to replace `hir_with_applicability` with `hir_with_context` to generate snippets of the macro call instead of the expansion.

fixes #12776

changelog: [`assigning_clones`]: use `hir_with_context` to produce correct snippets
2024-05-09 21:38:05 +00:00
lcnr
9b4ad016ec always use GenericArgsRef 2024-05-09 19:52:02 +00:00
bors
5a28d8f01e Auto merge of #12650 - cocodery:issue/12098, r=xFrednet
fix false positive in Issue/12098 because lack of consideration of mutable caller

fixes [Issue#12098](https://github.com/rust-lang/rust-clippy/issues/12098)

In issue#12098, the former code doesn't consider the caller for clone is mutable, and suggests to delete clone function.

In this change, we first get the inner caller requests for clone,
and if it's immutable, the following code will suggest deleting clone.

If it's mutable, the loop will check whether a borrow check violation exists,
if exists, the lint should not execute, and the function will directly return;
otherwise, the following code will handle this.

changelog: [`clippy::unnecessary_to_owned`]: fix false positive
2024-05-09 17:41:49 +00:00
bors
9abaf91a68 Auto merge of #12719 - roddyrap:fix-website-dash-replace-12718, r=xFrednet
Fix website dash replacement

Fixes: #12718
changelog: Made clippy lints website search replace all occurrences of dashes with underscores instead of only the first one. This is in order to allow the user to search for lints with more than two words using dahses.
2024-05-09 14:38:04 +00:00
shanretoo
99a42bab30 fix wrong suggestions of assigning_clones when the assignment is a macro call 2024-05-09 09:29:18 +08:00
Matthias Krüger
18fe295d33 Rollup merge of #124876 - nnethercote:rm-use-crate-rustc_foo, r=compiler-errors
Simplify `use crate::rustc_foo::bar` occurrences.

They can just be written as `use rustc_foo::bar`, which is far more standard. (I didn't even know that a `crate::` prefix was valid.)

r? ``@eholk``
2024-05-08 23:33:26 +02:00