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 10 pull requests #120335

Merged
merged 28 commits into from
Jan 25, 2024
Merged

Rollup of 10 pull requests #120335

merged 28 commits into from
Jan 25, 2024

Commits on Dec 25, 2023

  1. Configuration menu
    Copy the full SHA
    0e6f7c6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fde86e5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    17b4333 View commit details
    Browse the repository at this point in the history

Commits on Jan 19, 2024

  1. Provide more context on recursive impl evaluation overflow

    When an associated type `Self::Assoc` is part of a `where` clause,
    we end up unable to evaluate the requirement and emit a E0275.
    
    We now point at the associated type if specified in the `impl`. If
    so, we also suggest using that type instead of `Self::Assoc`.
    Otherwise, we explain that these are not allowed.
    
    ```
    error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
      --> $DIR/impl-wf-cycle-1.rs:15:1
       |
    LL | / impl<T: Grault> Grault for (T,)
    LL | |
    LL | | where
    LL | |     Self::A: Baz,
    LL | |     Self::B: Fiz,
       | |_________________^
    LL |   {
    LL |       type A = ();
       |       ------ associated type `<(T,) as Grault>::A` is specified here
       |
    note: required for `(T,)` to implement `Grault`
      --> $DIR/impl-wf-cycle-1.rs:15:17
       |
    LL | impl<T: Grault> Grault for (T,)
       |                 ^^^^^^     ^^^^
    ...
    LL |     Self::A: Baz,
       |              --- unsatisfied trait bound introduced here
       = note: 1 redundant requirement hidden
       = note: required for `(T,)` to implement `Grault`
    help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
       |
    LL -     Self::A: Baz,
    LL +     ,
       |
    ```
    ```
    error[E0275]: overflow evaluating the requirement `<T as B>::Type == <T as B>::Type`
      --> $DIR/impl-wf-cycle-3.rs:7:1
       |
    LL | / impl<T> B for T
    LL | | where
    LL | |     T: A<Self::Type>,
       | |_____________________^
    LL |   {
    LL |       type Type = bool;
       |       --------- associated type `<T as B>::Type` is specified here
       |
    note: required for `T` to implement `B`
      --> $DIR/impl-wf-cycle-3.rs:7:9
       |
    LL | impl<T> B for T
       |         ^     ^
    LL | where
    LL |     T: A<Self::Type>,
       |        ------------- unsatisfied trait bound introduced here
    help: replace the associated type with the type specified in this `impl`
       |
    LL |     T: A<bool>,
       |          ~~~~
    ```
    ```
    error[E0275]: overflow evaluating the requirement `<T as Filter>::ToMatch == <T as Filter>::ToMatch`
      --> $DIR/impl-wf-cycle-4.rs:5:1
       |
    LL | / impl<T> Filter for T
    LL | | where
    LL | |     T: Fn(Self::ToMatch),
       | |_________________________^
       |
    note: required for `T` to implement `Filter`
      --> $DIR/impl-wf-cycle-4.rs:5:9
       |
    LL | impl<T> Filter for T
       |         ^^^^^^     ^
    LL | where
    LL |     T: Fn(Self::ToMatch),
       |        ----------------- unsatisfied trait bound introduced here
    note: associated types for the current `impl` cannot be restricted in `where` clauses
      --> $DIR/impl-wf-cycle-4.rs:7:11
       |
    LL |     T: Fn(Self::ToMatch),
       |           ^^^^^^^^^^^^^
    ```
    
    Fix rust-lang#116925
    estebank committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    2c2f3ed View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c85bb27 View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2024

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

