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 5 pull requests #95667

Merged
merged 34 commits into from
Apr 5, 2022
Merged

Rollup of 5 pull requests #95667

merged 34 commits into from
Apr 5, 2022

Commits on Mar 23, 2022

  1. bootstrap.py: nixos check in /etc/os-release with quotes

    Per https://www.freedesktop.org/software/systemd/man/os-release.html,
    
    > Variable assignment values must be enclosed in double or single quotes
    > if they include spaces, semicolons or other special characters outside
    > of A–Z, a–z, 0–9. (Assignments that do not include these special
    > characters may be enclosed in quotes too, but this is optional.)
    
    So, past `ID=nixos`, let's also check for `ID='nixos'` and `ID="nixos"`.
    
    One of these is necessary between NixOS/nixpkgs#162168 and
    NixOS/nixpkgs#164068, but this seems more correct either way.
    ben0x539 committed Mar 23, 2022
    Configuration menu
    Copy the full SHA
    76756cc View commit details
    Browse the repository at this point in the history

Commits on Mar 29, 2022

  1. Fix x doc --stage 0 compiler

    Eric figured out the fix to this almost 2 years ago, I just didn't read his comment carefully enough at the timme.
    The issue was that fake rustc and fake rustdoc were inconsistent about when they passed `--sysroot` to the real compiler.
    Change them to consistently only pass it when `--target` is present.
    jyn514 committed Mar 29, 2022
    Configuration menu
    Copy the full SHA
    064a559 View commit details
    Browse the repository at this point in the history

Commits on Apr 4, 2022

  1. Configuration menu
    Copy the full SHA
    bf2c3b0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    50cc0fa View commit details
    Browse the repository at this point in the history

