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 #120875

Closed
wants to merge 20 commits into from

Commits on Jan 28, 2024

  1. Configuration menu
    Copy the full SHA
    9a819ab View commit details
    Browse the repository at this point in the history

Commits on Feb 9, 2024

  1. Clarify that atomic and regular integers can differ in alignment

    The documentation for atomic integers says that they have the "same
    in-memory representation" as their underlying integers. This might be
    misconstrued as implying that they have the same layout. Therefore,
    clarify that atomic integers' alignment is equal to their size.
    LegionMammal978 committed Feb 9, 2024
    Configuration menu
    Copy the full SHA
    c94bbb2 View commit details
    Browse the repository at this point in the history
  2. wasm: Store rlib metadata in wasm object files

    The goal of this commit is to remove warnings using LLVM tip-of-tree
    `wasm-ld`. In llvm/llvm-project#78658 the `wasm-ld` LLD driver no longer
    looks at archive indices and instead looks at all the objects in
    archives. Previously `lib.rmeta` files were simply raw rustc metadata
    bytes, not wasm objects, meaning that `wasm-ld` would emit a warning
    indicating so.
    
    WebAssembly targets previously passed `--fatal-warnings` to `wasm-ld` by
    default which meant that if Rust were to update to LLVM 18 then all wasm
    targets would not work. This immediate blocker was resolved in
    rust-lang#120278 which removed `--fatal-warnings` which enabled a
    theoretical update to LLVM 18 for wasm targets. This current state is
    ok-enough for now because rustc squashes all linker output by default if
    it doesn't fail. This means, for example, that rustc squashes all the
    linker warnings coming out of `wasm-ld` about `lib.rmeta` files with
    LLVM 18. This again isn't a pressing issue because the information is
    all hidden, but it runs the risk of being annoying if another linker
    error were to happen and then the output would have all these unrelated
    warnings that couldn't be fixed.
    
    Thus, this PR comes into the picture. The goal of this PR is to resolve
    these warnings by using the WebAssembly object file format on wasm
    targets instead of using raw rustc metadata. When I first implemented
    the rlib-in-objects scheme in rust-lang#84449 I remember either concluding that
    `wasm-ld` would either include the metadata in the output or I thought
    we didn't have to do anything there at all. I think I was wrong on both
    counts as `wasm-ld` does not include the metadata in the final output
    unless the object is referenced and we do actually need to do something
    to resolve these warnings.
    
    This PR updates the object file format containing rustc metadata on
    WebAssembly targets to be an actual WebAssembly file. This enables the
    `wasm` feature of the `object` crate to be able to read the custom
    section in the same manner as other platforms, but currently `object`
    doesn't support writing wasm object files so a handwritten encoder is
    used instead.
    
    The only caveat I know of with this is that if `wasm-ld` does indeed
    look at the object file then the metadata will be included in the final
    output. I believe the only thing that could cause that at this time is
    `--whole-archive` which I don't think is passed for rlibs. I would
    clarify that I'm not 100% certain about this, however.
    alexcrichton committed Feb 9, 2024
    Configuration menu
    Copy the full SHA
    74481b3 View commit details
    Browse the repository at this point in the history
  3. Update src/tools/tidy/src/deps.rs

    Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
    alexcrichton and bjorn3 authored Feb 9, 2024
    Configuration menu
    Copy the full SHA
    4f3348d View commit details
    Browse the repository at this point in the history
  4. Loosen an assertion to account for stashed errors.

    The meaning of this assertion changed in rust-lang#120828 when the meaning of
    `has_errors` changed to exclude stashed errors. Evidently the new
    meaning is too restrictive.
    
    Fixes rust-lang#120856.
    nnethercote committed Feb 9, 2024
    Configuration menu
    Copy the full SHA
    bb60ded View commit details
    Browse the repository at this point in the history

