Commit graph

16649 commits

Author SHA1 Message Date
bors
797a7fed67 Auto merge of #10706 - Alexendoo:remove-old-generated-files-check, r=llogiq
Remove check for `lib.register_*` and `src/docs*` in `cargo dev update_lints`

The transition period has well passed

changelog: none
2023-04-23 14:39:07 +00:00
Alex Macleod
022baa5ce3 Remove check for lib.register_* and src/docs* in cargo dev update_lints
This reverts commit 22d435b266.
2023-04-23 14:25:19 +00:00
bors
e1f6305ecf Auto merge of #10704 - matthiaskrgr:splitest, r=llogiq
split test into 2

changelog: none
2023-04-23 13:44:57 +00:00
bors
496c11005c Auto merge of #10679 - y21:better-const-ctx-check, r=Jarcho
use `is_inside_const_context` for `in_constant` util fn

Fixes #10452.

This PR improves the `in_constant` util function to detect more cases of const contexts. Previously this function would not detect cases like expressions in array length position or expression in an inline const block `const { .. }`.

changelog: [`bool_to_int_with_if`]: recognize array length operand as being in a const context and don't suggest `usize::from` there
2023-04-23 13:33:51 +00:00
bors
316d83a4d8 Auto merge of #10670 - lukaslueg:issue10634, r=Jarcho
Don't suggest `suboptimal_flops` unavailable in nostd

Fixes #10634

changelog: Enhancement: [`suboptimal_flops`]: Do not suggest `{f32,f64}::abs()` or `{f32,f64}::mul_add()` in a `no_std`-environment.
2023-04-23 13:23:48 +00:00
Matthias Krüger
572eecd267 split test into 2 2023-04-23 15:11:31 +02:00
bors
f16bfa478f Auto merge of #10703 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-04-23 11:07:14 +00:00
bors
a3ed905928 Auto merge of #10578 - blyxyas:items_after_test_module, r=dswij
Add `items_after_test_module` lint

Resolves task *3* of #10506, alongside *1* resolved at #10543 in an effort to help standarize a little bit more testing modules.

---

changelog:[`items_after_test_module`]: Added the lint.
2023-04-23 10:56:50 +00:00
Philipp Krones
36bf3ef004
Fix dogfood test 2023-04-23 03:44:24 -07:00
Philipp Krones
d5a2c2ba71
Bump nightly version -> 2023-04-23 2023-04-23 03:39:29 -07:00
Philipp Krones
0add5bb0f1
Bump Clippy version -> 0.1.71 2023-04-23 03:39:19 -07:00
Philipp Krones
583c97e9bb
Merge remote-tracking branch 'upstream/master' into rustup 2023-04-23 03:39:03 -07:00
bors
419552227f Auto merge of #10701 - blyxyas:fix-fp-let_underscore_untyped, r=llogiq
Bugfix: Ignore `impl Trait`(s) @ `let_underscore_untyped`

Fixes #10411

changelog:[`let_underscore_untyped`]: Ignore `impl Trait`(s) that caused false positives.
2023-04-23 10:13:41 +00:00
blyxyas
bdd05456b1
Ignore impl Trait(s) 2023-04-23 12:09:36 +02:00
bors
9a337784c6 Auto merge of #10688 - klensy:no-semver, r=flip1995
clippy: drop unused semver crate

Drop unused `semver` crate dependency.

changelog: none
2023-04-23 10:00:44 +00:00
bors
6328371d24 Auto merge of #10681 - J-ZhengLi:issue10529, r=flip1995
make [`len_zero`] lint not spanning over parenthesis

sorry it should be a quick fix but I was caught up by other stuffs last couple weeks 🤦‍♂️

---

fixes: #10529

changelog: make [`len_zero`] lint not spanning over parenthesis
2023-04-23 09:50:16 +00:00
bors
982423473a Auto merge of #10696 - Alexendoo:allow-enum-variant-names, r=flip1995
Fix `#[allow(clippy::enum_variant_names)]` directly on variants

