-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Rollup of 8 pull requests #130964
Conversation
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.
This reverts commit 06f49f6.
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.
…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.
…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
Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4
…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
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.
…-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
…-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`
…-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.
@bors r+ rollup= ever p=8 |
@bors rollup=never |
@bors rollup=never p=8 |
☀️ Test successful - checks-actions |
📌 Perf builds for each rolled up PR:
previous master: 150247c338 In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
Finished benchmarking commit (612796c): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -5.2%, secondary -0.8%)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.
CyclesResults (secondary -4.4%)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.
Binary sizeResults (primary -0.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.
Bootstrap: 771.117s -> 767.487s (-0.47%) |
Successful merges:
read_buf
uses instd
#125404 (Fixread_buf
uses instd
)ProcMacro
docs section on helper attributes #130939 (rustdoc: updateProcMacro
docs section on helper attributes)r? @ghost
@rustbot modify labels: rollup
Create a similar rollup