-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compile error for associated_to attribute
- Loading branch information
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
crates/swift-bridge-macro/tests/ui/invalid-associated-to-attribute.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//! # To Run | ||
//! cargo test -p swift-bridge-macro -- ui trybuild=invalid-associated-to-attribute.rs | ||
#[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); | ||
} | ||
} | ||
|
||
pub struct SomeType; | ||
|
||
impl SomeType { | ||
fn immutable_method(&self) { | ||
|
||
} | ||
fn mutable_method(&mut self) { | ||
|
||
} | ||
fn owned_method() { | ||
|
||
} | ||
} | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
crates/swift-bridge-macro/tests/ui/invalid-associated-to-attribute.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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); | ||
| ^^^^ |