about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2022-04-05rustc_trait_selection changesPietro Albini-18/+0
2022-04-05trivial cfg(bootstrap) changesPietro Albini-314/+176
2022-04-05bump stage0 to the latest betaPietro Albini-336/+336
2022-04-05Auto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardinbors-334/+467
Let CTFE to handle partially uninitialized unions without marking the entire value as uninitialized. follow up to #94411 To fix https://github.com/rust-lang/rust/issues/69488 and by extension fix https://github.com/rust-lang/rust/issues/94371, we should stop treating types like `MaybeUninit<usize>` as something that the `Scalar` type in the interpreter engine can represent. So we add a new field to `abi::Primitive` that records whether the primitive is nested in a union cc `@RalfJung` r? `@ghost`
2022-04-05Auto merge of #95680 - Dylan-DPC:rollup-7jldtnz, r=Dylan-DPCbors-75/+453
Rollup of 4 pull requests Successful merges: - #95525 (Suggest derivable trait on E0277 error) - #95654 (diagnostics: use correct span for const generics) - #95660 (Update panic docs to make it clearer when to use panic vs Result) - #95670 (Refactor: remove unused function parameters) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-05Rollup merge of #95670 - TaKO8Ki:remove-unused-function-parameters, r=davidtwcoDylan DPC-12/+3
Refactor: remove unused function parameters
2022-04-05Rollup merge of #95660 - yaahc:panic-docs-update, r=Dylan-DPCDylan DPC-7/+19
Update panic docs to make it clearer when to use panic vs Result This is based on a question that came up in one of my [error handling office hours](https://twitter.com/yaahc_/status/1506376624509374467?s=20&t=Sp-cEjrx5kpMdNsAGPOo9w) meetings. I had a user who was fairly familiar with error type design, thiserror and anyhow, and rust in general, but who was still confused about when to use panics vs when to use Result and `Error`. This will also be cross referenced in an error handling FAQ that I will be creating in the https://github.com/rust-lang/project-error-handling repo shortly.
2022-04-05Rollup merge of #95654 - notriddle:notriddle/issue-95616, r=davidtwcoDylan DPC-56/+91
diagnostics: use correct span for const generics Fixes #95616
2022-04-05Rollup merge of #95525 - ohno418:suggest-derivable-trait-E0277, ↵Dylan DPC-0/+340
r=compiler-errors Suggest derivable trait on E0277 error Closes https://github.com/rust-lang/rust/issues/95099 .
2022-04-05Use WrappingRange::full instead of hand-rolling itOli Scherer-6/+3
2022-04-05mir-interpret now treats unions as non-immediate, even if they have scalar ↵Oli Scherer-47/+115
layout, allowing partially initializing them
2022-04-05Mark scalar layout unions so that backends that do not support partially ↵Oli Scherer-289/+357
initialized scalars can special case them.
2022-04-05remove unused function parametersTakayuki Maeda-12/+3
2022-04-05Auto merge of #95667 - Dylan-DPC:rollup-n7xzs3y, r=Dylan-DPCbors-1191/+3104
Rollup of 5 pull requests Successful merges: - #95234 (bootstrap.py: nixos check in /etc/os-release with quotes) - #95449 (Fix `x doc --stage 0 compiler`) - #95512 (diagnostics: translation infrastructure) - #95607 (Note invariance reason for FnDef types) - #95645 (Fix intra doc link ICE when trying to get traits in scope for primitive) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-05Fix ui test for nllohno418-0/+4
2022-04-05Rollup merge of #95645 - ↵Dylan DPC-2/+18
GuillaumeGomez:intra-doc-link-ice-traits-in-scope-primitive, r=jyn514 Fix intra doc link ICE when trying to get traits in scope for primitive Fixes #95633. I think ``@notriddle`` was the one who worked on this part of the code last so: r? ``@notriddle``
2022-04-05Rollup merge of #95607 - compiler-errors:issue-95272, r=Aaron1011Dylan DPC-113/+158
Note invariance reason for FnDef types Fixes #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 #89336
2022-04-05Rollup merge of #95512 - davidtwco:diagnostic-translation, r=oli-obkDylan DPC-1071/+2911
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`
2022-04-05Rollup merge of #95449 - jyn514:doc-stage-0, r=ehussDylan DPC-4/+16
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 https://github.com/rust-lang/rust/issues/74976#issuecomment-667265945 Fixes https://github.com/rust-lang/rust/issues/79980 r? ``@ehuss``
2022-04-05Rollup merge of #95234 - ben0x539:nixquotes, r=Dylan-DPCDylan DPC-1/+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.
2022-04-05errors: support fluent + parallel compilerDavid Wood-3/+20
Conditional on the parallel compiler being enabled, use a different `IntlLangMemoizer` which supports being sent between threads in `FluentBundle`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05tidy: add fluent dependencies to whitelistDavid Wood-1/+19
Unfortunately, fluent comes with a lot of dependencies and these need to be added to the whitelist. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: use `impl Into<FluentId>`David Wood-5/+2
`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 <david.wood@huawei.com>
2022-04-05session: opt for enabling directionality markersDavid Wood-18/+27
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 <david.wood@huawei.com>
2022-04-05errors: add links to fluent documentationDavid Wood-1/+5
Add some links to the Fluent documentation to `DiagnosticMessage::FluentIdentifier` which explain what a Fluent message and attribute are. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05typeck: remove now-unnecessary parameter from diagDavid Wood-3/+1
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 <david.wood@huawei.com>
2022-04-05errors: don't try load default locale from sysrootDavid Wood-3/+9
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 <david.wood@huawei.com>
2022-04-05macros: support translatable suggestionsDavid Wood-123/+141
Extends support for generating `DiagnosticMessage::FluentIdentifier` messages from `SessionDiagnostic` derive to `#[suggestion]`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05macros: note/help in `SessionDiagnostic` deriveDavid Wood-10/+158
Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05macros: support translatable labelsDavid Wood-95/+140
Extends support for generating `DiagnosticMessage::FluentIdentifier` messages from `SessionDiagnostic` derive to `#[label]`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05macros: optional error codesDavid Wood-34/+21
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 <david.wood@huawei.com>
2022-04-05macros: add `#[no_arg]` to skip `set_arg` callDavid Wood-2/+45
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 <david.wood@huawei.com>
2022-04-05macros: rename `#[message]` to `#[primary_span]`David Wood-34/+31
Small commit renaming `#[message]` to `#[primary_span]` as this more accurately reflects what it does now. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05macros: translatable struct attrs and warningsDavid Wood-274/+727
Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05macros: update session diagnostic errorsDavid Wood-25/+25
Small commit adding backticks around types and annotations in the error messages from the session diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: disable directionality isolation markersDavid Wood-0/+9
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 <david.wood@huawei.com>
2022-04-05macros: add args for non-subdiagnostic fieldsDavid Wood-30/+122
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 <david.wood@huawei.com>
2022-04-05macros: move suggestion type handling to fnDavid Wood-68/+61
Move the handling of `Span` or `(Span, Applicability)` types in `#[suggestion]` attributes to its own function. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05macros: update commentsDavid Wood-27/+34
Various small changes to comments, like wrapping code in backticks, changing comments to doc comments and adding newlines. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement sysroot/testing bundle loadingDavid Wood-46/+322
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 <david.wood@huawei.com>
2022-04-05errors: implement fallback diagnostic translationDavid Wood-294/+920
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.
2022-04-05span: move `MultiSpan`David Wood-293/+354
`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 <david.wood@huawei.com>
2022-04-05errors: introduce `DiagnosticMessage`David Wood-43/+79
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 <david.wood@huawei.com>
2022-04-05Auto merge of #95337 - petrochenkov:doclink3, r=camelidbors-43/+53
rustdoc: Fix resolution of `crate`-relative paths in doc links Resolve `crate::foo` paths transparently to rustdoc, so their resolution no longer affects diagnostics and modules used for determining traits in scope. The proper solution is to account for the current `module_id`/`parent_scope` in `fn resolve_crate_root`, but it's a slightly larger compiler changes. This PR moves the code closer to it, but keeps it rustdoc-specific. Fixes https://github.com/rust-lang/rust/issues/78696 Fixes https://github.com/rust-lang/rust/issues/94924
2022-04-04Format invariance notes with backticksMichael Goulet-113/+113
2022-04-05Suggest only when all fields impl the traitohno418-26/+50
2022-04-04Handle reporting invariance of fn pointerMichael Goulet-0/+45
2022-04-05Suggest only when Rhs for PartialEq and PartialOrd is the same type as selfohno418-29/+31
2022-04-05Auto merge of #95662 - Dylan-DPC:rollup-fo7jsr6, r=Dylan-DPCbors-695/+1951
Rollup of 7 pull requests Successful merges: - #91873 (Mention implementers of unsatisfied trait) - #95588 (explicitly distinguish pointer::addr and pointer::expose_addr) - #95603 (Fix late-bound ICE in `dyn` return type suggestion) - #95620 (interpret: remove MemoryExtra in favor of giving access to the Machine) - #95630 (Update `NonNull` pointer provenance methods' documentation) - #95631 (Refactor: remove unnecessary nested blocks) - #95642 (`CandidateSource::XCandidate` -> `CandidateSource::X`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-05Suggest derivable trait on E0277ohno418-0/+310