You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For proc-macros is quite common to put the generated code inside unnamed constants, to not pollute the surrounding namespace. However the name of types defined inside such constants cannot be parsed by syn::Type:
use std::any::type_name;use syn::Type;traitA{typeT;}structFoo;const _:() = {structBar;implAforFoo{typeT = Bar;}};fnmain(){
syn::parse_str::<Type>(type_name::<<FooasA>::T>()).unwrap();}
This panics with
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("expected identifier")', src/main.rs:6:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The value of type_name::<<Foo as A>::T>() is foo::_::Bar (where foo is the crate), so maybe syn doesn't support ::_::. I hadn't seen that before myself either 😅
The text was updated successfully, but these errors were encountered:
For proc-macros is quite common to put the generated code inside unnamed constants, to not pollute the surrounding namespace. However the name of types defined inside such constants cannot be parsed by
syn::Type
:This panics with
The value of
type_name::<<Foo as A>::T>()
isfoo::_::Bar
(wherefoo
is the crate), so maybe syn doesn't support::_::
. I hadn't seen that before myself either 😅The text was updated successfully, but these errors were encountered: