dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

`rsx` assumes `get_line_num` to be in scope

Open rMazeiks opened this issue 3 years ago • 3 comments

This doesn't compile:

use dioxus::prelude::rsx;

fn main() {
    rsx!(div {});
}

Error:

error: cannot find macro `get_line_num` in this scope
 --> docs/guide/examples/test.rs:4:5
  |
4 |     rsx!(div {});
  |     ^^^^^^^^^^^^
  |
  = note: consider importing this macro:
          dioxus::prelude::get_line_num
  = note: this error originates in the macro `rsx` (in Nightly builds, run with -Z macro-backtrace for more info)

Importing the full prelude fixes it. Still, would be nice for the macro to be accessed through the absolute path for rsx to be clean.

  • [x] I'm doing something else right now, but maybe I'll fix this later

rMazeiks avatar Jul 01 '22 11:07 rMazeiks

We could use absolute paths for most of the macro, and with rsx-prelude it should still work in tests. I think @jkelleyrtp had some thoughts on this? dioxus_elements also needs to be in scope, which could be provided by dioxus or by the renderer so it needs to manually imported.

ealmloff avatar Jul 01 '22 12:07 ealmloff

dioxus_elements also needs to be in scope

This makes sense, since it is essentially used in user code (every time you type div you mean dioxus_elements::div or something). get_line_num is only in the generated code, and I agree that using the absolute path would be better because:

  • get_line_num might not be in scope
  • get_line_num might refer to something else in the scope, leading to weird issues

see also

rMazeiks avatar Jul 01 '22 13:07 rMazeiks

I believe this is fixed? If it hasn't, it will be in #387

jkelleyrtp avatar Jul 07 '22 05:07 jkelleyrtp