extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
184 stars 27 forks source link

Cannot use #[extendr(...)] in rust_source() #128

Closed yutannihilation closed 3 years ago

yutannihilation commented 3 years ago

As https://github.com/extendr/extendr/pull/222 adds an option to #[extendr()] macro, I wonder how the options should be supported on rextendr's side and then wanted to try the code below, but it fails with a cryptic error. I'll take a look later, but please let me know if I'm missing something very obvious...

code <- r"(
#[extendr(use_try_from = true)]
fn test_i32(val: i32) -> i32 {
    val
}
)"

rextendr::rust_source(code = code, patch.crates_io = list(`extendr-api` = list(git = "https://github.com/extendr/extendr")))
#> ℹ build directory: '/tmp/RtmphmzVDp/file14a9598749e1'
#> Error: Problem with `mutate()` input `..1`.
#> ℹ `..1 = .data$name`.
#> x Column `name` not found in `.data`

Created on 2021-07-17 by the reprex package (v2.0.0)

yutannihilation commented 3 years ago

We need to update this regex, at least.

https://github.com/extendr/rextendr/blob/95999abbf88645ba67af738ea9bf8bae139c3c9a/R/find_exports.R#L19-L22