Codebase list rust-libslirp / 81fc9a5
Update failure-derive to proc-macro2 v1, not yet complete Ximin Luo 4 years ago
3 changed file(s) with 137 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 rust-failure-derive (0.1.5-2) UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; urgency=medium
1
2 * Package failure_derive 0.1.5 from crates.io using debcargo 2.4.0
3 * Update to proc-macro2 v1.
4
5 -- Ximin Luo <infinity0@debian.org> Fri, 16 Aug 2019 08:32:18 -0700
6
07 rust-failure-derive (0.1.5-1) unstable; urgency=medium
18
29 * Package failure_derive 0.1.5 from crates.io using debcargo 2.2.10
0 --- a/Cargo.toml
1 +++ b/Cargo.toml
2 @@ -24,16 +24,16 @@
3 [lib]
4 proc-macro = true
5 [dependencies.proc-macro2]
6 -version = "0.4.8"
7 +version = "1"
8
9 [dependencies.quote]
10 -version = "0.6.3"
11 +version = "1"
12
13 [dependencies.syn]
14 -version = "0.15.0"
15 +version = "1"
16
17 [dependencies.synstructure]
18 -version = "0.10.0"
19 +version = "0.11.0"
20 [dev-dependencies.failure]
21 version = "0.1.0"
22
23 --- a/src/lib.rs
24 +++ b/src/lib.rs
25 @@ -120,7 +120,7 @@
26 }
27
28 let format_string = match msg.nested[0] {
29 - syn::NestedMeta::Meta(syn::Meta::NameValue(ref nv)) if nv.ident == "display" => {
30 + syn::NestedMeta::Meta(syn::Meta::NameValue(ref nv)) if nv.path.is_ident("display") => {
31 nv.lit.clone()
32 }
33 _ => {
34 @@ -131,44 +131,21 @@
35 }
36 };
37 let args = msg.nested.iter().skip(1).map(|arg| match *arg {
38 - syn::NestedMeta::Literal(syn::Lit::Int(ref i)) => {
39 - let bi = &v.bindings()[i.value() as usize];
40 + syn::NestedMeta::Lit(syn::Lit::Int(ref i)) => {
41 + let bi = &v.bindings()[i.base10_parse::<usize>()?];
42 Ok(quote!(#bi))
43 }
44 - syn::NestedMeta::Meta(syn::Meta::Word(ref id)) => {
45 - let id_s = id.to_string();
46 - if id_s.starts_with("_") {
47 - if let Ok(idx) = id_s[1..].parse::<usize>() {
48 - let bi = match v.bindings().get(idx) {
49 - Some(bi) => bi,
50 - None => {
51 - return Err(Error::new(
52 - arg.span(),
53 - &format!(
54 - "display attempted to access field `{}` in `{}::{}` which \
55 - does not exist (there are {} field{})",
56 - idx,
57 - s.ast().ident,
58 - v.ast().ident,
59 - v.bindings().len(),
60 - if v.bindings().len() != 1 { "s" } else { "" }
61 - )
62 - ));
63 - }
64 - };
65 - return Ok(quote!(#bi));
66 - }
67 - }
68 + syn::NestedMeta::Meta(syn::Meta::Path(ref path)) => {
69 for bi in v.bindings() {
70 - if bi.ast().ident.as_ref() == Some(id) {
71 + if path.is_ident(&(bi.ast().ident)) {
72 return Ok(quote!(#bi));
73 }
74 }
75 return Err(Error::new(
76 arg.span(),
77 &format!(
78 - "Couldn't find field `{}` in `{}::{}`",
79 - id,
80 + "Couldn't find field `{:?}` in `{}::{}`",
81 + path,
82 s.ast().ident,
83 v.ast().ident
84 )
85 @@ -192,8 +169,8 @@
86 fn find_error_msg(attrs: &[syn::Attribute]) -> Result<Option<syn::MetaList>, Error> {
87 let mut error_msg = None;
88 for attr in attrs {
89 - if let Some(meta) = attr.interpret_meta() {
90 - if meta.name() == "fail" {
91 + if let Ok(meta) = attr.parse_meta() {
92 + if meta.path().is_ident("fail") {
93 if error_msg.is_some() {
94 return Err(Error::new(
95 meta.span(),
96 @@ -223,7 +200,7 @@
97 segments: ref path, ..
98 },
99 }) => path.last().map_or(false, |s| {
100 - s.value().ident == "Backtrace" && s.value().arguments.is_empty()
101 + s.ident == "Backtrace" && s.arguments.is_empty()
102 }),
103 _ => false,
104 }
105 @@ -232,18 +209,18 @@
106 fn is_cause(bi: &&synstructure::BindingInfo) -> bool {
107 let mut found_cause = false;
108 for attr in &bi.ast().attrs {
109 - if let Some(meta) = attr.interpret_meta() {
110 - if meta.name() == "cause" {
111 + if let Ok(meta) = attr.parse_meta() {
112 + if meta.path().is_ident("cause") {
113 if found_cause {
114 panic!("Cannot have two `cause` attributes");
115 }
116 found_cause = true;
117 }
118 - if meta.name() == "fail" {
119 + if meta.path().is_ident("fail") {
120 if let syn::Meta::List(ref list) = meta {
121 if let Some(ref pair) = list.nested.first() {
122 - if let &&syn::NestedMeta::Meta(syn::Meta::Word(ref word)) = pair.value() {
123 - if word == "cause" {
124 + if let &&syn::NestedMeta::Meta(syn::Meta::Path(ref path)) = pair {
125 + if path.is_ident("cause") {
126 if found_cause {
127 panic!("Cannot have two `cause` attributes");
128 }