about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2023-12-23Give `DiagnosticBuilder` a default type.Nicholas Nethercote-29/+12
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the most common diagnostic level. It makes sense to do likewise for the closely-related (and much more widely used) `DiagnosticBuilder` type, letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many multi-line things becoming single line things.
2023-12-23Streamline `struct_lint_level`.Nicholas Nethercote-28/+0
We can just get the error level in the `match` and then use `DiagnosticBuilder::new`. This then means a number of `DiagCtxt` functions are no longer needed, because this was the one place that used them. Note: the commit changes the treatment of spans for `Expect`, which was different to all the other cases, but this has no apparent effect.
2023-12-19Add `EmitResult` associated type to `EmissionGuarantee`.Nicholas Nethercote-20/+26
This lets different error levels share the same return type from `emit_*`. - A lot of inconsistencies in the `DiagCtxt` API are removed. - `Noted` is removed. - `FatalAbort` is introduced for fatal errors (abort via `raise`), replacing the `EmissionGuarantee` impl for `!`. - `Bug` is renamed `BugAbort` (to avoid clashing with `Level::Bug` and to mirror `FatalAbort`), and modified to work in the new way with bug errors (abort via panic). - Various diagnostic creators and emitters updated to the new, better signatures. Note that `DiagCtxt::bug` no longer needs to call `panic_any`, because `emit` handles that. Also shorten the obnoxiously long `diagnostic_builder_emit_producing_guarantee` name.
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-9/+13
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-12/+19
2023-12-18Rename many `EarlyDiagCtxt` arguments.Nicholas Nethercote-132/+132
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-4/+4
2023-12-18Rename `EarlyDiagCtxt::handler` as `EarlyDiagCtxt::dcx`.Nicholas Nethercote-17/+14
2023-12-18Rename `SilentEmitter::fatal_handler` as `SilentEmitter::fatal_dcx`.Nicholas Nethercote-2/+2
2023-12-18Rename `UnstableOptions::diagnostic_handler_flags` as ↵Nicholas Nethercote-2/+2
`UnstableOptions::dcx_flags`.
2023-12-18Rename `ParseSess::with_span_handler` as `ParseSess::with_dcx`.Nicholas Nethercote-4/+4
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-42/+42
2023-12-18Rename `ParseSess::span_diagnostic` as `ParseSess::dcx`.Nicholas Nethercote-13/+12
2023-12-18Rename `HandlerFlags` as `DiagCtxtFlags`.Nicholas Nethercote-3/+3
2023-12-18Rename `EarlyErrorHandler` as `EarlyDiagCtxt`.Nicholas Nethercote-38/+32
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-16/+16
2023-12-15NFC don't convert types to identical typesMatthias Krüger-1/+1
2023-12-14Rollup merge of #118933 - nnethercote:cleanup-errors-even-more, ↵Jubilee-12/+3
r=compiler-errors Cleanup errors handlers even more A sequel to #118587. r? `@compiler-errors`
2023-12-14Rollup merge of #118908 - Urgau:check-cfg-target-features, ↵Jubilee-4/+6
r=TaKO8Ki,GuillaumeGomez,workingjubilee Add all known `target_feature` configs to check-cfg This PR adds all the known `target_feature` from ~~`rustc_codegen_ssa`~~ `rustc_target` to the well known list of check-cfg. It does so by moving the list from `rustc_codegen_ssa` to `rustc_target` ~~`rustc_session` (I not sure about this, but some of the moved function take a `Session`)~~, then using it the `fill_well_known` function. This already proved to be useful since portable-simd had a bad cfg. cc `@nnethercote` (since we discussed it in https://github.com/rust-lang/rust/pull/118494)
2023-12-15Change `msg: impl Into<String>` for bug diagnostics.Nicholas Nethercote-1/+1
To `msg: impl Into<DiagnosticMessage>`, like all the other diagnostics. For consistency.
2023-12-14rename `-Ztrait-solver` to `-Znext-solver`lcnr-41/+57
2023-12-14Don't forget pure rustc target features in check-cfgUrgau-2/+6
2023-12-14Use all the known features in check-cfgUrgau-4/+2
2023-12-14Avoid `struct_diagnostic` where possible.Nicholas Nethercote-11/+2
It's necessary for `derive(Diagnostic)`, but is best avoided elsewhere because there are clearer alternatives. This required adding `Handler::struct_almost_fatal`.
2023-12-13Add unstable `-Zdefault-hidden-visibility` cmdline flag for `rustc`.Lukasz Anforowicz-0/+10
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/656
2023-12-11Auto merge of #118494 - nnethercote:default_configuration-fill_well_known, ↵bors-154/+175
r=Mark-Simulacrum Rearrange `default_configuration` and `CheckCfg::fill_well_known`. There are comments saying these two functions should be kept in sync, but they have very different structures, process symbols in different orders, and there are some inconsistencies. This commit reorders them so they're both mostly processing symbols in alphabetical order, which makes cross-checking them a lot easier. The commit also adds some macros to factor out repetitive code patterns. The commit also moves the handling of `sym::test` out of `build_configuration` into `default_configuration`, where all the other symbols are handled. r? `@bjorn3`
2023-12-11Rearrange `default_configuration` and `CheckCfg::fill_well_known`.Nicholas Nethercote-154/+175
There are comments saying these two functions should be kept in sync, but they have very different structures, process symbols in different orders, and there are some inconsistencies. This commit reorders them so they're both mostly processing symbols in alphabetical order, which makes cross-checking them a lot easier. The commit also adds some macros to factor out repetitive code patterns. Plus it adds `sanitizer_cfi_normalize_{integers,pointers}` to `fill_well_known`, which were missing. The commit also moves the handling of `sym::test` out of `build_configuration` into `default_configuration`, where all the other symbols are handled.
2023-12-10Auto merge of #118368 - GuillaumeGomez:env-flag, r=Nilstriebbors-1/+43
Implement `--env` compiler flag (without `tracked_env` support) Part of https://github.com/rust-lang/rust/issues/80792. Implementation of https://github.com/rust-lang/compiler-team/issues/653. Not an implementation of https://github.com/rust-lang/rfcs/pull/2794. It adds the `--env` compiler flag option which allows to set environment values used by `env!` and `option_env!`. Important to note: When trying to retrieve an environment variable value, it will first look into the ones defined with `--env`, and if there isn't one, then only it will look into the environment variables. So if you use `--env PATH=a`, then `env!("PATH")` will return `"a"` and not the actual `PATH` value. As mentioned in the title, `tracked_env` support is not added here. I'll do it in a follow-up PR. r? rust-lang/compiler
2023-12-10Implement `--env` compiler flagGuillaume Gomez-1/+43
2023-12-09Strengthen well known check-cfg names and values testUrgau-0/+3
2023-12-09Auto merge of #117873 - quininer:android-emutls, r=Amanieubors-1/+3
Add emulated TLS support This is a reopen of https://github.com/rust-lang/rust/pull/96317 . many android devices still only use 128 pthread keys, so using emutls can be helpful. Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls. r? `@Amanieu`
2023-12-08Rollup merge of #118709 - oksbsb:fix-job-server, r=SparrowLiiMatthias Krüger-11/+12
fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use override #118589, resolve merge conflict `@petrochenkov` `@SparrowLii` Thanks!
2023-12-081. fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before useoksbsb-11/+12
2. jobserver::initialize_checked should call before build_session, still should use EarlyErrorHandler, so revert stderr change in #118635
2023-12-08Fuel is incompatible with incremental compilationTomasz Miąsko-1/+5
2023-12-07Inline check_thread_count implementationTomasz Miąsko-11/+7
2023-12-07Auto merge of #118635 - nnethercote:fewer-early-errors, r=davidtwcobors-18/+25
Fewer early errors r? `@davidtwco`
2023-12-07Add emulated TLS supportquininer-1/+3
Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls.
2023-12-06Fewer early errors.Nicholas Nethercote-18/+25
`build_session` is passed an `EarlyErrorHandler` and then constructs a `Handler`. But the `EarlyErrorHandler` is still used for some time after that. This commit changes `build_session` so it consumes the passed `EarlyErrorHandler`, and also drops it as soon as the `Handler` is built. As a result, `parse_cfg` and `parse_check_cfg` now take a `Handler` instead of an `EarlyErrorHandler`.
2023-12-05Rollup merge of #118587 - nnethercote:cleanup-error-handlers-2, ↵Michael Goulet-4/+4
r=compiler-errors Cleanup error handlers some more A sequel to #118470. r? ```@compiler-errors```
2023-12-04De-genericize some `IntoDiagnostic` impls.Nicholas Nethercote-3/+3
These impls are all needed for just a single `IntoDiagnostic` type, not a family of them. Note that `ErrorGuaranteed` is the default type parameter for `IntoDiagnostic`.
2023-12-04Always use `G` for `EmissionGuarantee` type variables.Nicholas Nethercote-2/+2
That's what is mostly used. This commit changes a few `EM` and `E` and `T` type variables to `G`.
2023-12-04Give `Handler::fatal` and `Session::fatal` the same return type.Nicholas Nethercote-1/+1
Currently, `Handler::fatal` returns `FatalError`. But `Session::fatal` returns `!`, because it calls `Handler::fatal` and then calls `raise` on the result. This inconsistency is unfortunate. This commit changes `Handler::fatal` to do the `raise` itself, changing its return type to `!`. This is safe because there are only two calls to `Handler::fatal`, one in `rustc_session` and one in `rustc_codegen_cranelift`, and they both call `raise` on the result. `HandlerInner::fatal` still returns `FatalError`, so I renamed it `fatal_no_raise` to emphasise the return type difference.
2023-12-03Rollup merge of #118574 - Enselic:query-instability, r=cjgillotMatthias Krüger-1/+7
rustc_session: Address all `rustc::potential_query_instability` lints Instead of allowing `rustc::potential_query_instability` on the whole crate we go over each lint and allow it individually if it is safe to do. Turns out all instances were safe to allow in this crate. Part of #84447 which is **E-help-wanted**.
2023-12-03Auto merge of #113730 - belovdv:jobserver-init-check, r=petrochenkovbors-1/+16
Report errors in jobserver inherited through environment variables This pr attempts to catch situations, when jobserver exists, but is not being inherited. r? `@petrochenkov`
2023-12-03rustc_session: Address all `rustc::potential_query_instability` lintsMartin Nordholts-1/+7
Instead of allowing `rustc::potential_query_instability` on the whole crate we go over each lint and allow it individually if it is safe to do. Turns out all instances were safe to allow in this crate.
2023-12-02Remove unnecessary qualifiers.Nicholas Nethercote-3/+3
2023-12-02Use `Session::diagnostic` in more places.Nicholas Nethercote-1/+1
2023-12-02Rename `Handler::delay_good_path_bug` as `Handler::good_path_delayed_bug`.Nicholas Nethercote-6/+9
In line with the previous commits.
2023-12-02Rename `HandlerInner::delayed_span_bugs` as `HandlerInner::span_delayed_bugs`.Nicholas Nethercote-2/+2
For reasons similar to the previous commit.
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-5/+9
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.