-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI test for invalid module items (#124)
This commit introduces a compile time error for invalid module items. For example, the following will now give a descriptive compile time error: ```rust #[swift_bridge::bridge] mod ffi { use std; fn foo() {} } // error: Only `extern` blocks, structs and enums are supported. // --> tests/ui/invalid-module-item.rs:6:5 // | // 3 | use std; // | ^^^^^^^^ // // error: Only `extern` blocks, structs and enums are supported. // --> tests/ui/invalid-module-item.rs:7:5 // | // 4 | fn foo() {} // | ^^^^^^^^^^^ // ``` Before this commit we would simply panic with an unhelpful message.
- Loading branch information
Showing
9 changed files
with
72 additions
and
40 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//! # To Run | ||
//! cargo test -p swift-bridge-macro -- ui trybuild=invalid-module-item.rs | ||
|
||
#[swift_bridge::bridge] | ||
mod ffi { | ||
use std; | ||
fn foo() {} | ||
} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
crates/swift-bridge-macro/tests/ui/invalid-module-item.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,11 @@ | ||
error: Only `extern` blocks, structs and enums are supported. | ||
--> tests/ui/invalid-module-item.rs:6:5 | ||
| | ||
6 | use std; | ||
| ^^^^^^^^ | ||
|
||
error: Only `extern` blocks, structs and enums are supported. | ||
--> tests/ui/invalid-module-item.rs:7:5 | ||
| | ||
7 | fn foo() {} | ||
| ^^^^^^^^^^^ |