-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Box in ValTreeKind::Branch(Box<[I::Const]>) changed to List
#152593
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2941,10 +2941,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |
|
|
||
| match pat.ctor() { | ||
| Constructor::Variant(variant_index) => { | ||
| let ValTreeKind::Branch(box [actual_variant_idx]) = *valtree else { | ||
| let ValTreeKind::Branch(branch) = *valtree else { | ||
| bug!("malformed valtree for an enum") | ||
| }; | ||
| let Some(actual_variant_idx) = branch.get(0) else { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we stop asserting that the len is |
||
| bug!("malformed valtree for an enum") | ||
| }; | ||
|
|
||
| let ValTreeKind::Leaf(actual_variant_idx) = *actual_variant_idx.to_value().valtree | ||
| else { | ||
| bug!("malformed valtree for an enum") | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ use rustc_type_ir_macros::{ | |||||
| GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic, | ||||||
| }; | ||||||
|
|
||||||
| use crate::inherent::*; | ||||||
| use crate::{self as ty, BoundVarIndexKind, Interner}; | ||||||
|
|
||||||
| /// Represents a constant in Rust. | ||||||
|
|
@@ -159,8 +160,7 @@ pub enum ValTreeKind<I: Interner> { | |||||
| /// the fields of the variant. | ||||||
| /// | ||||||
| /// ZST types are represented as an empty slice. | ||||||
| // FIXME(mgca): Use a `List` here instead of a boxed slice | ||||||
| Branch(Box<[I::Const]>), | ||||||
| Branch(I::Consts), | ||||||
| } | ||||||
|
|
||||||
| impl<I: Interner> ValTreeKind<I> { | ||||||
|
|
@@ -179,7 +179,7 @@ impl<I: Interner> ValTreeKind<I> { | |||||
| #[inline] | ||||||
| pub fn to_branch(&self) -> &[I::Const] { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| match self { | ||||||
| ValTreeKind::Branch(branch) => &**branch, | ||||||
| ValTreeKind::Branch(branch) => branch.as_slice(), | ||||||
| ValTreeKind::Leaf(..) => panic!("expected branch, got {:?}", self), | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -195,7 +195,7 @@ impl<I: Interner> ValTreeKind<I> { | |||||
| /// Attempts to convert to a `ValTreeKind::Branch` value. | ||||||
| pub fn try_to_branch(&self) -> Option<&[I::Const]> { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||||||
| match self { | ||||||
| ValTreeKind::Branch(branch) => Some(&**branch), | ||||||
| ValTreeKind::Branch(branch) => Some(branch.as_slice()), | ||||||
| ValTreeKind::Leaf(_) => None, | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -577,8 +577,9 @@ pub fn structurally_relate_consts<I: Interner, R: TypeRelation<I>>( | |||||||||||||||
| if branches_a.len() == branches_b.len() => | ||||||||||||||||
| { | ||||||||||||||||
| branches_a | ||||||||||||||||
| .into_iter() | ||||||||||||||||
| .zip(branches_b) | ||||||||||||||||
| .as_slice() | ||||||||||||||||
| .iter() | ||||||||||||||||
| .zip(branches_b.as_slice().iter()) | ||||||||||||||||
| .all(|(a, b)| relation.relate(*a, *b).is_ok()) | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
| _ => false, | ||||||||||||||||
|
|
||||||||||||||||
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.
Constsshould implementSliceLikeso we can just do.iter()here nowThere 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.
ConstsimplementsSliceLike, but.iter()on fields returns&Constand the following code works only for iterator overConst: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 do think the
as_sliceshould not be needed 🤔Though given that we're in
rustc_middlei guess this is the inherent impl forListor via deref?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.
still relevant, can you try removing the
as_slice?Uh oh!
There was an error while loading. Please reload this page.
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.
^ (get rid of
as_slice)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.
Ah, sorry, I have overlooked your original reply. It is fixed now.