Block #[cfg] attributes on inner constants
This commit is contained in:
31
codegen/ui_tests/module_cfg_const.rs
Normal file
31
codegen/ui_tests/module_cfg_const.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
use rhai::FLOAT;
|
||||
|
||||
#[cfg(feature = "foo")]
|
||||
pub const MAGIC: FLOAT = 42.0 as FLOAT;
|
||||
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/module_cfg_const.stderr
Normal file
11
codegen/ui_tests/module_cfg_const.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: cfg attributes not allowed on this item
|
||||
--> $DIR/module_cfg_const.rs:13:5
|
||||
|
|
||||
13 | #[cfg(feature = "foo")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/module_cfg_const.rs:26:8
|
||||
|
|
||||
26 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
Reference in New Issue
Block a user