changelog: [`enum_variant_names`]: Fix `#[allow]` attributes applied directly to the enum variant

Fixes #10695
2023-04-23 09:39:10 +00:00
blyxyas
1ac8dc51bc
Compact emmited lint 2023-04-22 21:12:55 +02:00
blyxyas
0354cee137
Add lint items_after_test_module 2023-04-22 21:12:45 +02:00
Alex Macleod
397f36a78c Fix #[allow(clippy::enum_variant_names)] directly on variants 2023-04-22 14:53:15 +00:00
bors
f30fc0a5e2 Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJung
Evaluate place expression in `PlaceMention`

https://github.com/rust-lang/rust/pull/102256 introduces a `PlaceMention(place)` MIR statement which keep trace of `let _ = place` statements from surface rust, but without semantics.

This PR proposes to change the behaviour of `let _ =` patterns with respect to the borrow-checker to verify that the bound place is live.

Specifically, consider this code:
```rust
let _ = {
    let a = 5;
    &a
};
```

This passes borrowck without error on stable. Meanwhile, replacing `_` by `_: _` or `_p` errors with "error[E0597]: `a` does not live long enough", [see playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c448d25a7c205dc95a0967fe96bccce8).

This PR *does not* change how `_` patterns behave with respect to initializedness: it remains ok to bind a moved-from place to `_`.

The relevant test is `tests/ui/borrowck/let_underscore_temporary.rs`. Crater check found no regression.

For consistency, this PR changes miri to evaluate the place found in `PlaceMention`, and report eventual dangling pointers found within it.

r? `@RalfJung`
2023-04-22 09:54:21 +00:00
bors
86d8f1268a Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
Camille GILLOT
cb3e0fbb59 Evaluate place expression in PlaceMention. 2023-04-21 21:34:59 +00:00
klensy
8f702b0381 clippy: drop unused semver crate 2023-04-21 22:21:14 +03:00
bors
928349795f Auto merge of #10677 - Swatinem:patch-1, r=xFrednet
Fix typo in significant_drop_tightening

changelog: none
2023-04-21 15:36:56 +00:00
DrMeepster
68c4776b46 offset_of 2023-04-21 02:14:02 -07:00
J-ZhengLi
b8d6964bce
make [len_zero] lint not spanning over parenthesis 2023-04-21 16:56:17 +08:00
bors
84bab312ab Auto merge of #96840 - cjgillot:query-feed, r=oli-obk
Allow to feed a value in another query's cache and remove `WithOptConstParam`

I used it to remove `WithOptConstParam` queries, as an example.

The idea is that a query (here `typeck(function)`) can write into another query's cache (here `type_of(anon const)`). The dependency node for `type_of` would depend on all the current dependencies of `typeck`.

There is still an issue with cycles: if `type_of(anon const)` is accessed before `typeck(function)`, we will still have the usual cycle.  The way around this issue is to `ensure` that `typeck(function)` is called before accessing `type_of(anon const)`.

When replayed, we may the following cases:
- `typeck` is green, in that case `type_of` is green too, and all is right;
- `type_of` is green, `typeck` may still be marked as red (it depends on strictly more things than `type_of`) -> we verify that the saved value and the re-computed value of `type_of` have the same hash;
- `type_of` is red, then `typeck` is red -> it's the caller responsibility to ensure `typeck` is recomputed *before* `type_of`.

As `anon consts` have their own `DefPathData`, it's not possible to have the def-id of the anon-const point to something outside the original function, but the general case may have to be resolved before using this device more broadly.

There is an open question about loading from the on-disk cache.  If `typeck` is loaded from the on-disk cache, the side-effect does not happen. The regular `type_of` implementation can go and fetch the correct value from the decoded `typeck` results, and the dep-graph will check that the hashes match, but I'm not sure we want to rely on this behaviour.

I specifically allowed to feed the value to `type_of` from inside a call to `type_of`.  In that case, the dep-graph will check that the fingerprints of both values match.

