Strictly proof not tainted by errors in TypeckResults
#126381
Labels
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
I get here from #125888.
For now there is a hack when calling
tcx.typeck()
:rust/compiler/rustc_hir_typeck/src/writeback.rs
Lines 125 to 130 in 76c7382
so that in returned
TypeckResults
, thetainted_by_errors
may beNone
even though there is actually some errors. And this could cause many ICEs, because some functions trust that there is no type errors, and whenever it encounters an error, it won't throw an error report and just panic (#125888 is an example).In this
tainted_by_errors
function, I try to change the condition toif self.dcx().err_count_excluding_lint_errs() > 0
, then return theErrorGuaranteed
, and find that it could resolve 62 ICEs.Resolved ICE list
rust/compiler/rustc_infer/src/infer/mod.rs
Lines 1152 to 1172 in f6b4b71
But it will also break many ui tests, because as the hack said, it will affect diagnostic spans pretty negatively. So I think a proper way to resolve that is return a new defined enum rather than
Option
, such asrust/compiler/rustc_middle/src/ty/typeck_results.rs
Lines 161 to 163 in f6b4b71
So that we can choose to either early return or do more diagnostics.
@rustbot label +I-ICE +T-compiler
The text was updated successfully, but these errors were encountered: