about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src
AgeCommit message (Collapse)AuthorLines
2023-11-05Use the actual computed crate name for -Zprint-vtable-sizesbjorn3-2/+2
2023-11-05Don't steal the parse query when using --prettybjorn3-3/+7
This is the only place aside from the global_ctxt query where it is stolen.
2023-11-04Remove support for compiler plugins.Nicholas Nethercote-24/+21
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes #29597.
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-1/+2
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-10-30Delay parsing of `--cfg` and `--check-cfg` options.Nicholas Nethercote-4/+2
By storing the unparsed values in `Config` and then parsing them within `run_compiler`, the parsing functions can use the main symbol interner, and not create their own short-lived interners. This change also eliminates the need for one `EarlyErrorHandler` in rustdoc, because parsing errors can be reported by another, slightly later `EarlyErrorHandler`.
2023-10-28Rollup merge of #117268 - nnethercote:rustc_interface, r=oli-obkJubilee-1/+1
`rustc_interface` cleanups Particularly in and around `--cfg` and `--check-cfg` handling. r? `@oli-obk`
2023-10-28Clean up config mess.Nicholas Nethercote-1/+1
`parse_cfgspecs` and `parse_check_cfg` run very early, before the main interner is running. They each use a short-lived interner and convert all interned symbols to strings in their output data structures. Once the main interner starts up, these data structures get converted into new data structures that are identical except with the strings converted to symbols. All is not obvious from the current code, which is a mess, particularly with inconsistent naming that obscures the parallel string/symbol data structures. This commit clean things up a lot. - The existing `CheckCfg` type is generic, allowing both `CheckCfg<String>` and `CheckCfg<Symbol>` forms. This is really useful, but it defaults to `String`. The commit removes the default so we have to use `CheckCfg<String>` and `CheckCfg<Symbol>` explicitly, which makes things clearer. - Introduces `Cfg`, which is generic over `String` and `Symbol`, similar to `CheckCfg`. - Renames some things. - `parse_cfgspecs` -> `parse_cfg` - `CfgSpecs` -> `Cfg<String>`, plus it's used in more places, rather than the underlying `FxHashSet` type. - `CrateConfig` -> `Cfg<Symbol>`. - `CrateCheckConfig` -> `CheckCfg<Symbol>` - Adds some comments explaining the string-to-symbol conversions. - `to_crate_check_config`, which converts `CheckCfg<String>` to `CheckCfg<Symbol>`, is inlined and removed and combined with the overly-general `CheckCfg::map_data` to produce `CheckCfg::<String>::intern`. - `build_configuration` now does the `Cfg<String>`-to-`Cfg<Symbol>` conversion, so callers don't need to, which removes the need for `to_crate_config`. The diff for two of the fields in `Config` is a good example of the improved clarity: ``` - pub crate_cfg: FxHashSet<(String, Option<String>)>, - pub crate_check_cfg: CheckCfg, + pub crate_cfg: Cfg<String>, + pub crate_check_cfg: CheckCfg<String>, ``` Compare that with the diff for the corresponding fields in `ParseSess`, and the relationship to `Config` is much clearer than before: ``` - pub config: CrateConfig, - pub check_config: CrateCheckConfig, + pub config: Cfg<Symbol>, + pub check_config: CheckCfg<Symbol>, ```
2023-10-27Rollup merge of #116834 - nnethercote:rustc_symbol_mangling, r=davidtwcoMatthias Krüger-1/+0
Remove `rustc_symbol_mangling/messages.ftl`. It contains a single message that (a) doesn't contain any natural language, and (b) is only used in tests. r? `@davidtwco`
2023-10-26Auto merge of #116818 - Nilstrieb:stop-submitting-bug-reports, r=wesleywiserbors-9/+55
Stop telling people to submit bugs for internal feature ICEs This keeps track of usage of internal features, and changes the message to instead tell them that using internal features is not supported. I thought about several ways to do this but now used the explicit threading of an `Arc<AtomicBool>` through `Session`. This is not exactly incremental-safe, but this is fine, as this is set during macro expansion, which is pre-incremental, and also only affects the output of ICEs, at which point incremental correctness doesn't matter much anyways. See [MCP 620.](https://github.com/rust-lang/compiler-team/issues/596) ![image](https://github.com/rust-lang/rust/assets/48135649/be661f05-b78a-40a9-b01d-81ad2dbdb690)
2023-10-25Stop telling people to submit bugs for internal feature ICEsNilstrieb-9/+55
This keeps track of usage of internal features, and changes the message to instead tell them that using internal features is not supported. See MCP 620.
2023-10-18Auto merge of #116814 - estebank:windows-ice-path, r=petrochenkovbors-2/+7
Use `YYYY-MM-DDTHH_MM_SS` as datetime format for ICE dump files Windows paths do not support `:`, so use a datetime format in ICE dump paths that Windows will accept. CC #116809, fix #115180.
2023-10-17Use `YYYY-MM-DDTHH_MM_SS` as datetime format for ICE dump filesEsteban Küber-2/+7
Windows paths do not support `:`, so use a datetime format in ICE dump paths that Windows will accept. Fix #116809, fix #115180.
2023-10-17Rollup merge of #116827 - nnethercote:pub-handle_options, r=compiler-errorsMatthias Krüger-1/+5
Make `handle_options` public again. r? ``@compiler-errors``
2023-10-17Remove `rustc_symbol_mangling/messages.ftl`.Nicholas Nethercote-1/+0
It contains a single message that (a) doesn't contain any natural language, and (b) is only used in tests.
2023-10-17Make `handle_options` public again.Nicholas Nethercote-1/+5
2023-10-16Auto merge of #116731 - Alexendoo:hash-untracked-state, r=oli-obkbors-0/+1
Add `Config::hash_untracked_state` callback For context, I'm looking to use [late module passes](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/context/struct.LintStore.html#structfield.late_module_passes) in Clippy which unlike regular late passes run incrementally per module However we have a config file which can change between runs, we need changes to that to invalidate the `lint_mod` query. This PR adds a side channel for us to hash some extra state into `Options` in order to do that This does not make any changes to Clippy, I plan to do that in a PR to the Clippy repo along with some other required changes An alternative implementation would be to add a new query to track this state and override the `lint_mod` query in Clippy to first call that cc `@rust-lang/clippy`
2023-10-14Add `Config::hash_untracked_state` callbackAlex Macleod-0/+1
2023-10-13Format all the let chains in compilerMichael Goulet-3/+4
2023-10-13Remove unneeded `pub`s.Nicholas Nethercote-7/+7
2023-10-13Split and rename the annotation structs.Nicholas Nethercote-27/+36
`NoAnn` and `IdentifiedAnnotation` impl both `pprust_ast::PpAnn` and `pprust_hir::PpAnn`, which is a bit confusing, because the optional `tcx` is only needed for the HIR cases. (Currently the `tcx` is unnecessarily provided in the `expanded` AST cases.) This commit splits each one into `Ast` and `Hir` versions, which makes things clear about where the `tcx` is needed. The commit also renames all the traits so they consistently end with `Ann`.
2023-10-13Make `needs_analysis` true for `PpHirMode::Typed`.Nicholas Nethercote-1/+0
This avoids the need for a bespoke `tcx.analysis()` call.
2023-10-13Rename some `'hir` lifetimes as `'tcx`.Nicholas Nethercote-8/+8
Because they all end up within a `TyCtxt`.
2023-10-13Remove pretty-printing traits.Nicholas Nethercote-130/+52
`call_with_pp_support_ast` and `call_with_pp_support_hir` how each have a single call site. This commit inlines and removes them, which also removes the need for all the supporting traits: `Sess`, `AstPrinterSupport`, and `HirPrinterSupport`. The `sess` member is also removed from several structs.
2023-10-13Merge `print_*` functions.Nicholas Nethercote-70/+52
The handling of the `PpMode` variants is currently spread across three functions: `print_after_parsing`, `print_after_hir_lowering`, and `print_with_analysis`. Each one handles some of the variants. This split is primarily because `print_after_parsing` has slightly different arguments to the other two. This commit changes the structure. It merges the three functions into a single `print` function, and encapsulates the different arguments in a new enum `PrintExtra`. Benefits: - The code is a little shorter. - All the `PpMode` variants are handled in a single `match`, with no need for `unreachable!` arms. - It enables the trait removal in the subsequent commit by reducing the number of `call_with_pp_support_ast` call sites from two to one.
2023-10-13Simplify support traits.Nicholas Nethercote-70/+30
First, both `AstPrinterSupport` and `HirPrinterSupport` have a `sess` method. This commit introduces a `Sess` trait and makes the support traits be subtraits of `Sess`, to avoid some duplication. Second, both support traits have a `pp_ann` method that isn't needed if we enable `trait_upcasting`. This commit removes those methods. (Both of these traits will be removed in a subsequent commit, as will the `trait_upcasting` use.)
2023-10-13Remove unused `PrinterSupport::hir_map` method.Nicholas Nethercote-16/+0
2023-10-13Remove PpAstTreeMode.Nicholas Nethercote-3/+3
It's simpler to distinguish the two AST modes directly in `PpMode`.
2023-10-13Remove an outdated comment.Nicholas Nethercote-4/+0
`phase_3_run_analysis_passes` no longer exists, and AFAICT this code has been refactored so much since this comment was written that it no longer has any useful meaning.
2023-10-13Remove unnecessary call to `call_with_pp_support_hir`.Nicholas Nethercote-4/+2
The callback is trivial and no pp support is actually needed. This makes the `HirTree` case more like the `AstTree` case above.
2023-10-13Rename some things.Nicholas Nethercote-35/+35
- Rename `pprust` as `pprust_ast`, to align with `pprust_hir`. - Rename `PrinterSupport` as `AstPrinterSupport`, to align with `HirPrinterSupport`.
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+3
2023-10-06rustc_driver: avoid fallible conversionsTamir Duberstein-15/+18
Use `std::path::PathBuf` rather than `String`; use `std::env::var_os` rather than `std::env::var`. These changes avoid a number of error paths which can arise in the presence of non-UTF-8 paths.
2023-10-06compiler: always use var_os("RUST_BACKTRACE")Tamir Duberstein-2/+2
There are 3 instances of var(...) and 3 instances of var_os(...); the latter avoids an appearance of unhandled error, so use it everywhere.
2023-09-19Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-sebors-26/+54
Don't modify libstd to dump rustc ICEs Do a much simpler thing and just dump a `std::backtrace::Backtrace` to file. r? `@estebank` `@oli-obk` Fixes #115610
2023-09-13Auto merge of #115735 - bjorn3:better_list_crate_metadata, r=wesleywiserbors-2/+4
Extend rustc -Zls This makes it show a lot more things and thus a lot more useful.
2023-09-10Show lib features in -Zls and allow configuring which things are shownbjorn3-2/+4
2023-09-10Remove EarlyErrorHandler argument from after_analysis callbackbjorn3-2/+1
It is only used by miri which can create a new one using the Session.
2023-09-10Rename after_parsing callback to after_crate_root_parsingbjorn3-3/+4
To avoid confusion if it is called after all parsing is done or not.
2023-09-08Add missing Debuginfo to PDB debug file on windows.Florian Schmiderer-0/+1
Set Arg0 and CommandLineArgs in MCTargetoptions so LLVM outputs correct CL and CMD in LF_DEBUGINFO instead of empty/invalid values.
2023-09-07Make ICE backtrace actually match the panic handlerMichael Goulet-2/+19
2023-09-07Don't modify libstd to dump rustc ICEsMichael Goulet-26/+37
2023-08-30Rollup merge of #113565 - workingjubilee:better-signal-handler-message, ↵Matthias Krüger-66/+151
r=pnkfelix Make SIGSEGV handler emit nicer backtraces This annotates the code heavily with comments to explain what is going on, for the benefit of other compiler contributors. The backtrace also emits appropriate comments to clarify, to a programmer who may not know why a bunch of file paths and hexadecimal blather was just dumped into stderr, what is going on. Finally, it detects cycles and uses their regularity to avoid repeating a bunch of text. The previous backtraces we were emitting was extremely unfriendly, potentially confusing, and often alarming, and this makes things almost "nice". We can't necessarily make them much nicer than this, because a signal handler must use "signal-safe" functions. This precludes conveniences like dynamic allocations. Fortunately, Rust's stdlib has allocation-free formatting, but it may hinder integrating this error with our localization middleware, as I wasn't able to clearly ascertain, at a glance, whether there was a zero-alloc path through it. r? `@Nilstrieb`
2023-08-29Auto merge of #114114 - ↵bors-5/+3
keith:ks/always-add-lc_build_version-for-metadata-object-files, r=wesleywiser Always add LC_BUILD_VERSION for metadata object files As of Xcode 15 Apple's linker has become a bit more strict about the warnings it produces. One of those new warnings requires all valid Mach-O object files in an archive to have a LC_BUILD_VERSION load command: ``` ld: warning: no platform load command found in 'ARCHIVE[arm64][2106](lib.rmeta)', assuming: iOS-simulator ``` This was already being done for Mac Catalyst so this change expands this logic to include it for all Apple platforms. I filed this behavior change as FB12546320 and was told it was the new intentional behavior.
2023-08-24Move extra_compiler_flags() to rustc_sessionMartin Nordholts-48/+1
To make it available to other parts of the compiler.
2023-08-21Always add LC_BUILD_VERSION for metadata object filesKeith Smiley-5/+3
As of Xcode 15 Apple's linker has become a bit more strict about the warnings it produces. One of those new warnings requires all valid Mach-O object files in an archive to have a LC_BUILD_VERSION load command: ``` ld: warning: no platform load command found in 'ARCHIVE[arm64][2106](lib.rmeta)', assuming: iOS-simulator ``` This was already being done for Mac Catalyst so this change expands this logic to include it for all Apple platforms. I filed this behavior change as FB12546320 and was told it was the new intentional behavior.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-2/+0
Removes a piece of mutable state. Follow up to #114578.
2023-08-07rustc_interface: Dismantle `register_plugins` queryVadim Petrochenkov-10/+6
2023-08-06Auto merge of #114476 - Urgau:missing-dep-file-112898, r=oli-obkbors-0/+4
Fix missing dependency file with `-Zunpretty` This PR force the `output_filenames` to be run ~~in every early exits like~~ when using `-Zunpretty`, so to respect the `dep-info` flag. Fixes https://github.com/rust-lang/rust/issues/112898 r? `@oli-obk`
2023-08-04Fix missing dependency file with -ZunprettyUrgau-0/+4
2023-07-31Replace the many arguments of `EmitterWriter::stderr` with builder methodsOli Scherer-11/+1