export_fn: add return_raw attribute
This commit is contained in:
@@ -6,7 +6,7 @@ struct Point {
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_fn(unknown = true)]
|
||||
#[export_fn(unknown = "thing")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
error: unknown attribute 'unknown'
|
||||
--> $DIR/export_fn_bad_attr.rs:9:13
|
||||
|
|
||||
9 | #[export_fn(unknown = true)]
|
||||
9 | #[export_fn(unknown = "thing")]
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0425]: cannot find function `test_fn` in this scope
|
||||
|
@@ -1,4 +1,4 @@
|
||||
error: expecting string literal value
|
||||
error: expecting string literal
|
||||
--> $DIR/export_fn_bad_value.rs:9:20
|
||||
|
|
||||
9 | #[export_fn(name = true)]
|
||||
|
24
codegen/ui_tests/export_fn_extra_value.rs
Normal file
24
codegen/ui_tests/export_fn_extra_value.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_fn(return_raw = "yes")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/export_fn_extra_value.stderr
Normal file
11
codegen/ui_tests/export_fn_extra_value.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: extraneous value
|
||||
--> $DIR/export_fn_extra_value.rs:9:26
|
||||
|
|
||||
9 | #[export_fn(return_raw = "yes")]
|
||||
| ^^^^^
|
||||
|
||||
error[E0425]: cannot find function `test_fn` in this scope
|
||||
--> $DIR/export_fn_extra_value.rs:19:8
|
||||
|
|
||||
19 | if test_fn(n) {
|
||||
| ^^^^^^^ not found in this scope
|
@@ -1,4 +1,4 @@
|
||||
error: expected assignment expression
|
||||
error: expecting identifier
|
||||
--> $DIR/export_fn_junk_arg.rs:9:13
|
||||
|
|
||||
9 | #[export_fn("wheeeee")]
|
||||
|
24
codegen/ui_tests/export_fn_missing_value.rs
Normal file
24
codegen/ui_tests/export_fn_missing_value.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_fn(name)]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/export_fn_missing_value.stderr
Normal file
11
codegen/ui_tests/export_fn_missing_value.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: requires value
|
||||
--> $DIR/export_fn_missing_value.rs:9:13
|
||||
|
|
||||
9 | #[export_fn(name)]
|
||||
| ^^^^
|
||||
|
||||
error[E0425]: cannot find function `test_fn` in this scope
|
||||
--> $DIR/export_fn_missing_value.rs:19:8
|
||||
|
|
||||
19 | if test_fn(n) {
|
||||
| ^^^^^^^ not found in this scope
|
24
codegen/ui_tests/export_fn_path_attr.rs
Normal file
24
codegen/ui_tests/export_fn_path_attr.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_fn(rhai::name = "thing")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/export_fn_path_attr.stderr
Normal file
11
codegen/ui_tests/export_fn_path_attr.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: expecting attribute name
|
||||
--> $DIR/export_fn_path_attr.rs:9:13
|
||||
|
|
||||
9 | #[export_fn(rhai::name = "thing")]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error[E0425]: cannot find function `test_fn` in this scope
|
||||
--> $DIR/export_fn_path_attr.rs:19:8
|
||||
|
|
||||
19 | if test_fn(n) {
|
||||
| ^^^^^^^ not found in this scope
|
Reference in New Issue
Block a user