-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add BlockApi
trait.
#635
base: main
Are you sure you want to change the base?
Add BlockApi
trait.
#635
Conversation
Looks good to me, it duplicates a bit of code but I don't know another way that isn't a big rewrite, what do you think @raviqqe ? |
The alternative would be to duplicate the methods manually, but doing it this way allows us to have functions that accept both |
Thank you for the changes! I'm gonna take a look soon. |
melior/src/ir/block.rs
Outdated
} | ||
} | ||
|
||
impl<'c, 'v> BlockApi<'c, 'v> for Block<'c> { |
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.
Is this typing correct although blocks can be dangling? We don't need to append blocks to regions first to modify blocks in the current API.
Looking at the types and lifetimes of the implemented methods, you meant for 'v
to be the lifetime of Block
's themselves?
For example, currently the following test passes:
#[test]
fn static_argument() {
let context = create_test_context();
context.set_allow_unregistered_dialects(true);
let block = Block::new(&[(
IntegerType::new(&context, 64).into(),
Location::unknown(&context),
)]);
let _arg: BlockArgument<'_, 'static> = block.argument(0).unwrap();
}
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'm not sure, but it seems you've figured it out already.
Your way is probably better since you're binding the 'v
lifetime to Self
.
@edg-l @azteca1998 It doesn't have to be addressed here. But FYI, we should technically have |
1809a5e
to
c83aa2b
Compare
c83aa2b
to
ff388e5
Compare
Ah, sorry I somehow force pushed to your branch! |
@azteca1998 @edg-l Can you take a look at this? azteca1998#1 |
Update `BlockApi` implementation
No problem.
Merged. |
Solves #634 by moving the
Block
's API into a separate trait.The same principle can probably be applied also to
RegionRef
andOperationRef
.