-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix an ICE when a valtree failed to evaluate #118498
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
Conversation
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.
r=me after nit
let Some(c) = tcx.const_eval_resolve_for_typeck(param_env, unevaluated, span)? | ||
else { | ||
// This can happen when we run on ill-typed code. | ||
let e = tcx.sess.delay_span_bug( | ||
span.unwrap_or(DUMMY_SP), | ||
"`ty::Const::eval` called on a non-valtree-compatible type", | ||
); | ||
return Err(e.into()); | ||
}; | ||
Ok(c) |
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.
let Some(c) = tcx.const_eval_resolve_for_typeck(param_env, unevaluated, span)? | |
else { | |
// This can happen when we run on ill-typed code. | |
let e = tcx.sess.delay_span_bug( | |
span.unwrap_or(DUMMY_SP), | |
"`ty::Const::eval` called on a non-valtree-compatible type", | |
); | |
return Err(e.into()); | |
}; | |
Ok(c) | |
if let Some(c) = tcx.const_eval_resolve_for_typeck(param_env, unevaluated, span)? { | |
Ok(c) | |
} else { | |
// This can happen when we run on ill-typed code. | |
let e = tcx.sess.delay_span_bug( | |
span.unwrap_or(DUMMY_SP), | |
"`ty::Const::eval` called on a non-valtree-compatible type", | |
); | |
Err(e.into()) | |
} |
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.
Hm, IMO let else
expresses the flow better here. We handle the error, then we continue on the main path.
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.
hmm, I personally think that let-else is harder to read than an if let, so I only use it if I care about indentation 🤷 but given that it's a nit
@bors r+ rollup |
fix an ICE when a valtree failed to evaluate Fixes rust-lang#118285 r? `@lcnr`
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors r=lcnr |
☀️ Test successful - checks-actions |
Finished benchmarking commit (4eede98): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 672.207s -> 672.139s (-0.01%) |
Fixes #118285
r? @lcnr