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

Add UI test for invalid module items #124

Merged
merged 2 commits into from
Dec 15, 2022
Merged

Add UI test for invalid module items #124

merged 2 commits into from
Dec 15, 2022

Conversation

chinedufn
Copy link
Owner

@chinedufn chinedufn commented Dec 15, 2022

This commit introduces a compile time error for invalid module items.

For example, the following will now give a descriptive compile time
error:

#[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() {}
//   |     ^^^^^^^^^^^
//

This commit introduces a compile time error for invalid module items.

For example, the following will not 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.
@chinedufn chinedufn changed the title use ui test Add UI test for invalid module items Dec 15, 2022
@chinedufn chinedufn merged commit c2585ab into master Dec 15, 2022
chinedufn added a commit that referenced this pull request Dec 15, 2022
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.
@chinedufn chinedufn deleted the use-ui-test branch January 28, 2023 20:45
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

1 participant