Repository navigation
Codegen backend handles compare binops for the unit type #63551
Copy link
Copy link
Closed
Labels
A-codegenArea: Code generationArea: Code generationC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
rust/src/librustc_codegen_ssa/mir/rvalue.rs
Lines 586 to 592 in c43d03a
| mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt | | |
| mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_unit { | |
| bx.cx().const_bool(match op { | |
| mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt => false, | |
| mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => true, | |
| _ => unreachable!() | |
| }) |
libcore however doesn't use those for the implementations for PartialEq and PartialOrd for the unit type.
Lines 933 to 939 in c43d03a
| #[stable(feature = "rust1", since = "1.0.0")] | |
| impl PartialEq for () { | |
| #[inline] | |
| fn eq(&self, _other: &()) -> bool { true } | |
| #[inline] | |
| fn ne(&self, _other: &()) -> bool { false } | |
| } |
Lines 980 to 985 in c43d03a
| impl PartialOrd for () { | |
| #[inline] | |
| fn partial_cmp(&self, _: &()) -> Option<Ordering> { | |
| Some(Equal) | |
| } | |
| } |
This means that the special case in cg_ssa can be removed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
punitkoura commentedon Aug 14, 2019
Hi @bjorn3 @Centril, I'd like to work on this. Would be a good initial contribution to Rust :)
punitkoura commentedon Aug 14, 2019
I'm really new to the code base, though. Could you clarify what the
cg_ssameans above?jonas-schievink commentedon Aug 14, 2019
That's
librustc_codegen_ssa, a part of the code generation code in rustc. The code in the first snippet is located there.punitkoura commentedon Aug 15, 2019
Thanks for clarifying that! I'll go through the code and post any questions here.
TheOregonTrail commentedon Aug 25, 2019
Would love to help but don't know where to start. If mentoring is still possible please ping me or send me in the right direction somehow 👍 . @bjorn3 @Centril
TheOregonTrail commentedon Aug 25, 2019
or maybe @jonas-schievink if your up to the task :)
jonas-schievink commentedon Aug 25, 2019
@luigisHat I think you just need to look at
src/librustc_codegen_ssa/mir/rvalue.rsand remove the check foris_unitthat was mentioned. You can check https://rust-lang.github.io/rustc-guide/ for an overview of the compiler and instruction on how to build it and run tests.TheOregonTrail commentedon Aug 25, 2019
@jonas-schievink Thanks seems to be a little simpler then I thought once I dug into the docs. Will do hope your having a good one 👍 .
Auto merge of #63906 - luigishat:cmp_fix, r=bjorn3
Rollup merge of rust-lang#65605 - bjorn3:fix_63906, r=eddyb
Rollup merge of rust-lang#65605 - bjorn3:fix_63906, r=eddyb