diff options
author | Chih-Hung Hsieh <chh@google.com> | 2020-04-16 17:09:06 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2020-04-16 17:09:06 -0700 |
commit | 725b6eca99d4a90c8e6db5d6311e776be20cc9a8 (patch) | |
tree | 918149bd0b92ffcc7001bf2d5e8b85fd3446571f | |
parent | 3d045a538309e03e999b539d5b760bb495ccf780 (diff) | |
download | syn-725b6eca99d4a90c8e6db5d6311e776be20cc9a8.tar.gz |
Upgrade to version 1.0.17
Test: make
Change-Id: I2ecb37bf167a85b96c0be6893a40482a7b6a4fa8
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | Cargo.toml.orig | 3 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | benches/rust.rs | 15 | ||||
-rw-r--r-- | src/expr.rs | 2 | ||||
-rw-r--r-- | src/gen/fold.rs | 16 | ||||
-rw-r--r-- | src/gen/visit.rs | 17 | ||||
-rw-r--r-- | src/gen/visit_mut.rs | 17 | ||||
-rw-r--r-- | src/lib.rs | 6 | ||||
-rw-r--r-- | src/lit.rs | 27 | ||||
-rw-r--r-- | src/parse.rs | 6 | ||||
-rw-r--r-- | tests/common/eq.rs | 66 | ||||
-rw-r--r-- | tests/common/parse.rs | 6 | ||||
-rw-r--r-- | tests/repo/mod.rs | 1 | ||||
-rw-r--r-- | tests/test_precedence.rs | 20 | ||||
-rw-r--r-- | tests/test_round_trip.rs | 6 |
17 files changed, 75 insertions, 144 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 1339f731..95efb3e3 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "b76945a91ff2e6cccbab7d5dd09dbdfea300571d" + "sha1": "41043311ca07560a41b8063bed3e7f806826169f" } } @@ -13,7 +13,7 @@ [package] edition = "2018" name = "syn" -version = "1.0.16" +version = "1.0.17" 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" @@ -24,6 +24,7 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/syn" [package.metadata.docs.rs] all-features = true +targets = ["x86_64-unknown-linux-gnu"] [package.metadata.playground] all-features = true diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 79e5dc6e..832bb238 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "syn" -version = "1.0.16" # don't forget to update html_root_url and syn.json +version = "1.0.17" # 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" @@ -61,6 +61,7 @@ required-features = ["full", "parsing"] [package.metadata.docs.rs] all-features = true +targets = ["x86_64-unknown-linux-gnu"] [package.metadata.playground] all-features = true @@ -9,10 +9,10 @@ third_party { type: GIT value: "https://github.com/dtolnay/syn" } - version: "1.0.16" + version: "1.0.17" last_upgrade_date { year: 2020 - month: 3 - day: 20 + month: 4 + day: 16 } } diff --git a/benches/rust.rs b/benches/rust.rs index 941ecb90..b4c5732c 100644 --- a/benches/rust.rs +++ b/benches/rust.rs @@ -36,17 +36,18 @@ mod syn_parse { #[cfg(not(syn_only))] mod libsyntax_parse { + extern crate rustc_ast; extern crate rustc_data_structures; + extern crate rustc_errors; extern crate rustc_parse; + extern crate rustc_session; extern crate rustc_span; - extern crate syntax; use rustc_data_structures::sync::Lrc; - use rustc_span::FileName; - use syntax::edition::Edition; - use syntax::errors::{emitter::Emitter, Diagnostic, Handler}; - use syntax::sess::ParseSess; - use syntax::source_map::{FilePathMapping, SourceMap}; + use rustc_errors::{emitter::Emitter, Diagnostic, Handler}; + use rustc_session::parse::ParseSess; + use rustc_span::source_map::{FilePathMapping, SourceMap}; + use rustc_span::{edition::Edition, FileName}; pub fn bench(content: &str) -> Result<(), ()> { struct SilentEmitter; @@ -58,7 +59,7 @@ mod libsyntax_parse { } } - syntax::with_globals(Edition::Edition2018, || { + rustc_ast::with_globals(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/expr.rs b/src/expr.rs index b40f1caa..58d6eda7 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -15,7 +15,7 @@ ast_enum_of_structs! { /// A Rust expression. /// /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* + /// feature, but most of the variants are not available unless "full" is enabled.* /// /// # Syntax tree enums /// diff --git a/src/gen/fold.rs b/src/gen/fold.rs index f51218b7..97491b4b 100644 --- a/src/gen/fold.rs +++ b/src/gen/fold.rs @@ -433,35 +433,27 @@ pub trait Fold { fn fold_lifetime_def(&mut self, i: LifetimeDef) -> LifetimeDef { fold_lifetime_def(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_lit(&mut self, i: Lit) -> Lit { fold_lit(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_lit_bool(&mut self, i: LitBool) -> LitBool { fold_lit_bool(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_lit_byte(&mut self, i: LitByte) -> LitByte { fold_lit_byte(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_lit_byte_str(&mut self, i: LitByteStr) -> LitByteStr { fold_lit_byte_str(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_lit_char(&mut self, i: LitChar) -> LitChar { fold_lit_char(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_lit_float(&mut self, i: LitFloat) -> LitFloat { fold_lit_float(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_lit_int(&mut self, i: LitInt) -> LitInt { fold_lit_int(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_lit_str(&mut self, i: LitStr) -> LitStr { fold_lit_str(self, i) } @@ -2189,7 +2181,6 @@ where bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), } } -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_lit<F>(f: &mut F, node: Lit) -> Lit where F: Fold + ?Sized, @@ -2205,7 +2196,6 @@ where Lit::Verbatim(_binding_0) => Lit::Verbatim(_binding_0), } } -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_lit_bool<F>(f: &mut F, node: LitBool) -> LitBool where F: Fold + ?Sized, @@ -2215,7 +2205,6 @@ where span: f.fold_span(node.span), } } -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_lit_byte<F>(f: &mut F, node: LitByte) -> LitByte where F: Fold + ?Sized, @@ -2225,7 +2214,6 @@ where node.set_span(span); node } -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_lit_byte_str<F>(f: &mut F, node: LitByteStr) -> LitByteStr where F: Fold + ?Sized, @@ -2235,7 +2223,6 @@ where node.set_span(span); node } -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_lit_char<F>(f: &mut F, node: LitChar) -> LitChar where F: Fold + ?Sized, @@ -2245,7 +2232,6 @@ where node.set_span(span); node } -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_lit_float<F>(f: &mut F, node: LitFloat) -> LitFloat where F: Fold + ?Sized, @@ -2255,7 +2241,6 @@ where node.set_span(span); node } -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_lit_int<F>(f: &mut F, node: LitInt) -> LitInt where F: Fold + ?Sized, @@ -2265,7 +2250,6 @@ where node.set_span(span); node } -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_lit_str<F>(f: &mut F, node: LitStr) -> LitStr where F: Fold + ?Sized, diff --git a/src/gen/visit.rs b/src/gen/visit.rs index b667f530..abae5f74 100644 --- a/src/gen/visit.rs +++ b/src/gen/visit.rs @@ -20,7 +20,6 @@ macro_rules! full { unreachable!() }; } -#[cfg(any(feature = "full", feature = "derive"))] macro_rules! skip { ($($tt:tt)*) => {}; } @@ -434,35 +433,27 @@ pub trait Visit<'ast> { fn visit_lifetime_def(&mut self, i: &'ast LifetimeDef) { visit_lifetime_def(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit(&mut self, i: &'ast Lit) { visit_lit(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_bool(&mut self, i: &'ast LitBool) { visit_lit_bool(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_byte(&mut self, i: &'ast LitByte) { visit_lit_byte(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_byte_str(&mut self, i: &'ast LitByteStr) { visit_lit_byte_str(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_char(&mut self, i: &'ast LitChar) { visit_lit_char(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_float(&mut self, i: &'ast LitFloat) { visit_lit_float(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_int(&mut self, i: &'ast LitInt) { visit_lit_int(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_str(&mut self, i: &'ast LitStr) { visit_lit_str(self, i) } @@ -2537,7 +2528,6 @@ where } } } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit<'ast, V>(v: &mut V, node: &'ast Lit) where V: Visit<'ast> + ?Sized, @@ -2569,7 +2559,6 @@ where } } } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_bool<'ast, V>(v: &mut V, node: &'ast LitBool) where V: Visit<'ast> + ?Sized, @@ -2577,37 +2566,31 @@ where skip!(node.value); v.visit_span(&node.span); } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_byte<'ast, V>(v: &mut V, node: &'ast LitByte) where V: Visit<'ast> + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_byte_str<'ast, V>(v: &mut V, node: &'ast LitByteStr) where V: Visit<'ast> + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_char<'ast, V>(v: &mut V, node: &'ast LitChar) where V: Visit<'ast> + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_float<'ast, V>(v: &mut V, node: &'ast LitFloat) where V: Visit<'ast> + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_int<'ast, V>(v: &mut V, node: &'ast LitInt) where V: Visit<'ast> + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_str<'ast, V>(v: &mut V, node: &'ast LitStr) where V: Visit<'ast> + ?Sized, diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs index 5cddb827..9b4e3e5b 100644 --- a/src/gen/visit_mut.rs +++ b/src/gen/visit_mut.rs @@ -20,7 +20,6 @@ macro_rules! full { unreachable!() }; } -#[cfg(any(feature = "full", feature = "derive"))] macro_rules! skip { ($($tt:tt)*) => {}; } @@ -438,35 +437,27 @@ pub trait VisitMut { fn visit_lifetime_def_mut(&mut self, i: &mut LifetimeDef) { visit_lifetime_def_mut(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_mut(&mut self, i: &mut Lit) { visit_lit_mut(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_bool_mut(&mut self, i: &mut LitBool) { visit_lit_bool_mut(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_byte_mut(&mut self, i: &mut LitByte) { visit_lit_byte_mut(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_byte_str_mut(&mut self, i: &mut LitByteStr) { visit_lit_byte_str_mut(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_char_mut(&mut self, i: &mut LitChar) { visit_lit_char_mut(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_float_mut(&mut self, i: &mut LitFloat) { visit_lit_float_mut(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_int_mut(&mut self, i: &mut LitInt) { visit_lit_int_mut(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_lit_str_mut(&mut self, i: &mut LitStr) { visit_lit_str_mut(self, i) } @@ -2543,7 +2534,6 @@ where } } } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_mut<V>(v: &mut V, node: &mut Lit) where V: VisitMut + ?Sized, @@ -2575,7 +2565,6 @@ where } } } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_bool_mut<V>(v: &mut V, node: &mut LitBool) where V: VisitMut + ?Sized, @@ -2583,37 +2572,31 @@ where skip!(node.value); v.visit_span_mut(&mut node.span); } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_byte_mut<V>(v: &mut V, node: &mut LitByte) where V: VisitMut + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_byte_str_mut<V>(v: &mut V, node: &mut LitByteStr) where V: VisitMut + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_char_mut<V>(v: &mut V, node: &mut LitChar) where V: VisitMut + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_float_mut<V>(v: &mut V, node: &mut LitFloat) where V: VisitMut + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_int_mut<V>(v: &mut V, node: &mut LitInt) where V: VisitMut + ?Sized, { } -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_lit_str_mut<V>(v: &mut V, node: &mut LitStr) where V: VisitMut + ?Sized, @@ -242,7 +242,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.16")] +#![doc(html_root_url = "https://docs.rs/syn/1.0.17")] #![deny(clippy::all, clippy::pedantic)] // Ignored clippy lints. #![allow( @@ -289,7 +289,6 @@ extern crate unicode_xid; #[cfg(feature = "printing")] extern crate quote; -#[cfg(any(feature = "full", feature = "derive"))] #[macro_use] mod macros; @@ -312,7 +311,6 @@ pub use crate::attr::{ AttrStyle, Attribute, AttributeArgs, Meta, MetaList, MetaNameValue, NestedMeta, }; -#[cfg(any(feature = "full", feature = "derive"))] mod bigint; #[cfg(any(feature = "full", feature = "derive"))] @@ -369,9 +367,7 @@ pub use crate::file::File; mod lifetime; pub use crate::lifetime::Lifetime; -#[cfg(any(feature = "full", feature = "derive"))] mod lit; -#[cfg(any(feature = "full", feature = "derive"))] pub use crate::lit::{ Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, StrStyle, }; @@ -22,9 +22,6 @@ use crate::{Error, Result}; ast_enum_of_structs! { /// A Rust literal such as a string or integer or boolean. /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. @@ -64,9 +61,6 @@ ast_enum_of_structs! { ast_struct! { /// A UTF-8 string literal: `"foo"`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* pub struct LitStr #manual_extra_traits_debug { repr: Box<LitStrRepr>, } @@ -80,9 +74,6 @@ struct LitStrRepr { ast_struct! { /// A byte string literal: `b"foo"`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* pub struct LitByteStr #manual_extra_traits_debug { token: Literal, } @@ -90,9 +81,6 @@ ast_struct! { ast_struct! { /// A byte literal: `b'f'`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* pub struct LitByte #manual_extra_traits_debug { token: Literal, } @@ -100,9 +88,6 @@ ast_struct! { ast_struct! { /// A character literal: `'a'`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* pub struct LitChar #manual_extra_traits_debug { token: Literal, } @@ -110,9 +95,6 @@ ast_struct! { ast_struct! { /// An integer literal: `1` or `1u16`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* pub struct LitInt #manual_extra_traits_debug { repr: Box<LitIntRepr>, } @@ -129,9 +111,6 @@ ast_struct! { /// A floating point literal: `1f64` or `1.0e10f64`. /// /// Must be finite. May not be infinte or NaN. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* pub struct LitFloat #manual_extra_traits_debug { repr: Box<LitFloatRepr>, } @@ -146,9 +125,6 @@ struct LitFloatRepr { ast_struct! { /// A boolean literal: `true` or `false`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* pub struct LitBool #manual_extra_traits_debug { pub value: bool, pub span: Span, @@ -678,9 +654,6 @@ lit_extra_traits!(LitBool, value); ast_enum! { /// The style of a string literal, either plain quoted or a raw string like /// `r##"data"##`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* pub enum StrStyle #no_visit { /// An ordinary string like `"data"`. Cooked, diff --git a/src/parse.rs b/src/parse.rs index 96eecce6..fd53b634 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1117,6 +1117,7 @@ pub trait Parser: Sized { // Not public API. #[doc(hidden)] + #[cfg(any(feature = "full", feature = "derive"))] fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> { let _ = scope; self.parse2(tokens) @@ -1124,6 +1125,7 @@ pub trait Parser: Sized { // Not public API. #[doc(hidden)] + #[cfg(any(feature = "full", feature = "derive"))] fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> { input.parse().and_then(|tokens| self.parse2(tokens)) } @@ -1155,6 +1157,7 @@ where } #[doc(hidden)] + #[cfg(any(feature = "full", feature = "derive"))] fn __parse_scoped(self, scope: Span, tokens: TokenStream) -> Result<Self::Output> { let buf = TokenBuffer::new2(tokens); let cursor = buf.begin(); @@ -1170,15 +1173,18 @@ where } #[doc(hidden)] + #[cfg(any(feature = "full", feature = "derive"))] fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> { self(input) } } +#[cfg(any(feature = "full", feature = "derive"))] pub(crate) fn parse_scoped<F: Parser>(f: F, scope: Span, tokens: TokenStream) -> Result<F::Output> { f.__parse_scoped(scope, tokens) } +#[cfg(any(feature = "full", feature = "derive"))] pub(crate) fn parse_stream<F: Parser>(f: F, input: ParseStream) -> Result<F::Output> { f.__parse_stream(input) } diff --git a/tests/common/eq.rs b/tests/common/eq.rs index e03b25be..c48e4f6a 100644 --- a/tests/common/eq.rs +++ b/tests/common/eq.rs @@ -1,33 +1,33 @@ +extern crate rustc_ast; extern crate rustc_data_structures; extern crate rustc_span; extern crate rustc_target; -extern crate syntax; use std::mem; -use rustc_data_structures::sync::Lrc; -use rustc_data_structures::thin_vec::ThinVec; -use rustc_span::source_map::Spanned; -use rustc_span::{sym, Span, Symbol, SyntaxContext, DUMMY_SP}; -use syntax::ast::{ - AngleBracketedArgs, AnonConst, Arm, AsmDialect, AssocItem, AssocItemKind, AssocTyConstraint, +use rustc_ast::ast::{ + AngleBracketedArgs, AnonConst, Arm, AsmDialect, AssocItemKind, AssocTyConstraint, AssocTyConstraintKind, Async, AttrId, AttrItem, AttrKind, AttrStyle, Attribute, BareFnTy, BinOpKind, BindingMode, Block, BlockCheckMode, BorrowKind, CaptureBy, Const, Crate, CrateSugar, Defaultness, EnumDef, Expr, ExprKind, Extern, Field, FieldPat, FloatTy, FnDecl, FnHeader, - FnRetTy, FnSig, ForeignMod, GenericArg, GenericArgs, GenericBound, GenericParam, - GenericParamKind, Generics, GlobalAsm, Ident, ImplPolarity, InlineAsm, InlineAsmOutput, IntTy, - IsAuto, Item, ItemKind, Label, Lifetime, Lit, LitFloatType, LitIntType, LitKind, Local, Mac, - MacArgs, MacDelimiter, MacStmtStyle, MacroDef, Mod, Movability, MutTy, Mutability, NodeId, - Param, ParenthesizedArgs, Pat, PatKind, Path, PathSegment, PolyTraitRef, QSelf, RangeEnd, - RangeLimits, RangeSyntax, Stmt, StmtKind, StrLit, StrStyle, StructField, TraitBoundModifier, - TraitObjectSyntax, TraitRef, Ty, TyKind, UintTy, UnOp, Unsafe, UnsafeSource, UseTree, - UseTreeKind, Variant, VariantData, VisibilityKind, WhereBoundPredicate, WhereClause, - WhereEqPredicate, WherePredicate, WhereRegionPredicate, + FnRetTy, FnSig, ForeignItemKind, ForeignMod, GenericArg, GenericArgs, GenericBound, + GenericParam, GenericParamKind, Generics, GlobalAsm, Ident, ImplPolarity, InlineAsm, + InlineAsmOutput, IntTy, IsAuto, Item, ItemKind, Label, Lifetime, Lit, LitFloatType, LitIntType, + LitKind, Local, MacArgs, MacCall, MacDelimiter, MacStmtStyle, MacroDef, Mod, Movability, MutTy, + Mutability, NodeId, Param, ParenthesizedArgs, Pat, PatKind, Path, PathSegment, PolyTraitRef, + QSelf, RangeEnd, RangeLimits, RangeSyntax, Stmt, StmtKind, StrLit, StrStyle, StructField, + TraitBoundModifier, TraitObjectSyntax, TraitRef, Ty, TyKind, UintTy, UnOp, Unsafe, + UnsafeSource, UseTree, UseTreeKind, Variant, VariantData, VisibilityKind, WhereBoundPredicate, + WhereClause, WhereEqPredicate, WherePredicate, WhereRegionPredicate, }; -use syntax::ptr::P; -use syntax::token::{self, DelimToken, Token, TokenKind}; -use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree}; -use syntax::util::comments; +use rustc_ast::ptr::P; +use rustc_ast::token::{self, DelimToken, Token, TokenKind}; +use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; +use rustc_ast::util::comments; +use rustc_data_structures::sync::Lrc; +use rustc_data_structures::thin_vec::ThinVec; +use rustc_span::source_map::Spanned; +use rustc_span::{sym, Span, Symbol, SyntaxContext, DUMMY_SP}; pub trait SpanlessEq { fn eq(&self, other: &Self) -> bool; @@ -262,7 +262,6 @@ macro_rules! spanless_eq_enum { spanless_eq_struct!(AngleBracketedArgs; span args constraints); spanless_eq_struct!(AnonConst; id value); spanless_eq_struct!(Arm; attrs pat guard body span id is_placeholder); -spanless_eq_struct!(AssocItem; attrs id span vis ident defaultness kind !tokens); spanless_eq_struct!(AssocTyConstraint; id ident kind span); spanless_eq_struct!(AttrItem; path args); spanless_eq_struct!(Attribute; kind id style span); @@ -287,8 +286,8 @@ spanless_eq_struct!(Label; ident); spanless_eq_struct!(Lifetime; id ident); spanless_eq_struct!(Lit; token kind span); spanless_eq_struct!(Local; pat ty init id span attrs); -spanless_eq_struct!(Mac; path args prior_type_ascription); -spanless_eq_struct!(MacroDef; body legacy); +spanless_eq_struct!(MacCall; path args prior_type_ascription); +spanless_eq_struct!(MacroDef; body macro_rules); spanless_eq_struct!(Mod; inner items inline); spanless_eq_struct!(MutTy; ty mutbl); spanless_eq_struct!(Param; attrs ty pat id span is_placeholder); @@ -311,7 +310,7 @@ spanless_eq_struct!(WhereClause; predicates span); spanless_eq_struct!(WhereEqPredicate; id span lhs_ty rhs_ty); spanless_eq_struct!(WhereRegionPredicate; span lifetime bounds); spanless_eq_enum!(AsmDialect; Att Intel); -spanless_eq_enum!(AssocItemKind; Const(0 1) Static(0 1 2) Fn(0 1 2) TyAlias(0 1 2) Macro(0)); +spanless_eq_enum!(AssocItemKind; Const(0 1 2) Fn(0 1 2 3) TyAlias(0 1 2 3) MacCall(0)); spanless_eq_enum!(AssocTyConstraintKind; Equality(ty) Bound(bounds)); spanless_eq_enum!(Async; Yes(span closure_id return_impl_trait_id) No); spanless_eq_enum!(AttrKind; Normal(0) DocComment(0)); @@ -323,15 +322,16 @@ spanless_eq_enum!(BorrowKind; Ref Raw); spanless_eq_enum!(CaptureBy; Value Ref); spanless_eq_enum!(Const; Yes(0) No); spanless_eq_enum!(CrateSugar; PubCrate JustCrate); -spanless_eq_enum!(Defaultness; Default Final); +spanless_eq_enum!(Defaultness; Default(0) Final); spanless_eq_enum!(Extern; None Implicit Explicit(0)); spanless_eq_enum!(FloatTy; F32 F64); spanless_eq_enum!(FnRetTy; Default(0) Ty(0)); +spanless_eq_enum!(ForeignItemKind; Static(0 1 2) Fn(0 1 2 3) TyAlias(0 1 2 3) MacCall(0)); spanless_eq_enum!(GenericArg; Lifetime(0) Type(0) Const(0)); spanless_eq_enum!(GenericArgs; AngleBracketed(0) Parenthesized(0)); spanless_eq_enum!(GenericBound; Trait(0 1) Outlives(0)); spanless_eq_enum!(GenericParamKind; Lifetime Type(default) Const(ty)); -spanless_eq_enum!(ImplPolarity; Positive Negative); +spanless_eq_enum!(ImplPolarity; Positive Negative(0)); spanless_eq_enum!(IntTy; Isize I8 I16 I32 I64 I128); spanless_eq_enum!(IsAuto; Yes No); spanless_eq_enum!(LitFloatType; Suffixed(0) Unsuffixed); @@ -343,7 +343,7 @@ spanless_eq_enum!(Movability; Static Movable); spanless_eq_enum!(Mutability; Mut Not); spanless_eq_enum!(RangeEnd; Included(0) Excluded); spanless_eq_enum!(RangeLimits; HalfOpen Closed); -spanless_eq_enum!(StmtKind; Local(0) Item(0) Expr(0) Semi(0) Mac(0)); +spanless_eq_enum!(StmtKind; Local(0) Item(0) Expr(0) Semi(0) Empty MacCall(0)); spanless_eq_enum!(StrStyle; Cooked Raw(0)); spanless_eq_enum!(TokenTree; Token(0) Delimited(0 1 2)); spanless_eq_enum!(TraitBoundModifier; None Maybe MaybeConst MaybeConstMaybe); @@ -361,21 +361,21 @@ spanless_eq_enum!(ExprKind; Box(0) Array(0) Call(0 1) MethodCall(0 1) Tup(0) While(0 1 2) ForLoop(0 1 2 3) Loop(0 1) Match(0 1) Closure(0 1 2 3 4 5) Block(0 1) Async(0 1 2) Await(0) TryBlock(0) Assign(0 1 2) AssignOp(0 1 2) Field(0 1) Index(0 1) Range(0 1 2) Path(0 1) AddrOf(0 1 2) Break(0 1) - Continue(0) Ret(0) InlineAsm(0) Mac(0) Struct(0 1 2) Repeat(0 1) Paren(0) + Continue(0) Ret(0) InlineAsm(0) MacCall(0) Struct(0 1 2) Repeat(0 1) Paren(0) Try(0) Yield(0) Err); -spanless_eq_enum!(ItemKind; ExternCrate(0) Use(0) Static(0 1 2) Const(0 1) - Fn(0 1 2) Mod(0) ForeignMod(0) GlobalAsm(0) TyAlias(0 1 2) Enum(0 1) +spanless_eq_enum!(ItemKind; ExternCrate(0) Use(0) Static(0 1 2) Const(0 1 2) + Fn(0 1 2 3) Mod(0) ForeignMod(0) GlobalAsm(0) TyAlias(0 1 2 3) Enum(0 1) Struct(0 1) Union(0 1) Trait(0 1 2 3 4) TraitAlias(0 1) Impl(unsafety polarity defaultness constness generics of_trait self_ty items) - Mac(0) MacroDef(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) Or(0) Path(0 1) Tuple(0) Box(0) Ref(0 1) Lit(0) Range(0 1 2) Slice(0) Rest - Paren(0) Mac(0)); + Paren(0) MacCall(0)); spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Rptr(0 1) BareFn(0) Never Tup(0) Path(0 1) TraitObject(0 1) ImplTrait(0 1) Paren(0) Typeof(0) Infer - ImplicitSelf Mac(0) Err CVarArgs); + ImplicitSelf MacCall(0) Err CVarArgs); impl SpanlessEq for Ident { fn eq(&self, other: &Self) -> bool { diff --git a/tests/common/parse.rs b/tests/common/parse.rs index acdd172f..689289da 100644 --- a/tests/common/parse.rs +++ b/tests/common/parse.rs @@ -1,14 +1,14 @@ +extern crate rustc_ast; extern crate rustc_expand; extern crate rustc_parse as parse; extern crate rustc_session; extern crate rustc_span; -extern crate syntax; +use rustc_ast::ast; +use rustc_ast::ptr::P; use rustc_session::parse::ParseSess; use rustc_span::source_map::FilePathMapping; use rustc_span::FileName; -use syntax::ast; -use syntax::ptr::P; use std::panic; diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs index 6ab8d2e2..c1dc7e0a 100644 --- a/tests/repo/mod.rs +++ b/tests/repo/mod.rs @@ -124,6 +124,7 @@ pub fn base_dir_filter(entry: &DirEntry) -> bool { "test/ui/include-single-expr-helper.rs" | "test/ui/include-single-expr-helper-1.rs" | "test/ui/issues/auxiliary/issue-21146-inc.rs" | + "test/ui/json-bom-plus-crlf-multifile-aux.rs" | "test/ui/macros/auxiliary/macro-comma-support.rs" | "test/ui/macros/auxiliary/macro-include-items-expr.rs" => false, diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs index 80f51308..fe2b7642 100644 --- a/tests/test_precedence.rs +++ b/tests/test_precedence.rs @@ -14,18 +14,18 @@ //! spans. //! 5. Compare the expressions with one another, if they are not equal fail. +extern crate rustc_ast; extern crate rustc_data_structures; extern crate rustc_span; -extern crate syntax; mod features; use quote::quote; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use regex::Regex; +use rustc_ast::ast; +use rustc_ast::ptr::P; use rustc_span::edition::Edition; -use syntax::ast; -use syntax::ptr::P; use walkdir::{DirEntry, WalkDir}; use std::fs::File; @@ -165,7 +165,7 @@ fn test_expressions(exprs: Vec<syn::Expr>) -> (usize, usize) { let mut passed = 0; let mut failed = 0; - syntax::with_globals(Edition::Edition2018, || { + rustc_ast::with_globals(Edition::Edition2018, || { for expr in exprs { let raw = quote!(#expr).to_string(); @@ -208,12 +208,14 @@ fn libsyntax_parse_and_rewrite(input: &str) -> Option<P<ast::Expr>> { /// /// This method operates on libsyntax objects. fn libsyntax_brackets(mut libsyntax_expr: P<ast::Expr>) -> Option<P<ast::Expr>> { + use rustc_ast::ast::{ + Block, BorrowKind, Expr, ExprKind, Field, MacCall, Pat, Stmt, StmtKind, Ty, + }; + use rustc_ast::mut_visit::MutVisitor; + use rustc_ast::util::map_in_place::MapInPlace; use rustc_data_structures::thin_vec::ThinVec; use rustc_span::DUMMY_SP; use std::mem; - use syntax::ast::{Block, BorrowKind, Expr, ExprKind, Field, Mac, Pat, Stmt, StmtKind, Ty}; - use syntax::mut_visit::MutVisitor; - use syntax::util::map_in_place::MapInPlace; struct BracketsVisitor { failed: bool, @@ -246,7 +248,7 @@ fn libsyntax_brackets(mut libsyntax_expr: P<ast::Expr>) -> Option<P<ast::Expr>> } fn noop_visit_expr<T: MutVisitor>(e: &mut Expr, vis: &mut T) { - use syntax::mut_visit::{noop_visit_expr, visit_opt, visit_thin_attrs}; + use rustc_ast::mut_visit::{noop_visit_expr, visit_opt, visit_thin_attrs}; match &mut e.kind { ExprKind::AddrOf(BorrowKind::Raw, ..) => {} ExprKind::Struct(path, fields, expr) => { @@ -300,7 +302,7 @@ fn libsyntax_brackets(mut libsyntax_expr: P<ast::Expr>) -> Option<P<ast::Expr>> let _ = ty; } - fn visit_mac(&mut self, mac: &mut Mac) { + fn visit_mac(&mut self, mac: &mut MacCall) { // By default when folding over macros, libsyntax panics. This is // because it's usually not what you want, you want to run after // macro expansion. We do want to do that (syn doesn't do macro diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs index a7e48c84..d4f525b1 100644 --- a/tests/test_round_trip.rs +++ b/tests/test_round_trip.rs @@ -2,23 +2,23 @@ #![recursion_limit = "1024"] #![feature(rustc_private)] +extern crate rustc_ast; extern crate rustc_errors; extern crate rustc_expand; extern crate rustc_parse as parse; extern crate rustc_session; extern crate rustc_span; -extern crate syntax; mod features; use quote::quote; use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use rustc_ast::ast; use rustc_errors::PResult; use rustc_session::parse::ParseSess; use rustc_span::edition::Edition; use rustc_span::source_map::FilePathMapping; use rustc_span::FileName; -use syntax::ast; use walkdir::{DirEntry, WalkDir}; use std::fs::File; @@ -80,7 +80,7 @@ fn test_round_trip() { let back = quote!(#krate).to_string(); let equal = panic::catch_unwind(|| { - syntax::with_globals(Edition::Edition2018, || { + rustc_ast::with_globals(Edition::Edition2018, || { let sess = ParseSess::new(FilePathMapping::empty()); let before = match libsyntax_parse(content, &sess) { Ok(before) => before, |