about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-12-04Inline and remove `fatal_no_raise`.Nicholas Nethercote-10/+3
This makes `Handler::fatal` more like `Handler::{err,warn,bug,note}`.
2023-12-04Make `Handler::{err,bug}` more like `Handler::{warn,note}`.Nicholas Nethercote-10/+3
2023-12-04Remove `HandlerInner::emit`.Nicholas Nethercote-12/+12
This is weird: `HandlerInner::emit` calls `HandlerInner::emit_diagnostic`, but only after doing a `treat-err-as-bug` check. Which is fine, *except* that there are multiple others paths for an `Error` or `Fatal` diagnostic to be passed to `HandlerInner::emit_diagnostic` without going through `HandlerInner::emit`, e.g. `Handler::span_err` call `Handler::emit_diag_at_span`, which calls `emit_diagnostic`. So that suggests that the coverage for `treat-err-as-bug` is incomplete. This commit removes `HandlerInner::emit` and moves the `treat-err-as-bug` check to `HandlerInner::emit_diagnostic`, so it cannot by bypassed.
2023-12-04Move some `HandlerInner` functions to `Handler`.Nicholas Nethercote-212/+164
`Handler` is a wrapper around `HanderInner`. Some functions on on `Handler` just forward to the samed-named functions on `HandlerInner`. This commit removes as many of those as possible, implementing functions on `Handler` where possible, to avoid the boilerplate required for forwarding. The commit is moderately large but it's very mechanical.
2023-12-04Use `DiagnosticBuilder::new` more.Nicholas Nethercote-5/+5
By making it generic, instead of only for `EmissionGuarantee = ()`, we can use it everywhere.
2023-12-04Inline and remove more `DiagnosticBuilder::new_diagnostic_*` functions.Nicholas Nethercote-3/+3
They each have a single call site. Note: the `make_diagnostic_builder` calls in `lib.rs` will be replaced in a subsequent commit.
2023-12-04Give `Handler::fatal` and `Session::fatal` the same return type.Nicholas Nethercote-6/+7
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-02`Handler` tweaks.Nicholas Nethercote-8/+6
- Avoid unnecessary `inner` local variables. - Use `borrow_mut` everywhere (instead of the synonym `lock`).
2023-12-02Rename `Handler::delay_good_path_bug` as `Handler::good_path_delayed_bug`.Nicholas Nethercote-12/+12
In line with the previous commits.
2023-12-02Rename `HandlerInner::delayed_span_bugs` as `HandlerInner::span_delayed_bugs`.Nicholas Nethercote-14/+14
For reasons similar to the previous commit.
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-9/+12
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-12-02Rename `*note_without_error` as `*note`.Nicholas Nethercote-10/+3
Because the variant name in `Level` is `Note`, and the `without_error` suffix is omitted in similar cases like `struct_allow` and `struct_help`.
2023-12-02Rename `HandlerInner::failure` as `HandlerInner::failure_note`.Nicholas Nethercote-4/+4
To match the `FailureNote` variant of `Level`.
2023-12-02Rename `Handler::span_note_diag` as `struct_span_note`.Nicholas Nethercote-1/+1
Because `span_note_diag` doesn't follow the naming structure used for the error reporting functions.
2023-12-02Remove an unnecessary local variable.Nicholas Nethercote-2/+1
2023-12-02Return `ErrorGuaranteed` from `span_err_with_code` methods.Nicholas Nethercote-2/+3
`ErrorGuaranteed` should be used for all error methods involving the `Error` level, e.g. as is done for the corresponding `span_err` methods.
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-24Show number in error message even for one errorNilstrieb-1/+1
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-15Bump cfg(bootstrap)sMark Rousskov-2/+2
2023-11-13Auto merge of #116866 - slanterns:inspect-stabilize, r=BurntSushibors-1/+0
Stabilize `result_option_inspect` This PR stabilizes `result_option_inspect`: ```rust // core::option impl Option<T> { pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self; } // core::result impl Result<T, E> { pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self; pub fn inspect_err<F: FnOnce(&E)>(self, f: F) -> Self; } ``` <br> Tracking issue: https://github.com/rust-lang/rust/issues/91345. Implementation PR: https://github.com/rust-lang/rust/pull/91346. Closes https://github.com/rust-lang/rust/issues/91345.
2023-10-30Don't emit delayed good-path bugs on panicMichael Goulet-1/+1
2023-10-26Stash and cancel cycle errors for auto trait leakage in opaquesMichael Goulet-0/+2
2023-10-18Remove `#![feature(result_option_inspect)]` from the compilerSlanterns-1/+0
2023-10-16Rollup merge of #115196 - chenyukang:yukang-fix-86094, r=estebankMatthias Krüger-0/+1
Suggest adding `return` if the for semi which can coerce to the fn return type Fixes #86094 r? `@estebank`
2023-10-15Suggest adding `return` if the type of unused semi return value can coerce ↵yukang-0/+1
to the fn return type
2023-10-13Format all the let chains in compilerMichael Goulet-1/+5
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+2
2023-10-05Add a note to duplicate diagnosticsAlex Macleod-3/+8
2023-09-22Allow `-Z treat-err-as-bug=0`Lieselotte-7/+5
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-09-08Auto merge of #115418 - Zoxc:freeze-source, r=oli-obkbors-1/+1
Use `Freeze` for `SourceFile` This uses the `Freeze` type in `SourceFile` to let accessing `external_src` and `lines` be lock-free. Behavior of `add_external_src` is changed to set `ExternalSourceKind::AbsentErr` on a hash mismatch which matches the documentation. `ExternalSourceKind::Unneeded` was removed as it's unused. Based on https://github.com/rust-lang/rust/pull/115401.
2023-09-07Use `Freeze` for `SourceFile.external_src`John Kåre Alsaker-1/+1
2023-09-07Implement refinement lint for RPITITMichael Goulet-3/+3
2023-09-04Add OnceHelp lint level (same as OnceNote, except for help)Urgau-3/+5
2023-09-01Add comment so pub items are not removedChristian Legnitto-0/+2
As suggested in https://github.com/rust-lang/rust/pull/115393, add a comment so someone doesn't clean these up.
2023-08-30Make `termcolor` types public in `rustc_errors`Christian Legnitto-1/+1
After https://github.com/rust-lang/rust/pull/114104, `rust-gpu` is unable to create a custom `Emitter` as the bounds have changed to include `WriteColor`. I was able to work around this by adding `termcolor` as a direct dependency, but I believe this should be exposed as part of `rustc_errors` proper. See https://github.com/rust-lang/rust/pull/102992 for why `rust-gpu` needs to create a custom emitter.
2023-08-30Use conditional synchronization for LockJohn Kåre Alsaker-5/+5
2023-08-24Add comment to the push_trailing functionallaboutevemirolive-2/+16
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-18fixKyle Lin-1/+1
2023-08-18lint linksKyle Lin-3/+3
2023-08-04Auto merge of #114104 - oli-obk:syn2, r=compiler-errorsbors-12/+1
Lots of tiny incremental simplifications of `EmitterWriter` internals ignore the first commit, it's https://github.com/rust-lang/rust/pull/114088 squashed and rebased, but it's needed to use to use `derive_setters`, as they need a newer `syn` version. Then this PR starts out with removing many arguments that are almost always defaulted to `None` or `false` and replace them with builder methods that can set these fields in the few cases that want to set them. After that it's one commit after the other that removes or merges things until everything becomes some very simple trait objects
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-07-31Replace the many arguments of `EmitterWriter::stderr` with builder methodsOli Scherer-12/+1
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-5/+3
2023-07-29Auto merge of #113099 - bvanjoi:fix-112713-2, r=petrochenkovbors-0/+16
fix(resolve): update the ambiguity glob binding as warning recursively Fixes #47525 Fixes #56593, but `issue-56593-2.rs` is not fixed to ensure backward compatibility. Fixes #98467 Fixes #105235 Fixes #112713 This PR had added a field called `warn_ambiguous` in `NameBinding` which is only for back compatibly reason and used for lint. More details: https://github.com/rust-lang/rust/pull/112743 r? `@petrochenkov`
2023-07-28Rollup merge of #114128 - estebank:delayed-span-bug-dump, r=davidtwcoMatthias Krüger-2/+2
When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist Fix #113881.
2023-07-29fix(resolve): update the ambiguity glob binding as warning recursivelybohan-0/+16
2023-07-27When flushing delayed span bugs, write to the ICE dump file even if it ↵Esteban Küber-2/+2
doesn't exist Fix #113881.
2023-07-27Auto merge of #113281 - dayo05:master, r=davidtwcobors-14/+28
Implement diagnostic translation for rustc-errors This is my first PR to rustc yeah~ I'm going to implement diagnostic translation on rustc-errors crate. This PR is WIP, the reason of opening this as draft, I want to show my code to prevent the issue caused by misunderstanding and also I have few questions. Some error messages are processed by `pluralize!` macro which determines to use plural word or not. From now, I make two kinds of keys and combine with enum but I'm not sure is this best method to do it. Is there any prefered method to do this? => This resolved on conversation on PR. I'll remain to perform force-push until my first implementation looks good to me
2023-07-25Use a builder instead of boolean/option argumentsOli Scherer-24/+23