-
Notifications
You must be signed in to change notification settings - Fork 40
Support tuple in mir fn body #205
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: main
Are you sure you want to change the base?
Conversation
| // FIXME: we only support const in value expression of tuple for now, we can add support | ||
| // more in future. | ||
| let Constant(_) = value_expression else { | ||
| bail!("Only Constant is supported in ValueExpression::Struct for now.") |
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.
| bail!("Only Constant is supported in ValueExpression::Struct for now.") | |
| bail!("Only Constant is supported in ValueExpression::Tuple for now.") |
| let Some(adt_id) = ty.get_adt_id() else { | ||
| bail!("The local used for field projection is not adt.") | ||
| }; | ||
|
|
||
| let ( | ||
| _, | ||
| AdtDeclBoundData { | ||
| where_clause: _, | ||
| variants, | ||
| }, | ||
| ) = self.decls.adt_decl(&adt_id).binder.open(); | ||
| let AdtDeclVariant { name, fields } = variants.last().unwrap(); | ||
|
|
||
| if *name != VariantId::for_struct() { | ||
| bail!("The local used for field projection must be struct.") | ||
| if !ty.is_tuple() && !ty.is_adt() { | ||
| bail!("The local used for field projection must be ADT or Tuple") | ||
| } | ||
|
|
||
| // Check if the index is valid for the tuple. |
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.
This is wrong, While tuple (i32, u32)'s parameter is [i32, u32],
struct Foo<T> {
value: T
}struct Foo's parameter is T.
But I don't like how we need to go through self.decls to get the struct field information.
No description provided.