summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2022-06-23Auto merge of #97911 - dtolnay:numcpu, r=Mark-Simulacrumbors-1/+1
Revert "remove num_cpus dependency" in rustc and update cargo Fixes #97549. This PR reverts #94524 and does a Cargo update to pull in rust-lang/cargo#10737. Rust 1.61.0 has a regression in which it misidentifies the number of available CPUs in some environments, leading to enormously increased memory usage and failing builds. In between Rust 1.60 and 1.61 both rustc and cargo replaced some uses of `num_cpus` with `available_parallelism`, which eliminated support for cgroupv1, still apparently in common use. This PR switches both rustc and cargo back to using `num_cpus` in order to support environments where the available parallelism is controlled by cgroupv1. Both can use `available_parallism` again once it handles cgroupv1 (if ever). I have confirmed that the rustc part of this PR fixes the memory usage regression in my non-Cargo environment, and others have confirmed in #97549 that the Cargo regression was at fault for the memory usage regression in their environments.
2022-05-06sess: add `create_{err,warning}`David Wood-2/+28
Currently, the only API for creating errors from a diagnostic derive will emit it immediately. This makes it difficult to add subdiagnostics to diagnostics from the derive, so add `create_{err,warning}` functions that return the diagnostic without emitting it. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-28Rollup merge of #96433 - petrochenkov:delim, r=nnethercoteDylan DPC-2/+2
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter` Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming. After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`. It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is. cc https://github.com/rust-lang/rust/pull/96421 r? ``@nnethercote``
2022-04-28Rollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwcoDylan DPC-5/+25
Migrate ambiguous plus diagnostic to the new derive macro r? ````@davidtwco```` ````@jyn514````
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-2/+2
2022-04-28Auto merge of #96085 - jsgf:deny-unused-deps, r=compiler-errorsbors-6/+34
Make sure `-Dunused-crate-dependencies --json unused-externs` makes rustc exit with error status This PR: - fixes compiletest to understand unused extern notifications - adds tests for `--json unused-externs` - makes sure that deny-level unused externs notifications are treated as compile errors - refactors the `emit_unused_externs` callstack to plumb through the level as an enum as a string, and adds `Level::is_error` Update: adds `--json unused-externs-silent` with the original behaviour since Cargo needs it. Should address `@est31's` concerns. Fixes: https://github.com/rust-lang/rust/issues/96068
2022-04-28Rollup merge of #96483 - Urgau:check-cfg-target_feature, r=petrochenkovDylan DPC-0/+5
Add missing `target_feature` to the list of well known cfg names This PR adds the missing `target_feature` cfg name to the list of well known cfg names. It was notice missing in https://github.com/rust-lang/rust/issues/96472 thanks to `@bjorn3,` the reason being that `--check-cfg=names()` automatically inherit the names passed by `--cfg` (or internal to `rustc`) and is seems that the vast majority of targets have at least one target feature leading to `target_feature` being a well known name in most target but it should always be a well known name so this PR add it unconditionally to list. r? `@petrochenkov`
2022-04-27Add missing `target_feature` to the list of well known cfg namesLoïc BRANSTETT-0/+5
2022-04-27Add --json unused-externs-silent with original behaviourJeremy Fitzhardinge-6/+34
Since Cargo wants to do its own fatal error handling for unused dependencies, add the option `--json unused-externs-silent` which has the original behaviour of not indicating non-zero exit status for `deny`/`forbid`-level unused dependencies.
2022-04-25add `struct_warn` methodChristian Poveda-0/+4
2022-04-25fix formattingChristian Poveda-5/+1
2022-04-25use `ParseSess` instead of `Session` in `into_diagnostic`Christian Poveda-6/+26
2022-04-25Rollup merge of #96090 - JakobDegen:mir-tests, r=nagisaMatthias Krüger-0/+19
Implement MIR opt unit tests This implements rust-lang/compiler-team#502 . There's not much to say here, this implementation does everything as proposed. I also added the flag to a bunch of existing tests (mostly those to which I could add it without causing huge diffs due to changes in line numbers). Summarizing the changes to test outputs: - Every time an `MirPatch` is created, it adds a cleanup block to the body if it did not exist already. If this block is unused (as is usually the case), it usually gets removed soon after by some pass calling `SimplifyCFG` for unrelated reasons (in many cases this cycle happens quite a few times for a single body). We now run `SimplifyCFG` less often, so those blocks end up in some of our outputs. I looked at changing `MirPatch` to not do this, but that seemed too complicated for this PR. I may still do that in a follow-up. - The `InstCombine` test had set `-C opt-level=0` in its flags and so there were no storage markers. I don't really see a good motivation for doing this, so bringing it back in line with what everything else does seems correct. - One of the `EarlyOtherwiseBranch` tests had `UnreachableProp` running on it. Preventing that kind of thing is the goal of this feature, so this seems fine. For the remaining tests for which this feature might be useful, we can gradually migrate them as opportunities present themselves. In terms of documentation, I plan on submitting a PR to the rustc dev guide in the near future documenting this and other recent changes to MIR. If there's any other places to update, do let me know r? `@nagisa`
2022-04-23Add support for `nounused` --extern flagJeremy Fitzhardinge-1/+10
This adds `nounused` to the set of extern flags: `--extern nounused:core=/path/to/core/libcore.rlib`. The effect of this flag is to suppress `unused-crate-dependencies` warnings relating to the crate.
2022-04-20Auto merge of #96082 - michaelwoerister:less_impl_stable_hash_via_hash, ↵bors-26/+19
r=compiler-errors incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it. Fixes https://github.com/rust-lang/rust/issues/96013.
2022-04-19Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwcoDylan DPC-117/+0
Remove `--extern-location` and all associated code `--extern-location` was an experiment to investigate the best way to generate useful diagnostics for unused dependency warnings by enabling a build system to identify the corresponding build config. While I did successfully use this, I've since been convinced the alternative `--json unused-externs` mechanism is the way to go, and there's no point in having two mechanisms with basically the same functionality. This effectively reverts https://github.com/rust-lang/rust/pull/72603
2022-04-19incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.Michael Woerister-26/+19
2022-04-16Address nitsJakob Degen-5/+2
2022-04-16Add support for MIR opt unit testsJakob Degen-0/+22
2022-04-15Rollup merge of #96026 - matthiaskrgr:clippy_compl_1304, r=Dylan-DPCDylan DPC-1/+1
couple of clippy::complexity fixes
2022-04-15Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelixDylan DPC-0/+5
Create (unstable) 2024 edition [On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition. This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024. For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical. ````@rustbot```` label +T-lang +S-waiting-on-review Not sure on the relevant team, to be honest.
2022-04-15Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwcoDylan DPC-1/+1
Stabilize `derive_default_enum` This stabilizes `#![feature(derive_default_enum)]`, as proposed in [RFC 3107](https://github.com/rust-lang/rfcs/pull/3107) and tracked in #87517. In short, it permits you to `#[derive(Default)]` on `enum`s, indicating what the default should be by placing a `#[default]` attribute on the desired variant (which must be a unit variant in the interest of forward compatibility). ```````@rustbot``````` label +S-waiting-on-review +T-lang
2022-04-15Remove `--extern-location` and all associated codeJeremy Fitzhardinge-117/+0
`--extern-location` was an experiment to investigate the best way to generate useful diagnostics for unused dependency warnings by enabling a build system to identify the corresponding build config. While I did successfully use this, I've since been convinced the alternative `--json unused-externs` mechanism is the way to go, and there's no point in having two mechanisms with basically the same functionality. This effectively reverts https://github.com/rust-lang/rust/pull/72603
2022-04-13couple of clippy::complexity fixesMatthias Krüger-1/+1
2022-04-13errors: lazily load fallback fluent bundleDavid Wood-19/+9
Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-12sess: try sysroot candidates for fluent bundleDavid Wood-11/+13
Instead of checking only the user provided sysroot or the default (when no sysroot is provided), search user provided sysroot and then check default sysroots for locale requested by the user. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-09expand: Remove `ParseSess::missing_fragment_specifiers`Vadim Petrochenkov-2/+0
It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.
2022-04-07Stabilize `derive_default_enum`Jacob Pratt-1/+1
2022-04-05session: opt for enabling directionality markersDavid Wood-4/+10
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-05macros: translatable struct attrs and warningsDavid Wood-3/+13
Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement sysroot/testing bundle loadingDavid Wood-9/+47
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-38/+105
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-4/+6
`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-03Cleanup after some refactoring in rustc_targetLoïc BRANSTETT-1/+1
2022-04-03Replace every Vec in Target(Options) with it's Cow equivalentLoïc BRANSTETT-1/+1
2022-04-02Create 2024 editionJacob Pratt-0/+5
2022-04-02ast_lowering: Stop wrapping `ident` matchers into groupsVadim Petrochenkov-0/+4
The lowered forms goes to metadata, for example during encoding of macro definitions
2022-03-30Stabilize native library modifier syntax and the `whole-archive` modifier ↵Vadim Petrochenkov-22/+67
specifically
2022-03-27Make fatal DiagnosticBuilder yield neverMichael Goulet-20/+12
2022-03-26Auto merge of #95296 - workingjubilee:pretty-session, r=Dylan-DPCbors-120/+85
Prettify rustc_session with recent conveniences No functional changes. I felt like making something beautiful.
2022-03-24Use a let-chain in _session::output (nfc)Jubilee Young-15/+10
2022-03-24Vigorously refactor _session::code_stats (nfc)Jubilee Young-19/+11
2022-03-24Prettify rustc_session fmt with capturing args (nfc)Jubilee Young-86/+64
2022-03-20Filter OnceNote in diagnostic infra.Camille GILLOT-73/+1
2022-03-18Auto merge of #88098 - Amanieu:oom_panic, r=nagisabors-3/+37
Implement -Z oom=panic This PR removes the `#[rustc_allocator_nounwind]` attribute on `alloc_error_handler` which allows it to unwind with a panic instead of always aborting. This is then used to implement `-Z oom=panic` as per RFC 2116 (tracking issue #43596). Perf and binary size tests show negligible impact.
2022-03-17Rollup merge of #94960 - codehorseman:master, r=oli-obkDylan DPC-4/+4
Fix many spelling mistakes Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-16rustc_error: make ErrorReported impossible to constructmark-18/+29
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-4/+4
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-15fix typosDylan DPC-3/+3
2022-03-10Rollup merge of #94274 - djkoloski:unknown_unstable_lints, r=tmandryDylan DPC-2/+19
Treat unstable lints as unknown This change causes unstable lints to be ignored if the `unknown_lints` lint is allowed. To achieve this, it also changes lints to apply as soon as they are processed. Previously, lints in the same set were processed as a batch and then all simultaneously applied. Implementation of https://github.com/rust-lang/compiler-team/issues/469