about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2024-03-27Start replacing `CStore` trait methods with hooks.Oli Scherer-6/+0
This also avoids the cyclic definition issues with CrateStore being defined after TyCtxt, but needing to be used in TyCtxt.
2024-03-25Replace implementation with @RUSTC_BUILTIN prefix substitution varLukas Wirth-14/+8
2024-03-25Make sysroot mandatory for rustdocLukas Wirth-14/+4
2024-03-25Implement `-L builtin:$path`Lukas Wirth-6/+33
2024-03-25Rollup merge of #122842 - pacak:explicit_name, r=michaelwoeristerMatthias Krüger-0/+5
Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name Fixes #122509 You can ask `rustc` to produce some intermediate results with `--emit foo`, this operation comes in two flavors: `--emit asm` and `--emit asm=foo.s`. First one produces one or more `.s` files without any name guarantees, second one renames it into `foo.s`. Second version only works when compiler produces a single file - for asm files this means using a single compilation unit for example. In case compilation produced more than a single file `rustc` runs following check to emit some warnings: ```rust if crate_output.outputs.contains_key(&output_type) { // 2) Multiple codegen units, with `--emit foo=some_name`. We have // no good solution for this case, so warn the user. sess.dcx().emit_warn(errors::IgnoringEmitPath { extension }); } else if crate_output.single_output_file.is_some() { // 3) Multiple codegen units, with `-o some_name`. We have // no good solution for this case, so warn the user. sess.dcx().emit_warn(errors::IgnoringOutput { extension }); } else { // 4) Multiple codegen units, but no explicit name. We // just leave the `foo.0.x` files in place. // (We don't have to do any work in this case.) } ``` Comment in the final `else` branch implies that if user didn't ask for a specific name - there's no need to emit warnings. However because of the internal representation of `crate_output.outputs` - this doesn't work as expected: if user asked to produce an asm file without giving it an implicit name it will contain `Some(None)`. To fix the problem new code actually checks if user gave an explicit name. I think this was an original intentional behavior, at least comments imply that.
2024-03-24Rollup merge of #122737 - ytmimi:conditionally_ignore_fatal_diagnostic, ↵Matthias Krüger-1/+6
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-22-Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.Kevin Reid-4/+14
This should assist comprehending the size of coroutines. In particular, whenever a future is suspended while awaiting another future, the latter is given the special name `__awaitee`, and now the type of the awaited future will be printed, allowing identifying caller/callee — er, I mean, poller/pollee — relationships. It would be possible to include the type name in more cases, but I thought that that might be overly verbose (`print-type-sizes` is already a lot of text) and ordinary named fields or variables are easier for readers to discover the types of.
2024-03-22Don't emit an error about failing to produce a file with a specific nameMichael Baikov-0/+5
If user never gave an explicit name
2024-03-21Rename some `target_cfg` variables as `target`.Nicholas Nethercote-5/+4
Because the underlying type is called `Target`. (There is also a separate type called `TargetCfg`.)
2024-03-21Remove `CodegenBackend::target_override`.Nicholas Nethercote-27/+18
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-20Rollup merge of #122748 - nnethercote:rustc_session-pub, r=jackh726Matthias Krüger-132/+130
Reduce `pub` usage in `rustc_session`. In particular, almost none of the errors in `errors.rs` are used outside the crate. r? `@jackh726`
2024-03-20Reduce `pub` usage in `rustc_session`.Nicholas Nethercote-132/+130
In particular, almost none of the errors in `errors.rs` are used outside the crate.
2024-03-19conditionally ignore fatal diagnostic in the SilentEmitterYacin Tmimi-1/+6
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-18Rollup merge of #122158 - estebank:feature-sugg, r=WaffleLapkinMatthias Krüger-5/+20
Provide structured suggestion for `#![feature(foo)]` ``` error: `S2<'_>` is forbidden as the type of a const generic parameter --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); | ^^ | = note: the only supported types are integers, `bool` and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | ``` Fix #55941.
2024-03-18Provide structured suggestion for `#![feature(foo)]`Esteban Küber-5/+20
``` error: `S2<'_>` is forbidden as the type of a const generic parameter --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); | ^^ | = note: the only supported types are integers, `bool` and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | ``` Fix #55941.
2024-03-17some minor code simplificationsMatthias Krüger-7/+1
2024-03-15Rollup merge of #121207 - chriswailes:z-external-clangrt, r=michaelwoeristerMatthias Krüger-0/+2
Add `-Z external-clangrt` This adds the unstable `-Z external-clangrt` flag that will prevent rustc from emitting linker paths for the in-tree LLVM sanitizer runtime library.
2024-03-14Rollup merge of #122322 - Zalathar:branch, r=oli-obkMatthias Krüger-1/+1
coverage: Initial support for branch coverage instrumentation (This is a review-ready version of the changes that were drafted in #118305.) This PR adds support for branch coverage instrumentation, gated behind the unstable flag value `-Zcoverage-options=branch`. (Coverage instrumentation must also be enabled with `-Cinstrument-coverage`.) During THIR-to-MIR lowering (MIR building), if branch coverage is enabled, we collect additional information about branch conditions and their corresponding then/else blocks. We inject special marker statements into those blocks, so that the `InstrumentCoverage` MIR pass can reliably identify them even after the initially-built MIR has been simplified and renumbered. The rest of the changes are mostly just plumbing needed to gather up the information that was collected during MIR building, and include it in the coverage metadata that we embed in the final binary. Note that `llvm-cov show` doesn't print branch coverage information in its source views by default; that needs to be explicitly enabled with `--show-branches=count` or similar. --- The current implementation doesn't have any support for instrumenting `if let` or let-chains. I think it's still useful without that, and adding it would be non-trivial, so I'm happy to leave that for future work.
2024-03-14Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obkMatthias Krüger-3/+71
Make incremental sessions identity no longer depend on the crate names provided by source code This makes incremental sessions identity no longer depend on the crate names provided by source code, implementing https://github.com/rust-lang/compiler-team/issues/726. r? ````@oli-obk````
2024-03-14coverage: `-Zcoverage-options=branch` is no longer a placeholderZalathar-1/+1
2024-03-13Add `-Z external-sanitizer-runtime`Chris Wailes-0/+2
This adds the unstable `-Z external-sanitizer-runtime` flag that will prevent rustc from emitting linker paths for the in-tree LLVM sanitizer runtime library.
2024-03-13Make incremental sessions identity no longer depend on the crate names ↵John Kåre Alsaker-3/+71
provided by source code
2024-03-13extend docs of -Zprint-mono-itemsRalf Jung-1/+3
2024-03-13Rollup merge of #122226 - Zalathar:zcoverage-options, r=nnethercoteMatthias Krüger-68/+49
coverage: Remove or migrate all unstable values of `-Cinstrument-coverage` (This PR was substantially overhauled from its original version, which migrated all of the existing unstable values intact.) This PR takes the three nightly-only values that are currently accepted by `-Cinstrument-coverage`, completely removes two of them (`except-unused-functions` and `except-unused-generics`), and migrates the third (`branch`) over to a newly-introduced unstable flag `-Zcoverage-options`. I have a few motivations for wanting to do this: - It's unclear whether anyone actually uses the `except-unused-*` values, so this serves as an opportunity to either remove them, or prompt existing users to object to their removal. - After #117199, the stable values of `-Cinstrument-coverage` treat it as a boolean-valued flag, so having nightly-only extra values feels out-of-place. - Nightly-only values also require extra ad-hoc code to make sure they aren't accidentally exposed to stable users. - The new system allows multiple different settings to be toggled independently, which isn't possible in the current single-value system. - The new system makes it easier to introduce new behaviour behind an unstable toggle, and then gather nightly-user feedback before possibly making it the default behaviour for all users. - The new system also gives us a convenient place to put relatively-narrow options that won't ever be the default, but that nightly users might still want access to. - It's likely that we will eventually want to give stable users more fine-grained control over coverage instrumentation. The new flag serves as a prototype of what that stable UI might eventually look like. The `branch` option is a placeholder that currently does nothing. It will be used by #122322 to opt into branch coverage instrumentation. --- I see `-Zcoverage-options` as something that will exist more-or-less indefinitely, though individual sub-options might come and go as appropriate. I think there will always be some demand for nightly-only toggles, so I don't see `-Zcoverage-options` itself ever being stable, though we might eventually stabilize something similar to it.
2024-03-13Auto merge of #122227 - Zoxc:query-hash-verify, r=michaelwoeristerbors-1/+3
Verify that query keys result in unique dep nodes This implements checking that query keys result into unique dep nodes as mentioned in https://github.com/rust-lang/rust/pull/112469. We could do a perf check to see how expensive this is. r? `@michaelwoerister`
2024-03-13coverage: Add `-Zcoverage-options` for fine control of coverageZalathar-6/+45
This new nightly-only flag can be used to toggle fine-grained flags that control the details of coverage instrumentation. Currently the only supported flag value is `branch` (or `no-branch`), which is a placeholder for upcoming support for branch coverage. Other flag values can be added in the future, to prototype proposed new behaviour, or to enable special non-default behaviour.
2024-03-13coverage: Remove all unstable values of `-Cinstrument-coverage`Zalathar-65/+7
2024-03-12sess: stabilize relro-levelDavid Wood-3/+3
Signed-off-by: David Wood <david@davidtw.co>
2024-03-12Verify that query keys result in unique dep nodesJohn Kåre Alsaker-1/+3
2024-03-11Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillotJubilee-20/+13
Allow targets to override default codegen backend Implements https://github.com/rust-lang/compiler-team/issues/670.
2024-03-11Rollup merge of #116791 - WaffleLapkin:unparallel-backends, r=oli-obkJubilee-1/+1
Allow codegen backends to opt-out of parallel codegen This makes it a bit easier to write cursed codegen backends.
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-11/+7
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-7/+7
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-10Introduce perma-unstable `wasm-c-abi` flagdaxpedda-2/+17
2024-03-06Rollup merge of #121959 - sundeep-kokkonda:patch-2, r=davidtwcoMatthias Krüger-13/+0
Removing absolute path in proc-macro With rust 1.75 the absolute build path name is embedding into proc-macro (.rustc section) and which causes reproducibility issues. Detailed issue description is here - https://github.com/rust-lang/rust/issues/120825#issuecomment-1964307219 With this change the 'absolute path' changed back to '/rust/$hash' format as in earlier revisions.
2024-03-06Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, ↵Matthias Krüger-3/+8
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-06Change the documented implicit value of `-C instrument-coverage` to `=yes`Zalathar-19/+18
2024-03-06Add missing `#[rustc_lint_diagnostics]` attributes.Nicholas Nethercote-0/+2
Prior to the previous commit, `#[rust_lint_diagnostics]` attributes could only be used on methods with an `impl Into<{D,Subd}iagMessage>` parameter. But there are many other nearby diagnostic methods (e.g. `Diag::span`) that don't take such a parameter and should have the attribute. This commit adds the missing attribute to these `Diag` methods. This requires adding some missing `#[allow(rustc::diagnostic_outside_of_impl)]` markers at call sites to these methods.
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-3/+6
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`.
2024-03-05Rollup merge of #121301 - davidtwco:rustfmt-silent-emitter, r=pnkfelixMatthias Krüger-6/+12
errors: share `SilentEmitter` between rustc and rustfmt Fixes rust-lang/rustfmt#6082. Shares the `SilentEmitter` between rustc and rustfmt, and gives it a fallback bundle (since it can emit diagnostics in some contexts).
2024-03-05errors: share `SilentEmitter` between rustc and rustfmtDavid Wood-6/+12
Signed-off-by: David Wood <david@davidtw.co>
2024-03-05Limit the number of names and values in check-cfg diagnosticsUrgau-0/+2
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-3/+3
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-17/+17
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-13/+12
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-03-04Remove `file_path_mapping` param from `ParseSess::new`.Nicholas Nethercote-2/+2
It's always empty.
2024-03-04Removing absolute path in proc-macroSundeep KOKKONDA-13/+0
With rust 1.75 the absolute build path is embedding into '.rustc' section and which causes reproducibility issues. Detailed issue is here. https://github.com/rust-lang/rust/issues/120825#issuecomment-1964307219 With this change the 'absolute path' changed back to '/rust/$hash' format.
2024-03-01Add initial support for DataFlowSanitizerRamon de C Valle-2/+18
Adds initial support for DataFlowSanitizer to the Rust compiler. It currently supports `-Zsanitizer-dataflow-abilist`. Additional options for it can be passed to LLVM command line argument processor via LLVM arguments using `llvm-args` codegen option (e.g., `-Cllvm-args=-dfsan-combine-pointer-labels-on-load=false`).
2024-02-29Rollup merge of #121783 - nnethercote:emitter-cleanups, r=oli-obkGuillaume Gomez-29/+38
Emitter cleanups Some cleanups I made when reading emitter code. In particular, `HumanEmitter` and `JsonEmitter` have gone from three constructors to one. r? `@oli-obk`
2024-02-29Make `JsonEmitter` more like `HumanEmitter`.Nicholas Nethercote-13/+7
Use `derive(Setters)` to derive setters, and then change `JsonEmitter::new` to only have the arguments that are always used.