Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #134590

Merged
merged 25 commits into from
Dec 21, 2024
Merged

Rollup of 7 pull requests #134590

merged 25 commits into from
Dec 21, 2024

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

michaelvanstraten and others added 25 commits November 30, 2024 10:17
Arbitrary self types v2 attempts to detect cases where methods in an
"outer" type (e.g. a smart pointer) might "shadow" methods in the
referent.

There are a couple of cases where the current code makes no attempt to
detect such shadowing. Both of these cases only apply if other unstable
features are enabled.

Add a test, mostly for illustrative purposes, so we can see the
shadowing cases that can occur.
The arbitrary self types v2 work introduces a check for shadowed
methods, whereby a method in some "outer" smart pointer type may called
in preference to a method in the inner referent. This is bad if the
outer pointer adds a method later, as it may change behavior, so we
ensure we error in this circumstance.

It was intended that this new shadowing detection system only comes into
play for users who enable the `arbitrary_self_types` feature (or of
course everyone later if it's stabilized). It was believed that the
new deshadowing code couldn't be reached without building the custom
smart pointers that `arbitrary_self_types` enables, and therefore there
was no risk of this code impacting existing users.

However, it turns out that cunning use of `Pin::get_ref` can cause
this type of shadowing error to be emitted now. This commit adds a test
for this case.
Do not allow users to apply `#[non_exaustive]` to a struct when they have also used default field values.
…ibute_list, r=ChrisDenton

Abstract `ProcThreadAttributeList` into its own struct

As extensively discussed in issue rust-lang#114854, the current implementation of the unstable `windows_process_extensions_raw_attribute` features lacks support for passing a raw pointer.

This PR wants to explore the opportunity to abstract away the `ProcThreadAttributeList` into its own struct to for one improve safety and usability and secondly make it possible to maybe also use it to spawn new threads.

try-job: x86_64-mingw
… r=rustdoc

Add `--doctest-compilation-args` option to add compilation flags to doctest compilation

Fixes rust-lang#67533.
Tracking issue: rust-lang#134172

It's been something I meant to take a look at for a long time and actually completely forgot... The idea is to allow to give more control over how doctests are compiled to users. To do so, this PR adds a new `--doctest-compilation-args` option which provides extra compilation flags.

r? `@notriddle`
…o,traviscross

Precedence improvements: closures and jumps

This PR fixes some cases where rustc's pretty printers would redundantly parenthesize expressions that didn't need it.

<table>
<tr><th>Before</th><th>After</th></tr>
<tr><td><code>return (|x: i32| x)</code></td><td><code>return |x: i32| x</code></td></tr>
<tr><td><code>(|| -> &mut () { std::process::abort() }).clone()</code></td><td><code>|| -> &mut () { std::process::abort() }.clone()</code></td></tr>
<tr><td><code>(continue) + 1</code></td><td><code>continue + 1</code></td></tr>
</table>

Tested by `echo "fn main() { let _ = $AFTER; }" | rustc -Zunpretty=expanded /dev/stdin`.

The pretty-printer aims to render the syntax tree as it actually exists in rustc, as faithfully as possible, in Rust syntax. It can insert parentheses where forced by Rust's grammar in order to preserve the meaning of a macro-generated syntax tree, for example in the case of `a * $rhs` where $rhs is `b + c`. But for any expression parsed from source code, without a macro involved, there should never be a reason for inserting additional parentheses not present in the original.

For closures and jumps (return, break, continue, yield, do yeet, become) the unneeded parentheses came from the precedence of some of these expressions being misidentified. In the same order as the table above:

- Jumps and closures are supposed to have equal precedence. The [Rust Reference](https://doc.rust-lang.org/1.83.0/reference/expressions.html#expression-precedence) says so, and in Syn they do. There is no Rust syntax that would require making a precedence distinction between jumps and closures. But in rustc these were previously 2 distinct levels with the closure being lower, hence the parentheses around a closure inside a jump (but not a jump inside a closure).

- When a closure is written with an explicit return type, the grammar [requires](https://doc.rust-lang.org/1.83.0/reference/expressions/closure-expr.html) that the closure body consists of exactly one block expression, not any other arbitrary expression as usual for closures. Parsing of the closure body does not continue after the block expression. So in `|| { 0 }.clone()` the clone is inside the closure body and applies to `{ 0 }`, whereas in `|| -> _ { 0 }.clone()` the clone is outside and applies to the closure as a whole.

- Continue never needs parentheses. It was previously marked as having the lowest possible precedence but it should have been the highest, next to paths and loops and function calls, not next to jumps.
… r=wesleywiser

Arbitrary self types v2: niche deshadowing test

Arbitrary self types v2 attempts to detect cases where methods in an "outer" type (e.g. a smart pointer) might "shadow" methods in the referent.

There are a couple of cases where the current code makes no attempt to detect such shadowing. Both of these cases only apply if other unstable features are enabled.

Add a test, mostly for illustrative purposes, so we can see the shadowing cases that can occur.

Part of rust-lang#44874
r? ```@wesleywiser```
Arbitrary self types v2: no deshadow pre feature.

The arbitrary self types v2 work introduces a check for shadowed methods, whereby a method in some "outer" smart pointer type may called in preference to a method in the inner referent. This is bad if the outer pointer adds a method later, as it may change behavior, so we ensure we error in this circumstance.

It was intended that this new shadowing detection system only comes into play for users who enable the `arbitrary_self_types` feature (or of course everyone later if it's stabilized). It was believed that the new deshadowing code couldn't be reached without building the custom smart pointers that `arbitrary_self_types` enables, and therefore there was no risk of this code impacting existing users.

However, it turns out that cunning use of `Pin::get_ref` can cause this type of shadowing error to be emitted now. This commit adds a test for this case.

As we want this test to pass without arbitrary_self_types, but fail with it, I've split it into two files (one with run-pass and one without). If there's a better way I can amend it.

Part of rust-lang#44874

r? ```@wesleywiser```
…r=jieyouxu

Restrict `#[non_exaustive]` on structs with default field values

Do not allow users to apply `#[non_exaustive]` to a struct when they have also used default field values.
…er-errors

Also lint on option of function pointer comparisons

This PR is the first part of rust-lang#134536, ie. the linting on `Option<{fn ptr}>` in the `unpredictable_function_pointer_comparisons` lint, which isn't part of the lang nomination that the second part is going trough, and so should be able to be approved independently.

Related to rust-lang#134527
r? `@compiler-errors`
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs O-windows Operating system: Windows 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. labels Dec 21, 2024
@rustbot rustbot added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Dec 21, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=7

@bors
Copy link
Contributor

bors commented Dec 21, 2024

📌 Commit b7ac8d7 has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors 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 Dec 21, 2024
@bors
Copy link
Contributor

bors commented Dec 21, 2024

⌛ Testing commit b7ac8d7 with merge 13170cd...

@bors
Copy link
Contributor

bors commented Dec 21, 2024

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 21, 2024
@bors bors merged commit 13170cd into rust-lang:master Dec 21, 2024
7 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Dec 21, 2024
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#123604 Abstract ProcThreadAttributeList into its own struct b2f2011d15ca33686ec1a9a6af6b5419b2113c1e (link)
#128780 Add --doctest-compilation-args option to add compilation … ba8dfd37d8e39b7a6079a169d09f939cd9ff0835 (link)
#133782 Precedence improvements: closures and jumps 0ee322c019e17dd032770fba62cb04d9e737ad7d (link)
#134509 Arbitrary self types v2: niche deshadowing test 5877e4e67bce44c70badd5f68b48c68825e9c69f (link)
#134524 Arbitrary self types v2: no deshadow pre feature. aa370bfc7b3539d008c46f603e40eaf4e9481ed4 (link)
#134539 Restrict #[non_exaustive] on structs with default field v… 5456cddb2b09000d8fa0acb4d05f048386ac13d2 (link)
#134586 Also lint on option of function pointer comparisons b2f8864ff895b5307bcd27fbe2d49ab0abe1efd9 (link)

previous master: 5f23ef7d3f

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
Collaborator

Finished benchmarking commit (13170cd): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.2%] 7
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.5%, secondary 1.1%)

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.

mean range count
Regressions ❌
(primary)
1.8% [1.8%, 1.8%] 1
Regressions ❌
(secondary)
6.7% [6.7%, 6.7%] 1
Improvements ✅
(primary)
-0.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
-0.8% [-0.8%, -0.8%] 3
All ❌✅ (primary) 0.5% [-0.8%, 1.8%] 2

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: 767.681s -> 767.128s (-0.07%)
Artifact size: 330.22 MiB -> 330.26 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs merged-by-bors This PR was explicitly merged by bors. O-windows Operating system: Windows rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants