-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fix early exiting when ExprUseVisitor
meets unresolved type var
#87879
Conversation
I think we should add a test where the match discriminant also needs to be borrowed mutably so we can confirm that this fix actually resolves the root issue. For instance, something like this also causes an ICE on nightly: #![feature(try_reserve)]
#![feature(capture_disjoint_fields)]
fn main() {
let mut schema_all : (Vec<String>, Vec<String>) = (vec![], vec![]);
let _c = || {
match schema_all.0.try_reserve(1) as Result<(), _> {
Ok(()) => (),
Err(_) => (),
}
};
}
|
This comment has been minimized.
This comment has been minimized.
The original use case of |
ExprUseVisitor
meets unresolved type varExprUseVisitor
meets unresolved type var
@bors try @rust-timer +queue |
Insufficient permissions to issue commands to rust-timer. |
@ldm0: 🔑 Insufficient privileges: not in try users |
I believe we ignore the error returned by I agree that we can definitely just not return early for now, although I am not sure if we should close the issue; I think we should still figure out why I think there is a simpler way to do this than your current change; we should just need to replace the |
@roxelo Thanks for reviewing!
Hm.... the field checking is skipped I think. Why it's still "correct" in this situation? 🤔
When a typeck error is uncovered, rustc should pessimistically assume borrow is needed(correct me if I'm wrong). BTW, I changed the signature of the closure given to |
Oh right, you can ignore my earlier comment.
As a workaround for this issue I guess yes, but we really want it to be deterministic since it wasn't expected that
I am personally not a fan of using an error in that part of the code as it's not an error for the discriminant to need to be read/borrowed... |
…pe var. Add regression test for issue-87814 Set needs_to_read to true when typeck errors.
Closing in favor of #88266 |
resolve type variables after checking casts r? `@jackh726` Fixes rust-lang#87814 Fixes rust-lang#88118 Supercedes rust-lang#87879 (cc `@ldm0)`
Closes #87814
ExprUseVisitor::walk_expr ======> hir::ExprKind::Match => MemCategorizationContext::cat_pattern ======> self.cat_pattern_ ======> PatKind::TupleStruct => self.pat_ty_adjusted ======> self.pat_ty_unadjusted ======> self.node_ty ======> self.resolve_type_vars_or_error
With
as Result<(), _>
presents, the argumentty
ofresolve_type_vars_or_error
when checkingErr(_) => ..
arm is a type var rather than a unit. And the error bubbles through all the functions listed above. Which means thewalk_arm()
call in theExprUseVisitor::walk_expr
is skipped.I think
walk_arm
is a process not mangled with thecat_pattern
. So working around this problem by swallowing the type var resolving error.r? @roxelo @nikomatsakis