Skip to content
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

Use const fn for op declaration #685

Merged
merged 3 commits into from
Apr 6, 2024
Merged

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Apr 6, 2024

Switch op declaration from a impl #name to a const fn #name.
This form for declaration can be used inside impl blocks.

struct Foo {}

impl Foo {
    #[op2(fast)]
    pub fn bar(#[state] state: &mut OpState) {}
}

// const DECL: OpDecl = Foo::bar();

Based on Matt's suggestion in #682

Playground link

This patch wraps const around the existing
impl codegen to unblock work on op2++

Switch op declaration from a `impl #name` to a `const fn #name`.

Based on Matt's suggestion in denoland#682

[Playground link](https://play.rust-lang.org/?version=stable&mode=release&edition=2021&gist=2d7152d548b4a466779c401551b21b05)

This patch wraps `const` around the existing
`impl` codegen to unblock work on op2++
@littledivy littledivy requested a review from mmastrac April 6, 2024 06:58
@codecov-commenter
Copy link

codecov-commenter commented Apr 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.26%. Comparing base (742afe5) to head (ed3a7f0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #685   +/-   ##
=======================================
  Coverage   81.26%   81.26%           
=======================================
  Files          95       95           
  Lines       24294    24295    +1     
=======================================
+ Hits        19743    19744    +1     
  Misses       4551     4551           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ops/op2/mod.rs Outdated
#[inline(always)]
#(#attrs)*
#op_fn
#[deprecated(note = "Use the const op::DECL instead")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be OK to remove this as part of this work

Copy link
Contributor

@mmastrac mmastrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, optional if you'd like to remove the deprecated stuff

@littledivy littledivy merged commit 5245f5d into denoland:main Apr 6, 2024
17 checks passed
@littledivy littledivy deleted the op2++_part_1 branch April 6, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants