NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io, #9 most downloaded on crates.io
Quasi-quoting macro quote!(...)
Latest stable
1.0.47
Last release 4 months ago
19 Jul 2026
Release timing varies
gaps range from 8 days to 7 months
Most releases are documented
notes for 47 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
10 years old
95 releases · first in 2016
Drag across the ruler to compare, or tap a release to open it.
Documentation improvements
Avoid repeated get_span in quote_spanned ( #329 , thanks @Noratrieb )
get_span in quote_spanned (#329, thanks @Noratrieb)Your coding agent can read these notes before it upgrades. Set up the MCP server →
Add ToTokens impl for Arc<T>
Support raw lifetime syntax 'r#async
'r#async (#323)Disambiguate references to stringify! macro inside generated code
stringify! macro inside generated code (#316)Tweaks to improve build speed ( #305 , #306 , #307 , #308 , thanks @dishmaker )
Improve compile error when repetition contains no interpolated value that is an iterator
Optimize construction of lifetime tokens ( #293 , thanks @aatifsyed )
Documentation improvements
Support interpolating arrays inside of arrays using a repetition
Implement ToTokens for CStr and CString
Nothing published for this version
Update proc-macro2 to fix caching issue when using a rustc-wrapper such as sccache
Nothing published for this version
Partially work around rust-analyzer bug
Documentation improvements (thanks @mfreeborn)
Eliminate build.rs to reduce build time
Nothing published for this version
Fix proc_macro_span_shrink-related build error when built with -Zminimal-versions
proc_macro_span_shrink-related build error when built with -Zminimal-versionsEnable proc_macro support on wasm targets
Nothing published for this version
Improve error message on incorrectly typed span
Generalize quote_spanned! to accept DelimSpan as span
quote_spanned! to accept DelimSpan as span (#239)Nothing published for this version
Opt out of -Zrustdoc-scrape-examples on docs.rs for now
-Zrustdoc-scrape-examples on docs.rs for nowNothing published for this version
Add keywords to crates.io metadata
Remove workaround for dealing with invalid spans on new enough compilers (#224, thanks @mystor)
Ident::new_raw to quote raw identifiers (#225, thanks @mystor)Improve the way rustc's -Zunpretty=expanded renders quote's expanded code
Special case quote!/quote_spanned! for inputs of size 1 and 2 tokens to improve performance (#217, thanks @nnethercote)
quote!/quote_spanned! for inputs of size 1 and 2 tokens to improve performance (#217, thanks @nnethercote)Nothing published for this version
Improve compile time of quote! and quote_spanned! calls by a few percent (#209, #210, thanks @nnethercote @lqd)
quote! and quote_spanned! calls by a few percent (#209, #210, thanks @nnethercote @lqd)Retrigger docs.rs build to work around rustdoc regression
Optimization to reduce calls over the proc macro bridge
Nothing published for this version
Fix proc-macro2 dependency to work with -Zminimal-versions builds
-Zminimal-versions buildsImprove performance of quote invocations involving literals, lifetimes, and underscore tokens
Work around regression in nightly Clippy: https://github.com/rust-lang/rust-clippy/issues/7768
Nothing published for this version
Help debug invalid raw identifiers passed to format_ident! (#173, #175)
format_ident! (#173, #175)Add fast path to improve compile time of generated code when using quote! with the default span
quote! with the default span (#159)Support Cow used as an ident fragment inside format_ident! (#158, thanks @randomPoison)
Cow used as an ident fragment inside format_ident! (#158, thanks @randomPoison)Nothing published for this version
Permit char as a fragment in the `format_ident!` macro
char as a fragment in the format_ident! macroAvoid panic when using quote! on raw identifiers
Fix missing token if there is a star adjacent to repetition
Nothing published for this version
This release fixes some longstanding limitations of the quote! macro, bringing quote better in line with the patterns that macro authors are used to f
This release fixes some longstanding limitations of the quote! macro, bringing quote better in line with the patterns that macro authors are used to from working with macro_rules.
<br>
In past versions of quote, interpolating the same variable multiple times inside of one repeating block was not allowed.
For example if we had an iterator of local variable names and wanted the generated code to do a clone of each one, that wouldn't compile:
error[E0416]: identifier `var` is bound more than once in the same pattern
--> src/main.rs:7:27
|
7 | #( let #var = #var.clone(); )*
| ^^^ used in a pattern more than once
Macros usually worked around this by having the same sequence of interpolated values named two different things:
// old workaround 1
let var = input.fields.iter().map(|field| &field.ident);
let var2 = var.clone();
quote! {
#( let #var = #var2.clone(); )*
}
or by giving up on repetitions and doing more of the work within the iterator chain:
// old workaround 2
let var_clones = input
.fields
.iter()
.map(|field| {
let var = &field.ident;
quote! {
let #var = #var.clone();
}
});
quote! {
#(#var_clones)*
}
As of quote 1.0, these workarounds are no longer necessary and values can be used as many times as necessary in a repetition. This fix is thanks to a technique and implementation by @mystor.
// quote 1.0
let var = input.fields.iter().map(|field| &field.ident);
quote! {
#( let #var = #var.clone(); )*
}
<br>
In past versions of quote, every interpolated variable in a repetition had to have an IntoIterator impl, where each iteration of the repetition would interpolate the next item from each of the iterators. Thus it wasn't possible to mix repeating and non-repeating values inside the same repetition.
// previously nonworking code
let obj = &input.ident;
let field = input.fields.iter().map(|field| &field.ident);
quote! {
#( #obj.#field.print(); )*
}
error[E0599]: no method named `into_iter` found for type `proc_macro2::Ident` in the current scope
--> src/main.rs:8:13
|
8 | #( #obj.#field.print(); )*
| ^^^
What's much worse, the IntoIterator impl could have extremely surprising and undesirable behavior when placing a TokenStream (such as produced by quote) inside a repetition in a subsequent quote.
// previously insane behavior
let default_impl = quote!(unimplemented!());
let names = &input.function_names;
quote! {
#(
fn #names() { #default_impl }
)*
}
What the macro author probably wanted the example above to produce was:
fn fname1() { unimplemented!() }
fn fname2() { unimplemented!() }
...
Instead what they would have gotten is:
fn fname1() { unimplemented }
fn fname2() { ! }
fn fname3() { () }
where because the default_impl TokenStream is used in the repetition, quote calls its IntoIterator impl which for TokenStreams produces one token of the stream at a time. The tokens of the default_impl thus get smeared across consecutive iterations of the repetition.
All of this is fixed in quote 1.0. Repetition is no longer based on the IntoIterator trait. Instead we separately handle any interpolated value that implements Iterator (by interpolating one item from the iterator per repetition), any value that implements ToTokens (by interpolating the entire thing each repetition), and a small additional set of common types like &[T] and Vec<T> and BTreeSet<T> which interpolate one element per iteration but themselves are not an Iterator.
This fix is thanks to a technique by @Goncalerta and an implementation by @mystor.
<br>
As a side benefit of no longer relying on the IntoIterator trait, owned values like Vec are no longer consumed the first time they are used in a repetition.
// code that did not compile before, but works in quote 1.0
let field = vec![a, b, c];
quote! {
struct S {
#( #field: String, )*
}
impl S {
fn print(&self) {
#( self.#field.print(); )*
}
}
}
error[E0382]: use of moved value: `field`
--> src/main.rs:10:13
|
11 | struct S {
12 | #( #field: String, )*
| ^^^^^ value moved here
...
17 | #( self.#field.print(); )*
| ^^^^^ value used here after move
<br>
The quote macro used to perform potentially deep recursive invocations in the style of a "tt muncher" macro. For large invocations this would sometimes require placing #![recursion_limit = "256"] or even higher in the proc macro crate in order for it to compile.
This is no longer necessary because quote no longer performs one-per-token recursive invocations. In quote 1.0 the recursion depth is proportional to the nesting depth (maximum number of nested parens/brackets/braces in the input) rather than total number of tokens, and nesting depth is typically far less than the compiler's default recursion limit.
The fix is thanks to a technique and implementation by @qnighy.
<br>
Quote 1.0 adds a format_ident! macro which works like format! but produces an Ident instead of string. When interpolated inside quote, idents are unquoted (like variable names) where strings would be quoted (like string literals).
let arg = format_ident!("arg{}", i);
// previously would have been written more verbosely as:
let arg = Ident::new(&format!("arg{}", i), Span::call_site());
There are some additional Ident-specific features of format_ident, like control over the Span of the identifier for hygiene and error reporting purposes. Refer to the rustdoc for details.
The idea for this macro and the implementation were contributed by @mystor.
<br>
Minimum required Rust version is raised from rustc 1.15 to 1.31.
Repetition is no longer based on the IntoIterator trait.
As discussed above. If you had interpolated a value inside a repetition that implemented IntoIterator but not Iterator, and was not Vec or &[T] or any of the other types that continue to be explicitly supported, then you will need to turn it into an iterator yourself. Usually this will be a matter of inserting a .iter() call.
Repetitions with nothing interpolated no longer compile.
This is intentional to help catch cases where the macro author writes a repetition but forgets to place any interpolation inside of it:
quote! {
// should have been #var
#( let var = Default::default(); )*
}
Formerly this would silently produce an empty token stream.
The quote_spanned macro requires the span to be a Span.
The quote_spanned! macro accepts a span argument to use as the default span instead of call_site for all tokens originating within the macro invocation. Formerly, when this fallback span was never used because the entire macro body consisted of interpolations, its type was never checked and may have been something other than a Span. In quote 1.0 the span given to quote_spanned must be of type Span no matter what, even when it happens to not be used.
Documentation improvements only
Support interpolating values of type Rc\ (#102, thanks @eddyb)
Update documentation to 2018 edition
Support interpolating values of type i128 and u128
Add crate metadata to appear in development-tools::procedural-macro-helpers
Support Rust 2018 style macro imports
Support Rust 2018 style macro imports (#78)
use quote::quote;
- Performance optimizations
Support building for wasm which has no proc-macro crate
Implement `ToTokens` for &mut T
ToTokens for &mut TNothing published for this version
Replace deprecated proc-macro2 TokenStream::empty call (#74, thanks @hcpl)
Nothing published for this version
One column per quarter.