-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"expected none or () delimited group, but found different token tree (note: do not use the macros from bunt-macros
directly, but only through bunt
)"
#20
Comments
I reproduced the problem locally. As to why this happens: good question! I don't know. I don't really know a lot about rust-analyzer and haven't used its proc macro expansion features yet. I would assume it's still not "finished" and that this is just a bug. So what's happening with So I'm pretty sure this is not a bug or problem in Please excuse me pinging you directly here, but maybe @jonas-schievink could help us out here? |
This certainly seems like a bug in rust-analyzer, but I'm not immediately sure what's causing it. |
It also happens when calling the procedural macro directly: bunt_macros::writeln!(
(bunt::termcolor::StandardStream::stdout(bunt::termcolor::ColorChoice::Auto))
["asdasd"]
); |
A closer manual invocation would be: bunt_macros::writeln!(
(bunt::termcolor::StandardStream::stdout(bunt::termcolor::ColorChoice::Auto))
[("hello")]
); It's a bit strange, but the
Maybe rust-analyzer does not add this "dummy group"? I think the behavior changed recently: rust-lang/rust#73084 But I guess I could also change |
Why is there an additional |
I managed to get a fairly minimal example to reproduce this problem. You can see it on this branch. We have three crates:
use proc_macro::TokenStream;
#[proc_macro]
pub fn writeln(input: TokenStream) -> TokenStream {
panic!("{:#?}", input);
}
pub extern crate bunt_macros;
#[macro_export]
macro_rules! foo {
($target:expr) => {
$crate::bunt_macros::writeln!($target)
};
}
fn main() {
bunt::foo!(peter);
} If you
However, if I just save
RA seems to not add this "dummy group" when evaluating the decl macro. But the most interesting part: if I rename @jonas-schievink Just to be clear, I don't expect you to help out here. Also, if I should just open an issue at the RA repo, let me know! |
This might just be because we don't reload proc. macros. Thanks for finding that reproduction! It would be great if you could open a rust-analyzer issue with that. |
Ouch. I regularly restarted RA while building the minimal example, but of course I forgot to restart it after renaming that. So yeah, you seem to be right. Once RA is reloaded, I see the same behavior for I created the RA issue. |
I checked the parsing code again and while some of the |
@LukasKalbertodt: Okay, thank you for investigating this. It looks like I should have reported this directly to RA. |
Hi,
When macro expansion is activated in
rust-analyser
inVSCode
, I get the following error, every time I usebunt::println!
:Is this somehow fixable?
Macro expansion is useful for completion of types that are created via proc macros (e.g.
typed_builder
), but now my code is littered with error messages that the compiler itself doesn't report as errors.The text was updated successfully, but these errors were encountered: