fix: report const generic args of the wrong type - #23062
Conversation
There was a problem hiding this comment.
More diagnostics is always a good thing and I would not oppose it, but... are you sure this really fixes the root cause? We have no logic in MIR lowering to skip lowering if there are diagnostics (we should have though, but it's tricky to decide what errors should prevent lowering).
Also about this diagnostic specifically, rustc does emit a diagnostic here but I'm not personally sure we should: of course we should emit a diagnostic, but when the the mismatch actually occurs (i.e. when you're using a i64 as an array length or similar) and not when the constant is used (rustc emits at both).
You're right. The change now just plugs
I dropped the Thanks for the review! |
This pr fixes #22953 (supersedes #23045). The panic from the issue was already fixed upstream by removing borrowck in #23043 .
The root cause is that although the
ConstArgHasTypeconstraint is registered when indexing an array, the resultingSelectionError::ConstArgHasWrongTypewas dropped implicitly insolver_errors::from_fulfillment_error, so no diagnostic was produced.