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 7 pull requests #108600

Closed
wants to merge 23 commits into from

Commits on Feb 17, 2023

  1. Configuration menu
    Copy the full SHA
    4de9c6d View commit details
    Browse the repository at this point in the history
  2. Correct eslint warning

    notriddle authored Feb 17, 2023
    Configuration menu
    Copy the full SHA
    d963318 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2023

  1. Configuration menu
    Copy the full SHA
    07cf219 View commit details
    Browse the repository at this point in the history
  2. use span of semicolon for eager recovery in expression

    instead of the span of the token after the semicolon
    Lukas Markeffsky committed Feb 22, 2023
    Configuration menu
    Copy the full SHA
    611ab68 View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2023

  1. Lazily compute crate name for consider_optimizing

    The extra query is unnecessary in the common case of not having fuel.
    Noratrieb committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    7ee01b4 View commit details
    Browse the repository at this point in the history

Commits on Feb 24, 2023

  1. Configuration menu
    Copy the full SHA
    8574085 View commit details
    Browse the repository at this point in the history
  2. add loop keyword to error diag

    y21 committed Feb 24, 2023
    Configuration menu
    Copy the full SHA
    8820631 View commit details
    Browse the repository at this point in the history
  3. recover from loop...else

    y21 committed Feb 24, 2023
    Configuration menu
    Copy the full SHA
    152a029 View commit details
    Browse the repository at this point in the history
  4. move old ui test

    y21 committed Feb 24, 2023
    Configuration menu
    Copy the full SHA
    13b8497 View commit details
    Browse the repository at this point in the history

Commits on Feb 25, 2023

  1. Update search eBNF with ! moved

    Co-Authored-By: GuillaumeGomez <[email protected]>
    notriddle and GuillaumeGomez authored Feb 25, 2023
    Configuration menu
    Copy the full SHA
    96e6fb6 View commit details
    Browse the repository at this point in the history
  2. Add CastKind::Transmute to MIR

    Nothing actually produces it in this commit.
    scottmcm committed Feb 25, 2023
    Configuration menu
    Copy the full SHA
    0905bad View commit details
    Browse the repository at this point in the history

Commits on Feb 26, 2023

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

Commits on Feb 27, 2023

  1. Configuration menu
    Copy the full SHA
    3fbdbcc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6f49f85 View commit details
    Browse the repository at this point in the history
  3. rustc_middle: Remove trait DefIdTree

    This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
    petrochenkov committed Feb 27, 2023
    Configuration menu
    Copy the full SHA
    6afe9e3 View commit details
    Browse the repository at this point in the history

Commits on Feb 28, 2023

  1. Add Option::as_slice(_mut)

    This adds the following functions:
    
    * `Option<T>::as_slice(&self) -> &[T]`
    * `Option<T>::as_slice_mut(&mut self) -> &[T]`
    
    The `as_slice` and `as_slice_mut` functions benefit from an
    optimization that makes them completely branch-free.
    
    Note that the optimization's soundness hinges on the fact that either
    the niche optimization makes the offset of the `Some(_)` contents zero
    or the mempory layout of `Option<T>` is equal to that of
    `Option<MaybeUninit<T>>`.
    llogiq committed Feb 28, 2023
    Configuration menu
    Copy the full SHA
    41da875 View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2023

  1. Rollup merge of rust-lang#105871 - llogiq:option-as-slice, r=scottmcm

    Add `Option::as_`(`mut_`)`slice`
    
    This adds the following functions:
    
    * `Option<T>::as_slice(&self) -> &[T]`
    * `Option<T>::as_mut_slice(&mut self) -> &[T]`
    
    The `as_slice` and `as_mut_slice_mut` functions benefit from an optimization that makes them completely branch-free. ~~Unfortunately, this optimization is not available on by-value Options, therefore the `into_slice` implementations use the plain `match` + `slice::from_ref` approach.~~
    
    Note that the optimization's soundness hinges on the fact that either the niche optimization makes the offset of the `Some(_)` contents zero or the mempory layout of `Option<T>` is equal to that of `Option<MaybeUninit<T>>`.
    
    The idea has been discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Option.3A.3Aas_slice). Notably the idea for the `as_slice_mut` and `into_slice´ methods came from `@cuviper` and `@Sp00ph` hardened the optimization against niche-optimized Options.
    
    The [rust playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=74f8e4239a19f454c183aaf7b4a969e0) shows that the generated assembly of the optimized method is basically only a copy while the naive method generates code containing a `test dx, dx` on x86_64.
    
    ---
    
    EDIT from reviewer: ACP is rust-lang/libs-team#150
    matthiaskrgr authored Mar 1, 2023
    Configuration menu
    Copy the full SHA
    f70045c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    19ff1f2 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#108244 - lukas-code:semicolon-recovery-span…

    …, r=compiler-errors
    
    Use span of semicolon for eager recovery in expression
    
    Instead of the span of the token after the semicolon. This will hopefully cause fewer errors from overlapping spans.
    
    fixes rust-lang#108242
    based on rust-lang#108239
    matthiaskrgr authored Mar 1, 2023
    Configuration menu
    Copy the full SHA
    5b64847 View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#108351 - petrochenkov:rmdit, r=cjgillot

    rustc_middle: Remove trait `DefIdTree`
    
    This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
    matthiaskrgr authored Mar 1, 2023
    Configuration menu
    Copy the full SHA
    5368f78 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#108405 - Nilstrieb:lazy-crate-name-optimiza…

    …tion-fuel, r=WaffleLapkin
    
    Lazily compute crate name for consider_optimizing
    
    The extra query is unnecessary in the common case of not having fuel.
    matthiaskrgr authored Mar 1, 2023
    Configuration menu
    Copy the full SHA
    4ebf78a View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#108427 - y21:for-else-diagnostic, r=compile…

    …r-errors
    
    Recover from for-else and while-else
    
    This recovers from attempts at writing for-else or while-else loops, which might help users coming from e.g. Python.
    ```rs
    for _ in 0..0 {
      // ...
    } else {
      // ...
    }
    ```
    Combined with trying to store it in a let binding, the current diagnostic can be a bit confusing. It mentions let-else and suggests wrapping the loop in parentheses, which the user probably doesn't want. let-else doesn't make sense for `for` and `while` loops, as they are of type `()` (which already is an irrefutable pattern and doesn't need let-else).
    <details>
    <summary>Current diagnostic</summary>
    
    ```rs
    error: right curly brace `}` before `else` in a `let...else` statement not allowed
     --> src/main.rs:4:5
      |
    4 |     } else {
      |     ^
      |
    help: wrap the expression in parentheses
      |
    2 ~     let _x = (for _ in 0..0 {
    3 |
    4 ~     }) else {
      |
    ```
    </details>
    
    Some questions:
    - Can the wording for the error message be improved? Would "for...else loops are not allowed" fit better?
    - Should we be more "conservative" in case we want to support this in the future (i.e. say "for...else loops are **currently** not allowed/supported")?
    - Is there a better way than storing a `&'static str` for the loop type? It is used for substituting the placeholder in the locale file (since it can emit either `for...else` or `while...else`). Maybe there is an enum I could use that I couldn't find
    matthiaskrgr authored Mar 1, 2023
    Configuration menu
    Copy the full SHA
    75bd7cc View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#108442 - scottmcm:mir-transmute, r=oli-obk

    Add `CastKind::Transmute` to MIR
    
    ~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~
    
    Includes lowering `transmute` calls to it, so it's used.
    
    Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
    matthiaskrgr authored Mar 1, 2023
    Configuration menu
    Copy the full SHA
    b0e4d56 View commit details
    Browse the repository at this point in the history