Skip to content

invalid suggestion to add .into_iter() into the source code of quote #137345

Closed
@cyrgani

Description

@cyrgani

Code

use proc_macro::TokenStream;

#[proc_macro]
pub fn default_args_fn(_: TokenStream) -> TokenStream {
    let decl_macro = TokenStream::new();

    quote::quote! {
        #(#decl_macro)*
    }
    .into()
}

Current output

error[E0599]: no method named `quote_into_iter` found for struct `proc_macro::TokenStream` in the current scope
 --> src/lib.rs:7:5
  |
7 | /     quote::quote! {
8 | |         #(#decl_macro)*
9 | |     }
  | |_____^ `proc_macro::TokenStream` is not an iterator
  |
  = note: this error originates in the macro `$crate::quote_bind_into_iter` which comes from the expansion of the macro `quote::quote` (in Nightly builds, run with -Z macro-backtrace for more info)
help: call `.into_iter()` first
 --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/quote-1.0.38/src/lib.rs:744:34
  |
74|         let (mut $var, i) = $var.into_iter().quote_into_iter();
  |                                  ++++++++++++

For more information about this error, try `rustc --explain E0599`.

Desired output

editing foreign code should not be suggested

Rationale and extra context

No response

Other cases

Rust Version

rustc 1.87.0-nightly (f280acf4c 2025-02-19)
binary: rustc
commit-hash: f280acf4c743806abbbbcfe65050ac52ec4bdec0
commit-date: 2025-02-19
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions