-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect cycle errors hidden by opaques during monomorphization #115801
Conversation
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
🤦 @rustbot author |
75d4bc0
to
704ded3
Compare
704ded3
to
8fbd78c
Compare
// Rustdoc may attempt to normalize type alias types which are not | ||
// well-formed. Rustdoc also normalizes types that are just not | ||
// well-formed, since we don't do as much HIR analysis (checking | ||
// that impl vars are constrained by the signature, for example). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it do that for code that passes rustc? We are allowed to cause new errors in rustdoc if the code also wouldn't compile in rustc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a more graceful way than ICEing
ah, that's the issue. hmm.. does rustdoc unwrap something instead of reporting an error? or where is the ICE coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are allowed to cause new errors in rustdoc if the code also wouldn't compile in rustc
Well, the problem is that we need to do HIR analysis to make sure we don't have things like malformed and overlapping impl blocks too. These are probably not what we want to "fix" in rustdoc, since we compile rustdoc with all features enabled and stuff?
We also would need to check all type aliases as well-formed too, which we don't even do in rustc yet.
does rustdoc unwrap something instead of reporting an error? or where is the ICE coming from?
The ICE is coming from a failed projection in the QueryNormalizer
.
What happens is that we hit a cycle here:
rust/compiler/rustc_trait_selection/src/traits/project.rs
Lines 1193 to 1196 in 0692db1
Err(ProjectionCacheEntry::Recur) => { | |
debug!("recur cache"); | |
return Err(InProgress); | |
} |
Which means we treat the projection as ambiguous and emit a projection goal with an infer var on the RHS. That causes us to hit this assertion with debug assertions enabled:
debug_assert!(!erased.has_infer(), "{erased:?}"); |
Or just errors out with NoSolution
, which causes normalize_erasing_regions
to ICE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... yea that makes sense sadly.
Tho Rustdoc is moving towards doing wf checks in the future, so this will get cleaned up
@bors r+ |
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#113383 (style-guide: Add section on bugs, and resolving bugs) - rust-lang#115499 (rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member) - rust-lang#115801 (Detect cycle errors hidden by opaques during monomorphization) - rust-lang#115947 (Custom code classes in docs warning) - rust-lang#115957 (fix mismatched symbols) - rust-lang#115958 (explain mysterious addition in float minimum/maximum) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#115801 - compiler-errors:async-cycle-mono, r=oli-obk Detect cycle errors hidden by opaques during monomorphization Opaque types may reveal to projections, which themselves normalize to opaques. We don't currently normalize when checking that opaques are cyclical, and we may also not know that the opaque is cyclical until monomorphization (see `tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs`). Detect cycle errors in `normalize_projection_ty` and report a fatal overflow (in the old solver). Luckily, this is already detected as a fatal overflow in the new solver. Fixes rust-lang#112047
Opaque types may reveal to projections, which themselves normalize to opaques. We don't currently normalize when checking that opaques are cyclical, and we may also not know that the opaque is cyclical until monomorphization (see
tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs
).Detect cycle errors in
normalize_projection_ty
and report a fatal overflow (in the old solver). Luckily, this is already detected as a fatal overflow in the new solver.Fixes #112047