summary refs log tree commit diff
path: root/compiler/rustc_interface/src/util.rs
AgeCommit message (Collapse)AuthorLines
2023-05-18Auto merge of #111345 - jyn514:cfg-release-caching, r=cjgillot,est31bors-0/+1
Only depend on CFG_VERSION in rustc_interface This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`. cc https://github.com/rust-lang/rust/issues/76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
2023-05-17Only depend on CFG_VERSION in rustc_interfacejyn-0/+1
this avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-7/+7
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-04-29Auto merge of #109611 - Zoxc:query-engine-rem, r=cjgillotbors-2/+3
Remove `QueryEngine` trait This removes the `QueryEngine` trait and `Queries` from `rustc_query_impl` and replaced them with function pointers and fields in `QuerySystem`. As a side effect `OnDiskCache` is moved back into `rustc_middle` and the `OnDiskCache` trait is also removed. This has a couple of benefits. - `TyCtxt` is used in the query system instead of the removed `QueryCtxt` which is larger. - Function pointers are more flexible to work with. A variant of https://github.com/rust-lang/rust/pull/107802 is included which avoids the double indirection. For https://github.com/rust-lang/rust/pull/108938 we can name entry point `__rust_end_short_backtrace` to avoid some overhead. For https://github.com/rust-lang/rust/pull/108062 it avoids the duplicate `QueryEngine` structs. - `QueryContext` now implements `DepContext` which avoids many `dep_context()` calls in `rustc_query_system`. - The `rustc_driver` size is reduced by 0.33%, hopefully that means some bootstrap improvements. - This avoids the unsafe code around the `QueryEngine` trait. r? `@cjgillot`
2023-04-26Remove QueryEngine traitJohn Kåre Alsaker-2/+3
2023-04-16Move the WorkerLocal type from the rustc-rayon fork into rustc_data_structuresJohn Kåre Alsaker-0/+6
2023-03-28Rollup merge of #108480 - Zoxc:rayon-tlv, r=cuvipernils-1/+1
Use Rayon's TLV directly This accesses Rayon's `TLV` thread local directly avoiding wrapper functions. This makes rustc work with https://github.com/rust-lang/rustc-rayon/pull/10. r? `@cuviper`
2023-03-28Rollup merge of #109685 - est31:not_llvm_but_backend, r=jyn514Matthias Krüger-1/+1
Make doc comment a little bit more accurate It queries not LLVM in particular but the codegen backend *in general*. While cranelift does not provide target features, other codegen backends do. Found while looking for [this answer](https://github.com/rust-lang/rust/issues/108680#issuecomment-1484324690).
2023-03-28Make doc comment a little bit more accurateest31-1/+1
It queries not LLVM in particular but the codegen backend *in general*. While cranelift does not provide target features, other codegen backends do.
2023-03-25Update indexmap and rayon cratesJohn Kåre Alsaker-1/+1
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-1/+1
2023-03-09Honor current target when checking conditional compilation valuesUrgau-1/+1
This is fixed by simply using the currently registered target in the current session. We need to use it because of target json that are not by design included in the rustc list of targets.
2023-02-22various: translation resources from cg backendDavid Wood-0/+3
Extend `CodegenBackend` trait with a function returning the translation resources from the codegen backend, which can be added to the complete list of resources provided to the emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22errors: generate typed identifiers in each crateDavid Wood-0/+2
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-19Make public API, docs algorithm-agnosticJacob Pratt-1/+1
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-15/+12
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-16Move compiler input and ouput paths into sessionOli Scherer-15/+10
2023-01-16Group some commonly passed together values into a structOli Scherer-11/+10
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-7/+6
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-11-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-5/+2
2022-11-09Fix `rustdoc --version` when used with download-rustcJoshua Nelson-16/+6
Previously, rustdoc would unconditionally report the version that *rustc* was compiled with. That showed things like `nightly-2022-10-30`, which wasn't right, since this was a `dev` build compiled from source. Fix it by changing `rustc_driver::version` to a macro expanded at invocation time.
2022-11-04improve `filesearch::get_or_default_sysroot` r=ozkanonurOnur Özkan-95/+2
Signed-off-by: Onur Özkan <work@onurozkan.dev>
2022-10-19Clarify `run_in_thread_pool_with_globals`.Nicholas Nethercote-44/+45
- Make the structure of the two variants more similar. - Add some comments. - Move various conditional `use` items inside the function that uses them. - Inline some closures.
2022-10-19Replace a `spawn_unchecked` with `spawn_scoped`.Nicholas Nethercote-12/+16
2022-10-19Apply `Lrc` later to `sess` and `codegen_backend`.Nicholas Nethercote-3/+2
This avoids the need for a degenerate `Lrc::get_mut` call.
2022-10-19Reduce visibility of some functions.Nicholas Nethercote-2/+2
2022-10-19Inline and remove `scoped_thread`.Nicholas Nethercote-15/+9
It has a single call site, and removing it slightly improves the confusing tangle of nested closures present at startup.
2022-10-18Remove `RunCompiler::emitter`.Nicholas Nethercote-3/+1
It's no longer used.
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+1
by module
2022-08-12Adjust cfgsMark Rousskov-1/+1
2022-07-31Rollup merge of #99519 - Urgau:check-cfg-implicit, r=petrochenkovMatthias Krüger-1/+0
Remove implicit names and values from `--cfg` in `--check-cfg` This PR remove the implicit names and values from `--cfg` in `--check-cfg` because the behavior is quite surprising but also because it's really easy to inadvertently really on the implicitness and when the `--cfg` is not set anymore to have an unexpected warning from an unexpected condition that pass with the implicitness. This change in behavior will also enable us to warn when an unexpected `--cfg` is passed, ex: the user wrote `--cfg=unstabl` instead of `--cfg=unstable`. The implementation of the warning will be done in a follow-up PR. cc `@petrochenkov`
2022-07-27lint: add bad opt access internal lintDavid Wood-0/+2
Some command-line options accessible through `sess.opts` are best accessed through wrapper functions on `Session`, `TyCtxt` or otherwise, rather than through field access on the option struct in the `Session`. Adds a new lint which triggers on those options that should be accessed through a wrapper function so that this is prohibited. Options are annotated with a new attribute `rustc_lint_opt_deny_field_access` which can specify the error message (i.e. "use this other function instead") to be emitted. A simpler alternative would be to simply rename the options in the option type so that it is clear they should not be used, however this doesn't prevent uses, just discourages them. Another alternative would be to make the option fields private, and adding accessor functions on the option types, however the wrapper functions sometimes rely on additional state from `Session` or `TyCtxt` which wouldn't be available in an function on the option type, so the accessor would simply make the field available and its use would be discouraged too. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20Remove implicit names and values from --cfg in --check-cfgUrgau-1/+0
2022-07-14Auto merge of #96544 - m-ysk:feature/issue-96358, r=cjgillotbors-18/+0
Stop keeping metadata in memory before writing it to disk Fixes #96358 I created this PR according with the instruction given in the issue except for the following points: - While the issue says "Write metadata into the temporary file in `encode_and_write_metadata` even if `!need_metadata_file`", I could not do that. That is because though I tried to do that and run `x.py test`, I got a lot of test failures as follows. <details> <summary>List of failed tests</summary> <pre> <code> failures: [ui] src/test/ui/json-multiple.rs [ui] src/test/ui/json-options.rs [ui] src/test/ui/rmeta/rmeta-rpass.rs [ui] src/test/ui/save-analysis/emit-notifications.rs [ui] src/test/ui/svh/changing-crates.rs [ui] src/test/ui/svh/svh-change-lit.rs [ui] src/test/ui/svh/svh-change-significant-cfg.rs [ui] src/test/ui/svh/svh-change-trait-bound.rs [ui] src/test/ui/svh/svh-change-type-arg.rs [ui] src/test/ui/svh/svh-change-type-ret.rs [ui] src/test/ui/svh/svh-change-type-static.rs [ui] src/test/ui/svh/svh-use-trait.rs test result: FAILED. 12915 passed; 12 failed; 100 ignored; 0 measured; 0 filtered out; finished in 71.41s Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu Build completed unsuccessfully in 0:01:58 </code> </pre> </details> - I could not resolve the extra tasks about `create_rmeta_file` and `create_compressed_metadata_file` for my lack of ability.
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-4/+4
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-13Rollup merge of #99155 - Amanieu:unstable-target-features, r=davidtwcoDylan DPC-1/+4
Keep unstable target features for asm feature checking Inline assembly uses the target features to determine which registers are available on the current target. However it needs to be able to access unstable target features for this. Fixes #99071
2022-07-11Keep unstable target features for asm feature checkingAmanieu d'Antras-1/+4
Inline assembly uses the target features to determine which registers are available on the current target. However it needs to be able to access unstable target features for this. Fixes #99071
2022-07-02remove non_durable_rename in rustc_interface::utilYoshiki Matsuda-18/+0
2022-06-29get rid of `tcx` in deadlock handler when parallel compilationSparrowLii-14/+6
2022-06-16Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock`Maybe Waffle-3/+3
2022-04-12sess: try sysroot candidates for fluent bundleDavid Wood-0/+14
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-03-03Remove the everybody loops passbjorn3-214/+1
It isn't used anymore by rustdoc
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-20Rollup merge of #94146 - est31:let_else, r=cjgillotMatthias Krüger-4/+1
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/+1
2022-02-18Rollup merge of #93915 - Urgau:rfc-3013, r=petrochenkovMatthias Krüger-0/+8
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/+8
Co-authored-by: Urgau <lolo.branstett@numericable.fr> Co-authored-by: Marcelina Kościelnicka <mwk@0x04.net>
2022-02-13Remove Config::stderrbjorn3-14/+3
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-12Move setup_callbacks call to create_compiler_and_runbjorn3-6/+2
This ensures that it is called even when run_in_thread_pool_with_globals is avoided and reduces code duplication between the parallel and non-parallel version of run_in_thread_pool_with_globals
2022-02-11Make two functions privatebjorn3-2/+2