diff options
author | Joel Galenson <jgalenson@google.com> | 2021-08-09 10:46:01 -0700 |
---|---|---|
committer | Joel Galenson <jgalenson@google.com> | 2021-08-09 10:46:01 -0700 |
commit | 1c4b9edcd47c78c4729dc0e29df575bdceb1d6a7 (patch) | |
tree | b7b549d867fa351756fd15712380692bbb0402e4 | |
parent | e4f3eca5e8b7e9ec7b1c19e5ab08571a0c5e6979 (diff) | |
download | syn-1c4b9edcd47c78c4729dc0e29df575bdceb1d6a7.tar.gz |
Upgrade rust/crates/syn to 1.0.74
Test: make
Change-Id: I5ec1f2ee8eedd48533212ece38f477b4cf458fbd
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 11 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | benches/file.rs | 2 | ||||
-rw-r--r-- | benches/rust.rs | 2 | ||||
-rw-r--r-- | src/item.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/ty.rs | 11 | ||||
-rw-r--r-- | tests/common/eq.rs | 4 | ||||
-rw-r--r-- | tests/repo/mod.rs | 3 | ||||
-rw-r--r-- | tests/test_precedence.rs | 10 | ||||
-rw-r--r-- | tests/test_round_trip.rs | 2 | ||||
-rw-r--r-- | tests/test_ty.rs | 68 |
15 files changed, 102 insertions, 33 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 48538741..86f59567 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "82ac4e6dc30495e936a9228d7dd6b2528fd48900" + "sha1": "9e206dad2346e2f4542abb2200c397ceefddfc06" } } @@ -65,6 +65,6 @@ rust_library_host { } // dependent_library ["feature_list"] -// proc-macro2-1.0.27 "default,proc-macro" +// proc-macro2-1.0.28 "default,proc-macro" // quote-1.0.9 "default,proc-macro" // unicode-xid-0.2.2 "default" @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "syn" -version = "1.0.73" +version = "1.0.74" authors = ["David Tolnay <dtolnay@gmail.com>"] include = ["/benches/**", "/build.rs", "/Cargo.toml", "/LICENSE-APACHE", "/LICENSE-MIT", "/README.md", "/src/**", "/tests/**"] description = "Parser for Rust source code" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index d7d070ef..efcfcb90 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "syn" -version = "1.0.73" # don't forget to update html_root_url and syn.json +version = "1.0.74" # don't forget to update html_root_url and syn.json authors = ["David Tolnay <dtolnay@gmail.com>"] license = "MIT OR Apache-2.0" description = "Parser for Rust source code" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/syn/syn-1.0.73.crate" + value: "https://static.crates.io/crates/syn/syn-1.0.74.crate" } - version: "1.0.73" + version: "1.0.74" license_type: NOTICE last_upgrade_date { year: 2021 - month: 6 - day: 21 + month: 8 + day: 9 } } diff --git a/benches/file.rs b/benches/file.rs index 58ab8df2..33d201c1 100644 --- a/benches/file.rs +++ b/benches/file.rs @@ -19,7 +19,7 @@ use std::fs; use std::str::FromStr; use test::Bencher; -const FILE: &str = "tests/rust/src/libcore/str/mod.rs"; +const FILE: &str = "tests/rust/library/core/src/str/mod.rs"; #[bench] fn parse_file(b: &mut Bencher) { diff --git a/benches/rust.rs b/benches/rust.rs index 50e1a7f6..28dff947 100644 --- a/benches/rust.rs +++ b/benches/rust.rs @@ -58,7 +58,7 @@ mod librustc_parse { } } - rustc_span::with_session_globals(Edition::Edition2018, || { + rustc_span::create_session_if_not_set_then(Edition::Edition2018, |_| { let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let emitter = Box::new(SilentEmitter); let handler = Handler::with_emitter(false, None, emitter); diff --git a/src/item.rs b/src/item.rs index acc56f86..40d94e05 100644 --- a/src/item.rs +++ b/src/item.rs @@ -1808,7 +1808,7 @@ pub mod parsing { #[cfg(not(test))] _ => unreachable!(), }; - attrs.extend(item_attrs.drain(..)); + attrs.append(item_attrs); *item_attrs = attrs; Ok(item) @@ -2293,7 +2293,7 @@ pub mod parsing { #[cfg(not(test))] _ => unreachable!(), }; - attrs.extend(item_attrs.drain(..)); + attrs.append(item_attrs); *item_attrs = attrs; Ok(item) } @@ -2637,7 +2637,7 @@ pub mod parsing { #[cfg(not(test))] _ => unreachable!(), }; - attrs.extend(item_attrs.drain(..)); + attrs.append(item_attrs); *item_attrs = attrs; } @@ -250,7 +250,7 @@ //! dynamic library libproc_macro from rustc toolchain. // Syn types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/syn/1.0.73")] +#![doc(html_root_url = "https://docs.rs/syn/1.0.74")] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![allow(non_camel_case_types)] // Ignored clippy lints. @@ -412,6 +412,7 @@ pub mod parsing { && !lookahead.peek(Token![self]) && !lookahead.peek(Token![Self]) && !lookahead.peek(Token![crate]) + || input.peek(Token![dyn]) { return Err(lookahead.error()); } @@ -540,15 +541,7 @@ pub mod parsing { || lookahead.peek(Token![<]) { if input.peek(Token![dyn]) { - let mut trait_object: TypeTraitObject = input.parse()?; - if lifetimes.is_some() { - match trait_object.bounds.iter_mut().next().unwrap() { - TypeParamBound::Trait(trait_bound) => { - trait_bound.lifetimes = lifetimes; - } - TypeParamBound::Lifetime(_) => unreachable!(), - } - } + let trait_object: TypeTraitObject = input.parse()?; return Ok(Type::TraitObject(trait_object)); } diff --git a/tests/common/eq.rs b/tests/common/eq.rs index 3c283ca4..4f195502 100644 --- a/tests/common/eq.rs +++ b/tests/common/eq.rs @@ -329,7 +329,7 @@ spanless_eq_struct!(PolyTraitRef; bound_generic_params trait_ref span); spanless_eq_struct!(QSelf; ty path_span position); spanless_eq_struct!(Stmt; id kind span); spanless_eq_struct!(StrLit; style symbol suffix span symbol_unescaped); -spanless_eq_struct!(StructExpr; path fields rest); +spanless_eq_struct!(StructExpr; qself path fields rest); spanless_eq_struct!(Token; kind span); spanless_eq_struct!(TraitKind; 0 1 2 3 4); spanless_eq_struct!(TraitRef; path ref_id); @@ -412,7 +412,7 @@ spanless_eq_enum!(ItemKind; ExternCrate(0) Use(0) Static(0 1 2) Const(0 1 2) Union(0 1) Trait(0) TraitAlias(0 1) Impl(0) MacCall(0) MacroDef(0)); spanless_eq_enum!(LitKind; Str(0 1) ByteStr(0) Byte(0) Char(0) Int(0 1) Float(0 1) Bool(0) Err(0)); -spanless_eq_enum!(PatKind; Wild Ident(0 1 2) Struct(0 1 2) TupleStruct(0 1) +spanless_eq_enum!(PatKind; Wild Ident(0 1 2) Struct(0 1 2 3) TupleStruct(0 1 2) Or(0) Path(0 1) Tuple(0) Box(0) Ref(0 1) Lit(0) Range(0 1 2) Slice(0) Rest Paren(0) MacCall(0)); spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Rptr(0 1) BareFn(0) Never diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs index 3964176d..58c239ac 100644 --- a/tests/repo/mod.rs +++ b/tests/repo/mod.rs @@ -26,6 +26,9 @@ static EXCLUDE: &[&str] = &[ "src/test/ui/issues/issue-34074.rs", "src/test/ui/proc-macro/trait-fn-args-2015.rs", + // Excessive nesting + "src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs", + // Not actually test cases "src/test/rustdoc-ui/test-compile-fail2.rs", "src/test/rustdoc-ui/test-compile-fail3.rs", diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs index 3eb2d348..b4526308 100644 --- a/tests/test_precedence.rs +++ b/tests/test_precedence.rs @@ -151,7 +151,7 @@ fn test_expressions(edition: Edition, exprs: Vec<syn::Expr>) -> (usize, usize) { let mut passed = 0; let mut failed = 0; - rustc_span::with_session_globals(edition, || { + rustc_span::create_session_if_not_set_then(edition, |_| { for expr in exprs { let raw = quote!(#expr).to_string(); @@ -240,7 +240,13 @@ fn librustc_brackets(mut librustc_expr: P<ast::Expr>) -> Option<P<ast::Expr>> { match &mut e.kind { ExprKind::AddrOf(BorrowKind::Raw, ..) => {} ExprKind::Struct(expr) => { - let StructExpr { path, fields, rest } = expr.deref_mut(); + let StructExpr { + qself, + path, + fields, + rest, + } = expr.deref_mut(); + vis.visit_qself(qself); vis.visit_path(path); fields.flat_map_in_place(|field| flat_map_field(field, vis)); if let StructRest::Base(rest) = rest { diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs index e8ed3454..0be16eb4 100644 --- a/tests/test_round_trip.rs +++ b/tests/test_round_trip.rs @@ -85,7 +85,7 @@ fn test(path: &Path, failed: &AtomicUsize, abort_after: usize) { let back = quote!(#krate).to_string(); let edition = repo::edition(path).parse().unwrap(); - rustc_span::with_session_globals(edition, || { + rustc_span::create_session_if_not_set_then(edition, |_| { let equal = match panic::catch_unwind(|| { let sess = ParseSess::new(FilePathMapping::empty()); let before = match librustc_parse(content, &sess) { diff --git a/tests/test_ty.rs b/tests/test_ty.rs index 7e20dd99..907fb201 100644 --- a/tests/test_ty.rs +++ b/tests/test_ty.rs @@ -217,3 +217,71 @@ fn test_group_colons() { } "###); } + +#[test] +fn test_trait_object() { + let tokens = quote!(dyn for<'a> Trait<'a> + 'static); + snapshot!(tokens as Type, @r###" + Type::TraitObject { + dyn_token: Some, + bounds: [ + Trait(TraitBound { + modifier: None, + lifetimes: Some(BoundLifetimes { + lifetimes: [ + LifetimeDef { + lifetime: Lifetime { + ident: "a", + }, + }, + ], + }), + path: Path { + segments: [ + PathSegment { + ident: "Trait", + arguments: PathArguments::AngleBracketed { + args: [ + Lifetime(Lifetime { + ident: "a", + }), + ], + }, + }, + ], + }, + }), + Lifetime(Lifetime { + ident: "static", + }), + ], + } + "###); + + let tokens = quote!(dyn 'a + Trait); + snapshot!(tokens as Type, @r###" + Type::TraitObject { + dyn_token: Some, + bounds: [ + Lifetime(Lifetime { + ident: "a", + }), + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Trait", + arguments: None, + }, + ], + }, + }), + ], + } + "###); + + // None of the following are valid Rust types. + syn::parse_str::<Type>("for<'a> dyn Trait<'a>").unwrap_err(); + syn::parse_str::<Type>("dyn for<'a> 'a + Trait").unwrap_err(); +} |