This implementation is still very sensitive to cycles, and requires that we call `typeck(function)` before `typeck(anon const)`.  The reason is that `typeck(anon const)` calls `type_of(anon const)`, which calls `typeck(function)`, which feeds `type_of(anon const)`, and needs to build the MIR so needs `typeck(anon const)`.  The latter call would not cycle, since `type_of(anon const)` has been set, but I'd rather not remove the cycle check.
2023-04-21 08:04:58 +00:00
bors
e8197b1a1a Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk
Enable flatten-format-args by default.

Part of https://github.com/rust-lang/rust/issues/99012.

This enables the `flatten-format-args` feature that was added by https://github.com/rust-lang/rust/pull/106824:

> This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir:
>
> ```rust
> println!("Hello, {}!", "World");
> println!("Hello, World!");
> ```
>
> ```rust
> println!("[info] {}", format_args!("error"));
> println!("[info] error");
> ```
>
> ```rust
> println!("[{}] {}", status, format_args!("error: {}", msg));
> println!("[{}] error: {}", status, msg);
> ```
>
> ```rust
> println!("{} + {} = {}", 1, 2, 1 + 2);
> println!("1 + 2 = {}", 1 + 2);
> ```
>
> And so on.
>
> This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`.
>
> It also means that `dbg!(x)` will have its file, line, and expression name inlined:
>
> ```rust
> eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before
> eprintln!("[example.rs:1] x = {:#?}", x); // after
> ```
>
> Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot.

This is mostly an optimization, except that it will be visible through [`fmt::Arguments::as_str()`](https://doc.rust-lang.org/nightly/std/fmt/struct.Arguments.html#method.as_str).

In https://github.com/rust-lang/rust/pull/106823, there was already a libs-api FCP about the documentation of `fmt::Arguments::as_str()` to allow it to give `Some` rather than `None` depending on optimizations like this. That was just a documentation update though. This PR is the one that actually makes the user visible change:

```rust
assert_eq!(format_args!("abc").as_str(), Some("abc")); // Unchanged.
assert_eq!(format_args!("ab{}", "c").as_str(), Some("abc")); // Was `None` before!
```
2023-04-20 23:19:19 +00:00
y21
654d12ff89 use is_inside_const_context query for in_constant 2023-04-20 22:43:59 +02:00
Arpad Borsos
7077bde9d2
Fix typo in significant_drop_tightening 2023-04-20 20:59:59 +02:00
bors
c976ad07ee Auto merge of #10675 - c410-f3r:bbbbbbbbbbb, r=llogiq
[arithmetic_side_effects] Cache symbols

An internal-only modification to speed up the processing of symbols because "intern" isn't very cheap, even more when you are doing the same thing for every method expression.

changelog: none
2023-04-20 18:34:16 +00:00
Caio
0b16f80c40 [arithmetic_side_effects] Cache symbols 2023-04-20 14:59:02 -03:00
Camille GILLOT
8ead58c67b Remove WithOptconstParam. 2023-04-20 17:48:32 +00:00
bors
06dace2920 Auto merge of #10669 - oli-obk:@, r=Alexendoo
Update to a compiletest-rs version that requires `//@` for commands

Requires https://github.com/Manishearth/compiletest-rs/pull/261 to get published

This PR is a smaller step towards https://github.com/rust-lang/rust-clippy/pull/10426

changelog: Move to a version of compiletest-rs that allows us to require `//`@`` for test suite commands.
2023-04-20 14:51:33 +00:00
Oli Scherer
def1705a27 Update to a compiletest-rs version that requires //@ for commands 2023-04-20 14:44:03 +00:00
bors
523c8fa2ed Auto merge of #10615 - c410-f3r:bbbbbbbbbbb, r=giraffate
[arithmetic_side_effects] Fix #10590

Fix #10590

changelog: [`arithmetic_side_effects`]: Detect integer methods that can introduce side effects
2023-04-20 13:27:22 +00:00
Lukas Lueg
2745c87842 Dont suggest suboptimal_flops unavailable in nostd
Fixes #10634
2023-04-19 20:04:17 +02:00
bors
4d35b5e27b Auto merge of #10668 - xFrednet:changelog-1-69, r=flip1995
Changelog for Rust 1.69 🌸

