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 8 pull requests #130964

Merged
merged 26 commits into from
Sep 28, 2024
Merged

Rollup of 8 pull requests #130964

merged 26 commits into from
Sep 28, 2024

Commits on Sep 23, 2024

  1. Fix io::Take::read_buf

    a1phyr committed Sep 23, 2024
    Configuration menu
    Copy the full SHA
    ba3b536 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    04710e2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bf76888 View commit details
    Browse the repository at this point in the history
  4. Add tests

    a1phyr committed Sep 23, 2024
    Configuration menu
    Copy the full SHA
    4b8a66c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d77664b View commit details
    Browse the repository at this point in the history

Commits on Sep 27, 2024

  1. Configuration menu
    Copy the full SHA
    d4ee408 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fa3215d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0bf9289 View commit details
    Browse the repository at this point in the history
  4. rustdoc: update ProcMacro docs section on helper attributes

    I believe the mention of attribute macros in the section on proc macro helper attributes is erroneous. As far as I can tell, attribute macros cannot define helper attributes.
    
    The following attribute macro is not valid (fails to build), no matter how I try to define (or skip defining) the helpers:
    ```rust
    #[proc_macro_attribute(attributes(helper))]
    pub fn attribute_helpers(_attr: TokenStream, item: TokenStream) -> TokenStream {
        item
    }
    ```
    
    The [language reference](https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros) also doesn't seem to mention attribute macro helpers. The helpers subsection is inside the section on derive macros.
    obi1kenobi authored Sep 27, 2024
    Configuration menu
    Copy the full SHA
    3b9db47 View commit details
    Browse the repository at this point in the history
  5. Revert "ci: Try to remove unused Xcode dirs"

    This reverts commit 06f49f6.
    workingjubilee committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    282d044 View commit details
    Browse the repository at this point in the history
  6. Partially revert "ci: Use mv instead of cp in upload step"

    This partially reverts commit fe7c97c.
    
    I kept a mv, not a cp, for the one that shuffles major artifacts around,
    because the size of those artifacts are big enough to matter, sometimes.
    I don't think the diagnostic info will be that heavy, by comparison.
    workingjubilee committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    a2a4ea0 View commit details
    Browse the repository at this point in the history
  7. add even more tests for ptr-to-ptr casts on trait objects

    Lukas Markeffsky committed Sep 27, 2024
    Configuration menu
    Copy the full SHA
    8302f2e View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    53f45c4 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    4fb097a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    d753aba View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    bcf8cf2 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    a1fbf25 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    19d5568 View commit details
    Browse the repository at this point in the history

