Closed JohnScience closed 2 years ago
I guess not all macros should be allowed in attributes. cc @petrochenkov (I think you were the one who implemented this feature?)
If the output of a macro is not a string literal, then it should produce an error. Not sure why the error is not produced in this case, someone (probably not me) needs to investigate.
When I run it I get:
error: unexpected expression: `{
let res =
::alloc::fmt::format(::core::fmt::Arguments::new_v1(&[":dep nalgebra_latex = { version = \"",
"\", features = [\"lin_sys\", \"evcxr\"] }"],
&[::core::fmt::ArgumentV1::new_display(&"1")]));
res
}`
--> foo.rs:1:9
|
1 | ... = format!(":dep nalgebra_latex = {{ version = \"{}\", features = [\"lin_sys\", \"evcxr\"] }}", env!("LOL"...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
FWIW, concat!
does work in #[doc]
attributes, so that is the preferred way to do this. I do agree this should be a compile error though.
I cannot reproduce it. So I guess it's worth closing.
In order to keep the doc test for evcxr fresh, I wanted to use
The code was in a plain library crate, not in a cell of Jupyter Notebook.
I expected to see a compile error at least when I would run
cargo doc
.Instead, it silently produced an empty line.
Meta
rustc --version --verbose
:Backtrace
```
```