about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src
AgeCommit message (Collapse)AuthorLines
2024-03-05Rollup merge of #121658 - jieyouxu:ice-outdated-nightly, r=oli-obkMatthias Krüger-4/+42
Hint user to update nightly on ICEs produced from outdated nightly This is a conservative best-effort approach to detect a potentially outdated nightly; it will fallback to the regular ICE-reporting if any of the following cases are true: - Channel is not nightly - Version information is not available - Version date is not parseable as a YYYY-MM-DD or is missing - System time is at least 36 hours ahead of the user's nightly release datetime. - Any internal features are used. Note that I'm not sure how to make a test for this: I tested this manually by `CFG_VER_DATE="2020-02-02" ./x build library --stage 1`, and also changing the channel detection in `rustc_driver_impl` from `Some("nightly")` to `Some("nightly" | "dev")`, and then running `rustc +stage1 test.rs -Ztreat-err-as-bug=1` with a non-existent `test.rs`. <img width="1145" alt="Screenshot 2024-02-27 at 01 12 28" src="https://github.com/rust-lang/rust/assets/39484203/eff6af2e-4b19-4a70-af57-cd739ecf0e84"> Closes #118832.
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-11/+9
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-02-29Inline and remove `HumanEmitter::stderr`.Nicholas Nethercote-2/+3
Because `HumanEmitter::new` is enough, in conjunction with the (renamed) `stderr_destination` function.
2024-02-29Rename `DiagCtxt::with_emitter` as `DiagCtxt::new`.Nicholas Nethercote-1/+1
Because it's now the only constructor.
2024-02-27Don't suggest update nightly if using internal features许杰友 Jieyou Xu (Joe)-24/+7
2024-02-27Hint user to update nightly on ICEs produced from outdated nightly许杰友 Jieyou Xu (Joe)-4/+59
2024-02-22Inline and remove `abort_on_err`.Nicholas Nethercote-17/+14
It's clumsy and doesn't improve readability.
2024-02-22Inline and remove `Session::compile_status`.Nicholas Nethercote-5/+12
Because it's now simple enough that it doesn't provide much benefit.
2024-02-22Remove `EarlyDiagCtxt::abort_if_errors`.Nicholas Nethercote-3/+2
Its one use isn't necessary, because it's not possible for errors to have been emitted at that point.
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-2/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-07Remove an `unchecked_claim_error_was_emitted` call.Nicholas Nethercote-7/+8
When `catch_fatal_errors` catches a `FatalErrorMarker`, it returns an `ErrorGuaranteed` that is conjured out of thin air with `unchecked_claim_error_was_emitted`. But that `ErrorGuaranteed` is never used. This commit changes it to instead conjure a `FatalError` out of thin air. (A non-deprecated action!) This makes more sense because `FatalError` and `FatalErrorMarker` are a natural pairing -- a `FatalErrorMarker` is created by calling `FatalError::raise`, so this is effectively getting back the original `FatalError`. This requires a tiny change in `catch_with_exit_code`. The old result of the `catch_fatal_errors` call there was `Result<Result<(), ErrorGuaranteed>, ErrorGuaranteed>` which could be `flatten`ed into `Result<(), ErrorGuaranteed>`. The new result of the `catch_fatal_errors` calls is `Result<Result<(), ErrorGuaranteed>, FatalError>`, which can't be `flatten`ed but is still easily matched for the success case.
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-30/+28
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-25Remove unused featuresclubby789-2/+0
2024-01-15Replace `TrimmedDefPaths` with a bool.Nicholas Nethercote-2/+2
It's a tri-state enum but the `Always` variant is never used, so a bool is simpler.
2024-01-10Rename `{create,emit}_warning` as `{create,emit}_warn`.Nicholas Nethercote-1/+1
For consistency with `warn`/`struct_warn`, and also `{create,emit}_err`, all of which use an abbreviated form.
2024-01-09Rollup merge of #118680 - djkoloski:shell_argfiles, r=compiler-errorsGuillaume Gomez-16/+91
Add support for shell argfiles Closes https://github.com/rust-lang/compiler-team/issues/684
2024-01-09Rollup merge of #119527 - klensy:ordering, r=compiler-errorsGuillaume Gomez-2/+1
don't reexport atomic::ordering via rustc_data_structures, use std import This looks simpler.
2024-01-08Add support for shell argfilesDavid Koloski-16/+91
2024-01-08Make `DiagnosticBuilder::emit` consuming.Nicholas Nethercote-1/+1
This works for most of its call sites. This is nice, because `emit` very much makes sense as a consuming operation -- indeed, `DiagnosticBuilderState` exists to ensure no diagnostic is emitted twice, but it uses runtime checks. For the small number of call sites where a consuming emit doesn't work, the commit adds `DiagnosticBuilder::emit_without_consuming`. (This will be removed in subsequent commits.) Likewise, `emit_unless` becomes consuming. And `delay_as_bug` becomes consuming, while `delay_as_bug_without_consuming` is added (which will also be removed in subsequent commits.) All this requires significant changes to `DiagnosticBuilder`'s chaining methods. Currently `DiagnosticBuilder` method chaining uses a non-consuming `&mut self -> &mut Self` style, which allows chaining to be used when the chain ends in `emit()`, like so: ``` struct_err(msg).span(span).emit(); ``` But it doesn't work when producing a `DiagnosticBuilder` value, requiring this: ``` let mut err = self.struct_err(msg); err.span(span); err ``` This style of chaining won't work with consuming `emit` though. For that, we need to use to a `self -> Self` style. That also would allow `DiagnosticBuilder` production to be chained, e.g.: ``` self.struct_err(msg).span(span) ``` However, removing the `&mut self -> &mut Self` style would require that individual modifications of a `DiagnosticBuilder` go from this: ``` err.span(span); ``` to this: ``` err = err.span(span); ``` There are *many* such places. I have a high tolerance for tedious refactorings, but even I gave up after a long time trying to convert them all. Instead, this commit has it both ways: the existing `&mut self -> Self` chaining methods are kept, and new `self -> Self` chaining methods are added, all of which have a `_mv` suffix (short for "move"). Changes to the existing `forward!` macro lets this happen with very little additional boilerplate code. I chose to add the suffix to the new chaining methods rather than the existing ones, because the number of changes required is much smaller that way. This doubled chainging is a bit clumsy, but I think it is worthwhile because it allows a *lot* of good things to subsequently happen. In this commit, there are many `mut` qualifiers removed in places where diagnostics are emitted without being modified. In subsequent commits: - chaining can be used more, making the code more concise; - more use of chaining also permits the removal of redundant diagnostic APIs like `struct_err_with_code`, which can be replaced easily with `struct_err` + `code_mv`; - `emit_without_diagnostic` can be removed, which simplifies a lot of machinery, removing the need for `DiagnosticBuilderState`.
2024-01-06don't reexport atomic::ordering via rustc_data_structures, use std importklensy-2/+1
2024-01-05Rollup merge of #119601 - nnethercote:Emitter-cleanups, r=oli-obkMichael Goulet-1/+1
`Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
2024-01-05Rename `EmitterWriter` as `HumanEmitter`.Nicholas Nethercote-1/+1
For consistency with other `Emitter` impls, such as `JsonEmitter`, `SilentEmitter`, `SharedEmitter`, etc.
2023-12-28Use Result::flatten in catch_with_exit_codeDaniPopes-2/+2
2023-12-26Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebankbors-1/+1
rework `-Zverbose` implements the changes described in https://github.com/rust-lang/compiler-team/issues/706 the first commit is only a name change from `-Zverbose` to `-Zverbose-internals` and does not change behavior. the second commit changes diagnostics. possible follow up work: - `ty::pretty` could print more info with `--verbose` than it does currently. `-Z verbose-internals` shows too much info in a way that's not helpful to users. michael had ideas about this i didn't fully understand: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408984200 - `--verbose` should imply `-Z write-long-types-to-disk=no`. the code in `ty_string_with_limit` should take `--verbose` into account (apparently this affects `Ty::sort_string`, i'm not familiar with this code). writing a file to disk should suggest passing `--verbose`. r? `@compiler-errors` cc `@estebank`
2023-12-24Remove more `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-5/+7
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-23Rename `EarlyDiagCtxt` methods to match `DiagCtxt`.Nicholas Nethercote-13/+12
- `early_error_no_abort` -> `early_err` - `early_error` -> `early_fatal` - `early_struct_error` -> `early_struct_fatal`
2023-12-19rename to verbose-internalsjyn-1/+1
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-32/+32
2023-12-18Rename many `EarlyDiagCtxt` arguments.Nicholas Nethercote-24/+24
2023-12-18Rename `EarlyErrorHandler` as `EarlyDiagCtxt`.Nicholas Nethercote-20/+16
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-4/+7
2023-12-12clippy::complexity fixesMatthias Krüger-3/+1
filter_map_identity needless_bool search_is_some unit_arg map_identity needless_question_mark derivable_impls
2023-12-11Extract exhaustiveness into its own crateNadrieril-0/+1
2023-12-05rustc_driver_impl: Address all `rustc::potential_query_instability` lintsMartin Nordholts-1/+0
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 there were no instances of this lint in this crate.
2023-12-01Auto merge of #118472 - nnethercote:rustc_session, r=bjorn3bors-1/+1
`rustc_session` cleanups r? `@bjorn3`
2023-11-30Move `MetadataLoader{,Dyn}` to `rustc_metadata`.Nicholas Nethercote-1/+1
They're not used in `rustc_session`, and `rustc_metadata` is a more obvious location. `MetadataLoader` was originally put into `rustc_session` in #41565 to avoid a dependency on LLVM, but things have changed a lot since then and that's no longer relevant, e.g. `rustc_codegen_llvm` depends on `rustc_metadata`.
2023-11-26Turn write_dep_info into a regular functionbjorn3-6/+2
It has side-effects and as such can't be cached.
2023-11-26Mostly revert "Accept crate name instead of attributes in ↵bjorn3-1/+1
build_output_filenames"
2023-11-26Feed the output filenames into the TyCtxtbjorn3-4/+4
Since the introduction of the crate attribute pre-expansion pass we don't need access to the TyCtxt to compute it.
2023-11-26Serialize OutputFilenames into rmeta filebjorn3-3/+2
This ensures that linking will use the correct crate name even when `#![crate_name = "..."]` is used to specify the crate name.
2023-11-26Accept crate name instead of attributes in build_output_filenamesbjorn3-1/+1
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-2/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+1
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-26Remove `rustc_error_messages/messages.ftl`.Nicholas Nethercote-1/+0
It's empty, and it doesn't even make sense, because `rustc_error_messages` is a lower-level crate than `rustc_errors`.
2023-11-22Merge `Queries::{ongoing_codegen,linker}`.Nicholas Nethercote-2/+1
There is no real need for them to be separate.
2023-11-22Make `Compiler::{sess,codegen_backend}` public.Nicholas Nethercote-3/+3
And remove the relevant getters on `Compiler` and `Queries`.
2023-11-22Add two useful comments.Nicholas Nethercote-0/+4
2023-11-18Auto merge of #118002 - nnethercote:unify-input-no-input, r=bjorn3bors-109/+80
Unify "input" and "no input" paths in `run_compiler` A follow-up to #117649. r? `@bjorn3`