about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
AgeCommit message (Collapse)AuthorLines
2023-11-22Auto merge of #118086 - nnethercote:queries-cleanups, r=bjorn3bors-45/+31
Queries cleanups r? `@bjorn3`
2023-11-22Auto merge of #117928 - nnethercote:rustc_ast_pretty, r=fee1-deadbors-1/+1
`rustc_ast_pretty` cleanups Some improvements I found while looking at this code. r? `@fee1-dead`
2023-11-22Merge `Queries::{ongoing_codegen,linker}`.Nicholas Nethercote-17/+13
There is no real need for them to be separate.
2023-11-22Make `Compiler::{sess,codegen_backend}` public.Nicholas Nethercote-31/+18
And remove the relevant getters on `Compiler` and `Queries`.
2023-11-22Add comments about a timer.Nicholas Nethercote-0/+3
2023-11-22Remove outdated reference to compiler plugins.Nicholas Nethercote-1/+1
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-11/+11
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-17Make `Compiler::sess` private.Nicholas Nethercote-2/+2
Like `Compiler::codegen_backend`.
2023-11-17Remove a low-value local variable.Nicholas Nethercote-3/+2
2023-11-17Rename `Linker::prepare_outputs` as `output_filenames`.Nicholas Nethercote-5/+5
It matches the type, and a noun makes more sense than a verb. The `output_filenames` function still uses a profiling label named `prepare_outputs`, but I think that makes sense as a verb and can be left unchanged.
2023-11-17Move `CodegenBackend` out of `Linker`.Nicholas Nethercote-19/+11
It can easily be passed in. And that removes the single clone of `Compiler::codegen_backend`, which means it no longer needs to be `Lrc`.
2023-11-17Move `Session` out of `Linker`.Nicholas Nethercote-19/+13
It can easily be passed in. And that removes the single clone of `Compiler::session`, which means it no longer needs to be `Lrc`.
2023-11-17Streamline `Queries::linker`.Nicholas Nethercote-19/+13
2023-11-17Remove `Compiler::register_lints`.Nicholas Nethercote-5/+0
Lint registration now happens early enough that we can run it from `Config`, before `Compiler` is created.
2023-11-17Move `lint_store` from `GlobalCtxt` to `Session`.Nicholas Nethercote-11/+12
This was made possible by the removal of plugin support, which simplified lint store creation. This simplifies the places in rustc and rustdoc that call `describe_lints`, which are early on. The lint store is now built before those places, so they don't have to create their own lint store for temporary use, they can just use the main one.
2023-11-17Inline and remove `create_lint_store`.Nicholas Nethercote-13/+6
2023-11-15Re-format code with new rustfmtMark Rousskov-7/+21
2023-11-15Auto merge of #116555 - paulmenage:llvm-module-flag, r=wesleywiserbors-0/+1
Add -Z llvm_module_flag Allow adding values to the `!llvm.module.flags` metadata for a generated module. The syntax is `-Z llvm_module_flag=<name>:<type>:<value>:<behavior>` Currently only u32 values are supported but the type is required to be specified for forward compatibility. The `behavior` element must match one of the named LLVM metadata behaviors.viors. This flag is expected to be perma-unstable.
2023-11-14Auto merge of #117773 - nnethercote:rm-Zperf-stats, r=wesleywiserbors-1/+0
Remove `-Zperf-stats`. The included measurements have varied over the years. At one point there were quite a few more, but #49558 deleted a lot that were no longer used. Today there's just four, and it's a motley collection that doesn't seem particularly valuable. I think it has been well and truly subsumed by self-profiling, which collects way more data. r? `@wesleywiser`
2023-11-13Remove `-Zperf-stats`.Nicholas Nethercote-1/+0
The included measurements have varied over the years. At one point there were quite a few more, but #49558 deleted a lot that were no longer used. Today there's just four, and it's a motley collection that doesn't seem particularly valuable. I think it has been well and truly subsumed by self-profiling, which collects way more data.
2023-11-11Add -Z llvm_module_flagPaul Menage-0/+1
Allow adding values to the `!llvm.module.flags` metadata for a generated module. The syntax is `-Z llvm_module_flag=<name>:<type>:<value>:<behavior>` Currently only u32 values are supported but the type is required to be specified for forward compatibility. The `behavior` element must match one of the named LLVM metadata behaviors.viors. This flag is expected to be perma-unstable.
2023-11-10Remove `-Zkeep-hygiene-data`.Nicholas Nethercote-1/+0
It was added way back in #28585 under the name `-Zkeep-mtwt-tables`. The justification was: > This is so that the resolution results can be used after analysis, > potentially for tool support. There are no uses of significance in the code base, and various Google searches for both option names (and variants) found nothing of interest. @petrochenkov says removing this part (and it's only part) of the hygiene data is dubious. It doesn't seem that big, so let's just keep it around.
2023-11-07Add -Zcross-crate-inline-threshold=yesBen Kimock-6/+6
2023-11-04Remove support for compiler plugins.Nicholas Nethercote-22/+4
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-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-1/+2
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
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-11-02Remove support for alias `-Z symbol-mangling-version`Zalathar-1/+0
2023-11-01Inline and remove `create_session`.Nicholas Nethercote-97/+54
Currently the parts of session initialization that happen within `rustc_interface` are split between `run_compiler` and `create_session`. This split isn't necessary and obscures what's happening. This commit merges the two functions. I think a single longer function is much clearer than splitting this code across two functions in different modules, especially when `create_session` has 13 parameters, and is misnamed (it also creates the codegen backend). The net result is 43 fewer lines of code.
2023-10-30Streamline some `use` items.Nicholas Nethercote-17/+7
2023-10-30Remove an unnecessary `drop`.Nicholas Nethercote-3/+1
2023-10-30Streamline `collect_crate_types`.Nicholas Nethercote-15/+7
- The early return can be right at the top. - The control flow is simplified with `if let`. - The `collect` isn't necessary. - The "Unconditionally" comment is erroneously duplicated from `check_attr_crate_type`, and can be removed.
2023-10-30Remove `check_output`.Nicholas Nethercote-21/+3
Using `find` and `any` from `std` makes the code shorter and clearer.
2023-10-30Wrap some overlong comments.Nicholas Nethercote-10/+12
2023-10-30Remove out-of-date comment.Nicholas Nethercote-2/+0
It was added in 51938c61f6f1b26e463f9071716f543543486e72, a commit with a 7,720 line diff and a one line commit message. Even then the comment was incorrect; there was a removed a `build_output_filenames` call with a `&[]` argument in rustdoc, but the commit removed that call. In such a large commit, it's easy for small errors to occur.
2023-10-30Improve readability of `parse_check_cfg`.Nicholas Nethercote-26/+13
2023-10-30Make `Cfg` and `CheckCfg` non-generic.Nicholas Nethercote-17/+8
They now only ever contains symbols.
2023-10-30Change cfg parsers to produce symbols instead of strings.Nicholas Nethercote-23/+15
2023-10-30Reduce exposure of cfg parsers.Nicholas Nethercote-2/+2
2023-10-30Delay parsing of `--cfg` and `--check-cfg` options.Nicholas Nethercote-253/+244
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-45/+41
`rustc_interface` cleanups Particularly in and around `--cfg` and `--check-cfg` handling. r? `@oli-obk`
2023-10-28Rollup merge of #117025 - Urgau:cleanup-improve-check-cfg-impl, r=petrochenkovJubilee-200/+185
Cleanup and improve `--check-cfg` implementation This PR removes some indentation in the code, as well as preventing some bugs/misusages and fix a nit in the doc. r? ```@petrochenkov``` (maybe)
2023-10-28Rollup merge of #116534 - cjgillot:no-dep-tasks, r=davidtwcoJubilee-1/+0
Remove -Zdep-tasks. This option is not useful any more, we can use `tracing` and `RUSTC_LOG` to debug the dep-graph.
2023-10-28Clean up config mess.Nicholas Nethercote-33/+35
`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-28Optimize `parse_cfgspecs`.Nicholas Nethercote-5/+7
In `parse_cfg`, we now construct a `FxHashSet<String>` directly instead of constructing a `FxHashSet<Symbol>` and then immediately converting it to a `FxHashSet<String>`(!) (The type names made this behaviour non-obvious. The next commit will make the type names clearer.)
2023-10-28Streamline `rustc_interface` tests.Nicholas Nethercote-11/+3
In `test_edition_parsing`, change the `build_session_options_and_crate_config` call to `build_session_options`, because the config isn't used. That leaves a single call site for `build_session_options_and_crate_config`, so just inline and remove it.
2023-10-28Fix a comment.Nicholas Nethercote-1/+1
2023-10-27Better guard against wrong input with check-cfg any()Urgau-3/+7
2023-10-26Remove most indentation in check-cfg implUrgau-200/+181
2023-10-26Rollup merge of #117207 - Zalathar:no-option, r=compiler-errorsMatthias Krüger-1/+1
The value of `-Cinstrument-coverage=` doesn't need to be `Option` (Extracted from #117199, since this is a purely internal cleanup that can land independently.) Not using this flag is identical to passing `-Cinstrument-coverage=off`, so there's no need to distinguish between `None` and `Some(Off)`.
2023-10-26The value of `-Cinstrument-coverage=` doesn't need to be `Option`Zalathar-1/+1
Not using this flag is identical to passing `-Cinstrument-coverage=off`, so there's no need to distinguish between `None` and `Some(Off)`.