mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
c9347f1e27
Add a new trait `proc_macro::ToTokens` Tracking issue #130977 This PR adds a new trait `ToTokens`, implemented for types that can be interpolated inside a `quote!` invocation. ```rust impl ToTokens for TokenTree impl ToTokens for TokenStream impl ToTokens for Literal impl ToTokens for Ident impl ToTokens for Punct impl ToTokens for Group impl<T: ToTokens + ?Sized> ToTokens for &T impl<T: ToTokens + ?Sized> ToTokens for &mut T impl<T: ToTokens + ?Sized> ToTokens for Box<T> impl<T: ToTokens + ?Sized> ToTokens for Rc<T> impl<T: ToTokens + ToOwned + ?Sized> ToTokens for Cow<'_, T> impl<T: ToTokens> ToTokens for Option<T> impl ToTokens for u{8,16,32,64,128} impl ToTokens for i{8,16,32,64,128} impl ToTokens for f{32,64} impl ToTokens for {u,i}size impl ToTokens for bool impl ToTokens for char impl ToTokens for str impl ToTokens for String impl ToTokens for CStr impl ToTokens for CString ``` ~This PR also implements the migration mentioned in the tracking issue, replacing `Extend<Token{Tree,Stream}>` with `Extend<T: ToTokens>`, and replacing `FromIterator<Token{Tree,Stream}>` with `FromIterator<T: ToTokens>`.~ **UPDATE**: Reverted. ```diff -impl FromIterator<TokenTree> for TokenStream -impl FromIterator<TokenStream> for TokenStream +impl<T: ToTokens> FromIterator<T> for TokenStream -impl Extend<TokenTree> for TokenStream -impl Extend<TokenStream> for TokenStream +impl<T: ToTokens> Extend<T> for TokenStream ``` I'm going to leave some comments in the review where I'm unsure and concerned. r? ``@dtolnay`` CC ``@tgross35`` |
||
---|---|---|
.. | ||
alloc | ||
backtrace@230570f2da | ||
core | ||
panic_abort | ||
panic_unwind | ||
portable-simd | ||
proc_macro | ||
profiler_builtins | ||
rtstartup | ||
rustc-std-workspace-alloc | ||
rustc-std-workspace-core | ||
rustc-std-workspace-std | ||
std | ||
stdarch@c881fe3231 | ||
sysroot | ||
test | ||
unwind | ||
windows_targets | ||
Cargo.lock | ||
Cargo.toml |