about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/interface.rs
AgeCommit message (Collapse)AuthorLines
2025-06-24rustc_session: Add a structure for keeping both explicit and default sysrootsVadim Petrochenkov-6/+7
Also avoid creating and cloning sysroot unnecessarily.
2025-06-19Extract SilentEmitterCameron Steffen-2/+0
2025-06-19Rename SilentEmitter -> FatalOnlyEmitterCameron Steffen-2/+2
2025-06-06Fix review commentsbjorn3-3/+2
2025-06-05Replace all uses of sysroot_candidates with get_or_default_sysrootbjorn3-2/+2
Before this change we had two different ways to attempt to locate the sysroot which are inconsistently used: * get_or_default_sysroot which tries to locate based on the 0th cli argument and if that doesn't work falls back to locating it using the librustc_driver.so location and returns a single path., * sysroot_candidates which takes the former and additionally does another attempt at locating using librustc_driver.so except without linux multiarch handling and then returns both paths., The latter was originally introduced to be able to locate the codegen backend back when cg_llvm was dynamically linked even for a custom driver when the --sysroot passed in does not contain a copy of cg_llvm. Back then get_or_default_sysroot did not attempt to locate the sysroot based on the location of librustc_driver.so yet. Because that is now done, the only case where removing sysroot_candidates can break things is if you have a custom driver inside what looks like a sysroot including the lib/rustlib directory, but which is missing some parts of the full sysroot like eg rust-lld.
2025-04-29Add some commentsJohn Kåre Alsaker-0/+4
2025-04-29Add a jobserver proxy to ensure at least one token is always heldJohn Kåre Alsaker-2/+4
2025-04-11Rollup merge of #138682 - Alexendoo:extra-symbols, r=fee1-deadStuart Cook-0/+5
Allow drivers to supply a list of extra symbols to intern Allows adding new symbols as `const`s in external drivers, desirable in Clippy so we can use them in patterns to replace code like https://github.com/rust-lang/rust/blob/75530e9f72a1990ed2305e16fd51d02f47048f12/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs#L66 The Clippy change adds a couple symbols as a demo, the exact `clippy_utils` API and replacing other usages can be done on the Clippy side to minimise sync conflicts --- try-job: aarch64-gnu
2025-04-10Allow drivers to supply a list of extra symbols to internAlex Macleod-0/+5
2025-04-03Allow boolean literals in `check-cfg`clubby789-0/+8
2025-03-12Make opts.maybe_sysroot non-optionalbjorn3-3/+3
build_session_options always uses materialize_sysroot anyway.
2025-02-06Construct DiagCtxt a bit earlier in build_sessionbjorn3-1/+0
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-2/+2
2025-01-28ABI-required target features: warn when they are missing in base CPU (rather ↵Ralf Jung-0/+2
than silently enabling them)
2025-01-23Rollup merge of #135880 - bjorn3:misc_driver_refactors, r=oli-obkMatthias Krüger-3/+11
Get rid of RunCompiler The various `set_*` methods that have been removed can be replaced by setting the respective fields in the `Callbacks::config` implementation. `set_using_internal_features` was often forgotten and it's equivalent is now done automatically.
2025-01-23Remove outdated sentencebjorn3-1/+0
2025-01-23Remove set_make_codegen_backend and set_file_loaderbjorn3-0/+10
They can both be set inside the config callback too.
2025-01-23Remove the need to manually call set_using_internal_featuresbjorn3-2/+1
2025-01-22Rollup merge of #135596 - compiler-errors:stack, r=oli-obkMatthias Krüger-6/+11
Properly note when query stack is being cut off cc #70953 also, i'm not certain whether we should even limit this at all. i don't see the problem with printing the full query stack, apparently it was limited b/c we used to ICE? but we're already printing the full stack to disk since #108714. r? oli-obk
2025-01-20Respect --target in get_backend_from_raw_matchesbjorn3-1/+1
2025-01-16Properly note when query stack is being cut offMichael Goulet-6/+11
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-13Explain why an untranslatable_diagnostic occursbjorn3-2/+5
2024-12-13Remove registered_lints field from Sessionbjorn3-1/+0
It only exists to pass some information from one part of the driver to another part. We can directly pass this information to the function that needs it to reduce the amount of mutation of the Session.
2024-12-07Reduce indentation in run_compilerbjorn3-24/+23
2024-12-06Handle unwinding out of the closure argument of run_compiler with pending ↵bjorn3-14/+17
delayed bugs
2024-12-06Store a single copy of the error registry in DiagCtxtbjorn3-2/+2
And pass this to the individual emitters when necessary.
2024-10-01add unstable support for outputting file checksums for use in cargoJacob Kiesel-1/+2
2024-09-30Rollup merge of #131057 - Urgau:cfg-erronous-unsafe, r=jieyouxuMatthias Krüger-1/+1
Reject leading unsafe in `cfg!(...)` and `--check-cfg` This PR reject leading unsafe in `cfg!(...)` and `--check-cfg`. Fixes (after-backport) https://github.com/rust-lang/rust/issues/131055 r? `@jieyouxu`
2024-09-30Reject leading unsafe in `cfg!(...)` and `--check-cfg`.Urgau-1/+1
2024-09-29cleanup: don't `.into()` identical typesMatthias Krüger-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-09-05Use a `Vec` in `rustc_interface::Config::locale_resources`arnaudgolfouse-1/+3
This allows a third-party tool to injects its own resources, when receiving the config via `rustc_driver::Callbacks::config`.
2024-07-30Add toggle for `parse_meta_item` unsafe parsingcarbotaniuman-2/+3
This makes it possible for the `unsafe(...)` syntax to only be valid at the top level, and the `NestedMetaItem`s will automatically reject `unsafe(...)`.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-8/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-22Ensure run_compiler always aborts on errorsbjorn3-12/+9
Before if the closure passed to run_compiler emitted an error without calling abort_if_errors and no diagnostics have been stashed, run_compiler would return normally as if no error had occured.
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-6/+6
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-05Make top-level `rustc_parse` functions fallible.Nicholas Nethercote-3/+3
Currently we have an awkward mix of fallible and infallible functions: ``` new_parser_from_source_str maybe_new_parser_from_source_str new_parser_from_file (maybe_new_parser_from_file) // missing (new_parser_from_source_file) // missing maybe_new_parser_from_source_file source_str_to_stream maybe_source_file_to_stream ``` We could add the two missing functions, but instead this commit removes of all the infallible ones and renames the fallible ones leaving us with these which are all fallible: ``` new_parser_from_source_str new_parser_from_file new_parser_from_source_file source_str_to_stream source_file_to_stream ``` This requires making `unwrap_or_emit_fatal` public so callers of formerly infallible functions can still work. This does make some of the call sites slightly more verbose, but I think it's worth it for the simpler API. Also, there are two `catch_unwind` calls and one `catch_fatal_errors` call in this diff that become removable thanks this change. (I will do that in a follow-up PR.)
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_interface`.Nicholas Nethercote-1/+1
2024-05-19defrost RUST_MIN_STACK=ice rustc hello.rsJubilee Young-0/+1
An earlier commit included the change for a suggestion here. Unfortunately, it also used unwrap instead of dying properly. Roll out the ~~rice paper~~ EarlyDiagCtxt before we do anything that might leave a mess.
2024-05-06Improve check-cfg CLI errors with more structured diagnosticsUrgau-10/+41
2024-04-16Move `initialize_checked_jobserver`.Nicholas Nethercote-1/+14
Currently it's a method on `EarlyDiagCtxt`, which is not the right place for it at all -- `EarlyDiagCtxt` is used to issue diagnostics, but shouldn't be doing any of the actual checking. This commit moves it into a standalone function that takes an `EarlyDiagCtxt` as an argument, which is more sensible. This does require adding `EarlyDiagCtxt::early_struct_warn`, so a warning can be returned and then modified with a note. (And that likely explains why somebody put `initialize_checked_jobserver` into `EarlyDiagCtxt` in the first place.)
2024-04-16Construct `SourceMap` at the same time as `SessionGlobals`.Nicholas Nethercote-47/+47
Currently `SourceMap` is constructed slightly later than `SessionGlobals`, and inserted. This commit changes things so they are done at the same time. Benefits: - `SessionGlobals::source_map` changes from `Lock<Option<Lrc<SourceMap>>>` to `Option<Lrc<SourceMap>>`. It's still optional, but mutability isn't required because it's initialized at construction. - `set_source_map` is removed, simplifying `run_compiler`, which is good because that's a critical function and it's nice to make it simpler. This requires moving things around a bit, so the necessary inputs are available when `SessionGlobals` is created, in particular the `loader` and `hash_kind`, which are no longer computed by `build_session`. These inputs are captured by the new `SourceMapInputs` type, which is threaded through various places.
2024-03-27Add a `CurrentGcx` type to let the deadlock handler access `TyCtxt`John Kåre Alsaker-3/+10
2024-03-24Rollup merge of #122737 - ytmimi:conditionally_ignore_fatal_diagnostic, ↵Matthias Krüger-0/+2
r=davidtwco conditionally ignore fatal diagnostic in the SilentEmitter This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in #121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to https://github.com/rust-lang/rustfmt/issues/6109. These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
2024-03-21Remove `CodegenBackend::target_override`.Nicholas Nethercote-42/+13
Backend and target selection is a mess: the target can override the backend (via `Target::default_codegen_backend`), *and* the backend can override the target (via `CodegenBackend::target_override`). The code that handles this is ugly. It calls `build_target_config` twice, once before getting the backend and once again afterward. It also must check that both overrides aren't triggering at the same time. This commit removes the latter override. It's used in rust-gpu but @eddyb said via Zulip that removing it would be ok. This simplifies the code greatly, and will allow some nice follow-up refactorings.
2024-03-19conditionally ignore fatal diagnostic in the SilentEmitterYacin Tmimi-0/+2
This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in PR 121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics. These changes allow rustfmt to maintain it's previous behaviour when using the SilentEmitter, while allowing rustc code to still emit fatal diagnostics.
2024-03-11Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillotJubilee-13/+48
Allow targets to override default codegen backend Implements https://github.com/rust-lang/compiler-team/issues/670.
2024-03-06Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, ↵Matthias Krüger-0/+1
r=davidtwco Rework `untranslatable_diagnostic` lint Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`. r? ``@davidtwco``
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-0/+1
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`.