Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jul 1, 2025

Err here clearly does not indicate an "error" of any sort, so the use of Result is confusing. Let's use a sum type that does not come with the baggage of Result.

@rustbot
Copy link
Collaborator

rustbot commented Jul 1, 2025

r? @saethlin

rustbot has assigned @saethlin.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 1, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@workingjubilee
Copy link
Member

r? @scottmcm

@rustbot rustbot assigned scottmcm and unassigned saethlin Jul 1, 2025
@@ -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:?}"),
Copy link
Member

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 :/

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants