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

Merged
merged 22 commits into from
Mar 27, 2021
Merged

Rollup of 8 pull requests #83580

merged 22 commits into from
Mar 27, 2021

Commits on Mar 24, 2021

  1. rustdoc: Use diagnostics for error when including sources

    This error probably almost never happens, but we should still use the
    diagnostic infrastructure. My guess is that the error was added back
    before rustdoc used the rustc diagnostic infrastructure (it was all
    `println!` and `eprintln!` back then!) and since it likely rarely occurs
    and this code doesn't change that much, no one thought to transition it
    to using diagnostics.
    
    Note that the old error was actually a warning (it didn't stop the rest
    of doc building). It seems very unlikely that this would fail without
    the rest of the doc build failing, so it makes more sense for it to be a
    hard error.
    
    The error looks like this:
    
        error: failed to render source code for `src/test/rustdoc/smart-punct.rs`: "bar": foo
          --> src/test/rustdoc/smart-punct.rs:3:1
           |
        3  | / #![crate_name = "foo"]
        4  | |
        5  | | //! This is the "start" of the 'document'! How'd you know that "it's" ...
        6  | | //!
        ...  |
        22 | | //! I say "don't smart-punct me -- please!"
        23 | | //! ```
           | |_______^
    
    I wasn't sure how to trigger the error, so to create that message I
    temporarily made rustdoc always emit it. That's also why it says "bar"
    and "foo" instead of a real error message.
    
    Note that the span of the diagnostic starts at line 3 because line 1 of
    that file is a (non-doc) comment and line 2 is a blank line.
    camelid committed Mar 24, 2021
    Configuration menu
    Copy the full SHA
    3d8ce0a View commit details
    Browse the repository at this point in the history

