Skip to content

Commit

Permalink
Minimal reproducible example for rust-lang/rust-analyzer#13360
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah committed Oct 6, 2022
1 parent ef5ab44 commit 5cc1e24
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
108 changes: 108 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "ra-bug"
version = "0.0.0"
edition = "2021"
license = "MIT OR Apache-2.0"

[features]
default = ["c_api"]
c_api = []

[dependencies]
safer-ffi = { version = "0.0.10", features = ["proc_macros"] }
30 changes: 30 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This one works
#[safer_ffi::derive_ReprC]
#[ReprC::opaque]
pub struct NotGated {
bar: String,
}

// This one doesn't work
#[cfg_attr(feature = "c_api", safer_ffi::derive_ReprC, ReprC::opaque)]
pub struct Gated {
bar: String,
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_foobar() {
let not_gated = NotGated {
bar: "yeet".to_string(),
};
let gated = Gated {
bar: "yeet".to_string(),
};
// Intellisense works for `not_gated` but fails on `gated`, go ahead and try it
assert_eq!(gated.bar, "yeet");
assert_eq!(not_gated.bar, "yeet");
}
}

0 comments on commit 5cc1e24

Please sign in to comment.