Closed olafes closed 23 minutes ago
@rustbot label T-compiler I-ICE A-diagnostics WG-compiler-parallel
yea, the reason this exists is that it wants to detect when queries invoked by the current InferCtxt cause errors. The way to fix this is to make more queries return Result<CurrentOutput, ErrorGuaranteed>
or taint their output in case the output supports that.
Next steps include some data gathering: remove this check and look at the failing ui tests with -Ztreat-err-as-bug
to see which queries are reporting errors, but not tainting their result.
Emitting diagnostics in one thread taints every infcx out there, but other threads don't expect their infcx to become tainted if they themselves aren't emitting anything. This leads to skipped diagnostics, early bailing out of queries that could've run to completion or painful to debug ICEs. For example, take #120601: snippet below run with
-Zthreads=3 --edition=2021
works, but crashes if you uncomment the last function.In parallel compiler, code that does different things depending on the result of
InferCtxt::tainted_by_errors()
can introduce spurious failures or even replace previously resolvedTy
's withTy::new_error()
: https://github.com/rust-lang/rust/blob/f9515fdd5aa132e27d9b580a35b27f4b453251c1/compiler/rustc_borrowck/src/nll.rs#L202 inregioncx.infer_opaque_types
: https://github.com/rust-lang/rust/blob/f9515fdd5aa132e27d9b580a35b27f4b453251c1/compiler/rustc_borrowck/src/region_infer/opaque_types.rs#L133-L134 https://github.com/rust-lang/rust/blob/f9515fdd5aa132e27d9b580a35b27f4b453251c1/compiler/rustc_borrowck/src/region_infer/opaque_types.rs#L278-L285 relevant part ofInferCtxt
: https://github.com/rust-lang/rust/blob/f9515fdd5aa132e27d9b580a35b27f4b453251c1/compiler/rustc_infer/src/infer/mod.rs#L1219-L1239