Commit graph

16759 commits

Author SHA1 Message Date
bors
d696f3b652 Auto merge of #10584 - blyxyas:fix-wildcard_imports_testsrs, r=flip1995
fix: `wildcard_imports` ignore `test.rs` files

Adds a check to see if the building crate is a test one, if so, ignore it

---

Closes #10580
changelog:[`wildcard_imports`]: Add a check to ignore files named `test.rs` and `tests.rs`
2023-05-08 16:46:23 +00:00
blyxyas
4c3e2ff2a4
Fix header 2023-05-08 18:38:41 +02:00
bors
90ce1a2e7c Auto merge of #10761 - lochetti:fix_9871, r=Manishearth
Ignore `borrow_deref_ref` warnings in code from procedural macros.

Don't linting `borrow_deref_ref` if code was generated by procedural macro.

This PR fixes https://github.com/rust-lang/rust-clippy/issues/8971

changelog: [`borrow_deref_ref`] avoiding warnings in macro-generated code
2023-05-08 16:29:02 +00:00
blyxyas
ba0e7e88cb
Now the lint ignores any crates with --cfg test 2023-05-08 18:24:59 +02:00
blyxyas
5acc2993e7
Really mini minor irrelevant change for formatting 2023-05-08 18:24:59 +02:00
blyxyas
54912410c7
Wildcard_imports ignore test.rs files 2023-05-08 18:24:58 +02:00
bors
e66488a669 Auto merge of #10757 - cakebaker:add_missing_word, r=Jarcho
Add missing word "are"

changelog: none
2023-05-08 15:43:18 +00:00
bors
8798c66a9e Auto merge of #10736 - NotAPenguin0:master, r=Alexendoo
initial clippy::ref_pattern implementation

This implements a new lint that discourages the use of the `ref` keyword as outlined in #9010. I think there are still some things to improve about this lint, but I need some feedback before I can implement those.

- [x] ~~Maybe it's desirable that a quick fix is listed too, instead of a generic `avoid using the ref keyword` lint.~~
- [x] `let ref x = y` already has a lint (`clippy::toplevel_ref_arg`). This implementation will report this too, so you get two lints for the same issue, which is not great. I don't really know a way around this though.
- [X] The dogfood test is currently failing locally, though I ran `cargo clippy -- -D clippy::all -D clippy::pedantic` and got no output, so I'm not sure why this is.

Any help with these would be greatly appreciated.

fixes #9010
changelog: [`ref_pattern`]: newly added lint
2023-05-08 12:24:56 +00:00
NotAPenguin
56e8e1a27d new lint: clippy::ref_patterns 2023-05-08 13:20:33 +02:00
bors
3aab0ddc43 Auto merge of #10752 - Alexendoo:default-units-macros, r=giraffate
Ignore expressions from macros in `default_constructed_unit_structs`

changelog: none, should be the same release as the lint itself
2023-05-08 00:21:43 +00:00
Renato Lochetti
394b4c1906
Ignore borrow_deref_ref warnings in code from procedural macros. 2023-05-07 12:35:17 +01:00
Daniel Hofstetter
f4b8cb1b28
Add missing word "are" 2023-05-06 16:21:45 +02:00
Alex Macleod
68eb864c91 Ignore expressions from macros in default_constructed_unit_structs 2023-05-05 18:35:54 +00:00
bors
371120bdbf Auto merge of #10749 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-05-05 15:30:22 +00:00
Philipp Krones
79656cc95e
Bump nightly version -> 2023-05-05 2023-05-05 17:29:40 +02:00
Philipp Krones
88c7632659
Merge remote-tracking branch 'upstream/master' into rustup 2023-05-05 17:29:35 +02:00
bors
d7173e2599 Auto merge of #10747 - Alexendoo:cargo-dev-dogfood-stdout, r=flip1995
Inherit stdout/stderr for `cargo dev dogfood`

changelog: none

Prints progress as it happens and in colour, and will also show anything printed to stderr
2023-05-05 12:22:25 +00:00
Alex Macleod
0f7b61d729 Inherit stdout/stderr for cargo dev dogfood 2023-05-05 12:10:36 +00:00
bors
8518391e72 Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnr
Replace `tcx.mk_trait_ref` with `TraitRef::new`

First step in implementing https://github.com/rust-lang/compiler-team/issues/616
r? `@lcnr`
2023-05-04 05:54:09 +00:00
bors
f9c1d155b4 Auto merge of #10716 - Icxolu:unitstruct_default_construction, r=Manishearth
Fixes #10609: Adds lint to detect construction of unit struct using `default`

Using `default` to construct a unit struct increases code complexity and adds a function call. This can be avoided by simply removing the call to `default` and simply construct by name.

changelog: [`default_constructed_unit_structs`]: detects construction of unit structs using `default`

