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 9 pull requests #125955

Closed
wants to merge 24 commits into from
Closed

Conversation

Noratrieb
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

beetrees and others added 24 commits April 28, 2024 19:27
Some of the bootstrap logics should be ignored during unit tests because they either
make the tests take longer or cause them to fail. Therefore we need to be able to exclude
them from the bootstrap when it's called by unit tests. This change introduces a new feature
called `bootstrap-self-test`, which is enabled on bootstrap unit tests by default. This allows
us to keep the logic separate between compiler builds and bootstrap tests without needing messy
workarounds (like checking if target names match those in the unit tests).

Signed-off-by: onur-ozkan <[email protected]>
While the semantic intent of a OnceCell/OnceLock is that it can only be written
to once (upon init), the fact of the matter is that both these types offer a
`take(&mut self) -> Option<T>` mechanism that, when successful, resets the cell
to its initial state, thereby technically allowing it to be written to again.

Despite the fact that this can only happen with a mutable reference (generally
only used during the construction of the OnceCell/OnceLock), it would be
incorrect to say that the type itself as a whole categorically prevents being
initialized or written to more than once (since it is possible to imagine an
identical type only without the `take()` method that actually fulfills that
contract).

To clarify, change "that cannot be.." to "that nominally cannot.." and add a
note to OnceCell about what can be done with an `&mut Self` reference.
…ference-self, r=BoxyUwU

Item bounds can reference self projections and still be object safe

### Background

Currently, we have some interesting rules about where `Self` is allowed to be mentioned in objects. Specifically, we allow mentioning `Self` behind associated types (e.g. `fn foo(&self) -> Self::Assoc`) only if that `Self` type comes from the trait we're defining or its supertraits:

```
trait Foo {
  fn good() -> Self::Assoc; // GOOD :)

  fn bad() -> <Self as OtherTrait>::Assoc; // BAD!
}
```

And more specifically, these `Self::Assoc` projections are *only* allowed to show up in:
  * (A1) Method signatures
  * (A2) Where clauses on traits, GATs and methods

But `Self::Assoc` projections are **not** allowed to show up in:
  * (B1) Supertrait bounds (specifically: all *super-predicates*, which includes the projections that come from elaboration, and not just the traits themselves).
  * (B2) Item bounds of associated types

The reason for (B1) is interesting: specifically, it arises from the fact that we currently eagerly elaborate all projection predicates into the object, so if we had the following code:

```
trait Sub<Assoc = Self::SuperAssoc> {}
trait Super {
    type SuperAssoc;
}
```

Then given `dyn Sub<SuperAssoc = i32>` we would need to have a type that is substituted into itself an infinite number of times[^1], like `dyn Sub<SuperAssoc = i32, Assoc = <dyn Sub<SuperAssoc = i32, Assoc = <dyn Sub<SuperAssoc = i32, Assoc = <... as Super>::SuperAssoc> as Super>::SuperAssoc> as Super>::SuperAssoc>`, i.e. the fixed-point of: `type T = dyn Sub<SuperAssoc = i32, Assoc = <T as Super>::SuperAssoc>`.

Similarly for (B2), we restrict mentioning `Self::Assoc` in associated type item bounds, which is the cause for rust-lang#122798. However, there is **no reason** for us to do so, since item bounds never show up structurally in the `dyn Trait` object type.

#### What?

This PR relaxes the check for item bounds so that `Self` may be mentioned behind associated types in the same cases that they currently work for method signatures (A1) and where clauses (A2).

#### Why?

Fixes rust-lang#122798. Removes a subtle and confusing inconsistency for the code mentioned in that issue.

This is sound because we only assemble alias bounds for rigid projections, and all projections coming from an object self type are not rigid, since all associated types should be specified by the type.

This is also desirable because we can do this via supertraits already. In rust-lang#122789, it is noted that an item bound of `Eq` already works, just not `PartialEq` because of the default item bound. This is weird and should be fixed.

#### Future work

We could make the check for `Self` in super-predicates more sophisticated as well, only erroring if `Self` shows up in a projection super-predicate.

[^1]: This could be fixed by some sort of structural replacement or eager normalization, but I don't think it's necessary currently.
…, r=ehuss

Add tracking issue and unstable book page for `"vectorcall"` ABI

Originally added in 2015 by rust-lang#30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now.

Tracking issue: rust-lang#124485
…albertlarsan68

