aboutsummaryrefslogtreecommitdiff
path: root/vendor/syn/tests/test_item.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/syn/tests/test_item.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/syn/tests/test_item.rs')
-rw-r--r--vendor/syn/tests/test_item.rs332
1 files changed, 0 insertions, 332 deletions
diff --git a/vendor/syn/tests/test_item.rs b/vendor/syn/tests/test_item.rs
deleted file mode 100644
index db9e3ab..0000000
--- a/vendor/syn/tests/test_item.rs
+++ /dev/null
@@ -1,332 +0,0 @@
-#![allow(clippy::uninlined_format_args)]
-
-#[macro_use]
-mod macros;
-
-use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
-use quote::quote;
-use syn::{Item, ItemTrait};
-
-#[test]
-fn test_macro_variable_attr() {
- // mimics the token stream corresponding to `$attr fn f() {}`
- let tokens = TokenStream::from_iter(vec![
- TokenTree::Group(Group::new(Delimiter::None, quote! { #[test] })),
- TokenTree::Ident(Ident::new("fn", Span::call_site())),
- TokenTree::Ident(Ident::new("f", Span::call_site())),
- TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
- TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
- ]);
-
- snapshot!(tokens as Item, @r###"
- Item::Fn {
- attrs: [
- Attribute {
- style: AttrStyle::Outer,
- meta: Meta::Path {
- segments: [
- PathSegment {
- ident: "test",
- },
- ],
- },
- },
- ],
- vis: Visibility::Inherited,
- sig: Signature {
- ident: "f",
- generics: Generics,
- output: ReturnType::Default,
- },
- block: Block {
- stmts: [],
- },
- }
- "###);
-}
-
-#[test]
-fn test_negative_impl() {
- // Rustc parses all of the following.
-
- #[cfg(any())]
- impl ! {}
- let tokens = quote! {
- impl ! {}
- };
- snapshot!(tokens as Item, @r###"
- Item::Impl {
- generics: Generics,
- self_ty: Type::Never,
- }
- "###);
-
- #[cfg(any())]
- #[rustfmt::skip]
- impl !Trait {}
- let tokens = quote! {
- impl !Trait {}
- };
- snapshot!(tokens as Item, @r###"
- Item::Impl {
- generics: Generics,
- self_ty: Type::Verbatim(`! Trait`),
- }
- "###);
-
- #[cfg(any())]
- impl !Trait for T {}
- let tokens = quote! {
- impl !Trait for T {}
- };
- snapshot!(tokens as Item, @r###"
- Item::Impl {
- generics: Generics,
- trait_: Some((
- Some,
- Path {
- segments: [
- PathSegment {
- ident: "Trait",
- },
- ],
- },
- )),
- self_ty: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "T",
- },
- ],
- },
- },
- }
- "###);
-
- #[cfg(any())]
- #[rustfmt::skip]
- impl !! {}
- let tokens = quote! {
- impl !! {}
- };
- snapshot!(tokens as Item, @r###"
- Item::Impl {
- generics: Generics,
- self_ty: Type::Verbatim(`! !`),
- }
- "###);
-}
-
-#[test]
-fn test_macro_variable_impl() {
- // mimics the token stream corresponding to `impl $trait for $ty {}`
- let tokens = TokenStream::from_iter(vec![
- TokenTree::Ident(Ident::new("impl", Span::call_site())),
- TokenTree::Group(Group::new(Delimiter::None, quote!(Trait))),
- TokenTree::Ident(Ident::new("for", Span::call_site())),
- TokenTree::Group(Group::new(Delimiter::None, quote!(Type))),
- TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
- ]);
-
- snapshot!(tokens as Item, @r###"
- Item::Impl {
- generics: Generics,
- trait_: Some((
- None,
- Path {
- segments: [
- PathSegment {
- ident: "Trait",
- },
- ],
- },
- )),
- self_ty: Type::Group {
- elem: Type::Path {
- path: Path {
- segments: [
- PathSegment {
- ident: "Type",
- },
- ],
- },
- },
- },
- }
- "###);
-}
-
-#[test]
-fn test_supertraits() {
- // Rustc parses all of the following.
-
- #[rustfmt::skip]
- let tokens = quote!(trait Trait where {});
- snapshot!(tokens as ItemTrait, @r###"
- ItemTrait {
- vis: Visibility::Inherited,
- ident: "Trait",
- generics: Generics {
- where_clause: Some(WhereClause),
- },
- }
- "###);
-
- #[rustfmt::skip]
- let tokens = quote!(trait Trait: where {});
- snapshot!(tokens as ItemTrait, @r###"
- ItemTrait {
- vis: Visibility::Inherited,
- ident: "Trait",
- generics: Generics {
- where_clause: Some(WhereClause),
- },
- colon_token: Some,
- }
- "###);
-
- #[rustfmt::skip]
- let tokens = quote!(trait Trait: Sized where {});
- snapshot!(tokens as ItemTrait, @r###"
- ItemTrait {
- vis: Visibility::Inherited,
- ident: "Trait",
- generics: Generics {
- where_clause: Some(WhereClause),
- },
- colon_token: Some,
- supertraits: [
- TypeParamBound::Trait(TraitBound {
- path: Path {
- segments: [
- PathSegment {
- ident: "Sized",
- },
- ],
- },
- }),
- ],
- }
- "###);
-
- #[rustfmt::skip]
- let tokens = quote!(trait Trait: Sized + where {});
- snapshot!(tokens as ItemTrait, @r###"
- ItemTrait {
- vis: Visibility::Inherited,
- ident: "Trait",
- generics: Generics {
- where_clause: Some(WhereClause),
- },
- colon_token: Some,
- supertraits: [
- TypeParamBound::Trait(TraitBound {
- path: Path {
- segments: [
- PathSegment {
- ident: "Sized",
- },
- ],
- },
- }),
- Token![+],
- ],
- }
- "###);
-}
-
-#[test]
-fn test_type_empty_bounds() {
- #[rustfmt::skip]
- let tokens = quote! {
- trait Foo {
- type Bar: ;
- }
- };
-
- snapshot!(tokens as ItemTrait, @r###"
- ItemTrait {
- vis: Visibility::Inherited,
- ident: "Foo",
- generics: Generics,
- items: [
- TraitItem::Type {
- ident: "Bar",
- generics: Generics,
- colon_token: Some,
- },
- ],
- }
- "###);
-}
-
-#[test]
-fn test_impl_visibility() {
- let tokens = quote! {
- pub default unsafe impl union {}
- };
-
- snapshot!(tokens as Item, @"Item::Verbatim(`pub default unsafe impl union { }`)");
-}
-
-#[test]
-fn test_impl_type_parameter_defaults() {
- #[cfg(any())]
- impl<T = ()> () {}
- let tokens = quote! {
- impl<T = ()> () {}
- };
- snapshot!(tokens as Item, @r###"
- Item::Impl {
- generics: Generics {
- lt_token: Some,
- params: [
- GenericParam::Type(TypeParam {
- ident: "T",
- eq_token: Some,
- default: Some(Type::Tuple),
- }),
- ],
- gt_token: Some,
- },
- self_ty: Type::Tuple,
- }
- "###);
-}
-
-#[test]
-fn test_impl_trait_trailing_plus() {
- let tokens = quote! {
- fn f() -> impl Sized + {}
- };
-
- snapshot!(tokens as Item, @r###"
- Item::Fn {
- vis: Visibility::Inherited,
- sig: Signature {
- ident: "f",
- generics: Generics,
- output: ReturnType::Type(
- Type::ImplTrait {
- bounds: [
- TypeParamBound::Trait(TraitBound {
- path: Path {
- segments: [
- PathSegment {
- ident: "Sized",
- },
- ],
- },
- }),
- Token![+],
- ],
- },
- ),
- },
- block: Block {
- stmts: [],
- },
- }
- "###);
-}