Skip to content

Rollup of 8 pull requests - #128853

Merged
bors merged 138 commits into
rust-lang:masterfrom
matthiaskrgr:rollup-pr222x1
Aug 9, 2024
Merged

Rollup of 8 pull requests#128853
bors merged 138 commits into
rust-lang:masterfrom
matthiaskrgr:rollup-pr222x1

Conversation

@matthiaskrgr

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

meithecatteand others added 30 commits June 6, 2024 17:04
This commit fixes a bug introduced in rust-lang#12706, where the behavior of the
lint has been changed, to avoid suggestions that introduce a move. The
motivation in the commit message is quite poor (if the detection for
significant drops is not sufficient because it's not transitive, the
proper fix would be to make it transitive). However, rust-lang#12454, the linked
issue, provides a good reason for the change — if the value being
borrowed is bound to a variable, then moving it will only introduce
friction into future refactorings.
Thus rust-lang#12706 changes the logic so that the lint triggers if the value
being borrowed is Copy, or is the result of a function call, simplifying
the logic to the point where analysing "is this the only use of this
value" isn't necessary.
However, said PR also introduces an undocumented carveout, where
referents that themselves are mutable references are treated as Copy,
to catch some cases that we do want to lint against. However, that is
not sound — it's possible to consume a mutable reference by moving it.
To avoid emitting false suggestions, this PR reintroduces the
referent_used_exactly_once logic and runs that check for referents that
are themselves mutable references.
Thinking about the code shape of &mut x, where x: &mut T, raises the
point that while removing the &mut outright won't work, the extra
indirection is still undesirable, and perhaps instead we should suggest
reborrowing: &mut *x. That, however, is left as possible future work.
Fixesrust-lang#12856
TODO: Should we move `ty::peel_mid_ty_refs_is_mutable` to super module too?
Fixesrust-lang#12751
changelog: Fix [`redundant_slicing`] when the slice is behind a mutable reference
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing).
Inlining format args prevents accidental `&` misuse.
Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
…-errors
Implement lint against ambiguous negative literals
This PR implements a lint against ambiguous negative literals with a literal and method calls right after it.
## `ambiguous_negative_literals`
(deny-by-default)
The `ambiguous_negative_literals` lint checks for cases that are confusing between a negative literal and a negation that's not part of the literal.
### Example
```rust,compile_fail
-1i32.abs(); // equals -1, while `(-1i32).abs()` equals 1
```
### Explanation
Method calls take precedence over unary precedence. Setting the precedence explicitly makes the code clearer and avoid potential bugs.
<details>
<summary>Old proposed lint</summary>
## `ambiguous_unary_precedence`
(deny-by-default)
The `ambiguous_unary_precedence` lint checks for use the negative unary operator with a literal and method calls.
### Example
```rust
-1i32.abs(); // equals -1, while `(-1i32).abs()` equals 1
```
### Explanation
Unary operations take precedence on binary operations and method calls take precedence over unary precedence. Setting the precedence explicitly makes the code clearer and avoid potential bugs.
</details>
-----
Note: This is a strip down version of rust-lang#117161, without the binary op precedence.
Fixesrust-lang#117155
`@rustbot` labels +I-lang-nominated
cc `@scottmcm`
r? compiler
Also get the receiver T in `T.method(|| f())`.
…=xFrednet
Remove unnecessary `res` field in `for_each_expr` visitors
Small refactor in the `for_each_expr*` visitors. This should not change anything functionally.
Instead of storing the final value `Option<B>` in the visitor and setting it to `Some` when we get a `ControlFlow::Break(B)` from the closure, we can just directly return it from the visitor itself now that visitors support that.
cc rust-lang#12829 and rust-lang/rust-clippy#12830 (comment)
changelog: none
… r=xFrednet
needless_borrows_for_generic_args: Fix for &mut
This commit fixes a bug introduced in rust-lang#12706, where the behavior of the lint has been changed, to avoid suggestions that introduce a move. The motivation in the commit message is quite poor (if the detection for significant drops is not sufficient because it's not transitive, the proper fix would be to make it transitive). However, rust-lang#12454, the linked issue, provides a good reason for the change — if the value being borrowed is bound to a variable, then moving it will only introduce friction into future refactorings.
Thus rust-lang#12706 changes the logic so that the lint triggers if the value being borrowed is Copy, or is the result of a function call, simplifying the logic to the point where analysing "is this the only use of this value" isn't necessary.
However, said PR also introduces an undocumented carveout, where referents that themselves are mutable references are treated as Copy, to catch some cases that we do want to lint against. However, that is not sound — it's possible to consume a mutable reference by moving it.
To avoid emitting false suggestions, this PR reintroduces the referent_used_exactly_once logic and runs that check for referents that are themselves mutable references.
Thinking about the code shape of &mut x, where x: &mut T, raises the point that while removing the &mut outright won't work, the extra indirection is still undesirable, and perhaps instead we should suggest reborrowing: &mut *x. That, however, is left as possible future work.
Fixesrust-lang#12856
changelog: none
…endoo
Fix handling of `Deref` in `assigning_clones`
The `assigning_clones` lint had a special case for producing a bit nicer code for mutable references:
```rust
fn clone_function_lhs_mut_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
*mut_thing = Clone::clone(ref_thing);
}
//v
fn clone_function_lhs_mut_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
Clone::clone_from(mut_thing, ref_thing);
}
```
However, this could [break](rust-lang/rust-clippy#12437) when combined with `Deref`.
This PR removes the special case, so that the generated code should work more generally. Later we can improve the detection of `Deref` and put the special case back in a way that does not break code.
Fixes: rust-lang/rust-clippy#12437
r? `@blyxyas`
changelog: [`assigning_clones`]: change applicability to `Unspecified` and fix a problem with `Deref`.
…tthiaskrgr
Clippy subtree update
r? `@Manishearth`
Updates Cargo.lock due to the Clippy version update and the ui_test bump to v0.24
…hat, r=y21
Make restriction lint's use `span_lint_and_then` (i -> p)
This migrates a few restriction lints to use `span_lint_and_then`. This change is motivated by rust-lang/rust-clippy#7797.
I've also cleaned up some lint message. Mostly minor stuff. For example: suggestions with a longer message than `"try"` now use `SuggestionStyle::ShowAlways`
---
cc: rust-lang/rust-clippy#7797
brother PR of: rust-lang/rust-clippy#13136
changelog: none
Signed-off-by: riyueguang <rustruby@outlook.com>
flip1995and others added 11 commits August 8, 2024 19:14
rwlock: disable 'frob' test in Miri on macOS
Due to rust-lang#121950, Miri will sometimes complain about this test on macOS. Better disable the test, as otherwise it can fail for unrelated PRs.
r? ``@joboet``
…=lcnr
Don't implement `AsyncFn` for `FnDef`/`FnPtr` that wouldnt implement `Fn`
Due to unsafety, ABI, or the presence of target features, some `FnDef`/`FnPtr` types don't implement `Fn*`. Do the same for `AsyncFn*`.
Noticed this due to rust-lang#128764, but this isn't really related to that ICE, which is fixed in rust-lang#128792.
Split `ColorConfig` off of `HumanReadableErrorType`
The previous setup tied two unrelated things together. Splitting these two is a better model.
Identified by https://github.com/rust-lang/rust/pull/126597/files#r1667800754
std float tests: special-case Miri in feature detection
Quick work-around to fix miri-test-libstd failures.
r? ``@tgross35``
…nTheVoid
rustdoc: strip unreachable modules
Modules are now stripped based on the same logic that's used to strip other item kinds
Fixesrust-lang#101105
…, r=aDotInTheVoid
rustdoc-json: add a test for impls on private & hidden types
Fixesrust-lang#107278 (or rather just ensures it won't resurface)
r? ``@aDotInTheVoid``
…Manishearth
Clippy subtree update
r? ``@Manishearth``
Updates Cargo.lock due to uitest bump
…ir, r=matthiaskrgr
Add comment that bors did not see pushed before it merged
In rust-lang#128612, bors merged 470ada2 instead of 1e07c19.
This means it dropped a useful comment I added, and a stage rename that is more descriptive.
@rustbotrustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) rollup A PR which is a rollup labels Aug 8, 2024
@matthiaskrgr

