Skip to content

Commit a0a7083

Browse files
authored
Update syn requirement to 2.0 (#42)
* Upgrade to syn v2 * Bump MSRV to 1.56 * const_err now a hard error, remove warning
1 parent 025c3ee commit a0a7083

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
rust:
1616
- stable
17-
- 1.45.0
17+
- 1.56.0
1818
steps:
1919
- uses: actions/checkout@v1
2020
- uses: actions-rs/toolchain@v1
@@ -64,7 +64,7 @@ jobs:
6464
strategy:
6565
matrix:
6666
rust:
67-
- 1.45.0
67+
- 1.56.0
6868
steps:
6969
- uses: actions/checkout@v1
7070
- uses: actions-rs/toolchain@v1
@@ -87,7 +87,7 @@ jobs:
8787
matrix:
8888
rust:
8989
- stable
90-
- 1.45.0
90+
- 1.56.0
9191
steps:
9292
- uses: actions/checkout@v1
9393
- uses: actions-rs/toolchain@v1

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ default = ["std"]
2222
std = []
2323

2424
[dependencies]
25-
syn = "1.0"
25+
syn = "2.0"
2626
quote = "1.0"
2727
proc-macro2 = "1.0"
2828

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This library provides a convenient derive macro for the standard library's
1414
displaydoc = "0.2"
1515
```
1616

17-
*Compiler support: requires rustc 1.45+*
17+
*Compiler support: requires rustc 1.56+*
1818

1919
<br>
2020

src/attr.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ impl AttrsHelper {
4242
pub(crate) fn new(attrs: &[Attribute]) -> Self {
4343
let ignore_extra_doc_attributes = attrs
4444
.iter()
45-
.any(|attr| attr.path.is_ident("ignore_extra_doc_attributes"));
45+
.any(|attr| attr.path().is_ident("ignore_extra_doc_attributes"));
4646
let prefix_enum_doc_attributes = attrs
4747
.iter()
48-
.any(|attr| attr.path.is_ident("prefix_enum_doc_attributes"));
48+
.any(|attr| attr.path().is_ident("prefix_enum_doc_attributes"));
4949

5050
Self {
5151
ignore_extra_doc_attributes,
@@ -54,7 +54,7 @@ impl AttrsHelper {
5454
}
5555

5656
pub(crate) fn display(&self, attrs: &[Attribute]) -> Result<Option<Display>> {
57-
let displaydoc_attr = attrs.iter().find(|attr| attr.path.is_ident("displaydoc"));
57+
let displaydoc_attr = attrs.iter().find(|attr| attr.path().is_ident("displaydoc"));
5858

5959
if let Some(displaydoc_attr) = displaydoc_attr {
6060
let lit = displaydoc_attr
@@ -71,19 +71,22 @@ impl AttrsHelper {
7171

7272
let num_doc_attrs = attrs
7373
.iter()
74-
.filter(|attr| attr.path.is_ident("doc"))
74+
.filter(|attr| attr.path().is_ident("doc"))
7575
.count();
7676

7777
if !self.ignore_extra_doc_attributes && num_doc_attrs > 1 {
7878
panic!("Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive.");
7979
}
8080

8181
for attr in attrs {
82-
if attr.path.is_ident("doc") {
83-
let meta = attr.parse_meta()?;
84-
let lit = match meta {
82+
if attr.path().is_ident("doc") {
83+
let lit = match &attr.meta {
8584
Meta::NameValue(syn::MetaNameValue {
86-
lit: syn::Lit::Str(lit),
85+
value:
86+
syn::Expr::Lit(syn::ExprLit {
87+
lit: syn::Lit::Str(lit),
88+
..
89+
}),
8790
..
8891
}) => lit,
8992
_ => unimplemented!(),

src/expand.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use proc_macro2::{Span, TokenStream};
33
use quote::{format_ident, quote};
44
use syn::{
55
punctuated::Punctuated,
6-
token::{Add, Colon, Colon2, Comma, Where},
6+
token::{Colon, Comma, PathSep, Plus, Where},
77
Data, DataEnum, DataStruct, DeriveInput, Error, Fields, Generics, Ident, Path, PathArguments,
88
PathSegment, PredicateType, Result, TraitBound, TraitBoundModifier, Type, TypeParam,
99
TypeParamBound, TypePath, WhereClause, WherePredicate,
@@ -110,7 +110,7 @@ fn impl_struct(input: &DeriveInput, data: &DataStruct) -> Result<TokenStream> {
110110

111111
/// Create a `where` predicate for `ident`, without any [bound][TypeParamBound]s yet.
112112
fn new_empty_where_type_predicate(ident: Ident) -> PredicateType {
113-
let mut path_segments = Punctuated::<PathSegment, Colon2>::new();
113+
let mut path_segments = Punctuated::<PathSegment, PathSep>::new();
114114
path_segments.push_value(PathSegment {
115115
ident,
116116
arguments: PathArguments::None,
@@ -127,7 +127,7 @@ fn new_empty_where_type_predicate(ident: Ident) -> PredicateType {
127127
colon_token: Colon {
128128
spans: [Span::call_site()],
129129
},
130-
bounds: Punctuated::<TypeParamBound, Add>::new(),
130+
bounds: Punctuated::<TypeParamBound, Plus>::new(),
131131
}
132132
}
133133

@@ -149,14 +149,14 @@ enum UseGlobalPrefix {
149149

150150
/// Create a path with segments composed of [Idents] *without* any [PathArguments].
151151
fn join_paths(name_segments: &[&str], use_global_prefix: UseGlobalPrefix) -> Path {
152-
let mut segments = Punctuated::<PathSegment, Colon2>::new();
152+
let mut segments = Punctuated::<PathSegment, PathSep>::new();
153153
assert!(!name_segments.is_empty());
154154
segments.push_value(PathSegment {
155155
ident: Ident::new(name_segments[0], Span::call_site()),
156156
arguments: PathArguments::None,
157157
});
158158
for name in name_segments[1..].iter() {
159-
segments.push_punct(Colon2 {
159+
segments.push_punct(PathSep {
160160
spans: [Span::call_site(), Span::mixed_site()],
161161
});
162162
segments.push_value(PathSegment {
@@ -166,7 +166,7 @@ fn join_paths(name_segments: &[&str], use_global_prefix: UseGlobalPrefix) -> Pat
166166
}
167167
Path {
168168
leading_colon: match use_global_prefix {
169-
UseGlobalPrefix::LeadingColon => Some(Colon2 {
169+
UseGlobalPrefix::LeadingColon => Some(PathSep {
170170
spans: [Span::call_site(), Span::mixed_site()],
171171
}),
172172
UseGlobalPrefix::NoLeadingColon => None,
@@ -205,7 +205,7 @@ fn add_display_constraint_to_type_predicate(
205205
path: display_path,
206206
});
207207
if !predicate_that_needs_a_display_impl.bounds.is_empty() {
208-
predicate_that_needs_a_display_impl.bounds.push_punct(Add {
208+
predicate_that_needs_a_display_impl.bounds.push_punct(Plus {
209209
spans: [Span::call_site()],
210210
});
211211
}

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! displaydoc = "0.2"
99
//! ```
1010
//!
11-
//! *Compiler support: requires rustc 1.45+*
11+
//! *Compiler support: requires rustc 1.56+*
1212
//!
1313
//! <br>
1414
//!
@@ -98,7 +98,6 @@
9898
rust_2018_idioms,
9999
unreachable_pub,
100100
bad_style,
101-
const_err,
102101
dead_code,
103102
improper_ctypes,
104103
non_shorthand_field_patterns,

0 commit comments

Comments
 (0)