|
1 | 1 | use syn::visit_mut::VisitMut; |
2 | 2 | use syn::{Attribute, ItemFn, ItemImpl}; |
3 | 3 |
|
4 | | -/* |
5 | | -Leaving code commented-out, as this might be very useful elsewhere |
6 | | -
|
7 | | -use proc_macro2::TokenStream; |
8 | | -use quote::ToTokens; |
9 | | -use syn::{Item}; |
10 | | -pub fn variant_collection_safety( |
11 | | - _attr: proc_macro::TokenStream, |
12 | | - item: proc_macro::TokenStream, |
13 | | -) -> Result<TokenStream, syn::Error> { |
14 | | - let mut item = syn::parse::<Item>(item)?; |
15 | | - let mut visit = IncludeDocs { |
16 | | - docs: &[ |
17 | | - "# Safety", |
18 | | - "", |
19 | | - "Generally, it's not recommended to mutate variant collections that may be shared. Prefer", |
20 | | - "`ThreadLocal` or `Unique` collections instead. If you're sure that the current reference", |
21 | | - "is unique, you may use [`assume_unique`](#method.assume_unique) to convert it to a `Unique`", |
22 | | - "collection. You may subsequently use [`into_thread_local`](#method.into_thread_local) to", |
23 | | - "convert it to a `ThreadLocal` one.", |
24 | | - "", |
25 | | - "It is only safe to perform operations that may allocate on a shared collection when no", |
26 | | - "other thread may access the underlying collection during the call.", |
27 | | - ], |
28 | | - deprecated: Some(concat!( |
29 | | - "Care should be used when mutating shared variant collections. Prefer `ThreadLocal` ", |
30 | | - "or `Unique` collections unless you're absolutely sure that you want this. ", |
31 | | - "You may use [assume_unique](#method.assume_unique) to convert this to a `Unique` ", |
32 | | - "collection if you are sure that this is in fact the only reference." |
33 | | - )), |
34 | | - }; |
35 | | - visit.visit_item_mut(&mut item); |
36 | | - Ok(item.to_token_stream()) |
37 | | -} |
38 | | -*/ |
39 | | - |
40 | 4 | struct IncludeDocs<'a> { |
41 | 5 | docs: &'a [&'a str], |
42 | 6 | deprecated: Option<&'a str>, |
|
0 commit comments