hir_ty_lowering: fix anon const type recovery#158874
Conversation
|
HIR ty lowering was modified cc @fmease |
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
0ce9ac1 to
2b086ad
Compare
This comment has been minimized.
This comment has been minimized.
2b086ad to
7eb6962
Compare
|
@fmease i pushed a much narrower version. i dropped the type-relative recovery path completely, so there is no separate iat/inherent assoc selection anymore. i also removed the generic-arg lowering helper from generics.rs. the remaining type_of code only accepts the exact simple shape from the repro: one resolved segment, one explicit const arg, one own const param, no parent generics, no self, no inferred args, no constraints, no late-bound regions. imo this is aligned with the review feedback while still fixing the bug. there is still a tiny guard in type_of to make sure the anon const maps to that one const param, but idk how to remove even that without either reusing an existing lowering hook or changing the shape of the fix more deeply. ltm if you want zero matching in type_of. in that case i think the next step is finding a proper existing hook, or maybe backing out of this query-side recovery approach. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
fixes #158818
with -zthreads=0, an anon const in a const generic arg could get its type_of queried before generic arg lowering had fed the expected type. that left an error type in the query cache, then the later feed tried to write u32 over it.
imo the safest fix is to recover the expected type only for the shapes we can prove here: normal resolved path args and inherent type-relative fn paths like s::f::<...>. malformed generic arg lists still bail out to the old path, which matters because idk that we want type_of doing diagnostic work here.
added ui coverage for the original repro and the adjacent inherent path case. ltm if you want this broader, but i kept it tight on purpose since this area is easy to overreach in.