Commits on Mar 26, 2021

  1. Add function core::iter::zip

    This makes it a little easier to `zip` iterators:
    
    ```rust
    for (x, y) in zip(xs, ys) {}
    // vs.
    for (x, y) in xs.into_iter().zip(ys) {}
    ```
    
    You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
    `iter()`, respectively. This can also support arbitrary nesting, where
    it's easier to see the item layout than with arbitrary `zip` chains:
    
    ```rust
    for ((x, y), z) in zip(zip(xs, ys), zs) {}
    for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
    // vs.
    for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
    for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
    ```
    
    It may also format more nicely, especially when the first iterator is a
    longer chain of methods -- for example:
    
    ```rust
        iter::zip(
            trait_ref.substs.types().skip(1),
            impl_trait_ref.substs.types().skip(1),
        )
        // vs.
        trait_ref
            .substs
            .types()
            .skip(1)
            .zip(impl_trait_ref.substs.types().skip(1))
    ```
    
    This replaces the tuple-pair `IntoIterator` in rust-lang#78204.
    There is prior art for the utility of this in [`itertools::zip`].
    
    [`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
    cuviper committed Mar 26, 2021
    Configuration menu
    Copy the full SHA
    b362958 View commit details
    Browse the repository at this point in the history
  2. Use iter::zip in library/

    cuviper committed Mar 26, 2021
    Configuration menu
    Copy the full SHA
    3b1f5e3 View commit details
    Browse the repository at this point in the history
  3. Use iter::zip in compiler/

    cuviper committed Mar 26, 2021
    Configuration menu
    Copy the full SHA
    72ebebe View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e82e812 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    addc51a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5ac917d View commit details
    Browse the repository at this point in the history

Commits on Mar 27, 2021

  1. Always preserve None-delimited groups in a captured TokenStream

    Previously, we would silently remove any `None`-delimiters when
    capturing a `TokenStream`, 'flattenting' them to their inner tokens.
    This was not normally visible, since we usually have
    `TokenKind::Interpolated` (which gets converted to a `None`-delimited
    group during macro invocation) instead of an actual `None`-delimited
    group.
    
    However, there are a couple of cases where this becomes visible to
    proc-macros:
    1. A cross-crate `macro_rules!` macro has a `None`-delimited group
       stored in its body (as a result of being produced by another
       `macro_rules!` macro). The cross-crate `macro_rules!` invocation
       can then expand to an attribute macro invocation, which needs
       to be able to see the `None`-delimited group.
    2. A proc-macro can invoke an attribute proc-macro with its re-collected
       input. If there are any nonterminals present in the input, they will
       get re-collected to `None`-delimited groups, which will then get
       captured as part of the attribute macro invocation.
    
    Both of these cases are incredibly obscure, so there hopefully won't be
    any breakage. This change will allow more agressive 'flattenting' of
    nonterminals in rust-lang#82608 without losing `None`-delimited groups.
    Aaron1011 committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    f94360f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ee1b33c View commit details
    Browse the repository at this point in the history
  3. Improve fs error open_from unix

    Consistency for rust-lang#79399
    Suggested by JohnTitor
    
    Improve fs error invaild input for sys_common
    
    The text was duplicated from unix.
    pickfire committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    6c6ef73 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    42150fb View commit details
    Browse the repository at this point in the history
  5. update tests

    lcnr committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    e461ddd View commit details
    Browse the repository at this point in the history
  6. make unaligned_refereces future-incompat lint warn-by-default, and re…

    …move the safe_packed_borrows lint that it replaces
    RalfJung committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    fb4f48e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    f0a6052 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#81351 - lcnr:big-money-big-prices, r=oli-obk

    combine: stop eagerly evaluating consts
    
    `super_relate_consts` eagerly evaluates constants which doesn't seem too great.
    
    I now also finally understand why all of the unused substs test passed. The reason being
    that we just evaluated the constants in `super_relate_consts` 😆
    
    While this change isn't strictly necessary as evaluating consts here doesn't hurt, it still feels a lot cleaner to do it this way
    
    r? `@oli-obk` `@nikomatsakis`
    Dylan-DPC committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    520c9a2 View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#82525 - RalfJung:unaligned-ref-warn, r=petr…

    …ochenkov
    
    make unaligned_references future-incompat lint warn-by-default
    
    and also remove the safe_packed_borrows lint that it replaces.
    
    `std::ptr::addr_of!` has hit beta now and will hit stable in a month, so I propose we start fixing rust-lang#27060 for real: creating a reference to a field of a packed struct needs to eventually become a hard error; this PR makes it a warn-by-default future-incompat lint. (The lint already existed, this just raises its default level.) At the same time I removed the corresponding code from unsafety checking; really there's no reason an `unsafe` block should make any difference here.
    
    For references to packed fields outside `unsafe` blocks, this means `unaligned_refereces` replaces the previous `safe_packed_borrows` warning with a link to rust-lang#82523 (and no more talk about unsafe blocks making any difference). So behavior barely changes, the warning is just worded differently. For references to packed fields inside `unsafe` blocks, this PR shows a new future-incompat warning.
    
    Closes rust-lang#46043 because that lint no longer exists.
    Dylan-DPC committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    a900677 View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#82626 - lcnr:encode_with_shorthandb, r=este…

    …bank
    
    update array missing `IntoIterator` msg
    
    fixes rust-lang#82602
    
    r? ```@estebank``` do you know whether we can use the expr span in `rustc_on_unimplemented`? The label isn't too great rn
    Dylan-DPC committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    ebea9d9 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#82917 - cuviper:iter-zip, r=m-ou-se

    Add function core::iter::zip
    
    This makes it a little easier to `zip` iterators:
    
    ```rust
    for (x, y) in zip(xs, ys) {}
    // vs.
    for (x, y) in xs.into_iter().zip(ys) {}
    ```
    
    You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
    `iter()`, respectively. This can also support arbitrary nesting, where
    it's easier to see the item layout than with arbitrary `zip` chains:
    
    ```rust
    for ((x, y), z) in zip(zip(xs, ys), zs) {}
    for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
    // vs.
    for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
    for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
    ```
    
    It may also format more nicely, especially when the first iterator is a
    longer chain of methods -- for example:
    
    ```rust
        iter::zip(
            trait_ref.substs.types().skip(1),
            impl_trait_ref.substs.types().skip(1),
        )
        // vs.
        trait_ref
            .substs
            .types()
            .skip(1)
            .zip(impl_trait_ref.substs.types().skip(1))
    ```
    
    This replaces the tuple-pair `IntoIterator` in rust-lang#78204.
    There is prior art for the utility of this in [`itertools::zip`].
    
    [`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
    Dylan-DPC committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    b2e2543 View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#82993 - camelid:source-use-diag, r=jyn514

    rustdoc: Use diagnostics for error when including sources
    
    This error probably almost never happens, but we should still use the
    diagnostic infrastructure. My guess is that the error was added back
    before rustdoc used the rustc diagnostic infrastructure (it was all
    `println!` and `eprintln!` back then!) and since it likely rarely occurs
    and this code doesn't change that much, no one thought to transition it
    to using diagnostics.
    
    Note that the old error was actually a warning (it didn't stop the rest
    of doc building). It seems very unlikely that this would fail without
    the rest of the doc build failing, so it makes more sense for it to be a
    hard error.
    
    The error looks like this:
    
        error: failed to render source code for `src/test/rustdoc/smart-punct.rs`: "bar": foo
          --> src/test/rustdoc/smart-punct.rs:3:1
           |
        3  | / #![crate_name = "foo"]
        4  | |
        5  | | //! This is the "start" of the 'document'! How'd you know that "it's" ...
        6  | | //!
        ...  |
        22 | | //! I say "don't smart-punct me -- please!"
        23 | | //! ```
           | |_______^
    
    I wasn't sure how to trigger the error, so to create that message I
    temporarily made rustdoc always emit it. That's also why it says "bar"
    and "foo" instead of a real error message.
    
    Note that the span of the diagnostic starts at line 3 because line 1 of
    that file is a (non-doc) comment and line 2 is a blank line.
    Dylan-DPC committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    f665e5a View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#83522 - pickfire:patch-6, r=JohnTitor

    Improve fs error open_from unix
    
    Consistency for rust-lang#79399
    Suggested by JohnTitor
    
    r? `@JohnTitor`
    
    Not user if the error is too long now, do we handle long errors well?
    Dylan-DPC committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    aee7b9e View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#83548 - Aaron1011:capture-none-delims, r=pe…

    …trochenkov
    
    Always preserve `None`-delimited groups in a captured `TokenStream`
    
    Previously, we would silently remove any `None`-delimiters when
    capturing a `TokenStream`, 'flattenting' them to their inner tokens.
    This was not normally visible, since we usually have
    `TokenKind::Interpolated` (which gets converted to a `None`-delimited
    group during macro invocation) instead of an actual `None`-delimited
    group.
    
    However, there are a couple of cases where this becomes visible to
    proc-macros:
    1. A cross-crate `macro_rules!` macro has a `None`-delimited group
       stored in its body (as a result of being produced by another
       `macro_rules!` macro). The cross-crate `macro_rules!` invocation
       can then expand to an attribute macro invocation, which needs
       to be able to see the `None`-delimited group.
    2. A proc-macro can invoke an attribute proc-macro with its re-collected
       input. If there are any nonterminals present in the input, they will
       get re-collected to `None`-delimited groups, which will then get
       captured as part of the attribute macro invocation.
    
    Both of these cases are incredibly obscure, so there hopefully won't be
    any breakage. This change will allow more agressive 'flattenting' of
    nonterminals in rust-lang#82608 without losing `None`-delimited groups.
    Dylan-DPC committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    1115acc View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#83555 - m-ou-se:inline-io-error-new-const, …

    …r=jackh726
    
    Add #[inline] to io::Error methods
    
    Fixes rust-lang#82812
    Dylan-DPC committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    7d6af67 View commit details
    Browse the repository at this point in the history