Commits on Jan 23, 2024

  1. Remove track_errors entirely

    oli-obk committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    db7cd57 View commit details
    Browse the repository at this point in the history
  2. Remove --fatal-warnings on wasm targets

    These were added with good intentions, but a recent change in LLVM 18
    emits a warning while examining .rmeta sections in .rlib files. Since
    this flag is a nice-to-have and users can update their LLVM linker
    independently of rustc's LLVM version, we can just omit the flag.
    djkoloski committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    849d884 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2024

  1. Configuration menu
    Copy the full SHA
    83ef18c View commit details
    Browse the repository at this point in the history
  2. coverage: Flatten the functions for extracting/refining coverage spans

    Consolidating this code into flatter functions reduces the amount of
    pointer-chasing required to read and modify it.
    Zalathar committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    572d7e9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    64f590a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cc34dc2 View commit details
    Browse the repository at this point in the history
  5. Let ctor_sub_tys return any Iterator they want

    Since we always clone and allocate the types somewhere else ourselves,
    no need to ask for `Cx` to do the allocation.
    Nadrieril committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    e088016 View commit details
    Browse the repository at this point in the history
  6. On E0308 involving dyn Trait, mention trait objects

    When encountering a type mismatch error involving `dyn Trait`, mention
    the existence of boxed trait objects if the other type involved
    implements `Trait`.
    
    Partially addresses rust-lang#102629.
    estebank committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    d992d9c View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    796814d View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    bdab213 View commit details
    Browse the repository at this point in the history
  9. Improve Range: Debug impl

    Nadrieril committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    354b45f View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    8f3af4c View commit details
    Browse the repository at this point in the history