fixes #10609
2023-05-03 21:43:02 +00:00
Icxolu
48ae5a071b fix lint docs 2023-05-03 21:43:10 +02:00
Icxolu
160371550f add rustfix annotation 2023-05-03 21:05:50 +02:00
Icxolu
4ed7fd1ecc fix failing tests 2023-05-03 20:55:14 +02:00
Icxolu
8701009860 add more test cases 2023-05-03 20:55:14 +02:00
Icxolu
4e04903631 rename to plural form 2023-05-03 19:25:25 +02:00
bors
c2e0d43485 Auto merge of #10734 - smoelius:patch-2, r=Alexendoo
Update macros.rs (typo)

r? `@Alexendoo`

changelog: none
2023-05-03 10:34:39 +00:00
bors
9353170dfb Auto merge of #10730 - blyxyas:no_std_mul_add, r=Jarcho
`imprecise_flops`: Globally ignore `#[no_std]` crates

Really small fix.
Fixes #10728
changelog: [`imprecise_flops`]: Fix false positives with `#[no_std]`
2023-05-03 01:47:52 +00:00
Samuel Moelius
7e24ff33e4
Update macros.rs 2023-05-02 19:02:06 -04:00
Nicholas Nethercote
431cce1540 Restrict From<S> for {D,Subd}iagnosticMessage.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.

This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.

As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-05-03 08:44:39 +10:00
blyxyas
0dd2501e0d
Don't ignore check_radians 2023-05-02 20:47:18 +02:00
bors
d36bde7db0 Auto merge of #109128 - chenyukang:yukang/remove-type-ascription, r=estebank
Remove type ascription from parser and diagnostics

Mostly based on https://github.com/rust-lang/rust/pull/106826

Part of #101728

r? `@estebank`
2023-05-02 09:41:35 +00: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
bors
824f2e701c Auto merge of #10724 - lukaslueg:largeerrdocs, r=giraffate
Clarify docs for `RESULT_LARGE_ERR`

Adds a paragraph to address https://github.com/rust-lang/rust-clippy/issues/10211#issuecomment-1521548238

changelog: [`result_large_err`]: Update the document
2023-05-02 00:41:36 +00:00
Icxolu
220a9db642 fixed span and corrected test output 2023-05-01 20:12:34 +02:00
bors
8354b34061 Auto merge of #111036 - RalfJung:miri, r=RalfJung
update Miri

r? `@ghost`
2023-05-01 11:13:49 +00:00
blyxyas
5749054241
globally ignore #[no_std] crates 2023-05-01 12:39:20 +02:00
yukang
d4baabe902 clean up Colon from clippy 2023-05-01 16:15:17 +08:00
Ralf Jung
de4bc66f94 Merge from rustc 2023-04-30 22:35:29 +02:00
Icxolu
032bc11fd4
fix diagnostic message style
Co-authored-by: Ruby Lazuli <general@patchmixolydic.com>
2023-04-29 21:11:34 +02:00
bors
7bc3da975a Auto merge of #10647 - y21:while_pop_unwrap, r=llogiq
new lint: `manual_while_let_some`

This PR implements the lint I suggested [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/lint.20on.20while.20pop.20unwrap).
It looks for while loops like these:
```rs
let mut numbers = vec![0, 1, 2];
while !numbers.is_empty() {
  let number = numbers.pop().unwrap();
  // use `number`
}
```
and suggests replacing it with a while-let loop, like this:
```rs
let mut numbers = vec![0, 1, 2];
while let Some(number) = numbers.pop() {
  // use `number`
}
```
... which is more concise and idiomatic.

It only looks for `Vec::pop()` calls in the first statement of the loop body in an attempt to not trigger FPs (as pop might only be called conditionally).

changelog: new lint [`manual_while_let_some`]
2023-04-29 17:57:25 +00:00
y21
9613ea85c6 fix run-rustfix directive 2023-04-29 19:10:52 +02:00
y21
8d8178f931 rename lint to manual_while_let_some 2023-04-29 18:59:07 +02:00
y21
f10e39fd2b make PopStmt copy+clone 2023-04-29 18:59:07 +02:00
y21
ab9b7a5ad2 remove unnecessary reference 2023-04-29 18:59:07 +02:00
y21
1d08325293 move lint to loops, emit proper suggestion, more tests 2023-04-29 18:59:07 +02:00
y21
bcdcc34ba9 elide lifetimes, get rid of glob import 2023-04-29 18:59:06 +02:00
y21
bb58083ce5 new lint: while_pop_unwrap 2023-04-29 18:59:06 +02:00
Lukas Lueg
2ed254e29f Clarify docs for RESULT_LARGE_ERR 2023-04-29 14:18:31 +02:00
bors
3594d55439 Auto merge of #10719 - blyxyas:fix-items_after_test_mod_imported_modules, r=Alexendoo
Fix `items_after_test_module`: Ignore imported modules

Fixes #10713. It does a little bit of dark magic, but intention is what really counts.
changelog:[`items_after_test_module`]: Ignore imported modules (`mod foo;`) with no body.
2023-04-28 18:42:58 +00:00
blyxyas
395b1f5bf3
Rename items + Delete imported_module.stderr 2023-04-28 20:40:47 +02:00