Skip to content

improve use of ErrorGuaranteed #103874

Closed
Closed
@lcnr

Description

@lcnr

there are multiple small things to improve ErrorGuaranteed:

  • remove https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.DelaySpanBugEmitted.html and always use ErrorGuaranteed directly.
  • add a way to create a ty_error and const_error by using an existing ErrorGuaranteed instead of using another delay_span_bug.
  • change uses of references_error which use delay_span_bug right after to instead use TypeVisitable::error_reported() and not emit a span_bug.
  • in TypeVisitable::error_reported(), instead of using ErrorGuaranteed::unchecked_claim_error_was_emitted(), use the tls tcx to check that tcx.sess.has_errors() is true (maybe in a #[cold] nested function for perf).
  • change error_reported to use Result<(), ErrorGuaranteed> instead of an option
  • consider merging error_reported and references_error so that there's only 1 function, using .is_ok() in the current uses of references_error. Not sure about this point, might not make stuff clearer and I can't think of a good name.

Metadata

Metadata

Assignees

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions