-
Notifications
You must be signed in to change notification settings - Fork 65
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 compile time error when using associated_to
on a method
#179
Comments
chinedufn
added a commit
to chinedufn/OctoBase
that referenced
this issue
Feb 24, 2023
This commit removes the `#[swift_bridge(associated_to = ...)]` from the methods on the `Block`, `DynamicValue` and `Workspace` types. The `associated_to` attribute is meant to be used for static methods. It does nothing on instance methods. In the future, `swift-bridge` will turn this into a compile time error chinedufn/swift-bridge#179 .
associated_to
on a method
I'd like to work on this issue!! |
Go for it! |
NiwakaDev
added a commit
that referenced
this issue
Mar 29, 2023
This commit adds support for generating a compile error message when using `#[swift_bridge(associated_to = OpaqueRustType)]` on instance methods. Related to #179. ```rust #[swift_bridge::bridge] mod ffi { extern "Rust" { type SomeType; #[swift_bridge(associated_to = SomeType)] fn immutable_method(&self); #[swift_bridge(associated_to = SomeType)] fn mutable_method(&mut self); #[swift_bridge(associated_to = SomeType)] fn owned_method(self); } } ``` Will generate the following error: ``` error: The associated_to attribute is used for only an associated method. --> tests/ui/invalid-associated-to-attribute.rs:10:29 | 10 | fn immutable_method(&self); | ^^^^^ error: The associated_to attribute is used for only an associated method. --> tests/ui/invalid-associated-to-attribute.rs:13:27 | 13 | fn mutable_method(&mut self); | ^^^^^^^^^ error: The associated_to attribute is used for only an associated method. --> tests/ui/invalid-associated-to-attribute.rs:16:25 | 16 | fn owned_method(self); | ^^^^ ```
Closed via #206 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now, the following code compiles:
We do not want this to compile, since
associated_to
is meant for declaring static methods.We can make this more clear by:
Renaming
associated_to
tostatic_method_of
(and making sure to update our docs and tests to use the new name)Introducing a compile time error when using
static_method_of
on a method (any function that takesself
,&self
or&mut self
).We can keep
associated_to
around until version0.2.0
, just like how we handleinto_return_type
swift-bridge/crates/swift-bridge-ir/src/parse/parse_extern_mod/function_attributes.rs
Lines 97 to 100 in 91b4802
The text was updated successfully, but these errors were encountered: