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 13 pull requests #93119

Merged
merged 40 commits into from
Jan 20, 2022
Merged

Rollup of 13 pull requests #93119

merged 40 commits into from
Jan 20, 2022

Commits on Nov 20, 2021

  1. Remove redundant check for promoteds

    For some time CTFE has been using a dedicated MIR which is never
    optimized, so the check for promoted became redundant.
    tmiasko committed Nov 20, 2021
    Configuration menu
    Copy the full SHA
    763703c View commit details
    Browse the repository at this point in the history
  2. Use IndexVec::indices instead of reimplementing it

    The change is limited to the iteration over indices instead of using
    `basic_blocks_mut()` directly, in the case the previous implementation
    intentionally avoided invalidating the caches stored in MIR body.
    tmiasko committed Nov 20, 2021
    Configuration menu
    Copy the full SHA
    d5a91f3 View commit details
    Browse the repository at this point in the history
  3. Fix a variant index and variant discriminant confusion

    Previously for enums using the `Variants::Single` layout, the variant
    index was being confused with its discriminant. For example, in the case
    of `enum E { A = 1 }`.
    
    Use `discriminant_for_variant` to avoid the issue.
    tmiasko committed Nov 20, 2021
    Configuration menu
    Copy the full SHA
    c3e71d8 View commit details
    Browse the repository at this point in the history

Commits on Jan 9, 2022

  1. Stabilize -Z print-link-args as --print link-args

    We have stable options for adding linker arguments; we should have a
    stable option to help debug linker arguments.
    joshtriplett committed Jan 9, 2022
    Configuration menu
    Copy the full SHA
    cd626fe View commit details
    Browse the repository at this point in the history
  2. Document --print link-args

    The documentation makes it clear that the *exact* format of the output
    is not a stable guarantee.
    joshtriplett committed Jan 9, 2022
    Configuration menu
    Copy the full SHA
    371bd46 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    36a1141 View commit details
    Browse the repository at this point in the history

Commits on Jan 13, 2022

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

Commits on Jan 17, 2022

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

Commits on Jan 18, 2022

  1. Configuration menu
    Copy the full SHA
    a8b7116 View commit details
    Browse the repository at this point in the history
  2. remove unnecessary fixme

    lcnr committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    621e60a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b2d8f0c View commit details
    Browse the repository at this point in the history
  4. privacy: update visit_infer

    lcnr committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    cbc6d35 View commit details
    Browse the repository at this point in the history
  5. intra-doc links

    lcnr committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    217458b View commit details
    Browse the repository at this point in the history

Commits on Jan 19, 2022

  1. intra-doc: Use the impl's assoc item where possible

    Before, the trait's associated item would be used. Now, the impl's
    associated item is used. The only exception is for impls that use
    default values for associated items set by the trait. In that case,
    the trait's associated item is still used.
    
    As an example of the old and new behavior, take this code:
    
        trait MyTrait {
            type AssocTy;
        }
    
        impl MyTrait for String {
            type AssocTy = u8;
        }
    
    Before, when resolving a link to `String::AssocTy`,
    `resolve_associated_trait_item` would return the associated item for
    `MyTrait::AssocTy`. Now, it would return the associated item for
    `<String as MyTrait>::AssocTy`, as it claims in its docs.
    camelid committed Jan 19, 2022
    Configuration menu
    Copy the full SHA
    29a2d6b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2938be6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    06b00ad View commit details
    Browse the repository at this point in the history
  4. Fix CVE-2022-21658 for Windows

    ChrisDenton authored and pietroalbini committed Jan 19, 2022
    Configuration menu
    Copy the full SHA
    5ab67bf View commit details
    Browse the repository at this point in the history
  5. Fix CVE-2022-21658 for UNIX-like

    hkratz authored and pietroalbini committed Jan 19, 2022
    Configuration menu
    Copy the full SHA
    54e22eb View commit details
    Browse the repository at this point in the history
  6. Fix CVE-2022-21658 for WASI

    alexcrichton authored and pietroalbini committed Jan 19, 2022
    Configuration menu
    Copy the full SHA
    cb748a2 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    32080ad View commit details
    Browse the repository at this point in the history
  8. Add MaybeUninit::as_bytes

    Amanieu committed Jan 19, 2022
    Configuration menu
    Copy the full SHA
    5c96dcf View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    6487845 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    5c15ad7 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    698631e View commit details
    Browse the repository at this point in the history

