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 12 pull requests #133561

Merged
merged 33 commits into from
Nov 28, 2024
Merged

Rollup of 12 pull requests #133561

merged 33 commits into from
Nov 28, 2024

Conversation

GuillaumeGomez
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

grinapo and others added 30 commits August 22, 2024 14:29
Include warning about losing setuid/gid when chowning, per POSIX.
Linked to chown(2) manpage on the web which expands on chown call behaviour.
Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
…in collect_return_position_impl_trait_in_trait_tys
…', and '<*mut [T]>::as_mut_array' conversion methods;
Now that `HashSet::entry()` exists, we don't need to fake it with a map.
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Expand std::os::unix::fs::chown() doc with a warning

Include warning about losing setuid/gid when chowning, per POSIX.

It is about the underlying system call but it is rather useful to mention it in the help in case someone accidentally forgets (don't look at me :)).
…onstrained-params, r=lcnr

Delay a bug when encountering an impl with unconstrained generics in `codegen_select`

Despite its name, `codegen_select` is what powers `Instance::try_resolve`, which is used in pre-codegen contexts to try to resolve a method where possible. One place that it's used is in the "recursion MIR lint" that detects recursive MIR bodies.

If we encounter an impl in `codegen_select` that contains unconstrained generic parameters, we expect that impl to caused an error to be reported; however, there's no temporal guarantee that this error is reported *before* we call `codegen_select`. This is what a delayed bug is *for*, and this PR makes us use a delayed bug rather than asserting something about errors already having been emitted.

Fixes  rust-lang#126646
…lcnr

Actually use placeholder regions for trait method late bound regions in `collect_return_position_impl_trait_in_trait_tys`

So in rust-lang#113182, I introduced a "diagnostics improvement" in the form of 473c88d, which changes which signature we end up instantiating with placeholder regions and which signature we end up instantiating with fresh region vars so that we have placeholders corresponding to the names of the late-bound regions coming from the *impl*.

However, this is not sound, since now we're essentially no longer proving that *all* instantiations of the trait method are compatible with an instantiation of the impl method, but vice versa (which is weaker).  Let's look at the example `tests/ui/impl-trait/in-trait/do-not-imply-from-trait-impl.rs`:

```rust
trait MkStatic {
    fn mk_static(self) -> &'static str;
}

impl MkStatic for &'static str {
    fn mk_static(self) -> &'static str { self }
}

trait Foo {
    fn foo<'a: 'static, 'late>(&'late self) -> impl MkStatic;
}

impl Foo for str {
    fn foo<'a: 'static>(&'a self) -> impl MkStatic + 'static {
        self
    }
}

fn call_foo<T: Foo + ?Sized>(t: &T) -> &'static str {
    t.foo().mk_static()
}

fn main() {
    let s = call_foo(String::from("hello, world").as_str());
    println!("> {s}");
}
```

To collect RPITITs, we were previously instantiating the trait signature with infer vars (`fn(&'?0 str) -> ?1t` where `?1t` is the variable we use to infer the RPITIT) and the impl signature with placeholders (there are no late-bound regions in that signature, so we just have `fn(&'a str) -> Opaque`).

Equating the signatures works, since all we do is unify `?1t` with `Opaque` and `'?0` with `'a`. However, conceptually it *shouldn't* hold, since this definition is not valid for *all* instantiations of the trait method but just the one where `'0` (i.e. `'late`) is equal to `'a` :(

## So what

This PR effectively reverts 473c88d to fix the unsoundness.

Fixes rust-lang#133427
Also fixes rust-lang#133425, which is actually coincidentally another instance of this bug (but not one that is weaponized into UB, just one that causes an ICE in refinement checking).
Add `as_array` and `as_mut_array` conversion methods to slices.

Tracking issue: rust-lang#133508

This PR unstably implements the `as_array` and `as_mut_array` converters to `[T]`, `*const [T]`, and `*mut [T]`.
Check `xform_ret_ty` for WF in the new solver to improve method winnowing

This is a bit interesting. Method probing in the old solver is stronger than the new solver because eagerly normalizing types causes us to check their corresponding trait goals. This is important because we don't end up checking all of the where clauses of a method when method probing; just the where clauses of the impl. i.e., for:

```
impl Foo
where
   WC1,
{
    fn method()
    where
        WC2,
    {}
}
```

We only check WC1 and not WC2. This is because at this point in probing the method is instantiated w/ infer vars, and checking the where clauses in WC2 will lead to cycles if we were to check them (at least that's my understanding; I could investigate changing that in general, incl. in the old solver, but I don't have much confidence that it won't lead to really bad overflows.)

This PR chooses to emulate the old solver by just checking that the return type is WF. This is theoretically stronger, but I'm not too worried about it. I think we alternatively have several approaches we can take here, though this one seems the simplest. Thoughts?

r? lcnr
…ve-mir-borrowck, r=lcnr

Structurally resolve before applying projection in borrowck

As far as I can tell, all other `.normalize` calls in borrowck are noops and can remain that way. This is the only one that actually requires structurally resolving the type.

r? lcnr
extend group-forbid-always-trumps-cli test

Test it not just for a lint group, but also an individual lint, or when mixing the lint and the group. And test both orders in which the flags could be passed.
…=GuillaumeGomez

[rustdoc] Fix new clippy lints

Lots of small things that clippy lints about.

r? `@fmease`
rustc_span: Replace a `HashMap<_, ()>` with `HashSet`

Now that `HashSet::entry()` exists, we don't need to fake it with a map.
@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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-release Relevant to the release subteam, 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 Nov 28, 2024
@GuillaumeGomez
Copy link
Member Author

@bors r+ p=10 rollup=never

@bors
Copy link
Contributor

bors commented Nov 28, 2024

📌 Commit ed913fe has been approved by GuillaumeGomez

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 Nov 28, 2024
@bors
Copy link
Contributor

bors commented Nov 28, 2024

⌛ Testing commit ed913fe with merge f005c74...

@bors
Copy link
Contributor

bors commented Nov 28, 2024

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez
Pushing f005c74 to master...

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

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#129409 Expand std::os::unix::fs::chown() doc with a warning 63e6ea3ece95c8093a0c30f71f0cdd2a380c27d1 (link)
#133320 Add release notes for Rust 1.83.0 b3946219325291a1ca667c3e32701119e876fd12 (link)
#133368 Delay a bug when encountering an impl with unconstrained ge… bc71824e6925d28fb4ee7b551a925c0f80745a29 (link)
#133428 Actually use placeholder regions for trait method late boun… dbed79a82cbd8dbc16ed4292e425ca5bed40f62a (link)
#133512 Add as_array and as_mut_array conversion methods to sli… 4023ee8b6ff6eea45f4b6466b7747817bf1680c1 (link)
#133519 Check xform_ret_ty for WF in the new solver to improve me… 22932f1cd1fbf2dc22cbe66c56f030c6545dd080 (link)
#133520 Structurally resolve before applying projection in borrowck e459e8205f9a853850ae4587bd52c2904318c880 (link)
#133534 extend group-forbid-always-trumps-cli test d14efb6c12104df77382dd4fa03497457e65276b (link)
#133537 [rustdoc] Fix new clippy lints 42f1f29100d6eabf6f71cf9d2d7e229d81dcf2d8 (link)
#133543 [AIX] create shim for lgammaf_r 4a7ff31c797a98feeeec719de899a44fd7f650ef (link)
#133547 rustc_span: Replace a HashMap<_, ()> with HashSet 7d18cfc25e8689953723ed853eeafb641520d225 (link)
#133550 print generated doc paths 617f8b35dae102505dac43aa5b8c713d442c7d96 (link)

previous master: eddb717281

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 (f005c74): comparison URL.

Overall result: ❌ regressions - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.2% [0.1%, 0.3%] 3
Regressions ❌
(secondary)
0.6% [0.2%, 0.9%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.1%, 0.3%] 3

Max RSS (memory usage)

Results (primary -4.5%)

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.0% [1.0%, 1.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-7.2% [-10.9%, -3.6%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.5% [-10.9%, 1.0%] 3

Cycles

Results (primary -0.6%)

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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.6%, -0.6%] 1

Binary size

Results (primary 0.0%)

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)
0.0% [0.0%, 0.3%] 16
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.1%, 0.3%] 20

Bootstrap: 795.273s -> 792.58s (-0.34%)
Artifact size: 335.82 MiB -> 335.88 MiB (0.02%)

@rustbot rustbot added the perf-regression Performance regression. label Nov 28, 2024
@rylev
Copy link
Member

rylev commented Dec 4, 2024

The regressions in the primary benchmarks reverted back to their previous mean after a few PRs so I don't think this is necessarily worth looking further into.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend merged-by-bors This PR was explicitly merged by bors. O-unix Operating system: Unix-like perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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-release Relevant to the release subteam, 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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.