I'm learning Rust and am trying to use cargo-expand on the default Hello, World program. From what I understand it's supposed to expand all the macros, but when I use it, it leaves in a macro that another macro generates.
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
fn main() {
{
::std::io::_print(format_args!("Hello, World\n"));
};
}
From what I understood, the output of cargo expand
should expand everything, so I'm a little confused. I tried googling and searching for an answer but everything I read showed no macros within the output.
Is this right or not?
If you mean the format_args!
, I'll quote dtolnay (the cargo-expand maintainer) from this issue:
This is working correctly.
format_args
does not expand to Rust code. (In the past it used to.)
Cargo-expand does recursively expand macros. Just in this case it can't.