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

Merged
merged 25 commits into from
Oct 12, 2022
Merged

Rollup of 7 pull requests #102975

merged 25 commits into from
Oct 12, 2022

Commits on Oct 10, 2022

  1. macros: tidy up lint changes

    Small tweaks to changes made in a previous PR, unrelated to eager
    translation.
    
    Signed-off-by: David Wood <david.wood@huawei.com>
    davidtwco committed Oct 10, 2022
    Configuration menu
    Copy the full SHA
    febbf71 View commit details
    Browse the repository at this point in the history
  2. errors: use HashMap to store diagnostic args

    Eager translation will enable subdiagnostics to be translated multiple
    times with different arguments - this requires the ability to replace
    the value of one argument with a new value, which is better suited to a
    `HashMap` than the previous storage, a `Vec`.
    
    Signed-off-by: David Wood <david.wood@huawei.com>
    davidtwco committed Oct 10, 2022
    Configuration menu
    Copy the full SHA
    508d7e6 View commit details
    Browse the repository at this point in the history
  3. errors: AddToDiagnostic::add_to_diagnostic_with

    `AddToDiagnostic::add_to_diagnostic_with` is similar to the previous
    `AddToDiagnostic::add_to_diagnostic` but takes a function that can be
    used by the caller to modify diagnostic messages originating from the
    subdiagnostic (such as performing translation eagerly).
    
    `add_to_diagnostic` now just calls `add_to_diagnostic_with` with an
    empty closure.
    
    Signed-off-by: David Wood <david.wood@huawei.com>
    davidtwco committed Oct 10, 2022
    Configuration menu
    Copy the full SHA
    b4ac262 View commit details
    Browse the repository at this point in the history
  4. errors: DiagnosticMessage::Eager

    Add variant of `DiagnosticMessage` for eagerly translated messages
    (messages in the target language which don't need translated by the
    emitter during emission). Also adds `eager_subdiagnostic` function which
    is intended to be invoked by the diagnostic derive for subdiagnostic
    fields which are marked as needing eager translation.
    
    Signed-off-by: David Wood <david.wood@huawei.com>
    davidtwco committed Oct 10, 2022
    Configuration menu
    Copy the full SHA
    540b203 View commit details
    Browse the repository at this point in the history
  5. macros: #[subdiagnostic(eager)]

    Add support for `eager` argument to the `subdiagnostic` attribute which
    generates a call to `eager_subdiagnostic`.
    
    Signed-off-by: David Wood <david.wood@huawei.com>
    davidtwco committed Oct 10, 2022
    Configuration menu
    Copy the full SHA
    291a473 View commit details
    Browse the repository at this point in the history
  6. query_system: finish migration

    Using eager translation, migrate the remaining repeated cycle stack
    diagnostic.
    
    Signed-off-by: David Wood <david.wood@huawei.com>
    davidtwco committed Oct 10, 2022
    Configuration menu
    Copy the full SHA
    113e943 View commit details
    Browse the repository at this point in the history
  7. macros: separate suggestion fmt'ing and emission

    Diagnostic derives have previously had to take special care when
    ordering the generated code so that fields were not used after a move.
    
    This is unlikely for most fields because a field is either annotated
    with a subdiagnostic attribute and is thus likely a `Span` and copiable,
    or is a argument, in which case it is only used once by `set_arg`
    anyway.
    
    However, format strings for code in suggestions can result in fields
    being used after being moved if not ordered carefully. As a result, the
    derive currently puts `set_arg` calls last (just before emission), such
    as:
    
    ```rust
    let diag = { /* create diagnostic */ };
    
    diag.span_suggestion_with_style(
        span,
        fluent::crate::slug,
        format!("{}", __binding_0),
        Applicability::Unknown,
        SuggestionStyle::ShowAlways
    );
    /* + other subdiagnostic additions */
    
    diag.set_arg("foo", __binding_0);
    /* + other `set_arg` calls */
    
    diag.emit();
    ```
    
    For eager translation, this doesn't work, as the message being
    translated eagerly can assume that all arguments are available - so
    arguments _must_ be set first.
    
    Format strings for suggestion code are now separated into two parts - an
    initialization line that performs the formatting into a variable, and a
    usage in the subdiagnostic addition.
    
    By separating these parts, the initialization can happen before
    arguments are set, preserving the desired order so that code compiles,
    while still enabling arguments to be set before subdiagnostics are
    added.
    
    ```rust
    let diag = { /* create diagnostic */ };
    
    let __code_0 = format!("{}", __binding_0);
    /* + other formatting */
    
    diag.set_arg("foo", __binding_0);
    /* + other `set_arg` calls */
    
    diag.span_suggestion_with_style(
        span,
        fluent::crate::slug,
        __code_0,
        Applicability::Unknown,
        SuggestionStyle::ShowAlways
    );
    /* + other subdiagnostic additions */
    
    diag.emit();
    ```
    
    Signed-off-by: David Wood <david.wood@huawei.com>
    davidtwco committed Oct 10, 2022
    Configuration menu
    Copy the full SHA
    7e20929 View commit details
    Browse the repository at this point in the history
  8. macros: simplify field ordering in diag derive

    Following the approach taken in earlier commits to separate formatting
    initialization from use in the subdiagnostic derive, simplify the
    diagnostic derive by removing the field-ordering logic that previously
    solved this problem.
    
    Signed-off-by: David Wood <david.wood@huawei.com>
    davidtwco committed Oct 10, 2022
    Configuration menu
    Copy the full SHA
    fbac1f2 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    d17a69e View commit details
    Browse the repository at this point in the history

