Skip to content

Commit 42f4684

Browse files
committed
Update dependencies
1 parent 239c74c commit 42f4684

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ debug_unreachable = "0.1.1"
3636
string_cache_shared = {path = "./shared", version = "0.3"}
3737

3838
[dev-dependencies]
39-
rand = "0.3"
39+
rand = "0.4"
4040

4141
[build-dependencies]
4242
string_cache_codegen = { version = "0.4", path = "./string-cache-codegen" }

string-cache-codegen/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ path = "lib.rs"
1616
string_cache_shared = {path = "../shared", version = "0.3"}
1717
phf_generator = "0.7.15"
1818
phf_shared = "0.7.4"
19-
quote = "0.3.9"
19+
proc-macro2 = "0.3.1"
20+
quote = "0.5.1"

string-cache-codegen/lib.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extern crate phf_generator;
7272
extern crate phf_shared;
7373
extern crate string_cache_shared as shared;
7474
#[macro_use] extern crate quote;
75+
extern crate proc_macro2;
7576

7677
use std::collections::HashSet;
7778
use std::fs::File;
@@ -169,7 +170,7 @@ impl AtomType {
169170
pub fn write_to<W>(&mut self, mut destination: W) -> io::Result<()> where W: Write {
170171
destination.write_all(
171172
self.to_tokens()
172-
.as_str()
173+
.to_string()
173174
// Insert some newlines to make the generated code slightly easier to read.
174175
.replace(" [ \"", "[\n\"")
175176
.replace("\" , ", "\",\n")
@@ -187,9 +188,11 @@ impl AtomType {
187188
let atoms: Vec<&str> = self.atoms.iter().map(|s| &**s).collect();
188189
let hash_state = phf_generator::generate_hash(&atoms);
189190
let phf_generator::HashState { key, disps, map } = hash_state;
191+
let (disps0, disps1): (Vec<_>, Vec<_>) = disps.into_iter().unzip();
190192
let atoms: Vec<&str> = map.iter().map(|&idx| atoms[idx]).collect();
193+
let atoms_ref = &atoms;
191194
let empty_string_index = atoms.iter().position(|s| s.is_empty()).unwrap() as u32;
192-
let data = (0..atoms.len()).map(|i| quote::Hex(shared::pack_static(i as u32)));
195+
let data = (0..atoms.len()).map(|i| proc_macro2::Literal::u64_suffixed(shared::pack_static(i as u32)));
193196

194197
let hashes: Vec<u32> =
195198
atoms.iter().map(|string| {
@@ -214,10 +217,11 @@ impl AtomType {
214217
Some(ref doc) => quote!(#[doc = #doc]),
215218
None => quote!()
216219
};
217-
let static_set_name = quote::Ident::from(format!("{}StaticSet", type_name));
218-
let type_name = quote::Ident::from(type_name);
219-
let macro_name = quote::Ident::from(&*self.macro_name);
220-
let path = iter::repeat(quote::Ident::from(&*self.path));
220+
let produce_term = |string: &str| proc_macro2::Term::new(string, proc_macro2::Span::call_site());
221+
let static_set_name = produce_term(&format!("{}StaticSet", type_name));
222+
let type_name = produce_term(type_name);
223+
let macro_name = produce_term(&*self.macro_name);
224+
let path = iter::repeat(produce_term(&*self.path));
221225

222226
quote! {
223227
#atom_doc
@@ -228,9 +232,9 @@ impl AtomType {
228232
fn get() -> &'static ::string_cache::PhfStrSet {
229233
static SET: ::string_cache::PhfStrSet = ::string_cache::PhfStrSet {
230234
key: #key,
231-
disps: &#disps,
232-
atoms: &#atoms,
233-
hashes: &#hashes
235+
disps: &[#((#disps0, #disps1)),*],
236+
atoms: &[#(#atoms_ref),*],
237+
hashes: &[#(#hashes),*]
234238
};
235239
&SET
236240
}
@@ -242,7 +246,7 @@ impl AtomType {
242246
#[macro_export]
243247
macro_rules! #macro_name {
244248
#(
245-
(#atoms) => {
249+
(#atoms_ref) => {
246250
$crate::#path {
247251
unsafe_data: #data,
248252
phantom: ::std::marker::PhantomData,

0 commit comments

Comments
 (0)