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

Merged
merged 30 commits into from
Jan 24, 2024
Merged

Rollup of 9 pull requests #120283

merged 30 commits into from
Jan 24, 2024

Commits on Nov 16, 2023

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

Commits on Jan 21, 2024

  1. Configuration menu
    Copy the full SHA
    bdfc64a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6d7e80c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0e3035b View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2024

  1. Configuration menu
    Copy the full SHA
    f58af9b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ac332bd View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f75361f View commit details
    Browse the repository at this point in the history
  4. Add some tests

    oli-obk committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    4e07699 View commit details
    Browse the repository at this point in the history
  5. Use an enum instead of a bool

    oli-obk committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    1829aa6 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5e5d135 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    f700ee4 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    390ef9b View commit details
    Browse the repository at this point in the history
  9. Suggest boxing if then expr if that solves divergent arms

    When encountering
    
    ```rust
    let _ = if true {
        Struct
    } else {
        foo() // -> Box<dyn Trait>
    };
    ```
    
    if `Struct` implements `Trait`, suggest boxing the then arm tail expression.
    
    Part of rust-lang#102629.
    estebank committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    ac56a2b View commit details
    Browse the repository at this point in the history
  10. Add Assume custom MIR.

    cjgillot committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    161c674 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2024

  1. Configuration menu
    Copy the full SHA
    d7a7be4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    afaac75 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f3682a1 View commit details
    Browse the repository at this point in the history
  4. Suggest boxing both arms of if expr if that solves divergent arms inv…

    …olving `impl Trait`
    
    When encountering the following
    
    ```rust
    // run-rustfix
    trait Trait {}
    struct Struct;
    impl Trait for Struct {}
    fn foo() -> Box<dyn Trait> {
        Box::new(Struct)
    }
    fn bar() -> impl Trait {
        Struct
    }
    fn main() {
        let _ = if true {
            Struct
        } else {
            foo() //~ ERROR E0308
        };
        let _ = if true {
            foo()
        } else {
            Struct //~ ERROR E0308
        };
        let _ = if true {
            Struct
        } else {
            bar() // impl Trait
        };
        let _ = if true {
            bar() // impl Trait
        } else {
            Struct
        };
    }
    ```
    
    suggest boxing both arms
    
    ```rust
        let _ = if true {
            Box::new(Struct) as Box<dyn Trait>
        } else {
            Box::new(bar())
        };
        let _ = if true {
            Box::new(bar()) as Box<dyn Trait>
        } else {
            Box::new(Struct)
        };
    ```
    estebank committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    34f4f3d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    3a07333 View commit details
    Browse the repository at this point in the history
  6. tidy

    HTGAzureX1212 committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    da1d0c4 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    851d4c4 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#112806 - kadiwa4:collect_intra_doc_links, r…

    …=notriddle
    
    Small code improvements in `collect_intra_doc_links.rs`
    
    Makes some of the code more readable by shortening it, and removes some unnecessary bounds checks.
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    023c3eb View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#119766 - oli-obk:split_tait_and_atpit, r=co…

    …mpiler-errors
    
    Split tait and impl trait in assoc items logic
    
    And simplify the assoc item logic where applicable.
    
    This separation shows that it is easier to reason about impl trait in assoc items compared with TAITs. See https://rust-lang.zulipchat.com/#narrow/stream/315482-t-compiler.2Fetc.2Fopaque-types/topic/impl.20trait.20in.20associated.20type for some discussion.
    
    The current plan is to try to stabilize impl trait in associated items before TAIT, as they do not have any issues with their defining scopes (see rust-lang#107645 for why this is not a trivial or uncontroversial topic).
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    5da220a View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#120139 - compiler-errors:fnonce-shim, r=Box…

    …yUwU
    
    Do not normalize closure signature when building `FnOnce` shim
    
    It is not necessary to normalize the closure signature when building an `FnOnce` shim for an `Fn`/`FnMut` closure. That closure shim is just calling `FnMut::call_mut(&mut self)` anyways.
    
    It's also somewhat sketchy that we were ever doing this to begin with, since we're normalizing with a `ParamEnv::reveal_all()` param-env, which is definitely not right with possibly polymorphic substs.
    
    This cuts out a tiny bit of unnecessary work in `Instance::resolve` and simplifies the signature because now we can unconditionally return an `Instance`.
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    6131ba6 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#120160 - reitermarkus:nonzero-traits, r=dto…

    …lnay
    
    Manually implement derived `NonZero` traits.
    
    Step 3 as mentioned in rust-lang#100428 (review).
    
    Manually implement the traits that would cause “borrow of layout constrained field with interior mutability” errors when switching to `NonZero<T>`.
    
    r? ```@dtolnay```
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    19a840d View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#120171 - cjgillot:jump-threading-assume-ass…

    …ert, r=tmiasko
    
    Fix assume and assert in jump threading
    
    r? ``@tmiasko``
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    6cca9b3 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#120183 - Zalathar:test-closure, r=compiler-…

    …errors
    
    Add `#[coverage(off)]` to closures introduced by `#[test]` and `#[bench]`
    
    These closures are an internal implementation detail of the `#[test]` and `#[bench]` attribute macros, so from a user perspective there is no reason to instrument them for coverage.
    
    Skipping them makes coverage reports slightly cleaner, and will also allow other changes to span processing during coverage instrumentation, without having to worry about how they affect the `#[test]` macro.
    
    The `#[coverage(off)]` attribute has no effect when `-Cinstrument-coverage` is not used.
    
    Fixes rust-lang#120046.
    
    ---
    
    Note that this PR has no effect on the user-written function that has the `#[test]` attribute attached to it. That function will still be instrumented as normal.
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    ecb8702 View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#120195 - bvanjoi:add-some-resolution-test-c…

    …ase, r=petrochenkov
    
    add several resolution test cases
    
    r? ``@petrochenkov``
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    7ee8142 View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#120259 - HTGAzureX1212:HTGAzureX1212/split-…

    …diagnostics-uncommon-codepoints, r=Manishearth
    
    Split Diagnostics for Uncommon Codepoints: Add List to Display Characters Involved
    
    This Pull Request adds a list of the uncommon codepoints involved in the `uncommon_codepoints` lint, as outlined as a first step in rust-lang#120228.
    
    Example rendered diagnostic:
    ```
    error: identifier contains an uncommon Unicode codepoint: 'µ'
      --> $DIR/lint-uncommon-codepoints.rs:3:7
       |
    LL | const µ: f64 = 0.000001;
       |       ^
       |
    note: the lint level is defined here
      --> $DIR/lint-uncommon-codepoints.rs:1:9
       |
    LL | #![deny(uncommon_codepoints)]
       |         ^^^^^^^^^^^^^^^^^^^
    ```
    
    (Retrying rust-lang#120258.)
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    4d9b983 View commit details
    Browse the repository at this point in the history
  16. Rollup merge of rust-lang#120261 - estebank:issue-102629, r=wesleywiser

    Provide structured suggestion to use trait objects in some cases of `if` arm type divergence
    
    ```
    error[E0308]: `if` and `else` have incompatible types
      --> $DIR/suggest-box-on-divergent-if-else-arms.rs:15:9
       |
    LL |       let _ = if true {
       |  _____________-
    LL | |         Struct
       | |         ------ expected because of this
    LL | |     } else {
    LL | |         foo()
       | |         ^^^^^ expected `Struct`, found `Box<dyn Trait>`
    LL | |     };
       | |_____- `if` and `else` have incompatible types
       |
       = note: expected struct `Struct`
                  found struct `Box<dyn Trait>`
    help: `Struct` implements `Trait` so you can box it to coerce to the trait object `Box<dyn Trait>`
       |
    LL |         Box::new(Struct)
       |         +++++++++      +
    
    error[E0308]: `if` and `else` have incompatible types
      --> $DIR/suggest-box-on-divergent-if-else-arms.rs:20:9
       |
    LL |       let _ = if true {
       |  _____________-
    LL | |         foo()
       | |         ----- expected because of this
    LL | |     } else {
    LL | |         Struct
       | |         ^^^^^^ expected `Box<dyn Trait>`, found `Struct`
    LL | |     };
       | |_____- `if` and `else` have incompatible types
       |
       = note: expected struct `Box<dyn Trait>`
                  found struct `Struct`
       = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
    help: store this in the heap by calling `Box::new`
       |
    LL |         Box::new(Struct)
       |         +++++++++      +
    
    error[E0308]: `if` and `else` have incompatible types
      --> $DIR/suggest-box-on-divergent-if-else-arms.rs:25:9
       |
    LL |   fn bar() -> impl Trait {
       |               ---------- the found opaque type
    ...
    LL |       let _ = if true {
       |  _____________-
    LL | |         Struct
       | |         ------ expected because of this
    LL | |     } else {
    LL | |         bar()
       | |         ^^^^^ expected `Struct`, found opaque type
    LL | |     };
       | |_____- `if` and `else` have incompatible types
       |
       = note:   expected struct `Struct`
               found opaque type `impl Trait`
    help: `Struct` implements `Trait` so you can box both arms and coerce to the trait object `Box<dyn Trait>`
       |
    LL ~         Box::new(Struct) as Box<dyn Trait>
    LL |     } else {
    LL ~         Box::new(bar())
       |
    
    error[E0308]: `if` and `else` have incompatible types
      --> $DIR/suggest-box-on-divergent-if-else-arms.rs:30:9
       |
    LL |   fn bar() -> impl Trait {
       |               ---------- the expected opaque type
    ...
    LL |       let _ = if true {
       |  _____________-
    LL | |         bar()
       | |         ----- expected because of this
    LL | |     } else {
    LL | |         Struct
       | |         ^^^^^^ expected opaque type, found `Struct`
    LL | |     };
       | |_____- `if` and `else` have incompatible types
       |
       = note: expected opaque type `impl Trait`
                       found struct `Struct`
    help: `Struct` implements `Trait` so you can box both arms and coerce to the trait object `Box<dyn Trait>`
       |
    LL ~         Box::new(bar()) as Box<dyn Trait>
    LL |     } else {
    LL ~         Box::new(Struct)
       |
    ```
    
    Partially address rust-lang#102629.
    fmease authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    3f2f8ee View commit details
    Browse the repository at this point in the history