Commits on Oct 11, 2022

  1. Configuration menu
    Copy the full SHA
    f9d3c83 View commit details
    Browse the repository at this point in the history
  2. rustdoc: remove unused CSS nav.sum

    This was added in 4fd061c, but never
    actually used.
    notriddle committed Oct 11, 2022
    Configuration menu
    Copy the full SHA
    87060c4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    46169e6 View commit details
    Browse the repository at this point in the history
  4. Update books

    ehuss committed Oct 11, 2022
    Configuration menu
    Copy the full SHA
    f8048aa View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2022

  1. Configuration menu
    Copy the full SHA
    c646c4d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    bef8681 View commit details
    Browse the repository at this point in the history
  3. Add tidy directoy tidy-alphabetical

    It can be used to ensure that a list of things is sorted alphabetically.
    It goes off lines, but contains several heuristics to work with normal
    Rust code (looking at indentation, ignoring comments and attributes).
    Noratrieb authored and Dylan-DPC committed Oct 12, 2022
    Configuration menu
    Copy the full SHA
    0e38673 View commit details
    Browse the repository at this point in the history
  4. Use tidy-alphabetical in the compiler

    Noratrieb authored and Dylan-DPC committed Oct 12, 2022
    Configuration menu
    Copy the full SHA
    7bfef19 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ce35609 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#102623 - davidtwco:translation-eager, r=com…

    …piler-errors
    
    translation: eager translation
    
    Part of rust-lang#100717. See [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20lists!/near/295010720) for additional context.
    
    - **Store diagnostic arguments in a `HashMap`**: Eager translation will enable subdiagnostics to be translated multiple times with different arguments - this requires the ability to replace the value of one argument with a new value, which is better suited to a `HashMap` than the previous storage, a `Vec`.
    - **Add `AddToDiagnostic::add_to_diagnostic_with`**: `AddToDiagnostic::add_to_diagnostic_with` is similar to the previous `AddToDiagnostic::add_to_diagnostic` but takes a function that can be used by the caller to modify diagnostic messages originating from the subdiagnostic (such as performing translation eagerly). `add_to_diagnostic` now just calls `add_to_diagnostic_with` with an empty closure.
    - **Add `DiagnosticMessage::Eager`**: Add variant of `DiagnosticMessage` for eagerly translated messages
    (messages in the target language which don't need translated by the emitter during emission). Also adds `eager_subdiagnostic` function which is intended to be invoked by the diagnostic derive for subdiagnostic fields which are marked as needing eager translation.
    - **Support `#[subdiagnostic(eager)]`**: Add support for `eager` argument to the `subdiagnostic` attribute which generates a call to `eager_subdiagnostic`.
    - **Finish migrating `rustc_query_system`**: Using eager translation, migrate the remaining repeated cycle stack diagnostic.
    - **Split formatting initialization and use in diagnostic derives**: Diagnostic derives have previously had to take special care when ordering the generated code so that fields were not used after a move.
    
      This is unlikely for most fields because a field is either annotated with a subdiagnostic attribute and is thus likely a `Span` and copiable, or is a argument, in which case it is only used once by `set_arg`
    anyway.
    
      However, format strings for code in suggestions can result in fields being used after being moved if not ordered carefully. As a result, the derive currently puts `set_arg` calls last (just before emission), such as:
    
          let diag = { /* create diagnostic */ };
    
          diag.span_suggestion_with_style(
              span,
              fluent::crate::slug,
              format!("{}", __binding_0),
              Applicability::Unknown,
              SuggestionStyle::ShowAlways
          );
          /* + other subdiagnostic additions */
    
          diag.set_arg("foo", __binding_0);
          /* + other `set_arg` calls */
    
          diag.emit();
    
      For eager translation, this doesn't work, as the message being translated eagerly can assume that all arguments are available - so arguments _must_ be set first.
    
      Format strings for suggestion code are now separated into two parts - an initialization line that performs the formatting into a variable, and a usage in the subdiagnostic addition.
    
      By separating these parts, the initialization can happen before arguments are set, preserving the desired order so that code compiles, while still enabling arguments to be set before subdiagnostics are added.
    
          let diag = { /* create diagnostic */ };
    
          let __code_0 = format!("{}", __binding_0);
          /* + other formatting */
    
          diag.set_arg("foo", __binding_0);
          /* + other `set_arg` calls */
    
          diag.span_suggestion_with_style(
              span,
              fluent::crate::slug,
              __code_0,
              Applicability::Unknown,
              SuggestionStyle::ShowAlways
          );
          /* + other subdiagnostic additions */
    
          diag.emit();
    
    - **Remove field ordering logic in diagnostic derive:** Following the approach taken in earlier commits to separate formatting initialization from use in the subdiagnostic derive, simplify the diagnostic derive by removing the field-ordering logic that previously solved this problem.
    
    r? ```@compiler-errors```
    Dylan-DPC authored Oct 12, 2022
    Configuration menu
    Copy the full SHA
    dc9f6f3 View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#102719 - Nilstrieb:tidy-alphabetical, r=jac…

    …kh726
    
    Enforce alphabetical sorting with tidy
    
    We have many places where things are supposed to be sorted alphabetically. For the smaller and more recent size assertions, this is mostly upheld, but in other more... alive places it's very messy.
    
    This introduces a new tidy directive to check that a section of code is sorted alphabetically and fixes all places where sorting has gone wrong.
    Dylan-DPC authored Oct 12, 2022
    Configuration menu
    Copy the full SHA
    40deece View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#102830 - compiler-errors:constness-parity, …

    …r=fee1-dead
    
    Unify `tcx.constness` query and param env constness checks
    
    The checks that we do in the `constness` query seem inconsistent with the checks that we do to determine if an item's param-env is const, so I merged them into the `constness` query and call that from the `param_env` query.
    
    I'm not sure if this totally makes sense -- is there a case where `tcx.param_env()` would return a const param-env for an item whose `tcx.constness()` is `Constness::NotConst`? Because if not, it seems a bit dangerous that these two differ.
    
    Luckily, not many places actually use `tcx.constness()`, and the checks in `tcx.param_env()` seem stricter than the checks in `tcx.constness()` (at least for the types of items we type-check).
    
    Also, due to the way that `tcx.param_env()` is implemented, it _never_ used to return a const param-env for a item coming from a different crate, which also seems dangerous (though also probably not weaponizable currently, because we seldom actually compute the param-env for a non-local item).
    Dylan-DPC authored Oct 12, 2022
    Configuration menu
    Copy the full SHA
    c763ebc View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#102883 - Urgau:fix-stabilization-half_open_…

    …range_patterns, r=lcnr
    
    Fix stabilization of `feature(half_open_range_patterns)`
    
    Fixes https://github.com/rust-lang/rust/pull/102275/files#r991292215 by removing the relevant code that was [already partial moved](https://github.com/rust-lang/rust/pull/102275/files#diff-307e0d3a2037c11a3fa16822fbaa0fec08e57ac7d0d6e7354f6005c9482a9e26).
    
    cc `@Undin`
    Dylan-DPC authored Oct 12, 2022
    Configuration menu
    Copy the full SHA
    117a98c View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#102927 - compiler-errors:let, r=davidtwco

    Fix `let` keyword removal suggestion in structs
    
    (1.) Fixes a bug where, given this code:
    ```rust
    struct Foo {
      let x: i32,
    }
    ```
    
    We were parsing the field name as `let` instead of `x`, which causes issues later on in the type-checking phase.
    
    (2.) Also, suggestions for `let: i32` as a field regressed, displaying this extra `help:` which is removed by this PR
    
    ```
    help: remove the let, the `let` keyword is not allowed in struct field definitions
      |
    2 -     let: i32,
    2 +     : i32,
    ```
    
    (3.) Makes the suggestion text a bit more succinct, since we don't need to re-explain that `let` is not allowed in this position (since it's in a note that follows). This causes the suggestion to render inline as well.
    
    cc `@gimbles,` this addresses a few nits I mentioned in your PR.
    Dylan-DPC authored Oct 12, 2022
    Configuration menu
    Copy the full SHA
    a9a5529 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#102936 - notriddle:notriddle/nav-sum, r=Dyl…

    …an-DPC
    
    rustdoc: remove unused CSS `nav.sum`
    
    This was added in 4fd061c, but never actually used.
    Dylan-DPC authored Oct 12, 2022
    Configuration menu
    Copy the full SHA
    dcf7052 View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#102940 - ehuss:update-books, r=ehuss

    Update books
    
    ## nomicon
    
    1 commits in f53bfa056929217870a5d2df1366d2e7ba35096d..9c73283775466d22208a0b28afcab44db4c0cc10
    2022-09-05 07:19:02 -0700 to 2022-09-30 07:31:22 +0900
    - Fix typo (rust-lang/nomicon#380)
    
    ## reference
    
    9 commits in a7cdac33ca7356ad49d5c2b5e2c5010889b33eee..f6ed74f582bddcec73f753eafaab3749c4f7df61
    2022-09-19 17:39:58 -0700 to 2022-10-08 02:43:26 -0700
    - Typo 'a' -&gt; 'an' (rust-lang/reference#1280)
    - One line one sentence for expressions and statements main chapters (rust-lang/reference#1277)
    - Document let else statements (rust-lang/reference#1156)
    - Document `label_break_value` in the reference (rust-lang/reference#1263)
    - Document target_has_atomic (rust-lang/reference#1171)
    - update 'unsafe' (rust-lang/reference#1278)
    - Update tokens.md (rust-lang/reference#1276)
    - One sentence, one line Patterns chapter (rust-lang/reference#1275)
    - Use semver-compliant example version (rust-lang/reference#1272)
    
    ## rust-by-example
    
    9 commits in 767a6bd9727a596d7cfdbaeee475e65b2670ea3a..5e7b296d6c345addbd748f242aae28c42555c015
    2022-09-14 09:17:18 -0300 to 2022-10-05 08:24:45 -0300
    - Make it clear that rustdoc uses the commonmark spec (rust-lang/rust-by-example#1622)
    - Update defaults.md (rust-lang/rust-by-example#1615)
    - added "see also" for the @ binding sigil (rust-lang/rust-by-example#1612)
    - add more precision to the effects of --bin flag (rust-lang/rust-by-example#1607)
    - create bar project in cargo/dependencies example (rust-lang/rust-by-example#1606)
    - use consistent wording about type annotation (rust-lang/rust-by-example#1603)
    - cast.md improvements (rust-lang/rust-by-example#1599)
    - Fix typo in macros.md (rust-lang/rust-by-example#1598)
    - Corrected mistaken "The" instead of "There" (rust-lang/rust-by-example#1617)
    
    ## rustc-dev-guide
    
    2 commits in 9a86c0467bbe42056f73fdf5b03fff757d7c4a9b..7518c3445dc02df0d196f5f84e568d633c5141fb
    2022-10-07 18:34:51 +0200 to 2022-10-08 12:29:47 +0200
    - Update debugging.md
    - Use llvm subdomain for compiler-explorer link
    
    ## embedded-book
    
    1 commits in 4ce51cb7441a6f02b5bf9b07b2eb755c21ab7954..c533348edd69f11a8f4225d633a05d7093fddbf3
    2022-09-15 08:53:09 +0000 to 2022-10-10 10:16:49 +0000
    - Fix a typo in registers.md  (rust-embedded/book#330)
    Dylan-DPC authored Oct 12, 2022
    Configuration menu
    Copy the full SHA
    f2c4810 View commit details
    Browse the repository at this point in the history