Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/item_tree/tests.rs')
| -rw-r--r-- | crates/hir-def/src/item_tree/tests.rs | 193 |
1 files changed, 18 insertions, 175 deletions
diff --git a/crates/hir-def/src/item_tree/tests.rs b/crates/hir-def/src/item_tree/tests.rs index 80b699649f..824fbfa592 100644 --- a/crates/hir-def/src/item_tree/tests.rs +++ b/crates/hir-def/src/item_tree/tests.rs @@ -1,4 +1,4 @@ -use expect_test::{expect, Expect}; +use expect_test::{Expect, expect}; use span::Edition; use test_fixture::WithFixture; @@ -83,11 +83,11 @@ extern "C" { #[on_extern_static] // AstId: 3 - pub(self) static EX_STATIC: u8 = _; + pub(self) static EX_STATIC = _; #[on_extern_fn] // AstId: 4 - pub(self) fn ex_fn() -> (); + pub(self) fn ex_fn; } "##]], ); @@ -131,35 +131,35 @@ enum E { // AstId: 2 pub(self) struct Struct { #[doc = " fld docs"] - pub(self) fld: (), + pub(self) fld, } // AstId: 3 pub(self) struct Tuple( #[attr] - pub(self) 0: u8, + pub(self) 0, ); // AstId: 4 pub(self) union Ize { - pub(self) a: (), - pub(self) b: (), + pub(self) a, + pub(self) b, } // AstId: 5 - pub(self) enum E { + pub(self) enum E // AstId: 6 #[doc = " comment on Unit"] Unit, // AstId: 7 #[doc = " comment on Tuple"] Tuple( - pub(self) 0: u8, + pub(self) 0, ), // AstId: 8 Struct { #[doc = " comment on a: u8"] - pub(self) a: u8, + pub(self) a, }, } "#]], @@ -186,33 +186,23 @@ trait Tr: SuperTrait + 'lifetime { "#, expect![[r#" // AstId: 1 - pub static mut ST: () = _; + pub static ST = _; // AstId: 2 - pub(self) const _: Anon = _; + pub(self) const _ = _; #[attr] #[inner_attr_in_fn] // AstId: 3 - pub(self) fn f( - #[attr] - u8, - (), - ) -> () { ... } + pub(self) fn f; // AstId: 4 - pub(self) trait Tr<Self> - where - Self: SuperTrait, - Self: 'lifetime - { + pub(self) trait Tr { // AstId: 6 - pub(self) type Assoc: AssocBound = Default; + pub(self) type Assoc; // AstId: 7 - pub(self) fn method( - self: &Self, - ) -> (); + pub(self) fn method; } "#]], ); @@ -242,7 +232,7 @@ mod outline; pub(self) use super::*; // AstId: 4 - pub(self) fn fn_in_module() -> () { ... } + pub(self) fn fn_in_module; } // AstId: 2 @@ -270,160 +260,13 @@ m!(); // AstId: 2 pub macro m2 { ... } - // AstId: 3, SyntaxContext: 2, ExpandTo: Items + // AstId: 3, SyntaxContextId: ROOT2024, ExpandTo: Items m!(...); "#]], ); } #[test] -fn mod_paths() { - check( - r#" -struct S { - a: self::Ty, - b: super::SuperTy, - c: super::super::SuperSuperTy, - d: ::abs::Path, - e: crate::Crate, - f: plain::path::Ty, -} - "#, - expect![[r#" - // AstId: 1 - pub(self) struct S { - pub(self) a: self::Ty, - pub(self) b: super::SuperTy, - pub(self) c: super::super::SuperSuperTy, - pub(self) d: ::abs::Path, - pub(self) e: crate::Crate, - pub(self) f: plain::path::Ty, - } - "#]], - ) -} - -#[test] -fn types() { - check( - r#" -struct S { - a: Mixed<'a, T, Item=(), OtherItem=u8>, - b: <Fully as Qualified>::Syntax, - c: <TypeAnchored>::Path::<'a>, - d: dyn for<'a> Trait<'a>, -} - "#, - expect![[r#" - // AstId: 1 - pub(self) struct S { - pub(self) a: Mixed::<'a, T, Item = (), OtherItem = u8>, - pub(self) b: Qualified::<Self=Fully>::Syntax, - pub(self) c: <TypeAnchored>::Path::<'a>, - pub(self) d: dyn for<'a> Trait::<'a>, - } - "#]], - ) -} - -#[test] -fn generics() { - check( - r#" -struct S<'a, 'b: 'a, T: Copy + 'a + 'b, const K: u8 = 0> { - field: &'a &'b T, -} - -struct Tuple<T: Copy, U: ?Sized>(T, U); - -impl<'a, 'b: 'a, T: Copy + 'a + 'b, const K: u8 = 0> S<'a, 'b, T, K> { - fn f<G: 'a>(arg: impl Copy) -> impl Copy {} -} - -enum Enum<'a, T, const U: u8> {} -union Union<'a, T, const U: u8> {} - -trait Tr<'a, T: 'a>: Super where Self: for<'a> Tr<'a, T> {} - "#, - expect![[r#" - // AstId: 1 - pub(self) struct S<'a, 'b, T, const K: u8> - where - T: Copy, - T: 'a, - T: 'b, - 'b: 'a - { - pub(self) field: &'a &'b T, - } - - // AstId: 2 - pub(self) struct Tuple<T, U>( - pub(self) 0: T, - pub(self) 1: U, - ) - where - T: Copy, - U: ?Sized; - - // AstId: 3 - impl<'a, 'b, T, const K: u8> S::<'a, 'b, T, K> - where - T: Copy, - T: 'a, - T: 'b, - 'b: 'a - { - // AstId: 9 - pub(self) fn f<G>( - impl Copy, - ) -> impl Copy - where - G: 'a { ... } - } - - // AstId: 4 - pub(self) enum Enum<'a, T, const U: u8> { - } - - // AstId: 5 - pub(self) union Union<'a, T, const U: u8> { - } - - // AstId: 6 - pub(self) trait Tr<'a, Self, T> - where - Self: Super, - T: 'a, - Self: for<'a> Tr::<'a, T> - { - } - "#]], - ) -} - -#[test] -fn generics_with_attributes() { - check( - r#" -struct S<#[cfg(never)] T>; -struct S<A, B, #[cfg(never)] C>; -struct S<A, #[cfg(never)] B, C>; - "#, - expect![[r#" - // AstId: 1 - pub(self) struct S<#[cfg(never)] T>; - - // AstId: 2 - pub(self) struct S<A, B, #[cfg(never)] C>; - - // AstId: 3 - pub(self) struct S<A, #[cfg(never)] B, C>; - "#]], - ) -} - -#[test] fn pub_self() { check( r#" |