error[E0425]: cannot find value `c_token` in this scope
--> <json_internal macros>:98:22
|
1 | / ( @ array [ $ ( $ elems : expr , ) * ] ) => { vec ! [ $ ( $ elems , ) * ] } ;
2 | | ( @ array [ $ ( $ elems : expr ) , * ] ) => { vec ! [ $ ( $ elems ) , * ] } ;
3 | | ( @ array [ $ ( $ elems : expr , ) * ] null $ ( $ rest : tt ) * ) => {
4 | | json_internal ! (
... |
98 | | @ object object ( ) ( $ ( $ tt ) + ) ( $ ( $ tt ) + ) ) ; object } ) } ; (
| | ^ not found in this scope
99 | | $ other : expr ) => { $ crate :: to_value ( & $ other ) . unwrap ( ) } ;
| |_________________________________________________________________________- in this expansion of `json_internal!`
|
::: <json macros>:1:1
|
1 | ( $ ( $ json : tt ) + ) => { json_internal ! ( $ ( $ json ) + ) } ;
| -------------------------------------------------------------------
| | |
| | in this macro invocation
| in this expansion of `json!`
error[E0425]: cannot find value `err` in this scope
--> <println macros>:3:44
|
3 | ) => ( print ! ( concat ! ( $ fmt , "\n" ) , $ ( $ arg ) * ) ) ;
| ^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
1 | use arc_reactor::futures::future::err;
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0425`.
error: Could not compile `paysquare`.
To learn more, run the command again with --verbose.
I get this error whenever i use invoke a macro that captures external vairables, either by logging with println
or using serde_json
's json! macro. this used to work, now it simply doesn't.
nightly => rustc 1.27.0-nightly (7360d6dd6 2018-04-15)
Can you help reproduce this? When I tried it, the following seems to work with rustc 1.27.0-nightly (7360d6dd6 2018-04-15).
#[macro_use]
extern crate serde_json;
fn main() {
let v = 1;
println!("{}", json!({"k": v}));
}
1 Like
extern crate futures_await as futures;
#[macro_use] extern crate serde_json;
use futures::prelude::*;
#[async]
pub fn test() -> Result<Value, ()> {
let lk = "haha, i'm a str";
#[derive(Serialize, Deserialize)]
struct Payment {
usd: u32,
}
let Payment { usd } = Payment { usd: 76 };
let res = match await!(f_future()) {
Ok(a) => a,
Err(err) => panic!("{:?}", err)
};
println!("{}", lk);
println!("{:?}", &res);
let json = json!({
"usd": usd,
"res": res
});
Ok(json)
}
fn f_future() -> impl Future<Item = bool, Error = ()> {
arc_reactor::futures::future::ok(true)
}
try compiling with cargo rustc -- -Z external-macro-backtrace
, you should get:
error[E0425]: cannot find value `err` in this scope
--> <panic macros>:9:25
|
9 | & format_args ! ( $ fmt , $ ( $ arg ) + ) , & (
| ^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
1 | use arc_reactor::futures::future::err;
|
error[E0425]: cannot find value `lk` in this scope
--> <println macros>:3:44
|
3 | ) => ( print ! ( concat ! ( $ fmt , "\n" ) , $ ( $ arg ) * ) ) ;
| ^ not found in this scope
error[E0425]: cannot find value `res` in this scope
--> <println macros>:3:44
|
3 | ) => ( print ! ( concat ! ( $ fmt , "\n" ) , $ ( $ arg ) * ) ) ;
| ^ not found in this scope
error[E0425]: cannot find value `usd` in this scope
--> <json_internal macros>:98:22
|
1 | / ( @ array [ $ ( $ elems : expr , ) * ] ) => { vec ! [ $ ( $ elems , ) * ] } ;
2 | | ( @ array [ $ ( $ elems : expr ) , * ] ) => { vec ! [ $ ( $ elems ) , * ] } ;
3 | | ( @ array [ $ ( $ elems : expr , ) * ] null $ ( $ rest : tt ) * ) => {
4 | | json_internal ! (
... |
98 | | @ object object ( ) ( $ ( $ tt ) + ) ( $ ( $ tt ) + ) ) ; object } ) } ; (
| | ^ not found in this scope
99 | | $ other : expr ) => { $ crate :: to_value ( & $ other ) . unwrap ( ) } ;
| |_________________________________________________________________________- in this expansion of `json_internal!`
|
::: <json macros>:1:1
|
1 | ( $ ( $ json : tt ) + ) => { json_internal ! ( $ ( $ json ) + ) } ;
| -------------------------------------------------------------------
| | |
| | in this macro invocation
| in this expansion of `json!`
error[E0425]: cannot find value `res` in this scope
--> <json_internal macros>:98:22
|
1 | / ( @ array [ $ ( $ elems : expr , ) * ] ) => { vec ! [ $ ( $ elems , ) * ] } ;
2 | | ( @ array [ $ ( $ elems : expr ) , * ] ) => { vec ! [ $ ( $ elems ) , * ] } ;
3 | | ( @ array [ $ ( $ elems : expr , ) * ] null $ ( $ rest : tt ) * ) => {
4 | | json_internal ! (
... |
98 | | @ object object ( ) ( $ ( $ tt ) + ) ( $ ( $ tt ) + ) ) ; object } ) } ; (
| | ^ not found in this scope
99 | | $ other : expr ) => { $ crate :: to_value ( & $ other ) . unwrap ( ) } ;
| |_________________________________________________________________________- in this expansion of `json_internal!`
|
::: <json macros>:1:1
|
1 | ( $ ( $ json : tt ) + ) => { json_internal ! ( $ ( $ json ) + ) } ;
| -------------------------------------------------------------------
| | |
| | in this macro invocation
| in this expansion of `json!`
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0425`.
error: Could not compile `paysquare`.
To learn more, run the command again with --verbose.
I minimized this further and filed rust-lang/rust#50061 to follow up. Thanks!
1 Like