Commits on Sep 28, 2024

  1. Rollup merge of rust-lang#125404 - a1phyr:fix-read_buf-uses, r=workin…

    …gjubilee
    
    Fix `read_buf` uses in `std`
    
    Following lib-team decision here: rust-lang#78485 (comment)
    
    Guard against the pathological behavior of both returning an error and performing a read.
    matthiaskrgr authored Sep 28, 2024
    Configuration menu
    Copy the full SHA
    6e9db86 View commit details
    Browse the repository at this point in the history
  2. Rollup merge of rust-lang#130866 - compiler-errors:dyn-instantiate-bi…

    …nder, r=lcnr
    
    Allow instantiating object trait binder when upcasting
    
    This PR fixes two bugs (that probably need an FCP).
    
    ### We use equality rather than subtyping for upcasting dyn conversions
    
    This code should be valid:
    
    ```rust
    #![feature(trait_upcasting)]
    
    trait Foo: for<'h> Bar<'h> {}
    trait Bar<'a> {}
    
    fn foo(x: &dyn Foo) {
        let y: &dyn Bar<'static> = x;
    }
    ```
    But instead:
    
    ```
    error[E0308]: mismatched types
     --> src/lib.rs:7:32
      |
    7 |     let y: &dyn Bar<'static> = x;
      |                                ^ one type is more general than the other
      |
      = note: expected existential trait ref `for<'h> Bar<'h>`
                 found existential trait ref `Bar<'_>`
    ```
    
    And so should this:
    
    ```rust
    #![feature(trait_upcasting)]
    
    fn foo(x: &dyn for<'h> Fn(&'h ())) {
        let y: &dyn FnOnce(&'static ()) = x;
    }
    ```
    
    But instead:
    
    ```
    error[E0308]: mismatched types
     --> src/lib.rs:4:39
      |
    4 |     let y: &dyn FnOnce(&'static ()) = x;
      |                                       ^ one type is more general than the other
      |
      = note: expected existential trait ref `for<'h> FnOnce<(&'h (),)>`
                 found existential trait ref `FnOnce<(&(),)>`
    ```
    
    Specifically, both of these fail because we use *equality* when comparing the supertrait to the *target* of the unsize goal. For the first example, since our supertrait is `for<'h> Bar<'h>` but our target is `Bar<'static>`, there's a higher-ranked type mismatch even though we *should* be able to instantiate that supertrait binder when upcasting. Similarly for the second example.
    
    ### New solver uses equality rather than subtyping for no-op (i.e. non-upcasting) dyn conversions
    
    This code should be valid in the new solver, like it is with the old solver:
    
    ```rust
    // -Znext-solver
    
    fn foo<'a>(x: &mut for<'h> dyn Fn(&'h ())) {
       let _: &mut dyn Fn(&'a ()) = x;
    }
    ```
    
    But instead:
    
    ```
    error: lifetime may not live long enough
     --> <source>:2:11
      |
    1 | fn foo<'a>(x: &mut dyn for<'h> Fn(&'h ())) {
      |        -- lifetime `'a` defined here
    2 |    let _: &mut dyn Fn(&'a ()) = x;
      |           ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
      |
      = note: requirement occurs because of a mutable reference to `dyn Fn(&())`
    ```
    
    Specifically, this fails because we try to coerce `&mut dyn for<'h> Fn(&'h ())` to `&mut dyn Fn(&'a ())`, which registers an `dyn for<'h> Fn(&'h ()): dyn Fn(&'a ())` goal. This fails because the new solver uses *equating* rather than *subtyping* in `Unsize` goals.
    
    This is *mostly* not a problem... You may wonder why the same code passes on the new solver for immutable references:
    
    ```
    // -Znext-solver
    
    fn foo<'a>(x: &dyn Fn(&())) {
       let _: &dyn Fn(&'a ()) = x; // works
    }
    ```
    
    That's because in this case, we first try to coerce via `Unsize`, but due to the leak check the goal fails. Then, later in coercion, we fall back to a simple subtyping operation, which *does* work.
    
    Since `&T` is covariant over `T`, but `&mut T` is invariant, that's where the discrepancy between these two examples crops up.
    
    ---
    
    r? lcnr or reassign :D
    matthiaskrgr authored Sep 28, 2024
    Configuration menu
    Copy the full SHA
    4e510da View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#130922 - tyilo:udp-unspecified, r=ibraheemdev

    Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4
    matthiaskrgr authored Sep 28, 2024
    Configuration menu
    Copy the full SHA
    9c4b81c View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#130924 - surechen:fix_130851, r=compiler-er…

    …rors
    
    Make clashing_extern_declarations considering generic args for ADT field
    
    In following example, G<u16> should be recognized as different from G<u32> :
    
    ```rust
    #[repr(C)] pub struct G<T> { g: [T; 4] }
    
    pub mod x { extern "C" { pub fn g(_: super::G<u16>); } }
    pub mod y { extern "C" { pub fn g(_: super::G<u32>); } }
    ```
    
    fixes rust-lang#130851
    matthiaskrgr authored Sep 28, 2024
    Configuration menu
    Copy the full SHA
    2df6b07 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#130939 - obi1kenobi:patch-2, r=aDotInTheVoid

    rustdoc: update `ProcMacro` docs section on helper attributes
    
    I believe the mention of attribute macros in the section on proc macro helper attributes is erroneous. As far as I can tell, attribute macros cannot define helper attributes.
    
    The following attribute macro is not valid (fails to build), no matter how I try to define (or skip defining) the helpers:
    ```rust
    #[proc_macro_attribute(attributes(helper))]
    pub fn attribute_helpers(_attr: TokenStream, item: TokenStream) -> TokenStream {
        item
    }
    ```
    
    The [language reference](https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros) also doesn't seem to mention attribute macro helpers. The helpers subsection is inside the section on derive macros.
    matthiaskrgr authored Sep 28, 2024
    Configuration menu
    Copy the full SHA
    7e32221 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#130940 - workingjubilee:remove-space-saving…

    …-operations, r=Kobzol
    
    Revert space-saving operations
    
    The "all of our artifacts" `mv` seems like it may save enough space to matter sometimes, since it can range up to a gigabyte of difference, if memory serves. For the rest, I think we're good.
    
    try-job: dist-aarch64-apple
    matthiaskrgr authored Sep 28, 2024
    Configuration menu
    Copy the full SHA
    6b5cd4e View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#130944 - lukas-code:ptr-ptr-sub, r=compiler…

    …-errors
    
    Allow instantiating trait object binder in ptr-to-ptr casts
    
    For unsizing coercions between trait objects with the same principal, we already allow instantiating the for binder. For example, coercing `Box<dyn for<'a> Trait<'a>` to `Box<dyn Trait<'static>>` is allowed.
    
    Since ptr-to-ptr casts will insert an unsizing coercion before the cast if possible, this has the consequence that the following compiles already:
    
    ```rust
    // This compiles today.
    fn cast<'b>(x: *mut dyn for<'a> Trait<'a>) -> *mut dyn Trait<'b> {
        // lowered as (roughly)
        // tmp: *mut dyn Trait<'?0> = Unsize(x)     // requires dyn for<'a> Trait<'a> <: dyn Trait<'?0>
        // ret: *mut dyn Trait<'b> = PtrToPtr(tmp)  // requires dyn Trait<'?0> == dyn Trait<'b>
        x as _
    }
    ```
    
    However, if no unsizing coercion is inserted then this currently fails to compile as one type is more general than the other. This PR will allow this code to compile, too, by changing ptr-to-ptr casts of pointers with vtable metadata to use sutyping instead of type equality.
    
    ```rust
    // This will compile after this PR.
    fn cast<'b>(x: *mut dyn for<'a> Trait<'a>) -> *mut Wrapper<dyn Trait<'b>> {
        // lowered as (roughly)
        // no Unsize here!
        // ret: *mut Wrapper<dyn Trait<'b>> = PtrToPtr(x)  // requires dyn for<'a> Trait<'a> == dyn Trait<'b>
        x as _
    }
    ```
    
    Note that it is already possible to work around the current restrictions and make the code compile before this PR by splitting the cast in two, so this shouldn't allow a new class of programs to compile:
    
    ```rust
    // Workaround that compiles today.
    fn cast<'b>(x: *mut dyn for<'a> Trait<'a>) -> *mut Wrapper<dyn Trait<'b>> {
        x as *mut dyn Trait<'_> as _
    }
    ```
    
    r? `@compiler-errors`
    cc `@WaffleLapkin`
    matthiaskrgr authored Sep 28, 2024
    Configuration menu
    Copy the full SHA
    58d0730 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#130953 - workingjubilee:rename-a-few-ctypes…

    …-tests, r=fee1-dead
    
    Rename a few tests to make tidy happier
    
    A somewhat random smattering of tests that I have recently looked at, and thus had cause to research and write down the reason for their existence.
    matthiaskrgr authored Sep 28, 2024
    Configuration menu
    Copy the full SHA
    5d7db93 View commit details
    Browse the repository at this point in the history