bootstrap: implement new feature `bootstrap-self-test`

Some of the bootstrap logics should be ignored during unit tests because they either make the tests take longer or cause them to fail. Therefore we need to be able to exclude them from the bootstrap when it's called by unit tests. This change introduces a new feature called `bootstrap-self-test`, which is enabled on bootstrap unit tests by default. This allows us to keep the logic separate between compiler builds and bootstrap tests without needing messy workarounds (like checking if target names match those in the unit tests).

Also, resolves rust-lang#122090 (without having to create separate modules)
Change pedantically incorrect OnceCell/OnceLock wording

While the semantic intent of a OnceCell/OnceLock is that it can only be written to once (upon init), the fact of the matter is that both these types offer a `take(&mut self) -> Option<T>` mechanism that, when successful, resets the cell to its initial state, thereby [technically allowing it to be written to again](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=415c023a6ae1ef35f371a2d3bb1aa735)

Despite the fact that this can only happen with a mutable reference (generally only used during the construction of the OnceCell/OnceLock), it would be incorrect to say that the type itself as a whole *categorically* prevents being initialized or written to more than once (since it is possible to imagine an identical type only without the `take()` method that actually fulfills that contract).

To clarify, change "that cannot be.." to "that nominally cannot.." and add a note to OnceCell about what can be done with an `&mut Self` reference.

`@rustbot` label +A-rustdocs
…huss

ARM Target Docs Update

Updates the ARM target docs, drawing more attention to the `arm-none-eabi` target group by placing all targets *within* that group as a sub-list in the Table of Contents.

Also updates the `armv4t-none-eabi` page (maintainer signoff: I'm that target's maintainer) to clarify that the page covers the arm version and the thumb version of the target, but that the target group page has the full info because there's nothing really specific to say for those targets.
Align `Term` methods with `GenericArg` methods, add `Term::expect_*`

* `Term::ty` -> `Term::as_type`.
* `Term::ct` -> `Term::as_const`.
* Adds `Term::expect_type` and `Term::expect_const`, and uses them in favor of `.ty().unwrap()`, etc.

I could also shorten these to `as_ty` and then do `GenericArg::as_ty` as well, but I do think the `as_` is important to signal that this is a conversion method, and not a getter, like `Const::ty` is.

r? types
…=petrochenkov

Handle no values cfgs with `--print=check-cfg`

This PR fix a bug with `--print=check-cfg`, where no values cfgs where not printed since we only printed cfgs that had at least one values.

The representation I choose is `CFG=`, since it doesn't correspond to any valid config, it also IMO nicely complements the `values()` (to indicate no values). Representing the absence of value by the absence of the value.

So for `cfg(feature, values())` we would print `feature=`.

I also added the missing tracking issue number in the doc.

r? `@petrochenkov`
…ket-impls, r=GuillaumeGomez

rustdoc: add a regression test for a former blanket impl synthesis ICE

Fixes rust-lang#119792 (also passes in rust-lang#125907 in case you were wondering).

r? rustdoc
@rustbot rustbot added 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-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 4, 2024
@rustbot rustbot added WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) rollup A PR which is a rollup labels Jun 4, 2024
@Noratrieb
Copy link
Member Author

r? bors

@Noratrieb
Copy link
Member Author

amazing

@bors r+ rollup=never p=9

@bors
Copy link
Contributor

bors commented Jun 4, 2024

📌 Commit 292985b has been approved by Nilstrieb

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 Jun 4, 2024
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Download action repository 'msys2/[email protected]' (SHA:cc11e9188b693c2b100158c3322424c4cc1dadea)
Download action repository 'actions/checkout@v4' (SHA:a5ac7e51b41094c92402da3b24376905380afc29)
Download action repository 'actions/setup-python@v5' (SHA:82c7e631bb3cdc910f68e0081d67478d79c6982d)
Download action repository 'actions/upload-artifact@v4' (SHA:65462800fd760344b1a7b4382951275a0abb4808)
Complete job name: PR - mingw-check-tidy
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
---
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

COPY host-x86_64/mingw-check/reuse-requirements.txt /tmp/
RUN pip3 install --no-deps --no-cache-dir --require-hashes -r /tmp/reuse-requirements.txt \
    && pip3 install virtualenv
COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/

# NOTE: intentionally uses python2 for x.py so we can test it still works.
# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
           --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
#    pip-compile --allow-unsafe --generate-hashes reuse-requirements.in
---