Roses are blue,
Violets are red,
Something is wrong,
We still commit!

---

changelog: none
2023-04-19 17:24:44 +00:00
bors
d3b1001ba4 Auto merge of #110496 - WaffleLapkin:🏳️‍⚧️sound, r=compiler-errors
Don't transmute `&List<GenericArg>` <-> `&List<Ty>`

In #93505 we allowed safely transmuting between `&List<GenericArg<'_>>` and `&List<Ty<'_>>`. This was possible because `GenericArg` is a tagged pointer and the tag for types is `0b00`, such that a `GenericArg` with a type inside has the same layout as `Ty`.

While this was meant as an optimization, it doesn't look like it was actually any perf or max-rss win (see https://github.com/rust-lang/rust/pull/94799#issuecomment-1064340003, https://github.com/rust-lang/rust/pull/94841, https://github.com/rust-lang/rust/pull/110496#issuecomment-1513799140).

Additionally the way it was done is quite fragile — `unsafe` code was not properly documented or contained in a module, types were not marked as `repr(C)` (making the transmutes possibly unsound). All of this makes the code maintenance harder and blocks other possible optimizations (as an example I've found out about these `transmutes` when my change caused them to sigsegv compiler).

Thus, I think we can safely (pun intended) remove those transmutes, making maintenance easier, optimizations possible, code less cursed, etc.

r? `@compiler-errors`
2023-04-19 17:01:06 +00:00
xFrednet
6ce346c942
Changelog for Rust 1.69 🌸 2023-04-19 16:37:28 +02:00
Caio
3db7352b81 [arithmetic_side_effects] Fix #10590 2023-04-19 10:58:00 -03:00
bors
f1a552ccec Auto merge of #10203 - c410-f3r:macro-lint, r=giraffate
Suppress the triggering of some lints in derived structures

Fixes #10185
Fixes #10417

For `integer_arithmetic`, `arithmetic_side_effects` and `shadow_reuse`.

* ~~Not sure how to test these use-cases so feel free to point any method or any related PR.~~

---

changelog: FP: [`integer_arithmetic`], [`arithmetic_side_effects`]: No longer lint inside proc macros
[#10203](https://github.com/rust-lang/rust-clippy/pull/10203)
<!-- changelog_checked -->
2023-04-19 12:56:19 +00:00
xFrednet
747ff0656b
Update version attribute for 1.69 lints 2023-04-19 14:55:18 +02:00
bors
0c44586ff7 Auto merge of #10651 - lukaslueg:issue10641, r=xFrednet
Add size-parameter to unecessary_box_returns

Fixes #10641

This adds a configuration-knob to the `unecessary_box_returns`-lint which allows _not_ linting a `fn() -> Box<T>` if `T` is "large". The default byte size above which we no longer lint is 128 bytes (due to https://github.com/rust-lang/rust-clippy/issues/4652#issue-505670554, also used in #9373). The overall rational is given in #10641.

---

changelog: Enhancement: [`unnecessary_box_returns`]: Added new lint configuration `unnecessary-box-size` to set the maximum size of `T` in `Box<T>` to be linted
[#10651](https://github.com/rust-lang/rust-clippy/pull/10651)
<!-- changelog_checked -->
2023-04-19 12:42:33 +00:00
Lukas Lueg
4bc68f9c60 Add size-parameter to unecessary_box_returns
Fixes #10641
2023-04-19 14:32:05 +02: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
8099f19516 Auto merge of #10667 - Alexendoo:manual-slice-size-calculation-macros, r=llogiq
Ignore `manual_slice_size_calculation` in code from macro expansions

changelog: none, assuming same release as #10659
2023-04-18 18:05:51 +00:00
Alex Macleod
2f4f798f9b Ignore manual_slice_size_calculation in code from macro expansions 2023-04-18 17:54:26 +00:00
Maybe Waffle
2ebfbc5753 Remove very useless as_substs usage from clippy 2023-04-18 17:39:08 +00:00