about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src
AgeCommit message (Collapse)AuthorLines
2024-03-11Never bail out early while running all the type check queriesOli Scherer-2/+4
2024-03-09Rollup merge of #122187 - bjorn3:merge_header_version_checks, r=petrochenkovMatthias Krüger-0/+1
Move metadata header and version checks together This will make it easier to report rustc versions for older metadata formats. Split out of https://github.com/rust-lang/rust/pull/120855
2024-03-09Lock stderr in panic handlerJohn Kåre Alsaker-0/+3
2024-03-08Move metadata header and version checks togetherbjorn3-0/+1
This will make it easier to report rustc versions for older metadata formats.
2024-03-08Rollup merge of #121194 - beetrees:rustc-raw-args, r=petrochenkovMatthias Krüger-24/+43
Refactor pre-getopts command line argument handling Rebased version of #111658. I've also fixed the Windows CI failure (although I don't have access to Windows to test it myself).
2024-03-07Rollup merge of #121089 - oli-obk:create_def_feed, r=petrochenkovGuillaume Gomez-3/+3
Remove `feed_local_def_id` best reviewed commit by commit Basically I returned `TyCtxtFeed` from `create_def` and then preserved that in the local caches based on https://github.com/rust-lang/rust/pull/121084 r? ````@petrochenkov````
2024-03-07Refactor argument UTF-8 checking into `rustc_driver::args::raw_args()`beetrees-13/+25
2024-03-07Make `arg_expand_all` not short-circuit on first errorbeetrees-11/+18
2024-03-06Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, ↵Matthias Krüger-0/+2
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/+2
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 #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-05Avoid using feed_unit_query from within queriesOli Scherer-3/+3
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-15Refactor out a repeating pattern with `get_or_default_sysroot`Maybe Waffle-6/+2
2024-02-14Allow targets to override default codegen backendMaybe Waffle-3/+16
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`