#9 [7/8] COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
#9 CACHED

#10 [6/8] RUN pip3 install --no-deps --no-cache-dir --require-hashes -r /tmp/reuse-requirements.txt     && pip3 install virtualenv

#11 [5/8] COPY host-x86_64/mingw-check/reuse-requirements.txt /tmp/
#11 CACHED

---
DirectMap4k:      225216 kB
DirectMap2M:     8163328 kB
DirectMap1G:    10485760 kB
##[endgroup]
Executing TIDY_PRINT_DIFF=1 python2.7 ../x.py test            --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint
+ TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://ci-artifacts.rust-lang.org/rustc-builds-alt/90d6255d82dcfd0b73dbaa4f172a7f9886dcc2c1/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
extracting /checkout/obj/build/cache/llvm-90d6255d82dcfd0b73dbaa4f172a7f9886dcc2c1-true/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz to /checkout/obj/build/x86_64-unknown-linux-gnu/ci-llvm
---
   Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
    Finished `release` profile [optimized] target(s) in 25.81s
##[endgroup]
fmt check
##[error]Diff in /checkout/src/bootstrap/src/core/config/tests.rs at line 14:
 
 fn parse(config: &str) -> Config {
-    Config::parse_inner(
-        &[
-        &[
-            "check".to_string(),
-            "--config=/does/not/exist".to_string(),
-        ],
-        |&_| toml::from_str(&config).unwrap(),
-    )
+    Config::parse_inner(&["check".to_string(), "--config=/does/not/exist".to_string()], |&_| {
+        toml::from_str(&config).unwrap()
 }
 
 #[test]
 #[test]
##[error]Diff in /checkout/src/bootstrap/src/core/config/tests.rs at line 232:
             .and_then(|table: toml::Value| TomlConfig::deserialize(table))
     }
-    Config::parse_inner(
-        &[
-            "check".to_owned(),
-            "check".to_owned(),
-        ],
-        get_toml,
-    );
+    Config::parse_inner(&["check".to_owned()], get_toml);
 
 #[test]
 #[test]
##[error]Diff in /checkout/src/bootstrap/src/core/config/config.rs at line 1258:
         // has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path.
         cmd.arg("rev-parse").arg("--show-cdup");
         // Discard stderr because we expect this to fail when building from a tarball.
-        let output = cmd.stderr(std::process::Stdio::null()).output().ok().and_then(|output| {
-            if output.status.success() {
-                Some(output)
-                None
-            }
-        });
+        let output = cmd
+        let output = cmd
+            .stderr(std::process::Stdio::null())
+            .output()
+            .ok()
+            .and_then(|output| if output.status.success() { Some(output) } else { None });
         if let Some(output) = output {
             let git_root_relative = String::from_utf8(output.stdout).unwrap();
             // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes,
##[error]Diff in /checkout/src/bootstrap/src/core/config/config.rs at line 2355:
             .get(&target)
             .and_then(|t| t.split_debuginfo)
             .or_else(|| {
-                if self.build == target {
-                    self.rust_split_debuginfo_for_build_triple
-                    None
-                }
-                }
+                if self.build == target { self.rust_split_debuginfo_for_build_triple } else { None }
             })
             .unwrap_or_else(|| SplitDebuginfo::default_for_platform(target))
     }
##[error]Diff in /checkout/src/bootstrap/src/core/config/config.rs at line 2412:
         let stage0_version =
             semver::Version::parse(stage0_output.next().unwrap().split('-').next().unwrap().trim())
-        let source_version =
-        let source_version =
-            semver::Version::parse(fs::read_to_string(self.src.join("src/version")).unwrap().trim())
+        let source_version = semver::Version::parse(
+        let source_version = semver::Version::parse(
+            fs::read_to_string(self.src.join("src/version")).unwrap().trim(),
+        .unwrap();
+        .unwrap();
         if !(source_version == stage0_version
             || (source_version.major == stage0_version.major
                 && (source_version.minor == stage0_version.minor
fmt: checked 4832 files
fmt error: Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/checkout" "--edition" "2021" "--unstable-features" "--skip-children" "--check" "/checkout/library/std/src/sys/pal/solid/net.rs" "/checkout/library/std/src/sys/pal/solid/fs.rs" "/checkout/library/std/src/sys/pal/solid/time.rs" "/checkout/library/std/src/sys/pal/solid/thread_local_dtor.rs" "/checkout/library/std/src/sys/pal/solid/os.rs" "/checkout/library/std/src/sys/mod.rs" "/checkout/src/bootstrap/build.rs" "/checkout/library/std/src/sys/thread_local/mod.rs" "/checkout/library/std/src/sys/thread_local/os_local.rs" "/checkout/library/std/src/sys/thread_local/static_local.rs" "/checkout/src/bootstrap/src/lib.rs" "/checkout/library/std/src/sys/thread_local/fast_local/mod.rs" "/checkout/library/std/src/sys/thread_local/fast_local/lazy.rs" "/checkout/library/std/src/sys/thread_local/fast_local/eager.rs" "/checkout/library/std/src/sys/cmath.rs" "/checkout/src/bootstrap/src/bin/rustc.rs" "/checkout/src/bootstrap/src/bin/sccache-plus-cl.rs" "/checkout/src/bootstrap/src/bin/rustdoc.rs" "/checkout/src/bootstrap/src/bin/main.rs" "/checkout/library/std/src/sys/personality/dwarf/eh.rs" "/checkout/library/std/src/sys/personality/dwarf/mod.rs" "/checkout/library/std/src/sys/personality/dwarf/tests.rs" "/checkout/library/std/src/sys/personality/mod.rs" "/checkout/library/std/src/sys/personality/emcc.rs" "/checkout/library/std/src/sys/personality/gcc.rs" "/checkout/src/bootstrap/src/core/config/mod.rs" "/checkout/src/bootstrap/src/core/config/flags.rs" "/checkout/src/bootstrap/src/core/config/tests.rs" "/checkout/src/bootstrap/src/core/config/config.rs" "/checkout/src/bootstrap/src/core/metadata.rs" "/checkout/src/bootstrap/src/core/builder.rs" "/checkout/src/bootstrap/src/core/mod.rs" "/checkout/library/std/src/sys/sync/condvar/no_threads.rs" "/checkout/library/std/src/sys/sync/condvar/mod.rs" "/checkout/library/std/src/sys/sync/condvar/pthread.rs" "/checkout/library/std/src/sys/sync/condvar/futex.rs" "/checkout/library/std/src/sys/sync/condvar/xous.rs" "/checkout/library/std/src/sys/sync/condvar/sgx.rs" "/checkout/library/std/src/sys/sync/condvar/itron.rs" "/checkout/library/std/src/sys/sync/condvar/teeos.rs" "/checkout/library/std/src/sys/sync/condvar/windows7.rs" "/checkout/library/std/src/sys/sync/mod.rs" "/checkout/library/std/src/sys/sync/rwlock/no_threads.rs" "/checkout/library/std/src/sys/sync/rwlock/solid.rs" "/checkout/library/std/src/sys/sync/rwlock/mod.rs" "/checkout/library/std/src/sys/sync/rwlock/futex.rs" "/checkout/library/std/src/sys/sync/rwlock/queue.rs" "/checkout/library/std/src/sys/sync/rwlock/teeos.rs" "/checkout/library/std/src/sys/sync/once/no_threads.rs" "/checkout/library/std/src/sys/sync/once/mod.rs" "/checkout/library/std/src/sys/sync/once/futex.rs" "/checkout/library/std/src/sys/sync/once/queue.rs" "/checkout/src/bootstrap/src/core/build_steps/synthetic_targets.rs" "/checkout/src/bootstrap/src/core/build_steps/suggest.rs" "/checkout/src/bootstrap/src/core/build_steps/vendor.rs" "/checkout/src/bootstrap/src/core/build_steps/compile.rs" "/checkout/src/bootstrap/src/core/build_steps/doc.rs" "/checkout/src/bootstrap/src/core/build_steps/mod.rs" "/checkout/src/bootstrap/src/core/build_steps/clippy.rs" "/checkout/src/bootstrap/src/core/build_steps/format.rs" "/checkout/src/bootstrap/src/core/build_steps/dist.rs" "/checkout/src/bootstrap/src/core/build_steps/setup.rs" "/checkout/src/bootstrap/src/core/build_steps/run.rs" "/checkout/library/std/src/sys/pal/solid/env.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
  local time: Tue Jun  4 06:06:37 UTC 2024
  network time: Tue, 04 Jun 2024 06:06:38 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@Noratrieb
Copy link
Member Author

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 4, 2024
@Noratrieb Noratrieb closed this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-unix Operating system: Unix-like rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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-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.