Commits on Jan 25, 2024

  1. Rollup merge of rust-lang#119305 - compiler-errors:async-fn-traits, r…

    …=oli-obk
    
    Add `AsyncFn` family of traits
    
    I'm proposing to add a new family of `async`hronous `Fn`-like traits to the standard library for experimentation purposes.
    
    ## Why do we need new traits?
    
    On the user side, it is useful to be able to express `AsyncFn` trait bounds natively via the parenthesized sugar syntax, i.e. `x: impl AsyncFn(&str) -> String` when experimenting with async-closure code.
    
    This also does not preclude `AsyncFn` becoming something else like a trait alias if a more fundamental desugaring (which can take many[^1] different[^2] forms) comes around. I think we should be able to play around with `AsyncFn` well before that, though.
    
    I'm also not proposing stabilization of these trait names any time soon (we may even want to instead express them via new syntax, like `async Fn() -> ..`), but I also don't think we need to introduce an obtuse bikeshedding name, since `AsyncFn` just makes sense.
    
    ## The lending problem: why not add a more fundamental primitive of `LendingFn`/`LendingFnMut`?
    
    Firstly, for `async` closures to be as flexible as possible, they must be allowed to return futures which borrow from the async closure's captures. This can be done by introducing `LendingFn`/`LendingFnMut` traits, or (equivalently) by adding a new generic associated type to `FnMut` which allows the return type to capture lifetimes from the `&mut self` argument of the trait. This was proposed in one of [Niko's blog posts](https://smallcultfollowing.com/babysteps/blog/2023/05/09/giving-lending-and-async-closures/).
    
    Upon further experimentation, for the purposes of closure type- and borrow-checking, I've come to the conclusion that it's significantly harder to teach the compiler how to handle *general* lending closures which may borrow from their captures. This is, because unlike `Fn`/`FnMut`, the `LendingFn`/`LendingFnMut` traits don't form a simple "inheritance" hierarchy whose top trait is `FnOnce`.
    
    ```mermaid
    flowchart LR
        Fn
        FnMut
        FnOnce
        LendingFn
        LendingFnMut
    
        Fn -- isa --> FnMut
        FnMut -- isa --> FnOnce
    
        LendingFn -- isa --> LendingFnMut
    
        Fn -- isa --> LendingFn
        FnMut -- isa --> LendingFnMut
    ```
    
    For example:
    
    ```
    fn main() {
      let s = String::from("hello, world");
      let f = move || &s;
      let x = f(); // This borrows `f` for some lifetime `'1` and returns `&'1 String`.
    ```
    
    That trait hierarchy means that in general for "lending" closures, like `f` above, there's not really a meaningful return type for `<typeof(f) as FnOnce>::Output` -- it can't return `&'static str`, for example.
    
    ### Special-casing this problem:
    
    By splitting out these traits manually, and making sure that each trait has its own associated future type, we side-step the issue of having to answer the questions of a general `LendingFn`/`LendingFnMut` implementation, since the compiler knows how to generate built-in implementations for first-class constructs like async closures, including the required future types for the (by-move) `AsyncFnOnce` and (by-ref) `AsyncFnMut`/`AsyncFn` trait implementations.
    
    [^1]: For example, with trait transformers, we may eventually be able to write: `trait AsyncFn = async Fn;`
    [^2]: For example, via the introduction of a more fundamental "`LendingFn`" trait, plus a [special desugaring with augmented trait aliases](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Lending.20closures.20and.20Fn*.28.29.20-.3E.20impl.20Trait/near/408471480).
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    8c6cf3c View commit details
    Browse the repository at this point in the history
  2. Rollup merge of rust-lang#119389 - estebank:issue-116925, r=TaKO8Ki

    Provide more context on recursive `impl` evaluation overflow
    
    When an associated type `Self::Assoc` is part of a `where` clause, we end up unable to evaluate the requirement and emit a E0275.
    
    We now point at the associated type if specified in the `impl`. If so, we also suggest using that type instead of `Self::Assoc`. Otherwise, we explain that these are not allowed.
    
    ```
    error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
      --> $DIR/impl-wf-cycle-1.rs:15:1
       |
    LL | / impl<T: Grault> Grault for (T,)
    LL | |
    LL | | where
    LL | |     Self::A: Baz,
    LL | |     Self::B: Fiz,
       | |_________________^
    LL |   {
    LL |       type A = ();
       |       ------ associated type `<(T,) as Grault>::A` is specified here
       |
    note: required for `(T,)` to implement `Grault`
      --> $DIR/impl-wf-cycle-1.rs:15:17
       |
    LL | impl<T: Grault> Grault for (T,)
       |                 ^^^^^^     ^^^^
    ...
    LL |     Self::A: Baz,
       |              --- unsatisfied trait bound introduced here
       = note: 1 redundant requirement hidden
       = note: required for `(T,)` to implement `Grault`
    help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
       |
    LL -     Self::A: Baz,
       |
    ```
    ```
    error[E0275]: overflow evaluating the requirement `<T as B>::Type == <T as B>::Type`
      --> $DIR/impl-wf-cycle-3.rs:7:1
       |
    LL | / impl<T> B for T
    LL | | where
    LL | |     T: A<Self::Type>,
       | |_____________________^
    LL |   {
    LL |       type Type = bool;
       |       --------- associated type `<T as B>::Type` is specified here
       |
    note: required for `T` to implement `B`
      --> $DIR/impl-wf-cycle-3.rs:7:9
       |
    LL | impl<T> B for T
       |         ^     ^
    LL | where
    LL |     T: A<Self::Type>,
       |        ------------- unsatisfied trait bound introduced here
    help: replace the associated type with the type specified in this `impl`
       |
    LL |     T: A<bool>,
       |          ~~~~
    ```
    ```
    error[E0275]: overflow evaluating the requirement `<T as Filter>::ToMatch == <T as Filter>::ToMatch`
      --> $DIR/impl-wf-cycle-4.rs:5:1
       |
    LL | / impl<T> Filter for T
    LL | | where
    LL | |     T: Fn(Self::ToMatch),
       | |_________________________^
       |
    note: required for `T` to implement `Filter`
      --> $DIR/impl-wf-cycle-4.rs:5:9
       |
    LL | impl<T> Filter for T
       |         ^^^^^^     ^
    LL | where
    LL |     T: Fn(Self::ToMatch),
       |        ----------------- unsatisfied trait bound introduced here
    note: associated types for the current `impl` cannot be restricted in `where` clauses
      --> $DIR/impl-wf-cycle-4.rs:7:11
       |
    LL |     T: Fn(Self::ToMatch),
       |           ^^^^^^^^^^^^^
    ```
    
    Fix rust-lang#116925
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    fd92d88 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#119895 - oli-obk:track_errors_3, r=matthewj…

    …asper
    
    Remove `track_errors` entirely
    
    follow up to rust-lang#119869
    
    r? `@matthewjasper`
    
    There are some diagnostic changes adding new diagnostics or not emitting some anymore. We can improve upon that in follow-up work imo.
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    0c45e3c View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#120230 - Urgau:for_scope-single-scope, r=mi…

    …chaelwoerister
    
    Assert that a single scope is passed to `for_scope`
    
    Addresses rust-lang#118518 (comment)
    
    r? ``@michaelwoerister``
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    55d5ea3 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#120278 - djkoloski:remove_fatal_warnings_wa…

    …sm, r=oli-obk
    
    Remove --fatal-warnings on wasm targets
    
    These were added with good intentions, but a recent change in LLVM 18 emits a warning while examining .rmeta sections in .rlib files. Since this flag is a nice-to-have and users can update their LLVM linker independently of rustc's LLVM version, we can just omit the flag.
    
    See [this comment on wasm targets' uses of `--fatal-warnings`](llvm/llvm-project#78658 (comment)).
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    565961b View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#120292 - Zalathar:dismantle, r=oli-obk

    coverage: Dismantle `Instrumentor` and flatten span refinement
    
    This is a combination of two refactorings that are unrelated, but would otherwise have a merge conflict.
    
    No functional changes, other than a small tweak to debug logging as part of rearranging some functions.
    
    Ignoring whitespace is highly recommended, since most of the modified lines have just been reindented.
    
    ---
    
    The first change is to dismantle `Instrumentor` into ordinary functions.
    
    This is one of those cases where encapsulating several values into a struct ultimately hurts more than it helps. With everything stored as local variables in one main function, and passed explicitly into helper functions, it's easier to see what is used where, and make changes as necessary.
    
    ---
    
    The second change is to flatten the functions for extracting/refining coverage spans.
    
    Consolidating this code into flatter functions reduces the amount of pointer-chasing required to read and modify it.
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    72b70ec View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#120315 - estebank:issue-102629-2, r=wesleyw…

    …iser
    
    On E0308 involving `dyn Trait`, mention trait objects
    
    When encountering a type mismatch error involving `dyn Trait`, mention the existence of boxed trait objects if the other type involved implements `Trait`.
    
    Fix rust-lang#102629.
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    0cbef47 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#120317 - Nadrieril:dont-force-slice-of-ty, …

    …r=compiler-errors
    
    pattern_analysis: Let `ctor_sub_tys` return any Iterator they want
    
    I noticed that we always `.cloned()` and allocate the output of `TypeCx::ctor_sub_tys` now, so there was no need to force it to return a slice. `ExactSizeIterator` is not super important but saves some manual counting.
    
    r? `@compiler-errors`
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    b677c77 View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#120318 - Nadrieril:share-debug-impl, r=comp…

    …iler-errors
    
    pattern_analysis: Reuse most of the `DeconstructedPat` `Debug` impl
    
    The `DeconstructedPat: Debug` is best-effort because we'd need `tcx` to get things like field names etc. Since rust-analyzer has a similar constraint, this PR moves most the impl to be shared between the two. While I was at it I also fixed a nit in the `IntRange: Debug` impl.
    
    r? `@compiler-errors`
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    a1ecced View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#120325 - cuviper:either-data, r=compiler-er…

    …rors
    
    rustc_data_structures: use either instead of itertools
    
    `itertools::Either` is a re-export from `either`, so we might as well use the source.
    
    This flattens the compiler build tree a little, but I don't really expect it to make much difference overall.
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    8c1ba59 View commit details
    Browse the repository at this point in the history