about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-16 10:09:05 +0000
committerbors <bors@rust-lang.org>2024-01-16 10:09:05 +0000
commit2d5ce888decbff2b779eccfc581b9e8fb01507f9 (patch)
tree23e134891102c90d7edcfeee07e8eae668219a34
parentc9afd412197db3b7e954fad9580448927d6718e6 (diff)
parent35e05e07fb7cd490d1ac6d07c63cc854dd1823aa (diff)
downloadrust-2d5ce888decbff2b779eccfc581b9e8fb01507f9.tar.gz
rust-2d5ce888decbff2b779eccfc581b9e8fb01507f9.zip
Auto merge of #16366 - Veykril:transp-queries, r=Veykril
internal: Make data queries transparent over their diagnostics variant

And a few other QoL things
-rw-r--r--Cargo.lock4
-rw-r--r--Cargo.toml2
-rw-r--r--crates/hir-def/src/data.rs7
-rw-r--r--crates/hir-def/src/data/adt.rs3
-rw-r--r--crates/hir-def/src/db.rs5
-rw-r--r--crates/hir-def/src/item_tree/pretty.rs94
-rw-r--r--crates/hir-def/src/item_tree/tests.rs69
-rw-r--r--crates/hir-def/src/macro_expansion_tests/mbe.rs22
-rw-r--r--crates/hir-def/src/macro_expansion_tests/mod.rs11
-rw-r--r--crates/hir-def/src/macro_expansion_tests/proc_macros.rs6
-rw-r--r--crates/hir/src/db.rs22
-rw-r--r--crates/ide-db/src/apply_change.rs5
-rw-r--r--crates/ide-db/src/lib.rs5
-rw-r--r--crates/ide/src/hover/render.rs6
-rw-r--r--crates/ide/src/hover/tests.rs159
-rw-r--r--crates/rust-analyzer/src/cli/rustc_tests.rs49
-rw-r--r--crates/span/src/lib.rs17
17 files changed, 329 insertions, 157 deletions
diff --git a/Cargo.lock b/Cargo.lock
index de3a5e8aa59..e1e85d0963d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1712,9 +1712,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
 
 [[package]]
 name = "smol_str"
-version = "0.2.0"
+version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c"
+checksum = "e6845563ada680337a52d43bb0b29f396f2d911616f6573012645b9e3d048a49"
 dependencies = [
  "serde",
 ]
diff --git a/Cargo.toml b/Cargo.toml
index 35bef151196..5f8bd61015e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -122,7 +122,7 @@ smallvec = { version = "1.10.0", features = [
   "union",
   "const_generics",
 ] }
-smol_str = "0.2.0"
+smol_str = "0.2.1"
 text-size = "1.1.1"
 tracing = "0.1.40"
 tracing-tree = "0.3.0"
diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs
index a42d6bb3378..ca02b5d68e2 100644
--- a/crates/hir-def/src/data.rs
+++ b/crates/hir-def/src/data.rs
@@ -233,6 +233,7 @@ pub struct TraitData {
 }
 
 impl TraitData {
+    #[inline]
     pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> {
         db.trait_data_with_diagnostics(tr).0
     }
@@ -241,12 +242,9 @@ impl TraitData {
         db: &dyn DefDatabase,
         tr: TraitId,
     ) -> (Arc<TraitData>, DefDiagnostics) {
-        let tr_loc @ ItemLoc { container: module_id, id: tree_id } = tr.lookup(db);
+        let ItemLoc { container: module_id, id: tree_id } = tr.lookup(db);
         let item_tree = tree_id.item_tree(db);
         let tr_def = &item_tree[tree_id.value];
-        let _cx = stdx::panic_context::enter(format!(
-            "trait_data_query({tr:?} -> {tr_loc:?} -> {tr_def:?})"
-        ));
         let name = tr_def.name.clone();
         let is_auto = tr_def.is_auto;
         let is_unsafe = tr_def.is_unsafe;
@@ -333,6 +331,7 @@ pub struct ImplData {
 }
 
 impl ImplData {
+    #[inline]
     pub(crate) fn impl_data_query(db: &dyn DefDatabase, id: ImplId) -> Arc<ImplData> {
         db.impl_data_with_diagnostics(id).0
     }
diff --git a/crates/hir-def/src/data/adt.rs b/crates/hir-def/src/data/adt.rs
index 5d443715213..5986b7df3d9 100644
--- a/crates/hir-def/src/data/adt.rs
+++ b/crates/hir-def/src/data/adt.rs
@@ -180,6 +180,7 @@ fn parse_repr_tt(tt: &Subtree) -> Option<ReprOptions> {
 }
 
 impl StructData {
+    #[inline]
     pub(crate) fn struct_data_query(db: &dyn DefDatabase, id: StructId) -> Arc<StructData> {
         db.struct_data_with_diagnostics(id).0
     }
@@ -236,6 +237,7 @@ impl StructData {
         )
     }
 
+    #[inline]
     pub(crate) fn union_data_query(db: &dyn DefDatabase, id: UnionId) -> Arc<StructData> {
         db.union_data_with_diagnostics(id).0
     }
@@ -322,6 +324,7 @@ impl EnumData {
 }
 
 impl EnumVariantData {
+    #[inline]
     pub(crate) fn enum_variant_data_query(
         db: &dyn DefDatabase,
         e: EnumVariantId,
diff --git a/crates/hir-def/src/db.rs b/crates/hir-def/src/db.rs
index 186a8cf2d9f..c1127ccaaf1 100644
--- a/crates/hir-def/src/db.rs
+++ b/crates/hir-def/src/db.rs
@@ -117,12 +117,14 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
 
     // region:data
 
+    #[salsa::transparent]
     #[salsa::invoke(StructData::struct_data_query)]
     fn struct_data(&self, id: StructId) -> Arc<StructData>;
 
     #[salsa::invoke(StructData::struct_data_with_diagnostics_query)]
     fn struct_data_with_diagnostics(&self, id: StructId) -> (Arc<StructData>, DefDiagnostics);
 
+    #[salsa::transparent]
     #[salsa::invoke(StructData::union_data_query)]
     fn union_data(&self, id: UnionId) -> Arc<StructData>;
 
@@ -132,6 +134,7 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
     #[salsa::invoke(EnumData::enum_data_query)]
     fn enum_data(&self, e: EnumId) -> Arc<EnumData>;
 
+    #[salsa::transparent]
     #[salsa::invoke(EnumVariantData::enum_variant_data_query)]
     fn enum_variant_data(&self, id: EnumVariantId) -> Arc<EnumVariantData>;
 
@@ -141,12 +144,14 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
         id: EnumVariantId,
     ) -> (Arc<EnumVariantData>, DefDiagnostics);
 
+    #[salsa::transparent]
     #[salsa::invoke(ImplData::impl_data_query)]
     fn impl_data(&self, e: ImplId) -> Arc<ImplData>;
 
     #[salsa::invoke(ImplData::impl_data_with_diagnostics_query)]
     fn impl_data_with_diagnostics(&self, e: ImplId) -> (Arc<ImplData>, DefDiagnostics);
 
+    #[salsa::transparent]
     #[salsa::invoke(TraitData::trait_data_query)]
     fn trait_data(&self, e: TraitId) -> Arc<TraitData>;
 
diff --git a/crates/hir-def/src/item_tree/pretty.rs b/crates/hir-def/src/item_tree/pretty.rs
index d8a0cb56983..520034d213c 100644
--- a/crates/hir-def/src/item_tree/pretty.rs
+++ b/crates/hir-def/src/item_tree/pretty.rs
@@ -2,6 +2,8 @@
 
 use std::fmt::{self, Write};
 
+use span::ErasedFileAstId;
+
 use crate::{
     generics::{TypeOrConstParamData, WherePredicate, WherePredicateTypeTarget},
     pretty::{print_path, print_type_bounds, print_type_ref},
@@ -118,7 +120,11 @@ impl Printer<'_> {
                 w!(self, "{{");
                 self.indented(|this| {
                     for field in fields.clone() {
-                        let Field { visibility, name, type_ref, ast_id: _ } = &this.tree[field];
+                        let Field { visibility, name, type_ref, ast_id } = &this.tree[field];
+                        this.print_ast_id(match ast_id {
+                            FieldAstId::Record(it) => it.erase(),
+                            FieldAstId::Tuple(it) => it.erase(),
+                        });
                         this.print_attrs_of(field, "\n");
                         this.print_visibility(*visibility);
                         w!(this, "{}: ", name.display(self.db.upcast()));
@@ -132,7 +138,11 @@ impl Printer<'_> {
                 w!(self, "(");
                 self.indented(|this| {
                     for field in fields.clone() {
-                        let Field { visibility, name, type_ref, ast_id: _ } = &this.tree[field];
+                        let Field { visibility, name, type_ref, ast_id } = &this.tree[field];
+                        this.print_ast_id(match ast_id {
+                            FieldAstId::Record(it) => it.erase(),
+                            FieldAstId::Tuple(it) => it.erase(),
+                        });
                         this.print_attrs_of(field, "\n");
                         this.print_visibility(*visibility);
                         w!(this, "{}: ", name.display(self.db.upcast()));
@@ -200,14 +210,16 @@ impl Printer<'_> {
 
         match item {
             ModItem::Use(it) => {
-                let Use { visibility, use_tree, ast_id: _ } = &self.tree[it];
+                let Use { visibility, use_tree, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "use ");
                 self.print_use_tree(use_tree);
                 wln!(self, ";");
             }
             ModItem::ExternCrate(it) => {
-                let ExternCrate { name, alias, visibility, ast_id: _ } = &self.tree[it];
+                let ExternCrate { name, alias, visibility, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "extern crate {}", name.display(self.db.upcast()));
                 if let Some(alias) = alias {
@@ -216,7 +228,8 @@ impl Printer<'_> {
                 wln!(self, ";");
             }
             ModItem::ExternBlock(it) => {
-                let ExternBlock { abi, ast_id: _, children } = &self.tree[it];
+                let ExternBlock { abi, ast_id, children } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 w!(self, "extern ");
                 if let Some(abi) = abi {
                     w!(self, "\"{}\" ", abi);
@@ -237,9 +250,10 @@ impl Printer<'_> {
                     abi,
                     params,
                     ret_type,
-                    ast_id: _,
+                    ast_id,
                     flags,
                 } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 if flags.contains(FnFlags::HAS_DEFAULT_KW) {
                     w!(self, "default ");
@@ -263,7 +277,12 @@ impl Printer<'_> {
                     self.indented(|this| {
                         for param in params.clone() {
                             this.print_attrs_of(param, "\n");
-                            match &this.tree[param].type_ref {
+                            let Param { type_ref, ast_id } = &this.tree[param];
+                            this.print_ast_id(match ast_id {
+                                ParamAstId::Param(it) => it.erase(),
+                                ParamAstId::SelfParam(it) => it.erase(),
+                            });
+                            match type_ref {
                                 Some(ty) => {
                                     if flags.contains(FnFlags::HAS_SELF_PARAM) {
                                         w!(this, "self: ");
@@ -288,7 +307,8 @@ impl Printer<'_> {
                 }
             }
             ModItem::Struct(it) => {
-                let Struct { visibility, name, fields, generic_params, ast_id: _ } = &self.tree[it];
+                let Struct { visibility, name, fields, generic_params, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "struct {}", name.display(self.db.upcast()));
                 self.print_generic_params(generic_params);
@@ -300,7 +320,8 @@ impl Printer<'_> {
                 }
             }
             ModItem::Union(it) => {
-                let Union { name, visibility, fields, generic_params, ast_id: _ } = &self.tree[it];
+                let Union { name, visibility, fields, generic_params, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "union {}", name.display(self.db.upcast()));
                 self.print_generic_params(generic_params);
@@ -312,14 +333,16 @@ impl Printer<'_> {
                 }
             }
             ModItem::Enum(it) => {
-                let Enum { name, visibility, variants, generic_params, ast_id: _ } = &self.tree[it];
+                let Enum { name, visibility, variants, generic_params, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "enum {}", name.display(self.db.upcast()));
                 self.print_generic_params(generic_params);
                 self.print_where_clause_and_opening_brace(generic_params);
                 self.indented(|this| {
                     for variant in FileItemTreeId::range_iter(variants.clone()) {
-                        let Variant { name, fields, ast_id: _ } = &this.tree[variant];
+                        let Variant { name, fields, ast_id } = &this.tree[variant];
+                        this.print_ast_id(ast_id.erase());
                         this.print_attrs_of(variant, "\n");
                         w!(this, "{}", name.display(self.db.upcast()));
                         this.print_fields(fields);
@@ -329,7 +352,8 @@ impl Printer<'_> {
                 wln!(self, "}}");
             }
             ModItem::Const(it) => {
-                let Const { name, visibility, type_ref, ast_id: _ } = &self.tree[it];
+                let Const { name, visibility, type_ref, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "const ");
                 match name {
@@ -341,7 +365,8 @@ impl Printer<'_> {
                 wln!(self, " = _;");
             }
             ModItem::Static(it) => {
-                let Static { name, visibility, mutable, type_ref, ast_id: _ } = &self.tree[it];
+                let Static { name, visibility, mutable, type_ref, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "static ");
                 if *mutable {
@@ -353,15 +378,9 @@ impl Printer<'_> {
                 wln!(self);
             }
             ModItem::Trait(it) => {
-                let Trait {
-                    name,
-                    visibility,
-                    is_auto,
-                    is_unsafe,
-                    items,
-                    generic_params,
-                    ast_id: _,
-                } = &self.tree[it];
+                let Trait { name, visibility, is_auto, is_unsafe, items, generic_params, ast_id } =
+                    &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 if *is_unsafe {
                     w!(self, "unsafe ");
@@ -380,7 +399,8 @@ impl Printer<'_> {
                 wln!(self, "}}");
             }
             ModItem::TraitAlias(it) => {
-                let TraitAlias { name, visibility, generic_params, ast_id: _ } = &self.tree[it];
+                let TraitAlias { name, visibility, generic_params, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "trait {}", name.display(self.db.upcast()));
                 self.print_generic_params(generic_params);
@@ -397,8 +417,9 @@ impl Printer<'_> {
                     is_unsafe,
                     items,
                     generic_params,
-                    ast_id: _,
+                    ast_id,
                 } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 if *is_unsafe {
                     w!(self, "unsafe");
                 }
@@ -422,8 +443,9 @@ impl Printer<'_> {
                 wln!(self, "}}");
             }
             ModItem::TypeAlias(it) => {
-                let TypeAlias { name, visibility, bounds, type_ref, generic_params, ast_id: _ } =
+                let TypeAlias { name, visibility, bounds, type_ref, generic_params, ast_id } =
                     &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "type {}", name.display(self.db.upcast()));
                 self.print_generic_params(generic_params);
@@ -440,7 +462,8 @@ impl Printer<'_> {
                 wln!(self);
             }
             ModItem::Mod(it) => {
-                let Mod { name, visibility, kind, ast_id: _ } = &self.tree[it];
+                let Mod { name, visibility, kind, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 w!(self, "mod {}", name.display(self.db.upcast()));
                 match kind {
@@ -459,15 +482,24 @@ impl Printer<'_> {
                 }
             }
             ModItem::MacroCall(it) => {
-                let MacroCall { path, ast_id: _, expand_to: _, call_site: _ } = &self.tree[it];
+                let MacroCall { path, ast_id, expand_to, call_site } = &self.tree[it];
+                let _ = writeln!(
+                    self,
+                    "// AstId: {:?}, Span: {}, ExpandTo: {:?}",
+                    ast_id.erase().into_raw(),
+                    call_site,
+                    expand_to
+                );
                 wln!(self, "{}!(...);", path.display(self.db.upcast()));
             }
             ModItem::MacroRules(it) => {
-                let MacroRules { name, ast_id: _ } = &self.tree[it];
+                let MacroRules { name, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 wln!(self, "macro_rules! {} {{ ... }}", name.display(self.db.upcast()));
             }
             ModItem::Macro2(it) => {
-                let Macro2 { name, visibility, ast_id: _ } = &self.tree[it];
+                let Macro2 { name, visibility, ast_id } = &self.tree[it];
+                self.print_ast_id(ast_id.erase());
                 self.print_visibility(*visibility);
                 wln!(self, "macro {} {{ ... }}", name.display(self.db.upcast()));
             }
@@ -583,6 +615,10 @@ impl Printer<'_> {
         });
         true
     }
+
+    fn print_ast_id(&mut self, ast_id: ErasedFileAstId) {
+        wln!(self, "// AstId: {:?}", ast_id.into_raw());
+    }
 }
 
 impl Write for Printer<'_> {
diff --git a/crates/hir-def/src/item_tree/tests.rs b/crates/hir-def/src/item_tree/tests.rs
index f97ae0d8e43..26f7b41c77a 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:3@0..5#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;
         "#]],
     )
diff --git a/crates/hir-def/src/macro_expansion_tests/mbe.rs b/crates/hir-def/src/macro_expansion_tests/mbe.rs
index f2046bfbce4..6d365bd93c0 100644
--- a/crates/hir-def/src/macro_expansion_tests/mbe.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mbe.rs
@@ -35,9 +35,9 @@ macro_rules! f {
     };
 }
 
-struct#FileId(0):1@58..64\2# MyTraitMap2#FileId(0):2@31..42\0# {#FileId(0):1@72..73\2#
-    map#FileId(0):1@86..89\2#:#FileId(0):1@89..90\2# #FileId(0):1@89..90\2#::#FileId(0):1@91..92\2#std#FileId(0):1@93..96\2#::#FileId(0):1@96..97\2#collections#FileId(0):1@98..109\2#::#FileId(0):1@109..110\2#HashSet#FileId(0):1@111..118\2#<#FileId(0):1@118..119\2#(#FileId(0):1@119..120\2#)#FileId(0):1@120..121\2#>#FileId(0):1@121..122\2#,#FileId(0):1@122..123\2#
-}#FileId(0):1@132..133\2#
+struct#0:1@58..64#2# MyTraitMap2#0:2@31..42#0# {#0:1@72..73#2#
+    map#0:1@86..89#2#:#0:1@89..90#2# #0:1@89..90#2#::#0:1@91..92#2#std#0:1@93..96#2#::#0:1@96..97#2#collections#0:1@98..109#2#::#0:1@109..110#2#HashSet#0:1@111..118#2#<#0:1@118..119#2#(#0:1@119..120#2#)#0:1@120..121#2#>#0:1@121..122#2#,#0:1@122..123#2#
+}#0:1@132..133#2#
 "#]],
     );
 }
@@ -75,12 +75,12 @@ macro_rules! f {
     };
 }
 
-fn#FileId(0):2@30..32\0# main#FileId(0):2@33..37\0#(#FileId(0):2@37..38\0#)#FileId(0):2@38..39\0# {#FileId(0):2@40..41\0#
-    1#FileId(0):2@50..51\0#;#FileId(0):2@51..52\0#
-    1.0#FileId(0):2@61..64\0#;#FileId(0):2@64..65\0#
-    (#FileId(0):2@74..75\0#(#FileId(0):2@75..76\0#1#FileId(0):2@76..77\0#,#FileId(0):2@77..78\0# )#FileId(0):2@78..79\0#,#FileId(0):2@79..80\0# )#FileId(0):2@80..81\0#.#FileId(0):2@81..82\0#0#FileId(0):2@82..85\0#.#FileId(0):2@82..85\0#0#FileId(0):2@82..85\0#;#FileId(0):2@85..86\0#
-    let#FileId(0):2@95..98\0# x#FileId(0):2@99..100\0# =#FileId(0):2@101..102\0# 1#FileId(0):2@103..104\0#;#FileId(0):2@104..105\0#
-}#FileId(0):2@110..111\0#
+fn#0:2@30..32#0# main#0:2@33..37#0#(#0:2@37..38#0#)#0:2@38..39#0# {#0:2@40..41#0#
+    1#0:2@50..51#0#;#0:2@51..52#0#
+    1.0#0:2@61..64#0#;#0:2@64..65#0#
+    (#0:2@74..75#0#(#0:2@75..76#0#1#0:2@76..77#0#,#0:2@77..78#0# )#0:2@78..79#0#,#0:2@79..80#0# )#0:2@80..81#0#.#0:2@81..82#0#0#0:2@82..85#0#.#0:2@82..85#0#0#0:2@82..85#0#;#0:2@85..86#0#
+    let#0:2@95..98#0# x#0:2@99..100#0# =#0:2@101..102#0# 1#0:2@103..104#0#;#0:2@104..105#0#
+}#0:2@110..111#0#
 
 
 "#]],
@@ -171,7 +171,7 @@ fn main(foo: ()) {
     }
 
     fn main(foo: ()) {
-        /* error: unresolved macro unresolved */"helloworld!"#FileId(0):3@207..323\6#;
+        /* error: unresolved macro unresolved */"helloworld!"#0:3@207..323#6#;
     }
 }
 
@@ -197,7 +197,7 @@ macro_rules! mk_struct {
 #[macro_use]
 mod foo;
 
-struct#FileId(1):1@59..65\2# Foo#FileId(0):2@32..35\0#(#FileId(1):1@70..71\2#u32#FileId(0):2@41..44\0#)#FileId(1):1@74..75\2#;#FileId(1):1@75..76\2#
+struct#1:1@59..65#2# Foo#0:2@32..35#0#(#1:1@70..71#2#u32#0:2@41..44#0#)#1:1@74..75#2#;#1:1@75..76#2#
 "#]],
     );
 }
diff --git a/crates/hir-def/src/macro_expansion_tests/mod.rs b/crates/hir-def/src/macro_expansion_tests/mod.rs
index ee806361237..550ce35f127 100644
--- a/crates/hir-def/src/macro_expansion_tests/mod.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mod.rs
@@ -291,15 +291,8 @@ fn pretty_print_macro_expansion(
             let span = map.span_for_range(token.text_range());
             format_to!(res, "#");
             if show_spans {
-                format_to!(
-                    res,
-                    "{:?}:{:?}@{:?}",
-                    span.anchor.file_id,
-                    span.anchor.ast_id.into_raw(),
-                    span.range,
-                );
-            }
-            if show_ctxt {
+                format_to!(res, "{span}",);
+            } else if show_ctxt {
                 format_to!(res, "\\{}", span.ctx);
             }
             format_to!(res, "#");
diff --git a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
index 060b8aa8c19..a4864c74d77 100644
--- a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
+++ b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
@@ -181,8 +181,8 @@ fn foo(&self) {
     self.0. 1;
 }
 
-fn#FileId(0):1@45..47\0# foo#FileId(0):1@48..51\0#(#FileId(0):1@51..52\0#&#FileId(0):1@52..53\0#self#FileId(0):1@53..57\0# )#FileId(0):1@57..58\0# {#FileId(0):1@59..60\0#
-    self#FileId(0):1@65..69\0# .#FileId(0):1@69..70\0#0#FileId(0):1@70..71\0#.#FileId(0):1@71..72\0#1#FileId(0):1@73..74\0#;#FileId(0):1@74..75\0#
-}#FileId(0):1@76..77\0#"#]],
+fn#0:1@45..47#0# foo#0:1@48..51#0#(#0:1@51..52#0#&#0:1@52..53#0#self#0:1@53..57#0# )#0:1@57..58#0# {#0:1@59..60#0#
+    self#0:1@65..69#0# .#0:1@69..70#0#0#0:1@70..71#0#.#0:1@71..72#0#1#0:1@73..74#0#;#0:1@74..75#0#
+}#0:1@76..77#0#"#]],
     );
 }
diff --git a/crates/hir/src/db.rs b/crates/hir/src/db.rs
index a2492840cb7..557c8d29a17 100644
--- a/crates/hir/src/db.rs
+++ b/crates/hir/src/db.rs
@@ -6,20 +6,18 @@
 pub use hir_def::db::{
     AttrsQuery, BlockDefMapQuery, BlockItemTreeQueryQuery, BodyQuery, BodyWithSourceMapQuery,
     ConstDataQuery, ConstVisibilityQuery, CrateDefMapQueryQuery, CrateLangItemsQuery,
-    CrateSupportsNoStdQuery, DefDatabase, DefDatabaseStorage, EnumDataQuery, EnumVariantDataQuery,
+    CrateSupportsNoStdQuery, DefDatabase, DefDatabaseStorage, EnumDataQuery,
     EnumVariantDataWithDiagnosticsQuery, ExprScopesQuery, ExternCrateDeclDataQuery,
     FieldVisibilitiesQuery, FieldsAttrsQuery, FieldsAttrsSourceMapQuery, FileItemTreeQuery,
-    FunctionDataQuery, FunctionVisibilityQuery, GenericParamsQuery, ImplDataQuery,
-    ImplDataWithDiagnosticsQuery, ImportMapQuery, InternAnonymousConstQuery, InternBlockQuery,
-    InternConstQuery, InternDatabase, InternDatabaseStorage, InternEnumQuery,
-    InternExternBlockQuery, InternExternCrateQuery, InternFunctionQuery, InternImplQuery,
-    InternInTypeConstQuery, InternMacro2Query, InternMacroRulesQuery, InternProcMacroQuery,
-    InternStaticQuery, InternStructQuery, InternTraitAliasQuery, InternTraitQuery,
-    InternTypeAliasQuery, InternUnionQuery, InternUseQuery, LangItemQuery, Macro2DataQuery,
-    MacroRulesDataQuery, ProcMacroDataQuery, StaticDataQuery, StructDataQuery,
-    StructDataWithDiagnosticsQuery, TraitAliasDataQuery, TraitDataQuery,
-    TraitDataWithDiagnosticsQuery, TypeAliasDataQuery, UnionDataQuery,
-    UnionDataWithDiagnosticsQuery,
+    FunctionDataQuery, FunctionVisibilityQuery, GenericParamsQuery, ImplDataWithDiagnosticsQuery,
+    ImportMapQuery, InternAnonymousConstQuery, InternBlockQuery, InternConstQuery, InternDatabase,
+    InternDatabaseStorage, InternEnumQuery, InternExternBlockQuery, InternExternCrateQuery,
+    InternFunctionQuery, InternImplQuery, InternInTypeConstQuery, InternMacro2Query,
+    InternMacroRulesQuery, InternProcMacroQuery, InternStaticQuery, InternStructQuery,
+    InternTraitAliasQuery, InternTraitQuery, InternTypeAliasQuery, InternUnionQuery,
+    InternUseQuery, LangItemQuery, Macro2DataQuery, MacroRulesDataQuery, ProcMacroDataQuery,
+    StaticDataQuery, StructDataWithDiagnosticsQuery, TraitAliasDataQuery,
+    TraitDataWithDiagnosticsQuery, TypeAliasDataQuery, UnionDataWithDiagnosticsQuery,
 };
 pub use hir_expand::db::{
     AstIdMapQuery, DeclMacroExpanderQuery, ExpandDatabase, ExpandDatabaseStorage,
diff --git a/crates/ide-db/src/apply_change.rs b/crates/ide-db/src/apply_change.rs
index 3d973dfe10a..766d1c1e43d 100644
--- a/crates/ide-db/src/apply_change.rs
+++ b/crates/ide-db/src/apply_change.rs
@@ -136,16 +136,11 @@ impl RootDatabase {
             hir::db::FileItemTreeQuery
             hir::db::CrateDefMapQueryQuery
             hir::db::BlockDefMapQuery
-            hir::db::StructDataQuery
             hir::db::StructDataWithDiagnosticsQuery
-            hir::db::UnionDataQuery
             hir::db::UnionDataWithDiagnosticsQuery
             hir::db::EnumDataQuery
             hir::db::EnumVariantDataWithDiagnosticsQuery
-            hir::db::EnumVariantDataQuery
-            hir::db::ImplDataQuery
             hir::db::ImplDataWithDiagnosticsQuery
-            hir::db::TraitDataQuery
             hir::db::TraitDataWithDiagnosticsQuery
             hir::db::TraitAliasDataQuery
             hir::db::TypeAliasDataQuery
diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs
index e1b6c13ba8e..dc61fc0e4ca 100644
--- a/crates/ide-db/src/lib.rs
+++ b/crates/ide-db/src/lib.rs
@@ -217,16 +217,11 @@ impl RootDatabase {
             hir_db::FileItemTreeQuery
             hir_db::CrateDefMapQueryQuery
             hir_db::BlockDefMapQuery
-            hir_db::StructDataQuery
             hir_db::StructDataWithDiagnosticsQuery
-            hir_db::UnionDataQuery
             hir_db::UnionDataWithDiagnosticsQuery
             hir_db::EnumDataQuery
-            hir_db::EnumDataQuery
             hir_db::EnumVariantDataWithDiagnosticsQuery
-            hir_db::ImplDataQuery
             hir_db::ImplDataWithDiagnosticsQuery
-            hir_db::TraitDataQuery
             hir_db::TraitDataWithDiagnosticsQuery
             hir_db::TraitAliasDataQuery
             hir_db::TypeAliasDataQuery
diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs
index ee2f15c5a6a..9d449bd18ee 100644
--- a/crates/ide/src/hover/render.rs
+++ b/crates/ide/src/hover/render.rs
@@ -463,9 +463,9 @@ pub(super) fn definition(
     };
 
     let label = match (value, layout_info) {
-        (Some(value), Some(layout_info)) => format!("{label} = {value}{layout_info}"),
+        (Some(value), Some(layout_info)) => format!("{layout_info}\n{label} = {value}"),
         (Some(value), None) => format!("{label} = {value}"),
-        (None, Some(layout_info)) => format!("{label}{layout_info}"),
+        (None, Some(layout_info)) => format!("{layout_info}\n{label}"),
         (None, None) => label,
     };
 
@@ -617,8 +617,6 @@ fn render_memory_layout(
     offset: impl FnOnce(&Layout) -> Option<u64>,
     tag: impl FnOnce(&Layout) -> Option<usize>,
 ) -> Option<String> {
-    // field
-
     let config = config?;
     let layout = layout().ok()?;
 
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index d5ec336fc7e..8ef8f295765 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -157,7 +157,8 @@ fn foo() {
             *local*
 
             ```rust
-            let local: i32 // size = 4, align = 4
+             // size = 4, align = 4
+            let local: i32
             ```
         "#]],
     );
@@ -433,7 +434,8 @@ fn main() {
             *iter*
 
             ```rust
-            let mut iter: Iter<Scan<OtherStruct<OtherStruct<i32>>, impl Fn(&mut u32, &u32, &mut u32) -> Option<u32>, u32>> // size = 8, align = 4
+             // size = 8, align = 4
+            let mut iter: Iter<Scan<OtherStruct<OtherStruct<i32>>, impl Fn(&mut u32, &u32, &mut u32) -> Option<u32>, u32>>
             ```
         "#]],
     );
@@ -674,7 +676,8 @@ struct Foo { fiel$0d_a: u8, field_b: i32, field_c: i16 }
             ```
 
             ```rust
-            field_a: u8 // size = 1, align = 1, offset = 6
+             // size = 1, align = 1, offset = 6
+            field_a: u8
             ```
         "#]],
     );
@@ -699,7 +702,8 @@ fn main() {
             ```
 
             ```rust
-            field_a: u32 // size = 4, align = 4, offset = 0
+             // size = 4, align = 4, offset = 0
+            field_a: u32
             ```
         "#]],
     );
@@ -721,7 +725,8 @@ fn main() {
             ```
 
             ```rust
-            field_a: u32 // size = 4, align = 4, offset = 0
+             // size = 4, align = 4, offset = 0
+            field_a: u32
             ```
         "#]],
     );
@@ -848,7 +853,8 @@ fn main() {
             *zz*
 
             ```rust
-            let zz: Test<i32> // size = 8, align = 4
+             // size = 8, align = 4
+            let zz: Test<i32>
             ```
         "#]],
     );
@@ -899,7 +905,8 @@ fn main() { let b$0ar = Some(12); }
             *bar*
 
             ```rust
-            let bar: Option<i32> // size = 4, align = 4
+             // size = 4, align = 4
+            let bar: Option<i32>
             ```
         "#]],
     );
@@ -968,7 +975,8 @@ fn hover_for_local_variable() {
             *foo*
 
             ```rust
-            foo: i32 // size = 4, align = 4
+             // size = 4, align = 4
+            foo: i32
             ```
         "#]],
     )
@@ -982,7 +990,8 @@ fn hover_for_local_variable_pat() {
             *foo*
 
             ```rust
-            foo: i32 // size = 4, align = 4
+             // size = 4, align = 4
+            foo: i32
             ```
         "#]],
     )
@@ -996,7 +1005,8 @@ fn hover_local_var_edge() {
             *foo*
 
             ```rust
-            foo: i32 // size = 4, align = 4
+             // size = 4, align = 4
+            foo: i32
             ```
         "#]],
     )
@@ -1010,7 +1020,8 @@ fn hover_for_param_edge() {
             *foo*
 
             ```rust
-            foo: i32 // size = 4, align = 4
+             // size = 4, align = 4
+            foo: i32
             ```
         "#]],
     )
@@ -1054,7 +1065,8 @@ fn main() { let foo_$0test = Thing::new(); }
             *foo_test*
 
             ```rust
-            let foo_test: Thing // size = 4, align = 4
+             // size = 4, align = 4
+            let foo_test: Thing
             ```
         "#]],
     )
@@ -1222,7 +1234,8 @@ fn y() {
             *x*
 
             ```rust
-            let x: i32 // size = 4, align = 4
+             // size = 4, align = 4
+            let x: i32
             ```
         "#]],
     )
@@ -1352,7 +1365,8 @@ fn foo(bar:u32) { let a = id!(ba$0r); }
             *bar*
 
             ```rust
-            bar: u32 // size = 4, align = 4
+             // size = 4, align = 4
+            bar: u32
             ```
         "#]],
     );
@@ -1370,7 +1384,8 @@ fn foo(bar:u32) { let a = id!(ba$0r); }
             *bar*
 
             ```rust
-            bar: u32 // size = 4, align = 4
+             // size = 4, align = 4
+            bar: u32
             ```
         "#]],
     );
@@ -1619,7 +1634,8 @@ fn test_hover_function_pointer_show_identifiers() {
             ```
 
             ```rust
-            type foo = fn(a: i32, b: i32) -> i32 // size = 8, align = 8, niches = 1
+             // size = 8, align = 8, niches = 1
+            type foo = fn(a: i32, b: i32) -> i32
             ```
         "#]],
     );
@@ -1637,7 +1653,8 @@ fn test_hover_function_pointer_no_identifier() {
             ```
 
             ```rust
-            type foo = fn(i32, i32) -> i32 // size = 8, align = 8, niches = 1
+             // size = 8, align = 8, niches = 1
+            type foo = fn(i32, i32) -> i32
             ```
         "#]],
     );
@@ -1783,7 +1800,8 @@ fn foo() { let bar = Ba$0r; }
             ```
 
             ```rust
-            struct Bar // size = 0, align = 1
+             // size = 0, align = 1
+            struct Bar
             ```
 
             ---
@@ -1819,7 +1837,8 @@ fn foo() { let bar = Ba$0r; }
             ```
 
             ```rust
-            struct Bar // size = 0, align = 1
+             // size = 0, align = 1
+            struct Bar
             ```
 
             ---
@@ -1848,7 +1867,8 @@ fn foo() { let bar = Ba$0r; }
             ```
 
             ```rust
-            struct Bar // size = 0, align = 1
+             // size = 0, align = 1
+            struct Bar
             ```
 
             ---
@@ -1876,7 +1896,8 @@ pub struct B$0ar
             ```
 
             ```rust
-            pub struct Bar // size = 0, align = 1
+             // size = 0, align = 1
+            pub struct Bar
             ```
 
             ---
@@ -1903,7 +1924,8 @@ pub struct B$0ar
             ```
 
             ```rust
-            pub struct Bar // size = 0, align = 1
+             // size = 0, align = 1
+            pub struct Bar
             ```
 
             ---
@@ -1992,7 +2014,8 @@ fn test_hover_layout_of_variant() {
             ```
 
             ```rust
-            Variant1(u8, u16) // size = 4, align = 2
+             // size = 4, align = 2
+            Variant1(u8, u16)
             ```
         "#]],
     );
@@ -2013,10 +2036,11 @@ fn test_hover_layout_of_enum() {
             ```
 
             ```rust
+             // size = 16 (0x10), align = 8, niches = 254
             enum Foo {
                 Variant1(u8, u16),
                 Variant2(i32, u8, i64),
-            } // size = 16 (0x10), align = 8, niches = 254
+            }
             ```
         "#]],
     );
@@ -3316,7 +3340,8 @@ fn main() {
             *f*
 
             ```rust
-            f: &i32 // size = 8, align = 8, niches = 1
+             // size = 8, align = 8, niches = 1
+            f: &i32
             ```
             ---
 
@@ -3325,7 +3350,8 @@ fn main() {
             ```
 
             ```rust
-            f: i32 // size = 4, align = 4, offset = 0
+             // size = 4, align = 4, offset = 0
+            f: i32
             ```
         "#]],
     );
@@ -3409,7 +3435,8 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<1> // size = 0, align = 1
+             // size = 0, align = 1
+            let value: Const<1>
             ```
         "#]],
     );
@@ -3429,7 +3456,8 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<0> // size = 0, align = 1
+             // size = 0, align = 1
+            let value: Const<0>
             ```
         "#]],
     );
@@ -3449,7 +3477,8 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<-1> // size = 0, align = 1
+             // size = 0, align = 1
+            let value: Const<-1>
             ```
         "#]],
     );
@@ -3469,7 +3498,8 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<true> // size = 0, align = 1
+             // size = 0, align = 1
+            let value: Const<true>
             ```
         "#]],
     );
@@ -3489,7 +3519,8 @@ fn main() {
             *value*
 
             ```rust
-            let value: Const<'🦀'> // size = 0, align = 1
+             // size = 0, align = 1
+            let value: Const<'🦀'>
             ```
         "#]],
     );
@@ -3508,7 +3539,8 @@ impl Foo {
             *self*
 
             ```rust
-            self: &Foo // size = 8, align = 8, niches = 1
+             // size = 8, align = 8, niches = 1
+            self: &Foo
             ```
         "#]],
     );
@@ -3528,7 +3560,8 @@ impl Foo {
             *self*
 
             ```rust
-            self: Arc<Foo> // size = 0, align = 1
+             // size = 0, align = 1
+            self: Arc<Foo>
             ```
         "#]],
     );
@@ -3913,7 +3946,8 @@ type Fo$0o2 = Foo<2>;
             ```
 
             ```rust
-            type Foo2 = Foo<2> // size = 0, align = 1
+             // size = 0, align = 1
+            type Foo2 = Foo<2>
             ```
         "#]],
     );
@@ -3955,7 +3989,8 @@ enum E {
             ```
 
             ```rust
-            A = 8 // size = 1, align = 1
+             // size = 1, align = 1
+            A = 8
             ```
 
             ---
@@ -3980,7 +4015,8 @@ enum E {
             ```
 
             ```rust
-            A = 12 (0xC) // size = 1, align = 1
+             // size = 1, align = 1
+            A = 12 (0xC)
             ```
 
             ---
@@ -4006,7 +4042,8 @@ enum E {
             ```
 
             ```rust
-            B = 2 // size = 1, align = 1
+             // size = 1, align = 1
+            B = 2
             ```
 
             ---
@@ -4032,7 +4069,8 @@ enum E {
             ```
 
             ```rust
-            B = 5 // size = 1, align = 1
+             // size = 1, align = 1
+            B = 5
             ```
 
             ---
@@ -4838,7 +4876,8 @@ fn foo(e: E) {
             ```
 
             ```rust
-            A = 3 // size = 0, align = 1
+             // size = 0, align = 1
+            A = 3
             ```
 
             ---
@@ -4860,7 +4899,8 @@ fn main() {
             *tile4*
 
             ```rust
-            let tile4: [u32; 8] // size = 32 (0x20), align = 4
+             // size = 32 (0x20), align = 4
+            let tile4: [u32; 8]
             ```
         "#]],
     );
@@ -5096,7 +5136,8 @@ pub fn gimme() -> theitem::TheItem {
             ```
 
             ```rust
-            pub struct TheItem // size = 0, align = 1
+             // size = 0, align = 1
+            pub struct TheItem
             ```
 
             ---
@@ -5244,7 +5285,8 @@ mod string {
             ```
 
             ```rust
-            struct String // size = 0, align = 1
+             // size = 0, align = 1
+            struct String
             ```
 
             ---
@@ -5921,7 +5963,8 @@ foo_macro!(
             ```
 
             ```rust
-            pub struct Foo // size = 0, align = 1
+             // size = 0, align = 1
+            pub struct Foo
             ```
 
             ---
@@ -5946,7 +5989,8 @@ pub struct Foo(i32);
             ```
 
             ```rust
-            pub struct Foo(i32); // size = 4, align = 4
+             // size = 4, align = 4
+            pub struct Foo(i32);
             ```
 
             ---
@@ -6045,7 +6089,8 @@ enum Enum {
             ```
 
             ```rust
-            RecordV { field: u32 } // size = 4, align = 4
+             // size = 4, align = 4
+            RecordV { field: u32 }
             ```
         "#]],
     );
@@ -6067,7 +6112,8 @@ enum Enum {
             ```
 
             ```rust
-            field: u32 // size = 4, align = 4
+             // size = 4, align = 4
+            field: u32
             ```
         "#]],
     );
@@ -6569,7 +6615,8 @@ fn test() {
             ```
 
             ```rust
-            f: u32 // size = 4, align = 4, offset = 0
+             // size = 4, align = 4, offset = 0
+            f: u32
             ```
         "#]],
     );
@@ -6588,7 +6635,8 @@ fn test() {
             *s*
 
             ```rust
-            let s: S // size = 0, align = 1
+             // size = 0, align = 1
+            let s: S
             ```
         "#]],
     );
@@ -6608,7 +6656,8 @@ fn test() {
             *foo*
 
             ```rust
-            let foo: i32 // size = 4, align = 4
+             // size = 4, align = 4
+            let foo: i32
             ```
         "#]],
     );
@@ -6628,7 +6677,8 @@ format_args!("{aaaaa$0}");
             *aaaaa*
 
             ```rust
-            let aaaaa: &str // size = 16 (0x10), align = 8, niches = 1
+             // size = 16 (0x10), align = 8, niches = 1
+            let aaaaa: &str
             ```
         "#]],
     );
@@ -6648,7 +6698,8 @@ format_args!("{$0aaaaa}");
             *aaaaa*
 
             ```rust
-            let aaaaa: &str // size = 16 (0x10), align = 8, niches = 1
+             // size = 16 (0x10), align = 8, niches = 1
+            let aaaaa: &str
             ```
         "#]],
     );
@@ -6668,7 +6719,8 @@ format_args!(r"{$0aaaaa}");
             *aaaaa*
 
             ```rust
-            let aaaaa: &str // size = 16 (0x10), align = 8, niches = 1
+             // size = 16 (0x10), align = 8, niches = 1
+            let aaaaa: &str
             ```
         "#]],
     );
@@ -6693,7 +6745,8 @@ foo!(r"{$0aaaaa}");
             *aaaaa*
 
             ```rust
-            let aaaaa: &str // size = 16 (0x10), align = 8, niches = 1
+             // size = 16 (0x10), align = 8, niches = 1
+            let aaaaa: &str
             ```
         "#]],
     );
diff --git a/crates/rust-analyzer/src/cli/rustc_tests.rs b/crates/rust-analyzer/src/cli/rustc_tests.rs
index 87bb3cbd341..baa85d3295d 100644
--- a/crates/rust-analyzer/src/cli/rustc_tests.rs
+++ b/crates/rust-analyzer/src/cli/rustc_tests.rs
@@ -55,7 +55,9 @@ fn detect_errors_from_rustc_stderr_file(p: PathBuf) -> HashMap<DiagnosticCode, u
 
 impl Tester {
     fn new() -> Result<Self> {
-        let tmp_file = AbsPathBuf::assert("/tmp/ra-rustc-test.rs".into());
+        let mut path = std::env::temp_dir();
+        path.push("ra-rustc-test.rs");
+        let tmp_file = AbsPathBuf::try_from(path).unwrap();
         std::fs::write(&tmp_file, "")?;
         let mut cargo_config = CargoConfig::default();
         cargo_config.sysroot = Some(RustLibSource::Discover);
@@ -122,26 +124,43 @@ impl Tester {
         change.change_file(self.root_file, Some(Arc::from(text)));
         self.host.apply_change(change);
         let diagnostic_config = DiagnosticsConfig::test_sample();
-        let diags = self
-            .host
-            .analysis()
-            .diagnostics(&diagnostic_config, ide::AssistResolveStrategy::None, self.root_file)
-            .unwrap();
+
         let mut actual = HashMap::new();
-        for diag in diags {
-            if !matches!(diag.code, DiagnosticCode::RustcHardError(_)) {
-                continue;
-            }
-            if !should_have_no_error && !SUPPORTED_DIAGNOSTICS.contains(&diag.code) {
-                continue;
+        let panicked = match std::panic::catch_unwind(|| {
+            self.host
+                .analysis()
+                .diagnostics(&diagnostic_config, ide::AssistResolveStrategy::None, self.root_file)
+                .unwrap()
+        }) {
+            Err(e) => Some(e),
+            Ok(diags) => {
+                for diag in diags {
+                    if !matches!(diag.code, DiagnosticCode::RustcHardError(_)) {
+                        continue;
+                    }
+                    if !should_have_no_error && !SUPPORTED_DIAGNOSTICS.contains(&diag.code) {
+                        continue;
+                    }
+                    *actual.entry(diag.code).or_insert(0) += 1;
+                }
+                None
             }
-            *actual.entry(diag.code).or_insert(0) += 1;
-        }
+        };
         // Ignore tests with diagnostics that we don't emit.
         ignore_test |= expected.keys().any(|k| !SUPPORTED_DIAGNOSTICS.contains(k));
         if ignore_test {
             println!("{p:?} IGNORE");
             self.ignore_count += 1;
+        } else if let Some(panic) = panicked {
+            if let Some(msg) = panic
+                .downcast_ref::<String>()
+                .map(String::as_str)
+                .or_else(|| panic.downcast_ref::<&str>().copied())
+            {
+                println!("{msg:?} ")
+            }
+            println!("PANIC");
+            self.fail_count += 1;
         } else if actual == expected {
             println!("{p:?} PASS");
             self.pass_count += 1;
@@ -225,11 +244,11 @@ impl flags::RustcTests {
                 let tester = AssertUnwindSafe(&mut tester);
                 let p = p.clone();
                 move || {
+                    let _guard = stdx::panic_context::enter(p.display().to_string());
                     let tester = tester;
                     tester.0.test(p);
                 }
             }) {
-                println!("panic detected at test {:?}", p);
                 std::panic::resume_unwind(e);
             }
         }
diff --git a/crates/span/src/lib.rs b/crates/span/src/lib.rs
index 7617acde64a..54fc0225ae5 100644
--- a/crates/span/src/lib.rs
+++ b/crates/span/src/lib.rs
@@ -2,7 +2,7 @@
 // FIXME: This should be moved into its own crate to get rid of the dependency inversion, base-db
 // has business depending on tt, tt should depend on a span crate only (which unforunately will have
 // to depend on salsa)
-use std::fmt;
+use std::fmt::{self, Write};
 
 use salsa::InternId;
 
@@ -37,6 +37,8 @@ pub const FIXUP_ERASED_FILE_AST_ID_MARKER: ErasedFileAstId =
     // is required to be stable for the proc-macro-server
     la_arena::Idx::from_raw(la_arena::RawIdx::from_u32(!0 - 1));
 
+pub type Span = SpanData<SyntaxContextId>;
+
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 pub struct SpanData<Ctx> {
     /// The text range of this span, relative to the anchor.
@@ -47,6 +49,7 @@ pub struct SpanData<Ctx> {
     /// The syntax context of the span.
     pub ctx: Ctx,
 }
+
 impl Span {
     #[deprecated = "dummy spans will panic if surfaced incorrectly, as such they should be replaced appropriately"]
     pub const DUMMY: Self = SpanData {
@@ -56,7 +59,17 @@ impl Span {
     };
 }
 
-pub type Span = SpanData<SyntaxContextId>;
+impl fmt::Display for Span {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        fmt::Debug::fmt(&self.anchor.file_id.index(), f)?;
+        f.write_char(':')?;
+        fmt::Debug::fmt(&self.anchor.ast_id.into_raw(), f)?;
+        f.write_char('@')?;
+        fmt::Debug::fmt(&self.range, f)?;
+        f.write_char('#')?;
+        self.ctx.fmt(f)
+    }
+}
 
 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
 pub struct SyntaxContextId(InternId);