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 | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/crates/hir-def/src/item_tree/tests.rs b/crates/hir-def/src/item_tree/tests.rs index f97ae0d8e4..26f7b41c77 100644 --- a/crates/hir-def/src/item_tree/tests.rs +++ b/crates/hir-def/src/item_tree/tests.rs @@ -34,17 +34,23 @@ use a::{c, d::{e}}; #![no_std] #![doc = " another file comment"] + // AstId: 1 pub(self) extern crate self as renamed; + // AstId: 2 pub(super) extern crate bli; + // AstId: 3 pub use crate::path::{nested, items as renamed, Trait as _}; + // AstId: 4 pub(self) use globs::*; #[doc = " docs on import"] + // AstId: 5 pub(self) use crate::{A, B}; + // AstId: 6 pub(self) use a::{c, d::{e}}; "##]], ); @@ -68,14 +74,18 @@ extern "C" { "#, expect![[r##" #[on_extern_block] + // AstId: 1 extern "C" { #[on_extern_type] + // AstId: 2 pub(self) type ExType; #[on_extern_static] + // AstId: 3 pub(self) static EX_STATIC: u8 = _; #[on_extern_fn] + // AstId: 4 pub(self) fn ex_fn() -> (); } "##]], @@ -112,38 +122,52 @@ enum E { } } "#, - expect![[r##" + expect![[r#" + // AstId: 1 pub(self) struct Unit; #[derive(Debug)] + // AstId: 2 pub(self) struct Struct { + // AstId: 6 #[doc = " fld docs"] pub(self) fld: (), } + // AstId: 3 pub(self) struct Tuple( + // AstId: 7 #[attr] pub(self) 0: u8, ); + // AstId: 4 pub(self) union Ize { + // AstId: 8 pub(self) a: (), + // AstId: 9 pub(self) b: (), } + // AstId: 5 pub(self) enum E { + // AstId: 10 #[doc = " comment on Unit"] Unit, + // AstId: 11 #[doc = " comment on Tuple"] Tuple( + // AstId: 13 pub(self) 0: u8, ), + // AstId: 12 Struct { + // AstId: 14 #[doc = " comment on a: u8"] pub(self) a: u8, }, } - "##]], + "#]], ); } @@ -166,26 +190,35 @@ trait Tr: SuperTrait + 'lifetime { } "#, expect![[r#" + // AstId: 1 pub static mut ST: () = _; + // AstId: 2 pub(self) const _: Anon = _; #[attr] #[inner_attr_in_fn] + // AstId: 3 pub(self) fn f( #[attr] + // AstId: 5 u8, + // AstId: 6 (), ) -> () { ... } + // AstId: 4 pub(self) trait Tr<Self> where Self: SuperTrait, Self: 'lifetime { + // AstId: 8 pub(self) type Assoc: AssocBound = Default; + // AstId: 9 pub(self) fn method( + // AstId: 10 self: &Self, ) -> (); } @@ -211,12 +244,16 @@ mod outline; expect![[r##" #[doc = " outer"] #[doc = " inner"] + // AstId: 1 pub(self) mod inline { + // AstId: 3 pub(self) use super::*; + // AstId: 4 pub(self) fn fn_in_module() -> () { ... } } + // AstId: 2 pub(self) mod outline; "##]], ); @@ -235,10 +272,13 @@ pub macro m2() {} m!(); "#, expect![[r#" + // AstId: 1 macro_rules! m { ... } + // AstId: 2 pub macro m2 { ... } + // AstId: 3, Span: 0:[email protected]#0, ExpandTo: Items m!(...); "#]], ); @@ -258,12 +298,19 @@ struct S { } "#, expect![[r#" + // AstId: 1 pub(self) struct S { + // AstId: 2 pub(self) a: self::Ty, + // AstId: 3 pub(self) b: super::SuperTy, + // AstId: 4 pub(self) c: super::super::SuperSuperTy, + // AstId: 5 pub(self) d: ::abs::Path, + // AstId: 6 pub(self) e: crate::Crate, + // AstId: 7 pub(self) f: plain::path::Ty, } "#]], @@ -282,10 +329,15 @@ struct S { } "#, expect![[r#" + // AstId: 1 pub(self) struct S { + // AstId: 2 pub(self) a: Mixed::<'a, T, Item = (), OtherItem = u8>, + // AstId: 3 pub(self) b: Qualified::<Self=Fully>::Syntax, + // AstId: 4 pub(self) c: <TypeAnchored>::Path::<'a>, + // AstId: 5 pub(self) d: dyn for<'a> Trait::<'a>, } "#]], @@ -312,42 +364,53 @@ 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 { + // AstId: 8 pub(self) field: &'a &'b T, } + // AstId: 2 pub(self) struct Tuple<T, U>( + // AstId: 9 pub(self) 0: T, + // AstId: 10 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 { + // AstId: 12 pub(self) fn f<G>( + // AstId: 13 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, @@ -366,6 +429,7 @@ fn generics_with_attributes() { struct S<#[cfg(never)] T>; "#, expect![[r#" + // AstId: 1 pub(self) struct S<#[cfg(never)] T>; "#]], ) @@ -378,6 +442,7 @@ fn pub_self() { pub(self) struct S; "#, expect![[r#" + // AstId: 1 pub(self) struct S; "#]], ) |