dtolnay / dtolnay/quote

Unit struct or const cannot be interpolated inside repetition

Open
#300 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.6k
Forks
113
PR merge metrics
No merged PRs in 30d

Description

```rust
use proc_macro2::{Ident, Span, TokenStream};
use quote::{ToTokens, quote};

struct Private;

impl ToTokens for Private {
fn to_tokens(&self, tokens: &mut TokenStream) {
Ident::new("private", Span::call_site()).to_tokens(tokens);
}
}

fn main() {
let _ = quote! {
// Okay
... #Private ...
};

let iter = vec!['0', '1', '2'];
let _ = quote! {
// Fail
#(#Private #iter)*
};
}
```

```console
error[E0530]: let bindings cannot shadow unit structs
--> src/main.rs:21:12
|
4 | struct Private;
| --------------- the unit struct `Private` is defined here
...
21 | #(#Private #iter)*
| ^^^^^^^ cannot be named the same as a unit struct
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.