about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
AgeCommit message (Collapse)AuthorLines
2022-06-03Remove support for -Zast-json and -Zast-json-noexpandbjorn3-11/+0
2022-05-24Remove the check_mod_intrinsics queryOli Scherer-1/+0
2022-05-23typoTshepang Lekhonkhobe-1/+1
2022-05-22rustc_parse: Move AST -> TokenStream conversion logic to `rustc_ast`Vadim Petrochenkov-7/+1
2022-05-10only_local: always check for misuselcnr-4/+1
2022-05-08Move lint expectation checking into a separate query (RFC 2383)xFrednet-0/+4
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-04-25Rollup merge of #96090 - JakobDegen:mir-tests, r=nagisaMatthias Krüger-0/+1
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-0/+1
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-17Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillotbors-19/+9
Refactor HIR item-like traversal (part 1) Issue #95004 - Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com> cc `@cjgillot`
2022-04-16Add support for MIR opt unit testsJakob Degen-0/+1
2022-04-16Rollup merge of #93969 - bjorn3:codegen_backend_dep_info, r=pnkfelixDylan DPC-4/+8
Only add codegen backend to dep info if -Zbinary-dep-depinfo is used I am currently migrating the cg_clif build system from using a binary linked to the codegen backend as rustc replacement to passing `-Zcodegen-backend` instead. Without this PR this would force cargo to rebuild the sysroot on any change to the codegen backend even if I explicitly specify that I want it to be preserved, which would make development of cg_clif a lot slower. If you still want to have changes to the codegen backend invalidate the cargo build cache you can explicitly specify `-Zbinary-dep-depinfo`. cc ``@eddyb`` as the codegen backend was initially added to the depinfo for rust-gpu.
2022-04-12sess: try sysroot candidates for fluent bundleDavid Wood-0/+15
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-09update Finder to store LocalDefIdMiguel Guarniz-3/+3
2022-04-09expand: Remove `ParseSess::missing_fragment_specifiers`Vadim Petrochenkov-16/+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-08remove ItemLikeVisitor impls in incremental, interface, metadata and ↵Miguel Guarniz-19/+2
symbol_mangling crates Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08remove some uses of visit_all_item_likes in incremental, metadata and ↵Miguel Guarniz-1/+8
interface crates Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-05span: move `MultiSpan`David Wood-2/+2
`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-02Address review comments and add a testJakub Beránek-1/+1
2022-04-02Include a header in .rlink files to provide nicer error messages when a ↵Jakub Beránek-3/+3
wrong file is parsed as .rlink
2022-03-31Stop emitting lints during lowering.Camille GILLOT-17/+15
2022-03-30Spellchecking compiler commentsYuri Astrakhan-1/+1
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-24Don't include invalid paths in the depinfo for builtin backendsbjorn3-1/+5
2022-03-24Only add codegen backend to dep info if -Zbinary-dep-depinfo is usedbjorn3-4/+4
2022-03-18Auto merge of #88098 - Amanieu:oom_panic, r=nagisabors-2/+3
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-16rustc_error: make ErrorReported impossible to constructmark-17/+16
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-04Rollup merge of #94362 - Urgau:check-cfg-values, r=petrochenkovDylan DPC-0/+3
Add well known values to `--check-cfg` implementation This pull-request adds well known values for the well known names via `--check-cfg=values()`. [RFC 3013: Checking conditional compilation at compile time](https://rust-lang.github.io/rfcs/3013-conditional-compilation-checking.html#checking-conditional-compilation-at-compile-time) doesn't define this at all, but this seems a nice improvement. The activation is done by a empty `values()` (new syntax) similar to `names()` except that `names(foo)` also activate well known names while `values(aa, "aa", "kk")` would not. As stated this use a different activation logic because well known values for the well known names are not always sufficient. In fact this is problematic for every `target_*` cfg because of non builtin targets, as the current implementation use those built-ins targets to create the list the well known values. The implementation is straight forward, first we gather (if necessary) all the values (lazily or not) and then we apply them. r? ```@petrochenkov```
2022-03-04Auto merge of #94096 - cjgillot:ensure-stability, r=lcnrbors-5/+6
Ensure stability directives are checked in all cases Split off #93017 Stability and deprecation were not checked in all cases, for instance if a type error happened. This PR moves the check earlier in the pipeline to ensure the errors are emitted in all cases. r? `@lcnr`
2022-03-03Cleanup feature gates.Camille GILLOT-5/+5
2022-03-03Remove the everybody loops passbjorn3-233/+8
It isn't used anymore by rustdoc
2022-03-03Force ensure stability_index.Camille GILLOT-0/+1
2022-03-03Add -Z oom={panic,abort} command-line optionAmanieu d'Antras-2/+3
2022-03-03Add support for values() with --check-cfgLoïc BRANSTETT-0/+3
2022-03-03Rollup merge of #94433 - Urgau:check-cfg-allowness, r=petrochenkovDylan DPC-1/+2
Improve allowness of the unexpected_cfgs lint This pull-request improve the allowness (`#[allow(...)]`) of the `unexpected_cfgs` lint. Before this PR only crate level `#![allow(unexpected_cfgs)]` worked, now with this PR it also work when put around `cfg!` or if it is in a upper level. Making it work ~for the attributes `cfg`, `cfg_attr`, ...~ for the same level is awkward as the current code is design to give "Some parent node that is close to this macro call" (cf. https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/base/struct.ExpansionData.html) meaning that allow on the same line as an attribute won't work. I'm note even sure if this would be possible. Found while working on https://github.com/rust-lang/rust/pull/94298. r? ````````@petrochenkov````````
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-11/+11
2022-03-01Improve allowness of the unexpected_cfgs lintLoïc BRANSTETT-1/+2
2022-02-27Rollup merge of #94415 - bjorn3:cfg_default_backend, r=Mark-SimulacrumMatthias Krüger-6/+2
Use the first codegen backend in the config.toml as default It is currently hard coded to llvm if enabled and cranelift otherwise. This made some sense when cranelift was the only alternative codegen backend. Since the introduction of the gcc backend this doesn't make much sense anymore. Before this PR bootstrapping rustc using a backend other than llvm or cranelift required changing the source of rustc_interface. With this PR it becomes a matter of putting the right backend as first enabled backend in config.toml. cc ```@antoyo```
2022-02-27Use the first codegen backend in the config.toml as defaultbjorn3-6/+2
It is currently hard coded to llvm if enabled and cranelift otherwise. This made some sense when cranelift was the only alternative codegen backend. Since the introduction of the gcc backend this doesn't make much sense anymore. Before this PR bootstrapping rustc using a backend other than llvm or cranelift required changing the source of rustc_interface. With this PR it becomes a matter of putting the right backend as first enabled backend in config.toml.
2022-02-26Auto merge of #93516 - nagisa:branch-protection, r=cjgillotbors-1/+4
No branch protection metadata unless enabled Even if we emit metadata disabling branch protection, this metadata may conflict with other modules (e.g. during LTO) that have different branch protection metadata set. This is an unstable flag and feature, so ideally the flag not being specified should act as if the feature wasn't implemented in the first place. Additionally this PR also ensures we emit an error if `-Zbranch-protection` is set on targets other than the supported aarch64. For now the error is being output from codegen, but ideally it should be moved to earlier in the pipeline before stabilization.
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-25Auto merge of #94130 - erikdesjardins:partially, r=nikicbors-1/+1
Use undef for (some) partially-uninit constants There needs to be some limit to avoid perf regressions on large arrays with undef in each element (see comment in the code). Fixes: #84565 Original PR: #83698 Depends on LLVM 14: #93577
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-4/+4
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`
2022-02-24Rollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkovDylan DPC-6/+12
Improve `--check-cfg` implementation This pull-request is a mix of improvements regarding the `--check-cfg` implementation: - Simpler internal representation (usage of `Option` instead of separate bool) - Add --check-cfg to the unstable book (based on the RFC) - Improved diagnostics: * List possible values when the value is unexpected * Suggest if possible a name or value that is similar - Add more tests (well known names, mix of combinations, ...) r? ```@petrochenkov```
2022-02-23Continue improvements on the --check-cfg implementationLoïc BRANSTETT-9/+5
- Test the combinations of --check-cfg with partial values() and --cfg - Test that we detect unexpected value when none are expected
2022-02-23rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.Eduard-Mihai Burtescu-4/+4
2022-02-22Improve CheckCfg internal representationLoïc BRANSTETT-6/+16
2022-02-20Rollup merge of #94146 - est31:let_else, r=cjgillotMatthias Krüger-8/+2
Adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.
2022-02-19Adopt let else in more placesest31-8/+2
2022-02-19No branch protection metadata unless enabledSimonas Kazlauskas-1/+4
Even if we emit metadata disabling branch protection, this metadata may conflict with other modules (e.g. during LTO) that have different branch protection metadata set. This is an unstable flag and feature, so ideally the flag not being specified should act as if the feature wasn't implemented in the first place. Additionally this PR also ensures we emit an error if `-Zbranch-protection` is set on targets other than the supported aarch64. For now the error is being output from codegen, but ideally it should be moved to earlier in the pipeline before stabilization.
2022-02-19switch to limiting the number of init/uninit chunksErik Desjardins-1/+1