-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
When encountering recursive requirements, elide some of the repeating output instead of having the following wall of text detailing every recursive step the compiler takes:
error[E0275]: overflow evaluating the requirement `Foo: std::marker::Sync`
--> src/main.rs:5:1
|
5 | / lazy_static! {
6 | | static ref CHAR: Foo = unimplemented!();
7 | | }
| |_^
|
= help: consider adding a `#![recursion_limit="128"]` attribute to your crate
= note: required because it appears within the type `std::marker::PhantomData<Foo>`
= note: required because it appears within the type `Bar`
= note: required because it appears within the type `std::marker::PhantomData<Bar>`
= note: required because it appears within the type `Foo`
= note: required because it appears within the type `std::marker::PhantomData<Foo>`
= note: required because it appears within the type `Bar`
= note: required because it appears within the type `std::marker::PhantomData<Bar>`
= note: required because it appears within the type `Foo`
= note: required because it appears within the type `std::marker::PhantomData<Foo>`
= note: required because it appears within the type `Bar`
8<8<8<8<8<8<8<
= note: required by `lazy_static::lazy::Lazy`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
The following code
rust/src/librustc/traits/error_reporting.rs
Lines 1285 to 1293 in a0dcecf
ObligationCauseCode::BuiltinDerivedObligation(ref data) => { | |
let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref); | |
err.note(&format!("required because it appears within the type `{}`", | |
parent_trait_ref.0.self_ty())); | |
let parent_predicate = parent_trait_ref.to_predicate(); | |
self.note_obligation_cause_code(err, | |
&parent_predicate, | |
&data.parent_code); | |
} |
needs to be modified to pass down a vector of the Ty
s note_obligation_cause_code
has encountered on previous runs. I feel it is reasonable to delay the note
s from being produced until the bottom has been reached, and prune the list then. The output should be something along the lines of
error[E0275]: overflow evaluating the requirement `Foo: std::marker::Sync`
--> src/main.rs:5:1
|
5 | / lazy_static! {
6 | | static ref CHAR: Foo = unimplemented!();
7 | | }
| |_^
|
= help: consider adding a `#![recursion_limit="128"]` attribute to your crate
= note: required because it appears within the type `std::marker::PhantomData<Foo>`
= note: required because it appears within the type `Bar`
= note: required because it appears within the type `std::marker::PhantomData<Bar>`
= note: required because it appears within the type `Foo`
= note: required because it appears within the type `std::marker::PhantomData<Foo>`
= note: ...and so on, these requirements repeat until reaching the recursion limit
= note: required by `lazy_static::lazy::Lazy`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
oberien
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.