This is a first step in the migration to {rlang} >= 1.0.0 process. One of the major changes was the introduction of call parameter in rlang::abort(), which controls the displayed error message (namely, the function name, from where an error originates). With the current implementation, all our errors originate in ui_throw(), which is confusing.
I have modified ui_throw() to deal with call and fixed its usage in rust_source(), which is the main source of thrown errors in our package (rust compilation errors).
Before
``` r
rextendr::rust_function("fn fun(x : i33, y : i34) -> i35 {}")
#> i build directory: 'C:/Users/[redacted]/AppData/Local/Temp/Rtmpmk16HM/filed4c2b0986b'
#> Error in `ui_throw()`:
#> ! Rust code could not be compiled successfully. Aborting.
#> x error[E0412]: cannot find type `i33` in this scope
#> --> src\lib.rs:3:12
#> |
#> 3 | fn fun(x : i33, y : i34) -> i35 {}
#> | ^^^ help: a builtin type with a similar name exists: `i32`
#> x error[E0412]: cannot find type `i34` in this scope
#> --> src\lib.rs:3:21
#> |
#> 3 | fn fun(x : i33, y : i34) -> i35 {}
#> | ^^^ help: a builtin type with a similar name exists: `i32`
#> x error[E0412]: cannot find type `i35` in this scope
#> --> src\lib.rs:3:29
#> |
#> 3 | fn fun(x : i33, y : i34) -> i35 {}
#> | ^^^ help: a builtin type with a similar name exists: `i32`
#> x error: aborting due to 3 previous errors
```
Created on 2022-02-09 by the [reprex package](https://reprex.tidyverse.org) (v2.0.1)After
``` r
rextendr::rust_function("fn fun(x : i33, y : i34) -> i35 {}")
#> i build directory: 'C:/Users/[redacted]/AppData/Local/Temp/RtmpYJU4wN/file77244b0d2091'
#> Error in `invoke_cargo()`:
#> ! Rust code could not be compiled successfully. Aborting.
#> x error[E0412]: cannot find type `i33` in this scope
#> --> src\lib.rs:3:12
#> |
#> 3 | fn fun(x : i33, y : i34) -> i35 {}
#> | ^^^ help: a builtin type with a similar name exists: `i32`
#> x error[E0412]: cannot find type `i34` in this scope
#> --> src\lib.rs:3:21
#> |
#> 3 | fn fun(x : i33, y : i34) -> i35 {}
#> | ^^^ help: a builtin type with a similar name exists: `i32`
#> x error[E0412]: cannot find type `i35` in this scope
#> --> src\lib.rs:3:29
#> |
#> 3 | fn fun(x : i33, y : i34) -> i35 {}
#> | ^^^ help: a builtin type with a similar name exists: `i32`
#> x error: aborting due to 3 previous errors
```
Created on 2022-02-09 by the [reprex package](https://reprex.tidyverse.org) (v2.0.1)
This will be revisited once {cli} usage is reworked.
This is a first step in the migration to
{rlang} >= 1.0.0
process. One of the major changes was the introduction ofcall
parameter inrlang::abort()
, which controls the displayed error message (namely, the function name, from where an error originates). With the current implementation, all our errors originate inui_throw()
, which is confusing.I have modified
ui_throw()
to deal withcall
and fixed its usage inrust_source()
, which is the main source of thrown errors in our package (rust compilation errors).Before
``` r rextendr::rust_function("fn fun(x : i33, y : i34) -> i35 {}") #> i build directory: 'C:/Users/[redacted]/AppData/Local/Temp/Rtmpmk16HM/filed4c2b0986b' #> Error in `ui_throw()`: #> ! Rust code could not be compiled successfully. Aborting. #> x error[E0412]: cannot find type `i33` in this scope #> --> src\lib.rs:3:12 #> | #> 3 | fn fun(x : i33, y : i34) -> i35 {} #> | ^^^ help: a builtin type with a similar name exists: `i32` #> x error[E0412]: cannot find type `i34` in this scope #> --> src\lib.rs:3:21 #> | #> 3 | fn fun(x : i33, y : i34) -> i35 {} #> | ^^^ help: a builtin type with a similar name exists: `i32` #> x error[E0412]: cannot find type `i35` in this scope #> --> src\lib.rs:3:29 #> | #> 3 | fn fun(x : i33, y : i34) -> i35 {} #> | ^^^ help: a builtin type with a similar name exists: `i32` #> x error: aborting due to 3 previous errors ``` Created on 2022-02-09 by the [reprex package](https://reprex.tidyverse.org) (v2.0.1)After
``` r rextendr::rust_function("fn fun(x : i33, y : i34) -> i35 {}") #> i build directory: 'C:/Users/[redacted]/AppData/Local/Temp/RtmpYJU4wN/file77244b0d2091' #> Error in `invoke_cargo()`: #> ! Rust code could not be compiled successfully. Aborting. #> x error[E0412]: cannot find type `i33` in this scope #> --> src\lib.rs:3:12 #> | #> 3 | fn fun(x : i33, y : i34) -> i35 {} #> | ^^^ help: a builtin type with a similar name exists: `i32` #> x error[E0412]: cannot find type `i34` in this scope #> --> src\lib.rs:3:21 #> | #> 3 | fn fun(x : i33, y : i34) -> i35 {} #> | ^^^ help: a builtin type with a similar name exists: `i32` #> x error[E0412]: cannot find type `i35` in this scope #> --> src\lib.rs:3:29 #> | #> 3 | fn fun(x : i33, y : i34) -> i35 {} #> | ^^^ help: a builtin type with a similar name exists: `i32` #> x error: aborting due to 3 previous errors ``` Created on 2022-02-09 by the [reprex package](https://reprex.tidyverse.org) (v2.0.1)This will be revisited once
{cli}
usage is reworked.