Commits on Jan 20, 2022

  1. Rustdoc mobile: put out-of-band on its own line

    Before this, the item name and the stability, source link, and "collapse
    all docs" would compete for room on a single line, resulting in awkward
    wrapping behavior on mobile. This gives a separate line for that
    out-of-band information. It also removes the "copy path" icon on mobile
    to make a little more room.
    
    Also, switch to flex-wrap: wrap, so anytime there's not enough room for
    `source`, it gets bumped to the next line.
    jsha committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    152e888 View commit details
    Browse the repository at this point in the history
  2. ⬆️ rust-analyzer

    lnicola committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    3b10045 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0a6c9ad View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#89747 - Amanieu:maybeuninit_bytes, r=m-ou-se

    Add MaybeUninit::(slice_)as_bytes(_mut)
    
    This adds methods to convert between `MaybeUninit<T>` and a slice of `MaybeUninit<u8>`. This is safe since `MaybeUninit<u8>` can correctly handle padding bytes in any `T`.
    
    These methods are added:
    ```rust
    impl<T> MaybeUninit<T> {
    	pub fn as_bytes(&self) -> &[MaybeUninit<u8>];
    	pub fn as_bytes_mut(&mut self) -> &mut [MaybeUninit<u8>];
    	pub fn slice_as_bytes(this: &[MaybeUninit<T>]) -> &[MaybeUninit<u8>];
    	pub fn slice_as_bytes_mut(this: &mut [MaybeUninit<T>]) -> &mut [MaybeUninit<u8>];
    }
    ```
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    98cb338 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#89764 - tmiasko:uninhabited-enums, r=wesley…

    …wiser
    
    Fix variant index / discriminant confusion in uninhabited enum branching
    
    Fix confusion between variant index and variant discriminant. The pass
    incorrectly assumed that for `Variants::Single` variant index is the same as
    variant discriminant.
    
    r? `@wesleywiser`
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    d188287 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#91606 - joshtriplett:stabilize-print-link-a…

    …rgs, r=pnkfelix
    
    Stabilize `-Z print-link-args` as `--print link-args`
    
    We have stable options for adding linker arguments; we should have a
    stable option to help debug linker arguments.
    
    Add documentation for the new option. In the documentation, make it clear that
    the *exact* format of the output is not a stable guarantee.
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    02379e9 View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#91694 - euclio:stability-improvements, r=Gu…

    …illaumeGomez
    
    rustdoc: decouple stability and const-stability
    
    This PR tweaks the stability rendering code to consider stability and const-stability separately. This fixes two issues:
    
    - Stabilities that match the enclosing item are now always omitted, even if the item has const-stability as well (rust-lang#90552)
    - Const-stable unstable functions will now have their (const-) stability rendered.
    
    Fixes rust-lang#90552.
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    405cf20 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#92183 - tmandry:issue-74256, r=estebank

    Point at correct argument when async fn output type lifetime disagrees with signature
    
    Fixes most of rust-lang#74256.
    
    ## Problems fixed
    
    This PR fixes a couple of related problems in the error reporting code.
    
    ### Highlighting the wrong argument
    
    First, the error reporting code was looking at the desugared return type of an `async fn` to decide which parameter to highlight. For example, a function like
    
    ```rust
    async fn async_fn(self: &Struct, f: &u32) -> &u32
    { f }
    ```
    
    desugars to
    
    ```rust
    async fn async_fn<'a, 'b>(self: &'a Struct, f: &'b u32)
    -> impl Future<Output = &'a u32> + 'a + 'b
    { f }
    ```
    
    Since `f: &'b u32` is returned but the output type is `&'a u32`, the error would occur when checking that `'a: 'b`.
    
    The reporting code would look to see if the "offending" lifetime `'b` was included in the return type, and because the code was looking at the desugared future type, it was included. So it defaulted to reporting that the source of the other lifetime `'a` (the `self` type) was the problem, when it was really the type of `f`. (Note that if it had chosen instead to look at `'a` first, it too would have been included in the output type, and it would have arbitrarily reported the error (correctly this time) on the type of `f`.)
    
    Looking at the actual future type isn't useful for this reason; it captures all input lifetimes. Using the written return type for `async fn` solves this problem and results in less confusing error messages for the user.
    
    This isn't a perfect fix, unfortunately; writing the "manually desugared" form of the above function still results in the wrong parameter being highlighted. Looking at the output type of every `impl Future` return type doesn't feel like a very principled approach, though it might work. The problem would remain for function signatures that look like the desugared one above but use different traits. There may be deeper changes required to pinpoint which part of each type is conflicting.
    
    ### Lying about await point capture causing lifetime conflicts
    
    The second issue fixed by this PR is the unnecessary complexity in `try_report_anon_anon_conflict`. It turns out that the root cause I suggested in rust-lang#76547 (comment) wasn't really the root cause. Adding special handling to report that a variable was captured over an await point only made the error messages less correct and pointed to a problem other than the one that actually occurred.
    
    Given the above discussion, it's easy to see why: `async fn`s capture all input lifetimes in their return type, so holding an argument across an await point should never cause a lifetime conflict! Removing the special handling simplified the code and improved the error messages (though they still aren't very good!)
    
    ## Future work
    
    * Fix error reporting on the "desugared" form of this code
    * Get the `suggest_adding_lifetime_params` suggestion firing on these examples
      * cc rust-lang#42703, I think
    
    r? `@estebank`
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    413f490 View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#92582 - lcnr:generic-arg-infer, r=BoxyUwU

    improve `_` constants in item signature handling
    
    removing the "type" from the error messages does slightly worsen the error messages for types, but figuring out whether the placeholder is for a type or a constant and correctly dealing with that seemed fairly difficult to me so I took the easy way out ✨ Imo the error message is still clear enough.
    
    r? `@BoxyUwU` cc `@estebank`
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    db1253f View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#92680 - camelid:assoc-item-cleanup, r=petro…

    …chenkov
    
    intra-doc: Use the impl's assoc item where possible
    
    Before, the trait's associated item would be used. Now, the impl's
    associated item is used. The only exception is for impls that use
    default values for associated items set by the trait. In that case,
    the trait's associated item is still used.
    
    As an example of the old and new behavior, take this code:
    
        trait MyTrait {
            type AssocTy;
        }
    
        impl MyTrait for String {
            type AssocTy = u8;
        }
    
    Before, when resolving a link to `String::AssocTy`,
    `resolve_associated_trait_item` would return the associated item for
    `MyTrait::AssocTy`. Now, it would return the associated item for
    `<String as MyTrait>::AssocTy`, as it claims in its docs.
    
    r? `@petrochenkov`
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    1839829 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#92704 - 5225225:std_mem_transmute_ref_t_mut…

    …_t, r=michaelwoerister
    
    Change lint message to be stronger for &T -> &mut T transmute
    
    The old message implied that it's only UB if you use the reference to mutate, which (as far as I know) is not true. As in, the following program has UB, and a &T -> &mut T transmute is effectively an `unreachable_unchecked`.
    
    ```rust
    fn main() {
        #[allow(mutable_transmutes)]
        unsafe {
            let _ = std::mem::transmute::<&i32, &mut i32>(&0);
        }
    }
    ```
    
    In the future, it might be a good idea to use the edition system to make this a hard error, since I don't think it is *ever* defined behaviour? Unless we rule that `&UnsafeCell<i32> -> &mut i32` is fine. (That, and you always could just use `.get()`, so you're not losing anything)
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    5c10dbd View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#92861 - jsha:mobile-column-flex, r=Guillaum…

    …eGomez
    
    Rustdoc mobile: put out-of-band info on its own line
    
    Before this, the item name and the stability, source link, and "collapse
    all docs" would compete for room on a single line, resulting in awkward
    wrapping behavior on mobile. This gives a separate line for that
    out-of-band information. It also removes the "copy path" icon on mobile
    to make a little more room.
    
    Demo: https://rustdoc.crud.net/jsha/mobile-column-flex/std/string/struct.String.html
    
    r? `@GuillaumeGomez`
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    ed3bf67 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#92992 - kornelski:backtraceopt, r=Mark-Simu…

    …lacrum
    
    Help optimize out backtraces when disabled
    
    The comment in `rust_backtrace_env` says:
    
    >    // If the `backtrace` feature of this crate isn't enabled quickly return
    >   // `None` so this can be constant propagated all over the place to turn
    >  // optimize away callers.
    
    but this optimization has regressed, because the only caller of this function had an alternative path that unconditionally (and pointlessly) asked for a full backtrace, so the disabled state couldn't propagate.
    
    I've added a getter for the full format that respects the feature flag, so that the caller will now be able to really optimize out the disabled backtrace path. I've also made `rust_backtrace_env` trivially inlineable when backtraces are disabled.
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    1cb57e2 View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#93038 - GuillaumeGomez:block-doc-comments, …

    …r=notriddle
    
    Fix star handling in block doc comments
    
    Fixes rust-lang#92872.
    
    Some extra explanation about this PR and why rust-lang#92357 created this regression: when we merge doc comment kinds for example in:
    
    ```rust
    /// he
    /**
    * hello
    */
    #[doc = "boom"]
    ```
    
    We don't want to remove the empty lines between them. However, to correctly compute the "horizontal trim", we still need it, so instead, I put back a part of the "vertical trim" directly in the "horizontal trim" computation so it doesn't impact the output buffer but allows us to correctly handle the stars.
    
    r? `@camelid`
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    6c627d2 View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#93108 - lnicola:rust-analyzer-2022-01-20, r…

    …=lnicola
    
    ⬆️ rust-analyzer
    
    r? `@ghost`
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    d893b0a View commit details
    Browse the repository at this point in the history
  16. Rollup merge of rust-lang#93112 - pietroalbini:pa-cve-2022-21658-nigh…

    …tly, r=pietroalbini
    
    Fix CVE-2022-21658
    
    See https://blog.rust-lang.org/2022/01/20/cve-2022-21658.html. Patches reviewed by `@m-ou-se.`
    
    r? `@ghost`
    matthiaskrgr authored Jan 20, 2022
    Configuration menu
    Copy the full SHA
    dbc9749 View commit details
    Browse the repository at this point in the history