about summary refs log tree commit diff
path: root/compiler/rustc_driver
AgeCommit message (Collapse)AuthorLines
2022-03-04Rollup merge of #93913 - bjorn3:remove_everybody_loops, r=jackh726Dylan DPC-1/+1
Remove the everybody loops pass It isn't used anymore by rustdoc. Split out of https://github.com/rust-lang/rust/pull/92895. There has been some previous discussion there.
2022-03-03Remove the everybody loops passbjorn3-1/+1
It isn't used anymore by rustdoc
2022-03-03all: fix some typoscuishuang-1/+1
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-9/+9
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-20Rollup merge of #94146 - est31:let_else, r=cjgillotMatthias Krüger-4/+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-4/+2
2022-02-18Rollup merge of #93915 - Urgau:rfc-3013, r=petrochenkovMatthias Krüger-0/+2
Implement --check-cfg option (RFC 3013), take 2 This pull-request implement RFC 3013: Checking conditional compilation at compile time (https://github.com/rust-lang/rfcs/pull/3013) and is based on the previous attempt https://github.com/rust-lang/rust/pull/89346 by `@mwkmwkmwk` that was closed due to inactivity. I have address all the review comments from the previous attempt and added some more tests. cc https://github.com/rust-lang/rust/issues/82450 r? `@petrochenkov`
2022-02-16Implement --check-cfg option (RFC 3013)Loïc BRANSTETT-0/+2
Co-authored-by: Urgau <lolo.branstett@numericable.fr> Co-authored-by: Marcelina Kościelnicka <mwk@0x04.net>
2022-02-13Remove Config::stderrbjorn3-1/+0
1. It captured stdout and not stderr 2. It isn't used anywhere 3. All error messages should go to the DiagnosticOutput instead 4. It modifies thread local state
2022-02-12Remove the RustcDefaultCalls structbjorn3-151/+138
It is a leftover from before the introduction of rustc_interface
2022-02-05Store rlink data in opaque binary format on diskMark Rousskov-3/+5
2022-02-03Rollup merge of #93566 - Aaron1011:rustc-backtrace, r=davidtwcoYuki Okushi-0/+9
Make rustc use `RUST_BACKTRACE=full` by default Compiler panics should be rare - when they do occur, we want the report filed by the user to contain as much information as possible. This is especially important when the panic is due to an incremental compilation bug, since we may not have enough information to reproduce it. This PR sets `RUST_BACKTRACE=full` inside `rustc` if the user has not explicitly set `RUST_BACKTRACE`. This is more verbose than `RUST_BACKTRACE=1`, but this may make it easier to debug incremental compilation issues. Users who find this too verbose can still manually set `RUST_BACKTRACE` before invoking the compiler. This only affects `rustc` (and any tool using `rustc_driver::install_ice_hook`). It does *not* affect any user crates or the standard library - backtraces will continue to be off by default in any application *compiled* by rustc.
2022-02-03Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebankYuki Okushi-21/+21
rustdoc: Fix ICE report The ICE report in rustdoc was confusing because it was returning an argument parse error: ``` thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', compiler/rustc_errors/src/lib.rs:1212:27 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic error: Unrecognized option: 'crate-version' ``` This is because the ICE reporter was trying to parse the arguments as rustc, not rustdoc. Since an argument error is a fatal error, it was early-exiting with the argument error due to unwinding. This changes it to be a more primitive scan of the arguments. The arguments being checked are pretty simple, and only have a small handful of forms that are easy to check for. It now looks like this: ``` thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', compiler/rustc_errors/src/lib.rs:1212:27 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.59.0-dev running on x86_64-apple-darwin note: compiler flags: --crate-type lib -Z treat-err-as-bug note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack ``` It still says `rustc`, but I can live with that.
2022-02-01Make rustc use `RUST_BACKTRACE=full` by defaultAaron Hill-0/+9
Compiler panics should be rare - when they do occur, we want the report filed by the user to contain as much information as possible. This is especially important when the panic is due to an incremental compilation bug, since we may not have enough information to reproduce it. This PR sets `RUST_BACKTRACE=full` inside `rustc` if the user has not explicitly set `RUST_BACKTRACE`. This is more verbose than `RUST_BACKTRACE=1`, but this may make it easier to debug incremental compilation issues. Users who find this too verbose can still manually set `RUST_BACKTRACE` before invoking the compiler. This only affects `rustc` (and any tool using `rustc_driver::install_ice_hook`). It does *not* affect any user crates or the standard library - backtraces will continue to be off by default in any application *compiled* by rustc.
2022-02-01add a rustc::query_stability lintlcnr-1/+2
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-4/+1
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-20Rollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pnkfelixMatthias Krüger-3/+4
Stabilize `-Z print-link-args` as `--print link-args` We have stable options for adding linker arguments; we should have a stable option to help debug linker arguments. Add documentation for the new option. In the documentation, make it clear that the *exact* format of the output is not a stable guarantee.
2022-01-09Stabilize -Z print-link-args as --print link-argsJosh Triplett-3/+4
We have stable options for adding linker arguments; we should have a stable option to help debug linker arguments.
2022-01-06Rollup merge of #92504 - dtolnay:wall, r=jackh726Matthias Krüger-1/+1
Exit nonzero on rustc -Wall Previously `rustc -Wall /dev/null` would print a paragraph explaining that `-Wall` is not a thing in Rust, but would then exit 0. I believe exiting 0 is not the right behavior. For something like `rustc --version` or `rustc --help` or `rustc -C help` the user is requesting rustc to print some information; rustc prints that information and exits 0 because what the user requested has been accomplished. In the case of `rustc -Wall path/to/main.rs`, I don't find it correct to conceptualize this as "the user requested rustc to print information about the fact that Wall doesn't exist". The user requested a particular thing, and despite rustc knowing what they probably meant and informing them about that, the thing they requested has *not* been accomplished. Thus a nonzero exit code is needed.
2022-01-06Exit nonzero on rustc -WallDavid Tolnay-1/+1
2022-01-03Extract init_env_logger to crateDavid Tolnay-54/+9
2021-12-26rustdoc: Fix ICE reportEric Huss-21/+21
2021-12-22Upgrade `tracing-subscriber`pierwill-1/+1
2021-12-22Update chalk to 0.75.0pierwill-1/+1
- Compute flags in `intern_ty` - Remove tracing-serde from PERMITTED_DEPENDENCIES - Disable `tracing-full` feature in `chalk-solve` - Bump tracing-tree to 0.2.0
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-5/+5
2021-11-22add rustc option for using LLVM stack smash protectionBenjamin A. Bjørnseth-1/+6
LLVM has built-in heuristics for adding stack canaries to functions. These heuristics can be selected with LLVM function attributes. This patch adds a rustc option `-Z stack-protector={none,basic,strong,all}` which controls the use of these attributes. This gives rustc the same stack smash protection support as clang offers through options `-fno-stack-protector`, `-fstack-protector`, `-fstack-protector-strong`, and `-fstack-protector-all`. The protection this can offer is demonstrated in test/ui/abi/stack-protector.rs. This fills a gap in the current list of rustc exploit mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html), originally discussed in #15179. Stack smash protection adds runtime overhead and is therefore still off by default, but now users have the option to trade performance for security as they see fit. An example use case is adding Rust code in an existing C/C++ code base compiled with stack smash protection. Without the ability to add stack smash protection to the Rust code, the code base artifacts could be exploitable in ways not possible if the code base remained pure C/C++. Stack smash protection support is present in LLVM for almost all the current tier 1/tier 2 targets: see test/assembly/stack-protector/stack-protector-target-support.rs. The one exception is nvptx64-nvidia-cuda. This patch follows clang's example, and adds a warning message printed if stack smash protection is used with this target (see test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3 targets has not been checked. Since the heuristics are applied at the LLVM level, the heuristics are expected to add stack smash protection to a fraction of functions comparable to C/C++. Some experiments demonstrating how Rust code is affected by the different heuristics can be found in test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is potential for better heuristics using Rust-specific safety information. For example it might be reasonable to skip stack smash protection in functions which transitively only use safe Rust code, or which uses only a subset of functions the user declares safe (such as anything under `std.*`). Such alternative heuristics could be added at a later point. LLVM also offers a "safestack" sanitizer as an alternative way to guard against stack smashing (see #26612). This could possibly also be included as a stack-protection heuristic. An alternative is to add it as a sanitizer (#39699). This is what clang does: safestack is exposed with option `-fsanitize=safe-stack`. The options are only supported by the LLVM backend, but as with other codegen options it is visible in the main codegen option help menu. The heuristic names "basic", "strong", and "all" are hopefully sufficiently generic to be usable in other backends as well. Reviewed-by: Nikita Popov <nikic@php.net> Extra commits during review: - [address-review] make the stack-protector option unstable - [address-review] reduce detail level of stack-protector option help text - [address-review] correct grammar in comment - [address-review] use compiler flag to avoid merging functions in test - [address-review] specify min LLVM version in fortanix stack-protector test Only for Fortanix test, since this target specifically requests the `--x86-experimental-lvi-inline-asm-hardening` flag. - [address-review] specify required LLVM components in stack-protector tests - move stack protector option enum closer to other similar option enums - rustc_interface/tests: sort debug option list in tracking hash test - add an explicit `none` stack-protector option Revert "set LLVM requirements for all stack protector support test revisions" This reverts commit a49b74f92a4e7d701d6f6cf63d207a8aff2e0f68.
2021-11-07Made temps-dir an unstable option.Tor Hovland-7/+0
2021-11-02Added the --temps-dir option.Tor Hovland-1/+11
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-2/+1
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-1/+2
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-18Auto merge of #89124 - cjgillot:owner-info, r=michaelwoeristerbors-10/+20
Index and hash HIR as part of lowering Part of https://github.com/rust-lang/rust/pull/88186 ~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~ Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner. r? `@michaelwoerister` cc `@petrochenkov`
2021-10-15allow `potential_query_instability` everywherelcnr-1/+2
2021-10-10Fix RUSTC_LOG handlingMatthew Jasper-1/+1
Rustc was incorrectly reading the value of `RUSTC_LOG` as the environment vairable with the logging configuration, rather than the logging configuration itself.
2021-10-09Stop referring to hir::Crate in hir_pretty.Camille GILLOT-10/+20
2021-10-07Update compiler/rustc_driver/src/lib.rsEliza Weisman-1/+1
Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-10-07rustc_driver: Enable the `WARN` log level by defaultEliza Weisman-8/+11
This commit changes the `tracing_subscriber` initialization in `rustc_driver` so that the `WARN` verbosity level is enabled by default when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env variable is set, the filter string in the environment variable is honored, instead. Fixes #76824 Closes #89623 cc @eddyb, @oli-obk
2021-10-05Auto merge of #89363 - oli-obk:in_tracing_we_trust, r=Mark-Simulacrumbors-1/+1
Fix performance regression with #[instrument] linked tracing PR: https://github.com/tokio-rs/tracing/pull/1600 regression introduced by #89048
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-1/+1
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-04Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, r=nagisaJubilee-2/+2
Consistently use 'supertrait'. A subset of places referred to 'super-trait', so this changes them to all use 'supertrait'. This matches 'supertype' and some other usages. An exception is 'auto-trait' which is consistently used in that manner.
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-1/+1
2021-10-02Auto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillotbors-16/+15
Fix clippy lints I'm currently working on allowing clippy to run on librustdoc after a discussion I had with `@Mark-Simulacrum.` So in the meantime, I fixed a few lints on the compiler crates.
2021-10-02Bump tracing to get the instrumentation perf improvementOli Scherer-1/+1
2021-10-02Consistently use 'supertrait'.Bruce Mitchener-2/+2
A subset of places referred to 'super-trait', so this changes them to all use 'supertrait'. This matches 'supertype' and some other usages. An exception is 'auto-trait' which is consistently used in that manner.
2021-10-01Fix clippy lintsGuillaume Gomez-16/+15
2021-09-29Move body_owners to tcx.hir().Camille GILLOT-1/+1
2021-09-20Migrate to 2021Mark Rousskov-1/+1
2021-09-17Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obkYuki Okushi-4/+1
Couple of changes to FileSearch and SearchPath * Turn a couple of regular comments into doc comments * Move `get_tools_search_paths` from `FileSearch` to `Session` * Use Lrc instead of Option to avoid duplication of a `SearchPath`
2021-09-08Use Lrc instead of Option to avoid duplication of a SearchPathbjorn3-4/+1
2021-09-07Rename rustc_mir to rustc_const_eval.Camille GILLOT-1/+1