Skip to content

Commit aa00fbe

Browse files
taiki-egnzlbg
authored andcommitted
Update proc-macro2, syn, and quote to 1.0
1 parent 5d836b1 commit aa00fbe

File tree

5 files changed

+37
-42
lines changed

5 files changed

+37
-42
lines changed

crates/assert-instr-macro/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ proc-macro = true
88
test = false
99

1010
[dependencies]
11-
proc-macro2 = { version = "0.4", features = ["nightly"] }
12-
quote = "0.6"
13-
syn = { version = "0.15", features = ["full"] }
11+
proc-macro2 = "1.0"
12+
quote = "1.0"
13+
syn = { version = "1.0", features = ["full"] }

crates/assert-instr-macro/src/lib.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn assert_instr(
3636
};
3737

3838
let instr = &invoc.instr;
39-
let name = &func.ident;
39+
let name = &func.sig.ident;
4040

4141
// Disable assert_instr for x86 targets compiled with avx enabled, which
4242
// causes LLVM to generate different intrinsics that the ones we are
@@ -62,21 +62,21 @@ pub fn assert_instr(
6262
);
6363
let mut inputs = Vec::new();
6464
let mut input_vals = Vec::new();
65-
let ret = &func.decl.output;
66-
for arg in func.decl.inputs.iter() {
65+
let ret = &func.sig.output;
66+
for arg in func.sig.inputs.iter() {
6767
let capture = match *arg {
68-
syn::FnArg::Captured(ref c) => c,
68+
syn::FnArg::Typed(ref c) => c,
6969
ref v => panic!(
7070
"arguments must not have patterns: `{:?}`",
7171
v.clone().into_token_stream()
7272
),
7373
};
74-
let ident = match capture.pat {
74+
let ident = match *capture.pat {
7575
syn::Pat::Ident(ref i) => &i.ident,
7676
_ => panic!("must have bare arguments"),
7777
};
78-
if let Some(&(_, ref tts)) = invoc.args.iter().find(|a| *ident == a.0) {
79-
input_vals.push(quote! { #tts });
78+
if let Some(&(_, ref tokens)) = invoc.args.iter().find(|a| *ident == a.0) {
79+
input_vals.push(quote! { #tokens });
8080
} else {
8181
inputs.push(capture);
8282
input_vals.push(quote! { #ident });
@@ -91,7 +91,6 @@ pub fn assert_instr(
9191
.segments
9292
.first()
9393
.expect("attr.path.segments.first() failed")
94-
.value()
9594
.ident
9695
.to_string()
9796
.starts_with("target")
@@ -131,7 +130,7 @@ pub fn assert_instr(
131130
}
132131
};
133132

134-
let tts: TokenStream = quote! {
133+
let tokens: TokenStream = quote! {
135134
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
136135
#[cfg_attr(not(target_arch = "wasm32"), test)]
137136
#[allow(non_snake_case)]
@@ -148,13 +147,13 @@ pub fn assert_instr(
148147
}
149148
};
150149
// why? necessary now to get tests to work?
151-
let tts: TokenStream = tts.to_string().parse().expect("cannot parse tokenstream");
150+
let tokens: TokenStream = tokens.to_string().parse().expect("cannot parse tokenstream");
152151

153-
let tts: TokenStream = quote! {
152+
let tokens: TokenStream = quote! {
154153
#item
155-
#tts
154+
#tokens
156155
};
157-
tts.into()
156+
tokens.into()
158157
}
159158

160159
struct Invoc {
@@ -163,7 +162,7 @@ struct Invoc {
163162
}
164163

165164
impl syn::parse::Parse for Invoc {
166-
fn parse(input: syn::parse::ParseStream) -> syn::parse::Result<Self> {
165+
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
167166
use syn::{ext::IdentExt, Token};
168167

169168
let mut instr = String::new();

crates/simd-test-macro/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ proc-macro = true
88
test = false
99

1010
[dependencies]
11-
proc-macro2 = { version = "0.4", features = ["nightly"] }
12-
quote = "0.6"
11+
proc-macro2 = "1.0"
12+
quote = "1.0"

crates/stdarch-verify/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ authors = ["Alex Crichton <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
proc-macro2 = "0.4"
9-
quote = "0.6"
10-
syn = { version = "0.15", features = ["full"] }
8+
proc-macro2 = "1.0"
9+
quote = "1.0"
10+
syn = { version = "1.0", features = ["full"] }
1111

1212
[lib]
1313
proc-macro = true

crates/stdarch-verify/src/lib.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ extern crate quote;
66
extern crate syn;
77

88
use proc_macro::TokenStream;
9-
use proc_macro2::Span;
109
use std::{fs::File, io::Read, path::Path};
1110
use syn::ext::IdentExt;
1211

@@ -57,7 +56,7 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
5756

5857
let mut tests = std::collections::HashSet::<String>::new();
5958
for f in &functions {
60-
let id = format!("{}", f.0.ident);
59+
let id = format!("{}", f.0.sig.ident);
6160
if id.starts_with("test_") {
6261
tests.insert(id);
6362
}
@@ -66,7 +65,7 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
6665

6766
functions.retain(|&(ref f, _)| {
6867
if let syn::Visibility::Public(_) = f.vis {
69-
if f.unsafety.is_some() {
68+
if f.sig.unsafety.is_some() {
7069
return true;
7170
}
7271
}
@@ -79,17 +78,17 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
7978
let functions = functions
8079
.iter()
8180
.map(|&(ref f, path)| {
82-
let name = &f.ident;
81+
let name = &f.sig.ident;
8382
// println!("{}", name);
8483
let mut arguments = Vec::new();
85-
for input in f.decl.inputs.iter() {
84+
for input in f.sig.inputs.iter() {
8685
let ty = match *input {
87-
syn::FnArg::Captured(ref c) => &c.ty,
86+
syn::FnArg::Typed(ref c) => &c.ty,
8887
_ => panic!("invalid argument on {}", name),
8988
};
9089
arguments.push(to_type(ty));
9190
}
92-
let ret = match f.decl.output {
91+
let ret = match f.sig.output {
9392
syn::ReturnType::Default => quote! { None },
9493
syn::ReturnType::Type(_, ref t) => {
9594
let ty = to_type(t);
@@ -265,7 +264,6 @@ fn extract_path_ident(path: &syn::Path) -> syn::Ident {
265264
.segments
266265
.first()
267266
.expect("segment not found")
268-
.value()
269267
.arguments
270268
{
271269
syn::PathArguments::None => {}
@@ -274,7 +272,6 @@ fn extract_path_ident(path: &syn::Path) -> syn::Ident {
274272
path.segments
275273
.first()
276274
.expect("segment not found")
277-
.value()
278275
.ident
279276
.clone()
280277
}
@@ -318,7 +315,7 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<String> {
318315
// TODO: should probably just reuse `Invoc` from the `assert-instr-macro`
319316
// crate.
320317
impl syn::parse::Parse for AssertInstr {
321-
fn parse(content: syn::parse::ParseStream) -> syn::parse::Result<Self> {
318+
fn parse(content: syn::parse::ParseStream) -> syn::Result<Self> {
322319
let input;
323320
parenthesized!(input in content);
324321
let _ = input.parse::<syn::Meta>()?;
@@ -352,9 +349,9 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<String> {
352349

353350
attrs
354351
.iter()
355-
.filter(|a| a.path == syn::Ident::new("cfg_attr", Span::call_site()).into())
352+
.filter(|a| a.path.is_ident("cfg_attr"))
356353
.filter_map(|a| {
357-
syn::parse2::<AssertInstr>(a.tts.clone())
354+
syn::parse2::<AssertInstr>(a.tokens.clone())
358355
.ok()
359356
.map(|a| a.instr)
360357
})
@@ -365,9 +362,9 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
365362
attrs
366363
.iter()
367364
.flat_map(|a| {
368-
if let Some(a) = a.interpret_meta() {
365+
if let Ok(a) = a.parse_meta() {
369366
if let syn::Meta::List(i) = a {
370-
if i.ident == "target_feature" {
367+
if i.path.is_ident("target_feature") {
371368
return i.nested;
372369
}
373370
}
@@ -376,10 +373,10 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
376373
})
377374
.filter_map(|nested| match nested {
378375
syn::NestedMeta::Meta(m) => Some(m),
379-
syn::NestedMeta::Literal(_) => None,
376+
syn::NestedMeta::Lit(_) => None,
380377
})
381378
.find_map(|m| match m {
382-
syn::Meta::NameValue(ref i) if i.ident == "enable" => Some(i.clone().lit),
379+
syn::Meta::NameValue(ref i) if i.path.is_ident("enable") => Some(i.clone().lit),
383380
_ => None,
384381
})
385382
}
@@ -389,7 +386,7 @@ fn find_required_const(attrs: &[syn::Attribute]) -> Vec<usize> {
389386
.iter()
390387
.flat_map(|a| {
391388
if a.path.segments[0].ident == "rustc_args_required_const" {
392-
syn::parse::<RustcArgsRequiredConst>(a.tts.clone().into())
389+
syn::parse::<RustcArgsRequiredConst>(a.tokens.clone().into())
393390
.unwrap()
394391
.args
395392
} else {
@@ -404,14 +401,13 @@ struct RustcArgsRequiredConst {
404401
}
405402

406403
impl syn::parse::Parse for RustcArgsRequiredConst {
407-
#[allow(clippy::cast_possible_truncation)]
408-
fn parse(input: syn::parse::ParseStream) -> syn::parse::Result<Self> {
404+
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
409405
let content;
410406
parenthesized!(content in input);
411407
let list =
412408
syn::punctuated::Punctuated::<syn::LitInt, Token![,]>::parse_terminated(&content)?;
413409
Ok(Self {
414-
args: list.into_iter().map(|a| a.value() as usize).collect(),
410+
args: list.into_iter().map(|a| a.base10_parse::<usize>()).collect::<syn::Result<_>>()?,
415411
})
416412
}
417413
}

0 commit comments

Comments
 (0)