-
Notifications
You must be signed in to change notification settings - Fork 13.5k
codegen_ssa: replace a Result by an Either #143291
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
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in compiler/rustc_codegen_ssa |
r? @scottmcm |
@@ -648,9 +649,9 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, Result<V, abi::Scalar>> { | |||
pub fn build(&self) -> OperandRef<'tcx, V> { | |||
let OperandRef { val, layout } = *self; | |||
|
|||
let unwrap = |r: Result<V, abi::Scalar>| match r { | |||
Ok(v) => v, | |||
Err(_) => bug!("OperandRef::build called while fields are missing {self:?}"), |
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.
I'd used an Err here because in build it is an error.
An Either
is fine too, so I don't mind doing this, but I'd really rather land #138759 that will conflict with this first, since it's approaching 4 months :/
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.
I was mostly looking at the big match in insert_field
, which looked like it was... finding errors and removing them? That doesn't look like a Result
.
Some actual comments explaining what happens here with that sum type would have helped a lot but, not understanding the code I can't add those unfortunately. Would be great if you could. :)
An Either is fine too, so I don't mind doing this, but I'd really rather land #138759 that will conflict with this first, since it's approaching 4 months :/
Sure, this can wait.
Err
here clearly does not indicate an "error" of any sort, so the use ofResult
is confusing. Let's use a sum type that does not come with the baggage ofResult
.