Closed
Description
Code
#![crate_type = "proc-macro"]
// note: `quote` is in Cargo.toml
use proc_macro::TokenStream;
use syn::Lit;
#[proc_macro]
pub fn macro1(input: TokenStream) -> TokenStream {
let x = syn::parse_macro_input!(input as Lit);
x.into_token_stream()
}
Current output
error[E0599]: no method named `into_token_stream` found for enum `syn::Lit` in the current scope
--> src/lib.rs:10:7
|
10 | x.into_token_stream()
| ^^^^^^^^^^^^^^^^^
|
= help: items from traits can only be used if the trait is in scope
help: trait `ToTokens` which provides `into_token_stream` is implemented but not in scope; perhaps you want to import it
|
3 + use syn::__private::ToTokens;
|
help: there is a method `to_token_stream` with a similar name
|
10 | x.to_token_stream()
| ~~~~~~~~~~~~~~~
For more information about this error, try `rustc --explain E0599`.
Desired output
error[E0599]: no method named `into_token_stream` found for enum `syn::Lit` in the current scope
--> src/lib.rs:10:7
|
10 | x.into_token_stream()
| ^^^^^^^^^^^^^^^^^
|
= help: items from traits can only be used if the trait is in scope
help: trait `ToTokens` which provides `into_token_stream` is implemented but not in scope; perhaps you want to import it
|
3 + use ::quote::ToTokens;
|
help: there is a method `to_token_stream` with a similar name
|
10 | x.to_token_stream()
| ~~~~~~~~~~~~~~~
For more information about this error, try `rustc --explain E0599`.
Rationale and extra context
diagnostics should avoid referencing #[doc(hidden)]
items if at all possible. ideally it would suggest adding quote
to the extern prelude if it wasn't there already, but that is tricky when rustc
doesn't know anything about how dependencies are managed.
Other cases
No response
Rust Version
rustc 1.80.0-nightly (debd22da6 2024-05-29)
binary: rustc
commit-hash: debd22da66cfa97c74040ebf68e420672ac8560e
commit-date: 2024-05-29
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6
Anything else?
No response