Commits on Apr 5, 2022

  1. Configuration menu
    Copy the full SHA
    a8877cf View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2a129d4 View commit details
    Browse the repository at this point in the history
  3. errors: introduce DiagnosticMessage

    Introduce a `DiagnosticMessage` type that will enable diagnostic
    messages to be simple strings or Fluent identifiers.
    `DiagnosticMessage` is now used in the implementation of the standard
    `DiagnosticBuilder` APIs.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    8c68456 View commit details
    Browse the repository at this point in the history
  4. span: move MultiSpan

    `MultiSpan` contains labels, which are more complicated with the
    introduction of diagnostic translation and will use types from
    `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
    `rustc_span` cannot use types like `DiagnosticMessage` without
    dependency cycles. Introduce a new `rustc_error_messages` crate that can
    contain `DiagnosticMessage` and `MultiSpan`.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    c45f295 View commit details
    Browse the repository at this point in the history
  5. errors: implement fallback diagnostic translation

    This commit updates the signatures of all diagnostic functions to accept
    types that can be converted into a `DiagnosticMessage`. This enables
    existing diagnostic calls to continue to work as before and Fluent
    identifiers to be provided. The `SessionDiagnostic` derive just
    generates normal diagnostic calls, so these APIs had to be modified to
    accept Fluent identifiers.
    
    In addition, loading of the "fallback" Fluent bundle, which contains the
    built-in English messages, has been implemented.
    
    Each diagnostic now has "arguments" which correspond to variables in the
    Fluent messages (necessary to render a Fluent message) but no API for
    adding arguments has been added yet. Therefore, diagnostics (that do not
    require interpolation) can be converted to use Fluent identifiers and
    will be output as before.
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    7f91697 View commit details
    Browse the repository at this point in the history
  6. errors: implement sysroot/testing bundle loading

    Extend loading of Fluent bundles so that bundles can be loaded from the
    sysroot based on the language requested by the user, or using a nightly
    flag.
    
    Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    d5119c5 View commit details
    Browse the repository at this point in the history
  7. macros: update comments

    Various small changes to comments, like wrapping code in backticks,
    changing comments to doc comments and adding newlines.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    2bf64d6 View commit details
    Browse the repository at this point in the history
  8. macros: move suggestion type handling to fn

    Move the handling of `Span` or `(Span, Applicability)` types in
    `#[suggestion]` attributes to its own function.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    8677fef View commit details
    Browse the repository at this point in the history
  9. macros: add args for non-subdiagnostic fields

    Non-subdiagnostic fields (i.e. those that don't have `#[label]`
    attributes or similar and are just additional context) have to be added
    as arguments for Fluent messages to refer them. This commit extends the
    `SessionDiagnostic` derive to do this for all fields that do not have
    attributes and introduces an `IntoDiagnosticArg` trait that is
    implemented on all types that can be converted to a argument for Fluent.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    9956d4f View commit details
    Browse the repository at this point in the history
  10. errors: disable directionality isolation markers

    Fluent diagnostics can insert directionality isolation markers around
    interpolated variables indicating that there may be a shift from
    right-to-left to left-to-right text (or vice-versa). These are disabled
    because they are sometimes visible in the error output, but may be worth
    investigating in future (for example: if type names are left-to-right
    and the surrounding diagnostic messages are right-to-left, then these
    might be helpful).
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    a52b507 View commit details
    Browse the repository at this point in the history
  11. macros: update session diagnostic errors

    Small commit adding backticks around types and annotations in the error
    messages from the session diagnostic derive.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    f0de7df View commit details
    Browse the repository at this point in the history
  12. macros: translatable struct attrs and warnings

    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    d0fd8d7 View commit details
    Browse the repository at this point in the history
  13. macros: rename #[message] to #[primary_span]

    Small commit renaming `#[message]` to `#[primary_span]` as this more
    accurately reflects what it does now.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    8100541 View commit details
    Browse the repository at this point in the history
  14. macros: add #[no_arg] to skip set_arg call

    A call to `set_arg` is generated for every field of a
    `SessionDiagnostic` struct without attributes, but not all types support
    being an argument, so `#[no_arg]` is introduced to skip these fields.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    70ee0c9 View commit details
    Browse the repository at this point in the history
  15. macros: optional error codes

    In an effort to make it easier to port diagnostics to
    `SessionDiagnostic` (for translation) and since translation slugs could
    replace error codes, make error codes optional in the
    `SessionDiagnostic` derive.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    72dec56 View commit details
    Browse the repository at this point in the history
  16. macros: support translatable labels

    Extends support for generating `DiagnosticMessage::FluentIdentifier`
    messages from `SessionDiagnostic` derive to `#[label]`.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    a88717c View commit details
    Browse the repository at this point in the history
  17. macros: note/help in SessionDiagnostic derive

    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    b40ee88 View commit details
    Browse the repository at this point in the history
  18. macros: support translatable suggestions

    Extends support for generating `DiagnosticMessage::FluentIdentifier`
    messages from `SessionDiagnostic` derive to `#[suggestion]`.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    22685b9 View commit details
    Browse the repository at this point in the history
  19. errors: don't try load default locale from sysroot

    If the user requests a diagnostic locale of "en-US" then it doesn't make
    sense to try and load that from the `$sysroot` because it is just the
    default built-in locale.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    141f840 View commit details
    Browse the repository at this point in the history
  20. typeck: remove now-unnecessary parameter from diag

    Removes `expected_pluralize` parameter from diagnostic struct which is
    no longer necessary as the Fluent message can determine the correct
    pluralization.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    c6a3349 View commit details
    Browse the repository at this point in the history
  21. errors: add links to fluent documentation

    Add some links to the Fluent documentation to
    `DiagnosticMessage::FluentIdentifier` which explain what a Fluent
    message and attribute are.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    e27389b View commit details
    Browse the repository at this point in the history
  22. session: opt for enabling directionality markers

    Add an option for enabling and disabling Fluent's directionality
    isolation markers in output. Disabled by default as these can render in
    some terminals and applications.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    3c2f864 View commit details
    Browse the repository at this point in the history
  23. errors: use impl Into<FluentId>

    `FluentId` is the type alias that is used everywhere else so it should
    be used here too so that this doesn't need updated if the alias changes.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    66f22e5 View commit details
    Browse the repository at this point in the history
  24. tidy: add fluent dependencies to whitelist

    Unfortunately, fluent comes with a lot of dependencies and these need to
    be added to the whitelist.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    da56d92 View commit details
    Browse the repository at this point in the history
  25. errors: support fluent + parallel compiler

    Conditional on the parallel compiler being enabled, use a different
    `IntlLangMemoizer` which supports being sent between threads in
    `FluentBundle`.
    
    Signed-off-by: David Wood <[email protected]>
    davidtwco committed Apr 5, 2022
    Configuration menu
    Copy the full SHA
    ccd4820 View commit details
    Browse the repository at this point in the history
  26. Rollup merge of rust-lang#95234 - ben0x539:nixquotes, r=Dylan-DPC

    bootstrap.py: nixos check in /etc/os-release with quotes
    
    Per https://www.freedesktop.org/software/systemd/man/os-release.html,
    
    > Variable assignment values must be enclosed in double or single quotes
    > if they include spaces, semicolons or other special characters outside
    > of A–Z, a–z, 0–9. (Assignments that do not include these special
    > characters may be enclosed in quotes too, but this is optional.)
    
    So, past `ID=nixos`, let's also check for `ID='nixos'` and `ID="nixos"`.
    
    One of these is necessary between NixOS/nixpkgs#162168 and
    NixOS/nixpkgs#164068, but this seems more correct either way.
    Dylan-DPC authored Apr 5, 2022
    Configuration menu
    Copy the full SHA
    b7047c2 View commit details
    Browse the repository at this point in the history
  27. Rollup merge of rust-lang#95449 - jyn514:doc-stage-0, r=ehuss

    Fix `x doc --stage 0 compiler`
    
    Eric figured out the fix to this almost 2 years ago, I just didn't read his comment carefully enough at the timme.
    The issue was that fake rustc and fake rustdoc were inconsistent about when they passed `--sysroot` to the real compiler.
    Change them to consistently only pass it when `--target` is present.
    
    cc rust-lang#74976 (comment)
    Fixes rust-lang#79980
    
    r? ``@ehuss``
    Dylan-DPC authored Apr 5, 2022
    Configuration menu
    Copy the full SHA
    73eab35 View commit details
    Browse the repository at this point in the history
  28. Rollup merge of rust-lang#95512 - davidtwco:diagnostic-translation, r…

    …=oli-obk
    
    diagnostics: translation infrastructure
    
    An implementation of the infrastructure required to have translatable diagnostic messages.
    
    - Introduces a `DiagnosticMessage` type which can represent both the current non-translatable messages and identifiers for [Fluent](https://projectfluent.org/).
    - Modifies current diagnostic API so that existing calls still work but `DiagnosticMessage`s can be provided too.
    - Adds support for always loading a "fallback bundle" containing the English diagnostic messages, which are used when a `DiagnosticMessage::FluentIdentifier` is used in a diagnostic being emitted.
    - Adds support for loading a "primary bundle" which contains the user's preferred language translation, and is used preferentially when it contains a diagnostic message being emitted. Primary bundles are loaded either from the path provided to `-Ztranslate-alternate-ftl` (for testing), or from the sysroot at `$sysroot/locale/$locale/*.ftl` given a locale with `-Ztranslate-lang` (which is parsed as a language identifier).
    - Adds "diagnostic args" which enable normally-interpolated variables to be made available as variables for Fluent messages to use.
    - Updates `#[derive(SessionDiagnostic)]` so that it can only be used for translatable diagnostics and update the handful of diagnostics which used the derive to be translatable.
    
    For example, the following diagnostic...
    
    ```rust
    #[derive(SessionDiagnostic)]
    #[error = "E0195"]
    pub struct LifetimesOrBoundsMismatchOnTrait {
        #[message = "lifetime parameters or bounds on {item_kind} `{ident}` do not match the trait declaration"]
        #[label = "lifetimes do not match {item_kind} in trait"]
        pub span: Span,
        #[label = "lifetimes in impl do not match this {item_kind} in trait"]
        pub generics_span: Option<Span>,
        pub item_kind: &'static str,
        pub ident: Ident,
    }
    ```
    
    ...becomes...
    
    ```rust
    #[derive(SessionDiagnostic)]
    #[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
    pub struct LifetimesOrBoundsMismatchOnTrait {
        #[primary_span]
        #[label]
        pub span: Span,
        #[label = "generics-label"]
        pub generics_span: Option<Span>,
        pub item_kind: &'static str,
        pub ident: Ident,
    }
    ```
    
    ```fluent
    typeck-lifetimes-or-bounds-mismatch-on-trait =
        lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration
        .label = lifetimes do not match {$item_kind} in trait
        .generics-label = lifetimes in impl do not match this {$item_kind} in trait
    ```
    
    r? `@estebank`
    cc `@oli-obk` `@Manishearth`
    Dylan-DPC authored Apr 5, 2022
    Configuration menu
    Copy the full SHA
    d473024 View commit details
    Browse the repository at this point in the history
  29. Rollup merge of rust-lang#95607 - compiler-errors:issue-95272, r=Aaro…

    …n1011
    
    Note invariance reason for FnDef types
    
    Fixes rust-lang#95272. Is it worthwhile even printing a variance explanation here? Or should I try to track down which function parameter is responsible for the invariance?
    
    r? ``@Aaron1011`` since you wrote rust-lang#89336
    Dylan-DPC authored Apr 5, 2022
    Configuration menu
    Copy the full SHA
    2a7e7bd View commit details
    Browse the repository at this point in the history
  30. Rollup merge of rust-lang#95645 - GuillaumeGomez:intra-doc-link-ice-t…

    …raits-in-scope-primitive, r=jyn514
    
    Fix intra doc link ICE when trying to get traits in scope for primitive
    
    Fixes rust-lang#95633.
    
    I think ``@notriddle`` was the one who worked on this part of the code last so:
    
    r? ``@notriddle``
    Dylan-DPC authored Apr 5, 2022
    Configuration menu
    Copy the full SHA
    bf44a87 View commit details
    Browse the repository at this point in the history