Commits on Feb 10, 2024

  1. Configuration menu
    Copy the full SHA
    3d4a9f5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cf1096e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    973bbfb View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    fde695a View commit details
    Browse the repository at this point in the history
  5. Remove unused fn

    compiler-errors committed Feb 10, 2024
    Configuration menu
    Copy the full SHA
    e6f5af9 View commit details
    Browse the repository at this point in the history
  6. Allow restricted trait impls in macros with min_specialization

    Implementing traits marked with `#[rustc_specialization_trait]` normally
    requires (min-)specialization to be enabled for the enclosing crate.
    
    With this change, that permission can also be granted by an
    `allow_internal_unstable` attribute on the macro that generates the impl.
    Zalathar committed Feb 10, 2024
    Configuration menu
    Copy the full SHA
    7b73e4f View commit details
    Browse the repository at this point in the history
  7. Remove unnecessary min_specialization after bootstrap

    These crates all needed specialization for `newtype_index!`, which will no
    longer be necessary when the current nightly eventually becomes the next
    bootstrap compiler.
    Zalathar committed Feb 10, 2024
    Configuration menu
    Copy the full SHA
    a2479a4 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#117614 - RalfJung:static-mut-refs, r=davidt…

    …wco,oli-obk
    
    static mut: allow mutable reference to arbitrary types, not just slices and arrays
    
    For historical reasons, we allow this:
    ```rust
    static mut ARRAY: &'static mut [isize] = &mut [1];
    ```
    However, we do not allow this:
    ```rust
    static mut INT: &'static mut isize = &mut 1;
    ```
    
    I think that's terribly inconsistent. I don't care much for `static mut`, but we have to keep it around for backwards compatibility and so we have to keep supporting it properly in the compiler. In recent refactors of how we deal with mutability of data in `static` and `const`, I almost made a fatal mistake since I tested `static mut INT: &'static mut isize = &mut 1` and concluded that we don't allow such `'static` mutable references even inside `static mut`. After all, nobody would expect this to be allowed only for arrays and slices, right?!?? So for the sake of our own sanity, and of whoever else reverse engineers these rules in the future to understand what the Rust compiler accepts or does not accept, I propose that we accept this for all types, not just arrays and slices.
    matthiaskrgr authored Feb 10, 2024
    Configuration menu
    Copy the full SHA
    1798caf View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#120588 - alexcrichton:wasm-rmeta-object, r=…

    …wesleywiser
    
    wasm: Store rlib metadata in wasm object files
    
    The goal of this commit is to remove warnings using LLVM tip-of-tree `wasm-ld`. In llvm/llvm-project#78658 the `wasm-ld` LLD driver no longer looks at archive indices and instead looks at all the objects in archives. Previously `lib.rmeta` files were simply raw rustc metadata bytes, not wasm objects, meaning that `wasm-ld` would emit a warning indicating so.
    
    WebAssembly targets previously passed `--fatal-warnings` to `wasm-ld` by default which meant that if Rust were to update to LLVM 18 then all wasm targets would not work. This immediate blocker was resolved in rust-lang#120278 which removed `--fatal-warnings` which enabled a theoretical update to LLVM 18 for wasm targets. This current state is ok-enough for now because rustc squashes all linker output by default if it doesn't fail. This means, for example, that rustc squashes all the linker warnings coming out of `wasm-ld` about `lib.rmeta` files with LLVM 18. This again isn't a pressing issue because the information is all hidden, but it runs the risk of being annoying if another linker error were to happen and then the output would have all these unrelated warnings that couldn't be fixed.
    
    Thus, this PR comes into the picture. The goal of this PR is to resolve these warnings by using the WebAssembly object file format on wasm targets instead of using raw rustc metadata. When I first implemented the rlib-in-objects scheme in rust-lang#84449 I remember either concluding that `wasm-ld` would either include the metadata in the output or I thought we didn't have to do anything there at all. I think I was wrong on both counts as `wasm-ld` does not include the metadata in the final output unless the object is referenced and we do actually need to do something to resolve these warnings.
    
    This PR updates the object file format containing rustc metadata on WebAssembly targets to be an actual WebAssembly file. To avoid bringing in any new dependencies I've opted to hand-code this encoding at this time. If the object gets more complicated though it'd probably be best to pull in `wasmparser` and `wasm-encoder`. For now though there's two adjacent functions reading/writing wasm.
    
    The only caveat I know of with this is that if `wasm-ld` does indeed look at the object file then the metadata will be included in the final output. I believe the only thing that could cause that at this time is `--whole-archive` which I don't think is passed for rlibs. I would clarify that I'm not 100% certain about this, however.
    matthiaskrgr authored Feb 10, 2024
    Configuration menu
    Copy the full SHA
    37893f9 View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#120719 - compiler-errors:no-dyn-atb, r=lcnr

    Remove support for `associated_type_bound` nested in `dyn` types
    
    These necessarily desugar to `impl Trait`, which is inconsistent with the `associated_type_bound` feature after rust-lang#120584.
    
    This PR keeps the `is_in_dyn_type` hack, which kind of makes me sad. Ideally, we'd be validating that no object types have associated type bounds somewhere else. Unfortunately, we can't do this later during astconv (i think?), nor can we do it earlier during ast validation (i think?) because of the feature gating of ATB being a *warning* rather than an *error*. Let me know if you have thoughts about this.
    
    r? lcnr
    matthiaskrgr authored Feb 10, 2024
    Configuration menu
    Copy the full SHA
    9b3c5e1 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#120823 - LegionMammal978:clarify-atomic-ali…

    …gn, r=RalfJung
    
    Clarify that atomic and regular integers can differ in alignment
    
    The documentation for atomic integers says that they have the "same in-memory representation" as their underlying integers. This might be misconstrued as implying that they have the same layout. Therefore, clarify that atomic integers' alignment is equal to their size.
    matthiaskrgr authored Feb 10, 2024
    Configuration menu
    Copy the full SHA
    787a65a View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#120859 - nnethercote:fix-120856, r=oli-obk

    Loosen an assertion to account for stashed errors.
    
    The meaning of this assertion changed in rust-lang#120828 when the meaning of `has_errors` changed to exclude stashed errors. Evidently the new meaning is too restrictive.
    
    Fixes rust-lang#120856.
    
    r? `@oli-obk`
    matthiaskrgr authored Feb 10, 2024
    Configuration menu
    Copy the full SHA
    bf8960d View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#120865 - saethlin:missing-o-files, r=nnethe…

    …rcote
    
    Turn the "no saved object file in work product" ICE into a translatable fatal error
    
    I don't know if it's fair to say this fixes rust-lang#120854 but it surely makes the error reporting better and should encourage people with good instincts like `@CinchBlue.`
    matthiaskrgr authored Feb 10, 2024
    Configuration menu
    Copy the full SHA
    682b291 View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#120866 - Zalathar:no-min-spec, r=compiler-e…

    …rrors
    
    Remove unnecessary `#![feature(min_specialization)]`
    
    As of rust-lang#119963 and rust-lang#120676, we can now rely on `newtype_index!` having `#[allow_internal_unstable(min_specialization)]`, so there are a few compiler crates that no longer need to include min-spec in their own crate features.
    
    ---
    
    Some of the expansions of `newtype_index!` still appear to require min-spec in the crate features. I think this is because `#[orderable]` causes the expansion to include an implementation of `TrustedStep`, which is flagged with `#[rustc_specialization_trait]`, and for whatever reason that isn't permitted by allow-internal-unstable. So this PR only touches the crates where that isn't the case.
    matthiaskrgr authored Feb 10, 2024
    Configuration menu
    Copy the full SHA
    479cf6a View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#120870 - Zalathar:allow-min-spec, r=oli-obk

    Allow restricted trait impls under `#[allow_internal_unstable(min_specialization)]`
    
    This is a follow-up to rust-lang#119963 and a companion to rust-lang#120866, though it can land independently from the latter.
    
    ---
    
    We have several compiler crates that only enable `#[feature(min_specialization)]` because it is required by their expansions of `newtype_index!`, in order to implement traits marked with `#[rustc_specialization_trait]`.
    
    This PR allows those traits to be implemented internally by macros with `#[allow_internal_unstable(min_specialization)]`, without needing specialization to be enabled in the enclosing crate.
    matthiaskrgr authored Feb 10, 2024
    Configuration menu
    Copy the full SHA
    0bf346e View commit details
    Browse the repository at this point in the history