Copy link
Copy Markdown
MemberAuthor

@bors r+ rollup=never p=8

@bors

bors commented Aug 8, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit 9243aee has been approved by matthiaskrgr

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 8, 2024
@bors

bors commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 9243aee with merge fac7753...

@bors

bors commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing fac7753 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Aug 9, 2024
@bors
bors merged commit fac7753 into rust-lang:masterAug 9, 2024
@rustbotrustbot added this to the 1.82.0 milestone Aug 9, 2024
@rust-timer

Copy link
Copy Markdown
Collaborator

📌 Perf builds for each rolled up PR:

PR#MessagePerf Build Sha
#121364Implement lint against ambiguous negative literals❌ conflicts merging '5f3a6e1805' into previous master ❌
#124941Stabilize const {integer}::from_str_radix i.e. `const_int…❌ conflicts merging '26cdeed27e' into previous master ❌
#128640rwlock: disable 'frob' test in Miri on macOSf6e73540b822a31f6a402922b9940235c18f889a (link)
#128791Don't implement AsyncFn for FnDef/FnPtr that wouldnt …dd19b14e1f62dfa7e0134e1940d526608f3a64df (link)
#128806Split ColorConfig off of HumanReadableErrorTyped8590a3d787ae94b5523bfdf22f3559b073745e6 (link)
#128818std float tests: special-case Miri in feature detectiond11b191c04feaa2a3a9e5a17e61d3eb1791104ca (link)
#128834rustdoc: strip unreachable modulesdcb277aab19ffc34cd21e41d44a8ab42c413765d (link)
#128836rustdoc-json: add a test for impls on private & hidden typesb1a13b936d64caf18933b46c90bf369d88bf78c4 (link)
#128837Clippy subtree update9878e4ec2ccfbbd878c1e9a88b2798afbb3b6bb2 (link)
#128851Add comment that bors did not see pushed before it merged4274a1af25ee75d58146e29fd9bab6da68c370bd (link)

previous master: c7b0d4e81f

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (fac7753): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 3.3%, secondary 3.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

meanrangecount
Regressions ❌
(primary)
3.3%[3.3%, 3.3%]1
Regressions ❌
(secondary)
3.3%[2.7%, 3.6%]4
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)3.3%[3.3%, 3.3%]1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 762.109s -> 761.187s (-0.12%)
Artifact size: 337.09 MiB -> 337.12 MiB (0.01%)

@matthiaskrgr
matthiaskrgr deleted the rollup-pr222x1 branch September 1, 2024 17:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-jsonArea: Rustdoc JSON backendmerged-by-borsThis PR was explicitly merged by bors.rollupA PR which is a rollupS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

20 participants

@matthiaskrgr@bors@rust-timer@rustbot@meithecatte@Skgland@Urgau@yaxum62@tesuji@apoisternex@nyurik@xFrednet@jusexton@y21@flip1995@Bryanskiy@Kobzol@riyueguang@Alexendoo@GuillaumeGomez