Repository: rust-lang/rust-analyzer
Pull request #13818 (2022-12-21 20:38:42)

Simplify


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 3d9f0d7cc5..275b77ce4a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -586,9 +586,9 @@ dependencies = [
 
 [[package]]
 name = "hkalbasi-rustc-ap-rustc_abi"
-version = "0.0.20221125"
+version = "0.0.20221221"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29c8368a30e518c0102d670d8515f7d424d875ee615ec7a7b6d29217b57a0371"
+checksum = "adabaadad9aa7576f97af02241cdf5554d62fb3d51a84cb05d77ba28edd3013f"
 dependencies = [
  "bitflags",
  "hkalbasi-rustc-ap-rustc_index",
@@ -597,9 +597,9 @@ dependencies = [
 
 [[package]]
 name = "hkalbasi-rustc-ap-rustc_index"
-version = "0.0.20221125"
+version = "0.0.20221221"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c07bba80d7f6a8e1efb0f3e2115ef1eecbf97292dc8cad84e4982226b9aa12e2"
+checksum = "f4d3c48474e09afb0f5efbd6f758e05411699301a113c47d454d28ec7059d00e"
 dependencies = [
  "arrayvec",
  "smallvec",
diff --git a/crates/hir-def/Cargo.toml b/crates/hir-def/Cargo.toml
index 9ecce46601..698be76656 100644
--- a/crates/hir-def/Cargo.toml
+++ b/crates/hir-def/Cargo.toml
@@ -33,8 +33,8 @@ base-db = { path = "../base-db", version = "0.0.0" }
 syntax = { path = "../syntax", version = "0.0.0" }
 profile = { path = "../profile", version = "0.0.0" }
 hir-expand = { path = "../hir-expand", version = "0.0.0" }
-rustc_abi = { version = "0.0.20221125", package = "hkalbasi-rustc-ap-rustc_abi", default-features = false }
-rustc_index = { version = "0.0.20221125", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }
+rustc_abi = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_abi", default-features = false }
+rustc_index = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }
 mbe = { path = "../mbe", version = "0.0.0" }
 cfg = { path = "../cfg", version = "0.0.0" }
 tt = { path = "../tt", version = "0.0.0" }
diff --git a/crates/hir-ty/Cargo.toml b/crates/hir-ty/Cargo.toml
index e4dd244ab8..c72199c37f 100644
--- a/crates/hir-ty/Cargo.toml
+++ b/crates/hir-ty/Cargo.toml
@@ -25,7 +25,7 @@ chalk-derive = "0.88.0"
 la-arena = { version = "0.3.0", path = "../../lib/la-arena" }
 once_cell = "1.15.0"
 typed-arena = "2.0.1"
-rustc_index = { version = "0.0.20221125", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }
+rustc_index = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }
 
 stdx = { path = "../stdx", version = "0.0.0" }
 hir-def = { path = "../hir-def", version = "0.0.0" }
diff --git a/crates/hir-ty/src/layout/target.rs b/crates/hir-ty/src/layout/target.rs
index 54fa0fd9ea..37b831652f 100644
--- a/crates/hir-ty/src/layout/target.rs
+++ b/crates/hir-ty/src/layout/target.rs
@@ -3,12 +3,10 @@
 use std::sync::Arc;
 
 use base_db::CrateId;
-use hir_def::layout::{TargetDataLayout, TargetDataLayoutErrors};
+use hir_def::layout::{Endian, Size, TargetDataLayout};
 
 use crate::db::HirDatabase;
 
-use hir_def::layout::{AbiAndPrefAlign, AddressSpace, Align, Endian, Size};
-
 pub fn target_data_layout_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<TargetDataLayout> {
     let crate_graph = db.crate_graph();
     let target_layout = &crate_graph[krate].target_layout;
@@ -16,7 +14,7 @@ pub fn target_data_layout_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Tar
     Arc::new(
         target_layout
             .as_ref()
-            .and_then(|it| parse_from_llvm_datalayout_string(it).ok())
+            .and_then(|it| TargetDataLayout::parse_from_llvm_datalayout_string(it).ok())
             .unwrap_or_else(|| {
                 let endian = match cfg_options.get_cfg_values("target_endian").next() {
                     Some(x) if x.as_str() == "big" => Endian::Big,
@@ -36,96 +34,3 @@ pub fn target_data_layout_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Tar
             }),
     )
 }
-
-/// copied from rustc as it is not exposed yet
-fn parse_from_llvm_datalayout_string<'a>(
-    input: &'a str,
-) -> Result<TargetDataLayout, TargetDataLayoutErrors<'a>> {
-    // Parse an address space index from a string.
-    let parse_address_space = |s: &'a str, cause: &'a str| {
-        s.parse::<u32>().map(AddressSpace).map_err(|err| {
-            TargetDataLayoutErrors::InvalidAddressSpace { addr_space: s, cause, err }
-        })
-    };
-
-    // Parse a bit count from a string.
-    let parse_bits = |s: &'a str, kind: &'a str, cause: &'a str| {
-        s.parse::<u64>().map_err(|err| TargetDataLayoutErrors::InvalidBits {
-            kind,
-            bit: s,
-            cause,
-            err,
-        })
-    };
-
-    // Parse a size string.
-    let size = |s: &'a str, cause: &'a str| parse_bits(s, "size", cause).map(Size::from_bits);
-
-    // Parse an alignment string.
-    let align = |s: &[&'a str], cause: &'a str| {
-        if s.is_empty() {
-            return Err(TargetDataLayoutErrors::MissingAlignment { cause });
-        }
-        let align_from_bits = |bits| {
-            Align::from_bits(bits)
-                .map_err(|err| TargetDataLayoutErrors::InvalidAlignment { cause, err })
-        };
-        let abi = parse_bits(s[0], "alignment", cause)?;
-        let pref = s.get(1).map_or(Ok(abi), |pref| parse_bits(pref, "alignment", cause))?;
-        Ok(AbiAndPrefAlign { abi: align_from_bits(abi)?, pref: align_from_bits(pref)? })
-    };
-
-    let mut dl = TargetDataLayout::default();
-    let mut i128_align_src = 64;
-    for spec in input.split('-') {
-        let spec_parts = spec.split(':').collect::<Vec<_>>();
-
-        match &*spec_parts {
-            ["e"] => dl.endian = Endian::Little,
-            ["E"] => dl.endian = Endian::Big,
-            [p] if p.starts_with('P') => {
-                dl.instruction_address_space = parse_address_space(&p[1..], "P")?
-            }
-            ["a", ref a @ ..] => dl.aggregate_align = align(a, "a")?,
-            ["f32", ref a @ ..] => dl.f32_align = align(a, "f32")?,
-            ["f64", ref a @ ..] => dl.f64_align = align(a, "f64")?,
-            [p @ "p", s, ref a @ ..] | [p @ "p0", s, ref a @ ..] => {
-                dl.pointer_size = size(s, p)?;
-                dl.pointer_align = align(a, p)?;
-            }
-            [s, ref a @ ..] if s.starts_with('i') => {
-                let Ok(bits) = s[1..].parse::<u64>() else {
-                    size(&s[1..], "i")?; // For the user error.
-                    continue;
-                };
-                let a = align(a, s)?;
-                match bits {
-                    1 => dl.i1_align = a,
-                    8 => dl.i8_align = a,
-                    16 => dl.i16_align = a,
-                    32 => dl.i32_align = a,
-                    64 => dl.i64_align = a,
-                    _ => {}
-                }
-                if bits >= i128_align_src && bits <= 128 {
-                    // Default alignment for i128 is decided by taking the alignment of
-                    // largest-sized i{64..=128}.
-                    i128_align_src = bits;
-                    dl.i128_align = a;
-                }
-            }
-            [s, ref a @ ..] if s.starts_with('v') => {
-                let v_size = size(&s[1..], "v")?;
-                let a = align(a, s)?;
-                if let Some(v) = dl.vector_align.iter_mut().find(|v| v.0 == v_size) {
-                    v.1 = a;
-                    continue;
-                }
-                // No existing entry, add a new one.
-                dl.vector_align.push((v_size, a));
-            }
-            _ => {} // Ignore everything else.
-        }
-    }
-    Ok(dl)
-}
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index cc983ee014..b69380f08c 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -3691,13 +3691,6 @@ impl From<ItemInNs> for ScopeDef {
     }
 }
 
-#[derive(Clone, Debug, PartialEq, Eq)]
-pub struct Adjustment {
-    pub source: Type,
-    pub target: Type,
-    pub kind: Adjust,
-}
-
 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
 pub enum Adjust {
     /// Go from ! to any type.
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 2ed62372ae..f887c75984 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -2,7 +2,7 @@
 
 mod source_to_def;
 
-use std::{cell::RefCell, fmt, iter, mem, ops};
+use std::{cell::RefCell, fmt, iter, ops};
 
 use base_db::{FileId, FileRange};
 use hir_def::{
@@ -29,7 +29,7 @@ use crate::{
     db::HirDatabase,
     semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
     source_analyzer::{resolve_hir_path, SourceAnalyzer},
-    Access, Adjust, Adjustment, AutoBorrow, BindingMode, BuiltinAttr, Callable, ConstParam, Crate,
+    Access, Adjust, AutoBorrow, BindingMode, BuiltinAttr, Callable, ConstParam, Crate,
     DeriveHelper, Field, Function, HasSource, HirFileId, Impl, InFile, Label, LifetimeParam, Local,
     Macro, Module, ModuleDef, Name, OverloadedDeref, Path, ScopeDef, ToolModule, Trait, Type,
     TypeAlias, TypeParam, VariantDef,
@@ -334,7 +334,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
         self.imp.resolve_trait(trait_)
     }
 
-    pub fn expr_adjustments(&self, expr: &ast::Expr) -> Option<Vec<Adjustment>> {
+    pub fn expr_adjustments(&self, expr: &ast::Expr) -> Option<Vec<Adjust>> {
         self.imp.expr_adjustments(expr)
     }
 
@@ -1067,42 +1067,26 @@ impl<'db> SemanticsImpl<'db> {
         }
     }
 
-    fn expr_adjustments(&self, expr: &ast::Expr) -> Option<Vec<Adjustment>> {
+    fn expr_adjustments(&self, expr: &ast::Expr) -> Option<Vec<Adjust>> {
         let mutability = |m| match m {
             hir_ty::Mutability::Not => Mutability::Shared,
             hir_ty::Mutability::Mut => Mutability::Mut,
         };
-
-        let analyzer = self.analyze(expr.syntax())?;
-
-        let (mut source_ty, _) = analyzer.type_of_expr(self.db, expr)?;
-
-        analyzer.expr_adjustments(self.db, expr).map(|it| {
+        self.analyze(expr.syntax())?.expr_adjustments(self.db, expr).map(|it| {
             it.iter()
-                .map(|adjust| {
-                    let target =
-                        Type::new_with_resolver(self.db, &analyzer.resolver, adjust.target.clone());
-                    let kind = match adjust.kind {
-                        hir_ty::Adjust::NeverToAny => Adjust::NeverToAny,
-                        hir_ty::Adjust::Deref(Some(hir_ty::OverloadedDeref(m))) => {
-                            Adjust::Deref(Some(OverloadedDeref(mutability(m))))
-                        }
-                        hir_ty::Adjust::Deref(None) => Adjust::Deref(None),
-                        hir_ty::Adjust::Borrow(hir_ty::AutoBorrow::RawPtr(m)) => {
-                            Adjust::Borrow(AutoBorrow::RawPtr(mutability(m)))
-                        }
-                        hir_ty::Adjust::Borrow(hir_ty::AutoBorrow::Ref(m)) => {
-                            Adjust::Borrow(AutoBorrow::Ref(mutability(m)))
-                        }
-                        hir_ty::Adjust::Pointer(pc) => Adjust::Pointer(pc),
-                    };
-
-                    // Update `source_ty` for the next adjustment
-                    let source = mem::replace(&mut source_ty, target.clone());
-
-                    let adjustment = Adjustment { source, target, kind };
-
-                    adjustment
+                .map(|adjust| match adjust.kind {
+                    hir_ty::Adjust::NeverToAny => Adjust::NeverToAny,
+                    hir_ty::Adjust::Deref(Some(hir_ty::OverloadedDeref(m))) => {
+                        Adjust::Deref(Some(OverloadedDeref(mutability(m))))
+                    }
+                    hir_ty::Adjust::Deref(None) => Adjust::Deref(None),
+                    hir_ty::Adjust::Borrow(hir_ty::AutoBorrow::RawPtr(m)) => {
+                        Adjust::Borrow(AutoBorrow::RawPtr(mutability(m)))
+                    }
+                    hir_ty::Adjust::Borrow(hir_ty::AutoBorrow::Ref(m)) => {
+                        Adjust::Borrow(AutoBorrow::Ref(mutability(m)))
+                    }
+                    hir_ty::Adjust::Pointer(pc) => Adjust::Pointer(pc),
                 })
                 .collect()
         })
diff --git a/crates/ide-assists/src/handlers/remove_parentheses.rs b/crates/ide-assists/src/handlers/remove_parentheses.rs
index e9c7c6bae9..185beda9d0 100644
--- a/crates/ide-assists/src/handlers/remove_parentheses.rs
+++ b/crates/ide-assists/src/handlers/remove_parentheses.rs
@@ -29,8 +29,9 @@ pub(crate) fn remove_parentheses(acc: &mut Assists, ctx: &AssistContext<'_>) ->
 
     let expr = parens.expr()?;
 
-    let parent = parens.syntax().parent()?;
-    if expr.needs_parens_in(parent) {
+    let parent = ast::Expr::cast(parens.syntax().parent()?);
+    let is_ok_to_remove = expr.precedence() >= parent.as_ref().and_then(ast::Expr::precedence);
+    if !is_ok_to_remove {
         return None;
     }
 
@@ -57,31 +58,6 @@ mod tests {
         check_assist(remove_parentheses, r#"fn f() { (2$0) + 2; }"#, r#"fn f() { 2 + 2; }"#);
     }
 
-    #[test]
-    fn remove_parens_closure() {
-        check_assist(remove_parentheses, r#"fn f() { &$0(|| 42) }"#, r#"fn f() { &|| 42 }"#);
-
-        check_assist_not_applicable(remove_parentheses, r#"fn f() { $0(|| 42).f() }"#);
-    }
-
-    #[test]
-    fn remove_parens_if_let_chains() {
-        check_assist_not_applicable(
-            remove_parentheses,
-            r#"fn f() { if let true = $0(true && true) {} }"#,
-        );
-    }
-
-    #[test]
-    fn remove_parens_associativity() {
-        check_assist(
-            remove_parentheses,
-            r#"fn f() { $0(2 + 2) + 2; }"#,
-            r#"fn f() { 2 + 2 + 2; }"#,
-        );
-        check_assist_not_applicable(remove_parentheses, r#"fn f() { 2 + $0(2 + 2); }"#);
-    }
-
     #[test]
     fn remove_parens_precedence() {
         check_assist(
@@ -112,110 +88,4 @@ mod tests {
         check_assist_not_applicable(remove_parentheses, r#"fn f() { (2 +$0 2) }"#);
         check_assist_not_applicable(remove_parentheses, r#"fn f() {$0 (2 + 2) }"#);
     }
-
-    #[test]
-    fn remove_parens_doesnt_apply_when_expr_would_be_turned_into_a_statement() {
-        check_assist_not_applicable(remove_parentheses, r#"fn x() -> u8 { $0({ 0 } + 1) }"#);
-        check_assist_not_applicable(
-            remove_parentheses,
-            r#"fn x() -> u8 { $0(if true { 0 } else { 1 } + 1) }"#,
-        );
-        check_assist_not_applicable(remove_parentheses, r#"fn x() -> u8 { $0(loop {} + 1) }"#);
-    }
-
-    #[test]
-    fn remove_parens_doesnt_apply_weird_syntax_and_adge_cases() {
-        // removing `()` would break code because {} would be counted as the loop/if body
-        check_assist_not_applicable(remove_parentheses, r#"fn f() { for _ in $0(0..{3}) {} }"#);
-        check_assist_not_applicable(remove_parentheses, r#"fn f() { for _ in $0(S {}) {} }"#);
-        check_assist_not_applicable(remove_parentheses, r#"fn f() { if $0(S {} == 2) {} }"#);
-        check_assist_not_applicable(remove_parentheses, r#"fn f() { if $0(return) {} }"#);
-    }
-
-    #[test]
-    fn remove_parens_return_with_value_followed_by_block() {
-        check_assist(
-            remove_parentheses,
-            r#"fn f() { if $0(return ()) {} }"#,
-            r#"fn f() { if return () {} }"#,
-        );
-    }
-
-    #[test]
-    fn remove_exprs_let_else_restrictions() {
-        // `}` is not allowed before `else` here
-        check_assist_not_applicable(
-            remove_parentheses,
-            r#"fn f() { let _ = $0(S{}) else { return }; }"#,
-        );
-
-        // logic operators can't directly appear in the let-else
-        check_assist_not_applicable(
-            remove_parentheses,
-            r#"fn f() { let _ = $0(false || false) else { return }; }"#,
-        );
-        check_assist_not_applicable(
-            remove_parentheses,
-            r#"fn f() { let _ = $0(true && true) else { return }; }"#,
-        );
-    }
-
-    #[test]
-    fn remove_parens_weird_places() {
-        check_assist(
-            remove_parentheses,
-            r#"fn f() { match () { _=>$0(()) } }"#,
-            r#"fn f() { match () { _=>() } }"#,
-        );
-
-        check_assist(
-            remove_parentheses,
-            r#"fn x() -> u8 { { [$0({ 0 } + 1)] } }"#,
-            r#"fn x() -> u8 { { [{ 0 } + 1] } }"#,
-        );
-    }
-
-    #[test]
-    fn remove_parens_return_dot_f() {
-        check_assist(
-            remove_parentheses,
-            r#"fn f() { $0(return).f() }"#,
-            r#"fn f() { return.f() }"#,
-        );
-    }
-
-    #[test]
-    fn remove_parens_prefix_then_return_something() {
-        check_assist(
-            remove_parentheses,
-            r#"fn f() { &$0(return ()) }"#,
-            r#"fn f() { &return () }"#,
-        );
-    }
-
-    #[test]
-    fn remove_parens_double_paren_stmt() {
-        check_assist(
-            remove_parentheses,
-            r#"fn x() -> u8 { $0(({ 0 } + 1)) }"#,
-            r#"fn x() -> u8 { ({ 0 } + 1) }"#,
-        );
-
-        check_assist(
-            remove_parentheses,
-            r#"fn x() -> u8 { (($0{ 0 } + 1)) }"#,
-            r#"fn x() -> u8 { ({ 0 } + 1) }"#,
-        );
-    }
-
-    #[test]
-    fn remove_parens_im_tired_of_naming_tests() {
-        check_assist(
-            remove_parentheses,
-            r#"fn f() { 2 + $0(return 2) }"#,
-            r#"fn f() { 2 + return 2 }"#,
-        );
-
-        check_assist_not_applicable(remove_parentheses, r#"fn f() { $0(return 2) + 2 }"#);
-    }
 }
diff --git a/crates/ide-completion/src/completions/record.rs b/crates/ide-completion/src/completions/record.rs
index 6743ec897f..5d96fbd30a 100644
--- a/crates/ide-completion/src/completions/record.rs
+++ b/crates/ide-completion/src/completions/record.rs
@@ -124,12 +124,7 @@ fn complete_fields(
 
 #[cfg(test)]
 mod tests {
-    use ide_db::SnippetCap;
-
-    use crate::{
-        tests::{check_edit, check_edit_with_config, TEST_CONFIG},
-        CompletionConfig,
-    };
+    use crate::tests::check_edit;
 
     #[test]
     fn literal_struct_completion_edit() {
@@ -156,37 +151,6 @@ fn baz() {
         )
     }
 
-    #[test]
-    fn enum_variant_no_snippets() {
-        let conf = CompletionConfig { snippet_cap: SnippetCap::new(false), ..TEST_CONFIG };
-        check_edit_with_config(
-            conf,
-            "Variant()",
-            r#"
-enum Enum {
-    Variant(usize),
-}
-
-impl Enum {
-    fn new(u: usize) -> Self {
-        Self::Va$0
-    }
-}
-"#,
-            r#"
-enum Enum {
-    Variant(usize),
-}
-
-impl Enum {
-    fn new(u: usize) -> Self {
-        Self::Variant
-    }
-}
-"#,
-        )
-    }
-
     #[test]
     fn literal_struct_impl_self_completion() {
         check_edit(
diff --git a/crates/ide-completion/src/render/literal.rs b/crates/ide-completion/src/render/literal.rs
index 3aeb69258e..0c791ac570 100644
--- a/crates/ide-completion/src/render/literal.rs
+++ b/crates/ide-completion/src/render/literal.rs
@@ -96,7 +96,7 @@ fn render(
     if !should_add_parens {
         kind = StructKind::Unit;
     }
-    let label = format_literal_label(&qualified_name, kind, snippet_cap);
+    let label = format_literal_label(&qualified_name, kind);
     let lookup = if qualified {
         format_literal_lookup(&short_qualified_name.to_string(), kind)
     } else {
diff --git a/crates/ide-completion/src/render/pattern.rs b/crates/ide-completion/src/render/pattern.rs
index 21b4bc2174..c845ff21aa 100644
--- a/crates/ide-completion/src/render/pattern.rs
+++ b/crates/ide-completion/src/render/pattern.rs
@@ -33,7 +33,7 @@ pub(crate) fn render_struct_pat(
     let name = local_name.unwrap_or_else(|| strukt.name(ctx.db()));
     let (name, escaped_name) = (name.unescaped().to_smol_str(), name.to_smol_str());
     let kind = strukt.kind(ctx.db());
-    let label = format_literal_label(name.as_str(), kind, ctx.snippet_cap());
+    let label = format_literal_label(name.as_str(), kind);
     let lookup = format_literal_lookup(name.as_str(), kind);
     let pat = render_pat(&ctx, pattern_ctx, &escaped_name, kind, &visible_fields, fields_omitted)?;
 
@@ -67,7 +67,7 @@ pub(crate) fn render_variant_pat(
         }
         _ => {
             let kind = variant.kind(ctx.db());
-            let label = format_literal_label(name.as_str(), kind, ctx.snippet_cap());
+            let label = format_literal_label(name.as_str(), kind);
             let lookup = format_literal_lookup(name.as_str(), kind);
             let pat = render_pat(
                 &ctx,
diff --git a/crates/ide-completion/src/render/union_literal.rs b/crates/ide-completion/src/render/union_literal.rs
index 2d55a1bade..54e97dd57b 100644
--- a/crates/ide-completion/src/render/union_literal.rs
+++ b/crates/ide-completion/src/render/union_literal.rs
@@ -24,7 +24,7 @@ pub(crate) fn render_union_literal(
         Some(p) => (p.unescaped().to_string(), p.to_string()),
         None => (name.unescaped().to_string(), name.to_string()),
     };
-    let label = format_literal_label(&name.to_smol_str(), StructKind::Record, ctx.snippet_cap());
+    let label = format_literal_label(&name.to_smol_str(), StructKind::Record);
     let lookup = format_literal_lookup(&name.to_smol_str(), StructKind::Record);
     let mut item = CompletionItem::new(
         CompletionItemKind::SymbolKind(SymbolKind::Union),
diff --git a/crates/ide-completion/src/render/variant.rs b/crates/ide-completion/src/render/variant.rs
index d69906a706..24e6abdc9a 100644
--- a/crates/ide-completion/src/render/variant.rs
+++ b/crates/ide-completion/src/render/variant.rs
@@ -48,9 +48,6 @@ pub(crate) fn render_tuple_lit(
     fields: &[hir::Field],
     path: &str,
 ) -> RenderedLiteral {
-    if snippet_cap.is_none() {
-        return RenderedLiteral { literal: format!("{}", path), detail: format!("{}", path) };
-    }
     let completions = fields.iter().enumerate().format_with(", ", |(idx, _), f| {
         if snippet_cap.is_some() {
             f(&format_args!("${{{}:()}}", idx + 1))
@@ -90,14 +87,7 @@ pub(crate) fn visible_fields(
 }
 
 /// Format a struct, etc. literal option for display in the completions menu.
-pub(crate) fn format_literal_label(
-    name: &str,
-    kind: StructKind,
-    snippet_cap: Option<SnippetCap>,
-) -> SmolStr {
-    if snippet_cap.is_none() {
-        return name.into();
-    }
+pub(crate) fn format_literal_label(name: &str, kind: StructKind) -> SmolStr {
     match kind {
         StructKind::Tuple => SmolStr::from_iter([name, "(…)"]),
         StructKind::Record => SmolStr::from_iter([name, " {…}"]),
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 152f31b3a5..66a40627dc 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -1,26 +1,24 @@
 use std::fmt;
 
 use either::Either;
-use hir::{known, HasVisibility, HirDisplay, Semantics};
-use ide_db::{base_db::FileRange, famous_defs::FamousDefs, RootDatabase};
+use hir::{
+    known, Adjust, AutoBorrow, Callable, HasVisibility, HirDisplay, Mutability, OverloadedDeref,
+    PointerCast, Safety, Semantics, TypeInfo,
+};
+use ide_db::{
+    base_db::FileRange, famous_defs::FamousDefs, syntax_helpers::node_ext::walk_ty, FxHashMap,
+    RootDatabase,
+};
 use itertools::Itertools;
+use stdx::to_lower_snake_case;
 use syntax::{
-    ast::{self, AstNode},
-    match_ast, NodeOrToken, SyntaxNode, TextRange, TextSize,
+    ast::{self, AstNode, HasArgList, HasGenericParams, HasName, UnaryOp},
+    match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken, TextRange,
+    TextSize, T,
 };
 
 use crate::FileId;
 
-mod closing_brace;
-mod implicit_static;
-mod fn_lifetime_fn;
-mod closure_ret;
-mod adjustment;
-mod chaining;
-mod param_name;
-mod binding_mode;
-mod bind_pat;
-
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub struct InlayHintsConfig {
     pub render_colons: bool,
@@ -229,18 +227,18 @@ fn hints(
     file_id: FileId,
     node: SyntaxNode,
 ) {
-    closing_brace::hints(hints, sema, config, file_id, node.clone());
+    closing_brace_hints(hints, sema, config, file_id, node.clone());
     match_ast! {
         match node {
             ast::Expr(expr) => {
-                chaining::hints(hints, sema, &famous_defs, config, file_id, &expr);
-                adjustment::hints(hints, sema, config, &expr);
+                chaining_hints(hints, sema, &famous_defs, config, file_id, &expr);
+                adjustment_hints(hints, sema, config, &expr);
                 match expr {
-                    ast::Expr::CallExpr(it) => param_name::hints(hints, sema, config, ast::Expr::from(it)),
+                    ast::Expr::CallExpr(it) => param_name_hints(hints, sema, config, ast::Expr::from(it)),
                     ast::Expr::MethodCallExpr(it) => {
-                        param_name::hints(hints, sema, config, ast::Expr::from(it))
+                        param_name_hints(hints, sema, config, ast::Expr::from(it))
                     }
-                    ast::Expr::ClosureExpr(it) => closure_ret::hints(hints, sema, &famous_defs, config, file_id, it),
+                    ast::Expr::ClosureExpr(it) => closure_ret_hints(hints, sema, &famous_defs, config, file_id, it),
                     // We could show reborrows for all expressions, but usually that is just noise to the user
                     // and the main point here is to show why "moving" a mutable reference doesn't necessarily move it
                     // ast::Expr::PathExpr(_) => reborrow_hints(hints, sema, config, &expr),
@@ -248,19 +246,19 @@ fn hints(
                 }
             },
             ast::Pat(it) => {
-                binding_mode::hints(hints, sema, config, &it);
+                binding_mode_hints(hints, sema, config, &it);
                 if let ast::Pat::IdentPat(it) = it {
-                    bind_pat::hints(hints, sema, config, file_id, &it);
+                    bind_pat_hints(hints, sema, config, file_id, &it);
                 }
                 Some(())
             },
             ast::Item(it) => match it {
                 // FIXME: record impl lifetimes so they aren't being reused in assoc item lifetime inlay hints
                 ast::Item::Impl(_) => None,
-                ast::Item::Fn(it) => fn_lifetime_fn::hints(hints, config, it),
+                ast::Item::Fn(it) => fn_lifetime_fn_hints(hints, config, it),
                 // static type elisions
-                ast::Item::Static(it) => implicit_static::hints(hints, config, Either::Left(it)),
-                ast::Item::Const(it) => implicit_static::hints(hints, config, Either::Right(it)),
+                ast::Item::Static(it) => implicit_static_hints(hints, config, Either::Left(it)),
+                ast::Item::Const(it) => implicit_static_hints(hints, config, Either::Right(it)),
                 _ => None,
             },
             // FIXME: fn-ptr type, dyn fn type, and trait object type elisions
@@ -270,6 +268,755 @@ fn hints(
     };
 }
 
+fn closing_brace_hints(
+    acc: &mut Vec<InlayHint>,
+    sema: &Semantics<'_, RootDatabase>,
+    config: &InlayHintsConfig,
+    file_id: FileId,
+    node: SyntaxNode,
+) -> Option<()> {
+    let min_lines = config.closing_brace_hints_min_lines?;
+
+    let name = |it: ast::Name| it.syntax().text_range();
+
+    let mut closing_token;
+    let (label, name_range) = if let Some(item_list) = ast::AssocItemList::cast(node.clone()) {
+        closing_token = item_list.r_curly_token()?;
+
+        let parent = item_list.syntax().parent()?;
+        match_ast! {
+            match parent {
+                ast::Impl(imp) => {
+                    let imp = sema.to_def(&imp)?;
+                    let ty = imp.self_ty(sema.db);
+                    let trait_ = imp.trait_(sema.db);
+                    let hint_text = match trait_ {
+                        Some(tr) => format!("impl {} for {}", tr.name(sema.db), ty.display_truncated(sema.db, config.max_length)),
+                        None => format!("impl {}", ty.display_truncated(sema.db, config.max_length)),
+                    };
+                    (hint_text, None)
+                },
+                ast::Trait(tr) => {
+                    (format!("trait {}", tr.name()?), tr.name().map(name))
+                },
+                _ => return None,
+            }
+        }
+    } else if let Some(list) = ast::ItemList::cast(node.clone()) {
+        closing_token = list.r_curly_token()?;
+
+        let module = ast::Module::cast(list.syntax().parent()?)?;
+        (format!("mod {}", module.name()?), module.name().map(name))
+    } else if let Some(block) = ast::BlockExpr::cast(node.clone()) {
+        closing_token = block.stmt_list()?.r_curly_token()?;
+
+        let parent = block.syntax().parent()?;
+        match_ast! {
+            match parent {
+                ast::Fn(it) => {
+                    // FIXME: this could include parameters, but `HirDisplay` prints too much info
+                    // and doesn't respect the max length either, so the hints end up way too long
+                    (format!("fn {}", it.name()?), it.name().map(name))
+                },
+                ast::Static(it) => (format!("static {}", it.name()?), it.name().map(name)),
+                ast::Const(it) => {
+                    if it.underscore_token().is_some() {
+                        ("const _".into(), None)
+                    } else {
+                        (format!("const {}", it.name()?), it.name().map(name))
+                    }
+                },
+                _ => return None,
+            }
+        }
+    } else if let Some(mac) = ast::MacroCall::cast(node.clone()) {
+        let last_token = mac.syntax().last_token()?;
+        if last_token.kind() != T![;] && last_token.kind() != SyntaxKind::R_CURLY {
+            return None;
+        }
+        closing_token = last_token;
+
+        (
+            format!("{}!", mac.path()?),
+            mac.path().and_then(|it| it.segment()).map(|it| it.syntax().text_range()),
+        )
+    } else {
+        return None;
+    };
+
+    if let Some(mut next) = closing_token.next_token() {
+        if next.kind() == T![;] {
+            if let Some(tok) = next.next_token() {
+                closing_token = next;
+                next = tok;
+            }
+        }
+        if !(next.kind() == SyntaxKind::WHITESPACE && next.text().contains('\n')) {
+            // Only display the hint if the `}` is the last token on the line
+            return None;
+        }
+    }
+
+    let mut lines = 1;
+    node.text().for_each_chunk(|s| lines += s.matches('\n').count());
+    if lines < min_lines {
+        return None;
+    }
+
+    let linked_location = name_range.map(|range| FileRange { file_id, range });
+    acc.push(InlayHint {
+        range: closing_token.text_range(),
+        kind: InlayKind::ClosingBraceHint,
+        label: InlayHintLabel { parts: vec![InlayHintLabelPart { text: label, linked_location }] },
+        tooltip: None, // provided by label part location
+    });
+
+    None
+}
+
+fn implicit_static_hints(
+    acc: &mut Vec<InlayHint>,
+    config: &InlayHintsConfig,
+    statik_or_const: Either<ast::Static, ast::Const>,
+) -> Option<()> {
+    if config.lifetime_elision_hints != LifetimeElisionHints::Always {
+        return None;
+    }
+
+    if let Either::Right(it) = &statik_or_const {
+        if ast::AssocItemList::can_cast(
+            it.syntax().parent().map_or(SyntaxKind::EOF, |it| it.kind()),
+        ) {
+            return None;
+        }
+    }
+
+    if let Some(ast::Type::RefType(ty)) = statik_or_const.either(|it| it.ty(), |it| it.ty()) {
+        if ty.lifetime().is_none() {
+            let t = ty.amp_token()?;
+            acc.push(InlayHint {
+                range: t.text_range(),
+                kind: InlayKind::LifetimeHint,
+                label: "'static".to_owned().into(),
+                tooltip: Some(InlayTooltip::String("Elided static lifetime".into())),
+            });
+        }
+    }
+
+    Some(())
+}
+
+fn fn_lifetime_fn_hints(
+    acc: &mut Vec<InlayHint>,
+    config: &InlayHintsConfig,
+    func: ast::Fn,
+) -> Option<()> {
+    if config.lifetime_elision_hints == LifetimeElisionHints::Never {
+        return None;
+    }
+
+    let mk_lt_hint = |t: SyntaxToken, label: String| InlayHint {
+        range: t.text_range(),
+        kind: InlayKind::LifetimeHint,
+        label: label.into(),
+        tooltip: Some(InlayTooltip::String("Elided lifetime".into())),
+    };
+
+    let param_list = func.param_list()?;
+    let generic_param_list = func.generic_param_list();
+    let ret_type = func.ret_type();
+    let self_param = param_list.self_param().filter(|it| it.amp_token().is_some());
+
+    let is_elided = |lt: &Option<ast::Lifetime>| match lt {
+        Some(lt) => matches!(lt.text().as_str(), "'_"),
+        None => true,
+    };
+
+    let potential_lt_refs = {
+        let mut acc: Vec<_> = vec![];
+        if let Some(self_param) = &self_param {
+            let lifetime = self_param.lifetime();
+            let is_elided = is_elided(&lifetime);
+            acc.push((None, self_param.amp_token(), lifetime, is_elided));
+        }
+        param_list.params().filter_map(|it| Some((it.pat(), it.ty()?))).for_each(|(pat, ty)| {
+            // FIXME: check path types
+            walk_ty(&ty, &mut |ty| match ty {
+                ast::Type::RefType(r) => {
+                    let lifetime = r.lifetime();
+                    let is_elided = is_elided(&lifetime);
+                    acc.push((
+                        pat.as_ref().and_then(|it| match it {
+                            ast::Pat::IdentPat(p) => p.name(),
+                            _ => None,
+                        }),
+                        r.amp_token(),
+                        lifetime,
+                        is_elided,
+                    ))
+                }
+                _ => (),
+            })
+        });
+        acc
+    };
+
+    // allocate names
+    let mut gen_idx_name = {
+        let mut gen = (0u8..).map(|idx| match idx {
+            idx if idx < 10 => SmolStr::from_iter(['\'', (idx + 48) as char]),
+            idx => format!("'{idx}").into(),
+        });
+        move || gen.next().unwrap_or_default()
+    };
+    let mut allocated_lifetimes = vec![];
+
+    let mut used_names: FxHashMap<SmolStr, usize> =
+        match config.param_names_for_lifetime_elision_hints {
+            true => generic_param_list
+                .iter()
+                .flat_map(|gpl| gpl.lifetime_params())
+                .filter_map(|param| param.lifetime())
+                .filter_map(|lt| Some((SmolStr::from(lt.text().as_str().get(1..)?), 0)))
+                .collect(),
+            false => Default::default(),
+        };
+    {
+        let mut potential_lt_refs = potential_lt_refs.iter().filter(|&&(.., is_elided)| is_elided);
+        if let Some(_) = &self_param {
+            if let Some(_) = potential_lt_refs.next() {
+                allocated_lifetimes.push(if config.param_names_for_lifetime_elision_hints {
+                    // self can't be used as a lifetime, so no need to check for collisions
+                    "'self".into()
+                } else {
+                    gen_idx_name()
+                });
+            }
+        }
+        potential_lt_refs.for_each(|(name, ..)| {
+            let name = match name {
+                Some(it) if config.param_names_for_lifetime_elision_hints => {
+                    if let Some(c) = used_names.get_mut(it.text().as_str()) {
+                        *c += 1;
+                        SmolStr::from(format!("'{text}{c}", text = it.text().as_str()))
+                    } else {
+                        used_names.insert(it.text().as_str().into(), 0);
+                        SmolStr::from_iter(["\'", it.text().as_str()])
+                    }
+                }
+                _ => gen_idx_name(),
+            };
+            allocated_lifetimes.push(name);
+        });
+    }
+
+    // fetch output lifetime if elision rule applies
+    let output = match potential_lt_refs.as_slice() {
+        [(_, _, lifetime, _), ..] if self_param.is_some() || potential_lt_refs.len() == 1 => {
+            match lifetime {
+                Some(lt) => match lt.text().as_str() {
+                    "'_" => allocated_lifetimes.get(0).cloned(),
+                    "'static" => None,
+                    name => Some(name.into()),
+                },
+                None => allocated_lifetimes.get(0).cloned(),
+            }
+        }
+        [..] => None,
+    };
+
+    if allocated_lifetimes.is_empty() && output.is_none() {
+        return None;
+    }
+
+    // apply hints
+    // apply output if required
+    let mut is_trivial = true;
+    if let (Some(output_lt), Some(r)) = (&output, ret_type) {
+        if let Some(ty) = r.ty() {
+            walk_ty(&ty, &mut |ty| match ty {
+                ast::Type::RefType(ty) if ty.lifetime().is_none() => {
+                    if let Some(amp) = ty.amp_token() {
+                        is_trivial = false;
+                        acc.push(mk_lt_hint(amp, output_lt.to_string()));
+                    }
+                }
+                _ => (),
+            })
+        }
+    }
+
+    if config.lifetime_elision_hints == LifetimeElisionHints::SkipTrivial && is_trivial {
+        return None;
+    }
+
+    let mut a = allocated_lifetimes.iter();
+    for (_, amp_token, _, is_elided) in potential_lt_refs {
+        if is_elided {
+            let t = amp_token?;
+            let lt = a.next()?;
+            acc.push(mk_lt_hint(t, lt.to_string()));
+        }
+    }
+
+    // generate generic param list things
+    match (generic_param_list, allocated_lifetimes.as_slice()) {
+        (_, []) => (),
+        (Some(gpl), allocated_lifetimes) => {
+            let angle_tok = gpl.l_angle_token()?;
+            let is_empty = gpl.generic_params().next().is_none();
+            acc.push(InlayHint {
+                range: angle_tok.text_range(),
+                kind: InlayKind::LifetimeHint,
+                label: format!(
+                    "{}{}",
+                    allocated_lifetimes.iter().format(", "),
+                    if is_empty { "" } else { ", " }
+                )
+                .into(),
+                tooltip: Some(InlayTooltip::String("Elided lifetimes".into())),
+            });
+        }
+        (None, allocated_lifetimes) => acc.push(InlayHint {
+            range: func.name()?.syntax().text_range(),
+            kind: InlayKind::GenericParamListHint,
+            label: format!("<{}>", allocated_lifetimes.iter().format(", "),).into(),
+            tooltip: Some(InlayTooltip::String("Elided lifetimes".into())),
+        }),
+    }
+    Some(())
+}
+
+fn closure_ret_hints(
+    acc: &mut Vec<InlayHint>,
+    sema: &Semantics<'_, RootDatabase>,
+    famous_defs: &FamousDefs<'_, '_>,
+    config: &InlayHintsConfig,
+    file_id: FileId,
+    closure: ast::ClosureExpr,
+) -> Option<()> {
+    if config.closure_return_type_hints == ClosureReturnTypeHints::Never {
+        return None;
+    }
+
+    if closure.ret_type().is_some() {
+        return None;
+    }
+
+    if !closure_has_block_body(&closure)
+        && config.closure_return_type_hints == ClosureReturnTypeHints::WithBlock
+    {
+        return None;
+    }
+
+    let param_list = closure.param_list()?;
+
+    let closure = sema.descend_node_into_attributes(closure.clone()).pop()?;
+    let ty = sema.type_of_expr(&ast::Expr::ClosureExpr(closure))?.adjusted();
+    let callable = ty.as_callable(sema.db)?;
+    let ty = callable.return_type();
+    if ty.is_unit() {
+        return None;
+    }
+    acc.push(InlayHint {
+        range: param_list.syntax().text_range(),
+        kind: InlayKind::ClosureReturnTypeHint,
+        label: hint_iterator(sema, &famous_defs, config, &ty)
+            .unwrap_or_else(|| ty.display_truncated(sema.db, config.max_length).to_string())
+            .into(),
+        tooltip: Some(InlayTooltip::HoverRanged(file_id, param_list.syntax().text_range())),
+    });
+    Some(())
+}
+
+fn adjustment_hints(
+    acc: &mut Vec<InlayHint>,
+    sema: &Semantics<'_, RootDatabase>,
+    config: &InlayHintsConfig,
+    expr: &ast::Expr,
+) -> Option<()> {
+    if config.adjustment_hints == AdjustmentHints::Never {
+        return None;
+    }
+
+    // These inherit from the inner expression which would result in duplicate hints
+    if let ast::Expr::ParenExpr(_)
+    | ast::Expr::IfExpr(_)
+    | ast::Expr::BlockExpr(_)
+    | ast::Expr::MatchExpr(_) = expr
+    {
+        return None;
+    }
+
+    let parent = expr.syntax().parent().and_then(ast::Expr::cast);
+    let descended = sema.descend_node_into_attributes(expr.clone()).pop();
+    let desc_expr = descended.as_ref().unwrap_or(expr);
+    let adjustments = sema.expr_adjustments(desc_expr).filter(|it| !it.is_empty())?;
+    let needs_parens = match parent {
+        Some(parent) => {
+            match parent {
+                ast::Expr::AwaitExpr(_)
+                | ast::Expr::CallExpr(_)
+                | ast::Expr::CastExpr(_)
+                | ast::Expr::FieldExpr(_)
+                | ast::Expr::MethodCallExpr(_)
+                | ast::Expr::TryExpr(_) => true,
+                // FIXME: shorthands need special casing, though not sure if adjustments are even valid there
+                ast::Expr::RecordExpr(_) => false,
+                ast::Expr::IndexExpr(index) => index.base().as_ref() == Some(expr),
+                _ => false,
+            }
+        }
+        None => false,
+    };
+    if needs_parens {
+        acc.push(InlayHint {
+            range: expr.syntax().text_range(),
+            kind: InlayKind::OpeningParenthesis,
+            label: "(".into(),
+            tooltip: None,
+        });
+    }
+    for adjustment in adjustments.into_iter().rev() {
+        // FIXME: Add some nicer tooltips to each of these
+        let text = match adjustment {
+            Adjust::NeverToAny if config.adjustment_hints == AdjustmentHints::Always => {
+                "<never-to-any>"
+            }
+            Adjust::Deref(None) => "*",
+            Adjust::Deref(Some(OverloadedDeref(Mutability::Mut))) => "*",
+            Adjust::Deref(Some(OverloadedDeref(Mutability::Shared))) => "*",
+            Adjust::Borrow(AutoBorrow::Ref(Mutability::Shared)) => "&",
+            Adjust::Borrow(AutoBorrow::Ref(Mutability::Mut)) => "&mut ",
+            Adjust::Borrow(AutoBorrow::RawPtr(Mutability::Shared)) => "&raw const ",
+            Adjust::Borrow(AutoBorrow::RawPtr(Mutability::Mut)) => "&raw mut ",
+            // some of these could be represented via `as` casts, but that's not too nice and
+            // handling everything as a prefix expr makes the `(` and `)` insertion easier
+            Adjust::Pointer(cast) if config.adjustment_hints == AdjustmentHints::Always => {
+                match cast {
+                    PointerCast::ReifyFnPointer => "<fn-item-to-fn-pointer>",
+                    PointerCast::UnsafeFnPointer => "<safe-fn-pointer-to-unsafe-fn-pointer>",
+                    PointerCast::ClosureFnPointer(Safety::Unsafe) => {
+                        "<closure-to-unsafe-fn-pointer>"
+                    }
+                    PointerCast::ClosureFnPointer(Safety::Safe) => "<closure-to-fn-pointer>",
+                    PointerCast::MutToConstPointer => "<mut-ptr-to-const-ptr>",
+                    PointerCast::ArrayToPointer => "<array-ptr-to-element-ptr>",
+                    PointerCast::Unsize => "<unsize>",
+                }
+            }
+            _ => continue,
+        };
+        acc.push(InlayHint {
+            range: expr.syntax().text_range(),
+            kind: InlayKind::AdjustmentHint,
+            label: text.into(),
+            tooltip: None,
+        });
+    }
+    if needs_parens {
+        acc.push(InlayHint {
+            range: expr.syntax().text_range(),
+            kind: InlayKind::ClosingParenthesis,
+            label: ")".into(),
+            tooltip: None,
+        });
+    }
+    Some(())
+}
+
+fn chaining_hints(
+    acc: &mut Vec<InlayHint>,
+    sema: &Semantics<'_, RootDatabase>,
+    famous_defs: &FamousDefs<'_, '_>,
+    config: &InlayHintsConfig,
+    file_id: FileId,
+    expr: &ast::Expr,
+) -> Option<()> {
+    if !config.chaining_hints {
+        return None;
+    }
+
+    if matches!(expr, ast::Expr::RecordExpr(_)) {
+        return None;
+    }
+
+    let descended = sema.descend_node_into_attributes(expr.clone()).pop();
+    let desc_expr = descended.as_ref().unwrap_or(expr);
+
+    let mut tokens = expr
+        .syntax()
+        .siblings_with_tokens(Direction::Next)
+        .filter_map(NodeOrToken::into_token)
+        .filter(|t| match t.kind() {
+            SyntaxKind::WHITESPACE if !t.text().contains('\n') => false,
+            SyntaxKind::COMMENT => false,
+            _ => true,
+        });
+
+    // Chaining can be defined as an expression whose next sibling tokens are newline and dot
+    // Ignoring extra whitespace and comments
+    let next = tokens.next()?.kind();
+    if next == SyntaxKind::WHITESPACE {
+        let mut next_next = tokens.next()?.kind();
+        while next_next == SyntaxKind::WHITESPACE {
+            next_next = tokens.next()?.kind();
+        }
+        if next_next == T![.] {
+            let ty = sema.type_of_expr(desc_expr)?.original;
+            if ty.is_unknown() {
+                return None;
+            }
+            if matches!(expr, ast::Expr::PathExpr(_)) {
+                if let Some(hir::Adt::Struct(st)) = ty.as_adt() {
+                    if st.fields(sema.db).is_empty() {
+                        return None;
+                    }
+                }
+            }
+            acc.push(InlayHint {
+                range: expr.syntax().text_range(),
+                kind: InlayKind::ChainingHint,
+                label: hint_iterator(sema, &famous_defs, config, &ty)
+                    .unwrap_or_else(|| ty.display_truncated(sema.db, config.max_length).to_string())
+                    .into(),
+                tooltip: Some(InlayTooltip::HoverRanged(file_id, expr.syntax().text_range())),
+            });
+        }
+    }
+    Some(())
+}
+
+fn param_name_hints(
+    acc: &mut Vec<InlayHint>,
+    sema: &Semantics<'_, RootDatabase>,
+    config: &InlayHintsConfig,
+    expr: ast::Expr,
+) -> Option<()> {
+    if !config.parameter_hints {
+        return None;
+    }
+
+    let (callable, arg_list) = get_callable(sema, &expr)?;
+    let hints = callable
+        .params(sema.db)
+        .into_iter()
+        .zip(arg_list.args())
+        .filter_map(|((param, _ty), arg)| {
+            // Only annotate hints for expressions that exist in the original file
+            let range = sema.original_range_opt(arg.syntax())?;
+            let (param_name, name_syntax) = match param.as_ref()? {
+                Either::Left(pat) => ("self".to_string(), pat.name()),
+                Either::Right(pat) => match pat {
+                    ast::Pat::IdentPat(it) => (it.name()?.to_string(), it.name()),
+                    _ => return None,
+                },
+            };
+            Some((name_syntax, param_name, arg, range))
+        })
+        .filter(|(_, param_name, arg, _)| {
+            !should_hide_param_name_hint(sema, &callable, param_name, arg)
+        })
+        .map(|(param, param_name, _, FileRange { range, .. })| {
+            let mut tooltip = None;
+            if let Some(name) = param {
+                if let hir::CallableKind::Function(f) = callable.kind() {
+                    // assert the file is cached so we can map out of macros
+                    if let Some(_) = sema.source(f) {
+                        tooltip = sema.original_range_opt(name.syntax());
+                    }
+                }
+            }
+
+            InlayHint {
+                range,
+                kind: InlayKind::ParameterHint,
+                label: param_name.into(),
+                tooltip: tooltip.map(|it| InlayTooltip::HoverOffset(it.file_id, it.range.start())),
+            }
+        });
+
+    acc.extend(hints);
+    Some(())
+}
+
+fn binding_mode_hints(
+    acc: &mut Vec<InlayHint>,
+    sema: &Semantics<'_, RootDatabase>,
+    config: &InlayHintsConfig,
+    pat: &ast::Pat,
+) -> Option<()> {
+    if !config.binding_mode_hints {
+        return None;
+    }
+
+    let outer_paren_pat = pat
+        .syntax()
+        .ancestors()
+        .skip(1)
+        .map_while(ast::Pat::cast)
+        .map_while(|pat| match pat {
+            ast::Pat::ParenPat(pat) => Some(pat),
+            _ => None,
+        })
+        .last();
+    let range =
+        outer_paren_pat.as_ref().map_or_else(|| pat.syntax(), |it| it.syntax()).text_range();
+    sema.pattern_adjustments(&pat).iter().for_each(|ty| {
+        let reference = ty.is_reference();
+        let mut_reference = ty.is_mutable_reference();
+        let r = match (reference, mut_reference) {
+            (true, true) => "&mut",
+            (true, false) => "&",
+            _ => return,
+        };
+        acc.push(InlayHint {
+            range,
+            kind: InlayKind::BindingModeHint,
+            label: r.to_string().into(),
+            tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
+        });
+    });
+    match pat {
+        ast::Pat::IdentPat(pat) if pat.ref_token().is_none() && pat.mut_token().is_none() => {
+            let bm = sema.binding_mode_of_pat(pat)?;
+            let bm = match bm {
+                hir::BindingMode::Move => return None,
+                hir::BindingMode::Ref(Mutability::Mut) => "ref mut",
+                hir::BindingMode::Ref(Mutability::Shared) => "ref",
+            };
+            acc.push(InlayHint {
+                range: pat.syntax().text_range(),
+                kind: InlayKind::BindingModeHint,
+                label: bm.to_string().into(),
+                tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
+            });
+        }
+        ast::Pat::OrPat(pat) if outer_paren_pat.is_none() => {
+            acc.push(InlayHint {
+                range: pat.syntax().text_range(),
+                kind: InlayKind::OpeningParenthesis,
+                label: "(".into(),
+                tooltip: None,
+            });
+            acc.push(InlayHint {
+                range: pat.syntax().text_range(),
+                kind: InlayKind::ClosingParenthesis,
+                label: ")".into(),
+                tooltip: None,
+            });
+        }
+        _ => (),
+    }
+
+    Some(())
+}
+
+fn bind_pat_hints(
+    acc: &mut Vec<InlayHint>,
+    sema: &Semantics<'_, RootDatabase>,
+    config: &InlayHintsConfig,
+    file_id: FileId,
+    pat: &ast::IdentPat,
+) -> Option<()> {
+    if !config.type_hints {
+        return None;
+    }
+
+    let descended = sema.descend_node_into_attributes(pat.clone()).pop();
+    let desc_pat = descended.as_ref().unwrap_or(pat);
+    let ty = sema.type_of_pat(&desc_pat.clone().into())?.original;
+
+    if should_not_display_type_hint(sema, config, pat, &ty) {
+        return None;
+    }
+
+    let krate = sema.scope(desc_pat.syntax())?.krate();
+    let famous_defs = FamousDefs(sema, krate);
+    let label = hint_iterator(sema, &famous_defs, config, &ty);
+
+    let label = match label {
+        Some(label) => label,
+        None => {
+            let ty_name = ty.display_truncated(sema.db, config.max_length).to_string();
+            if config.hide_named_constructor_hints
+                && is_named_constructor(sema, pat, &ty_name).is_some()
+            {
+                return None;
+            }
+            ty_name
+        }
+    };
+
+    acc.push(InlayHint {
+        range: match pat.name() {
+            Some(name) => name.syntax().text_range(),
+            None => pat.syntax().text_range(),
+        },
+        kind: InlayKind::TypeHint,
+        label: label.into(),
+        tooltip: pat
+            .name()
+            .map(|it| it.syntax().text_range())
+            .map(|it| InlayTooltip::HoverRanged(file_id, it)),
+    });
+
+    Some(())
+}
+
+fn is_named_constructor(
+    sema: &Semantics<'_, RootDatabase>,
+    pat: &ast::IdentPat,
+    ty_name: &str,
+) -> Option<()> {
+    let let_node = pat.syntax().parent()?;
+    let expr = match_ast! {
+        match let_node {
+            ast::LetStmt(it) => it.initializer(),
+            ast::LetExpr(it) => it.expr(),
+            _ => None,
+        }
+    }?;
+
+    let expr = sema.descend_node_into_attributes(expr.clone()).pop().unwrap_or(expr);
+    // unwrap postfix expressions
+    let expr = match expr {
+        ast::Expr::TryExpr(it) => it.expr(),
+        ast::Expr::AwaitExpr(it) => it.expr(),
+        expr => Some(expr),
+    }?;
+    let expr = match expr {
+        ast::Expr::CallExpr(call) => match call.expr()? {
+            ast::Expr::PathExpr(path) => path,
+            _ => return None,
+        },
+        ast::Expr::PathExpr(path) => path,
+        _ => return None,
+    };
+    let path = expr.path()?;
+
+    let callable = sema.type_of_expr(&ast::Expr::PathExpr(expr))?.original.as_callable(sema.db);
+    let callable_kind = callable.map(|it| it.kind());
+    let qual_seg = match callable_kind {
+        Some(hir::CallableKind::Function(_) | hir::CallableKind::TupleEnumVariant(_)) => {
+            path.qualifier()?.segment()
+        }
+        _ => path.segment(),
+    }?;
+
+    let ctor_name = match qual_seg.kind()? {
+        ast::PathSegmentKind::Name(name_ref) => {
+            match qual_seg.generic_arg_list().map(|it| it.generic_args()) {
+                Some(generics) => format!("{}<{}>", name_ref, generics.format(", ")),
+                None => name_ref.to_string(),
+            }
+        }
+        ast::PathSegmentKind::Type { type_ref: Some(ty), trait_ref: None } => ty.to_string(),
+        _ => return None,
+    };
+    (ctor_name == ty_name).then(|| ())
+}
+
 /// Checks if the type is an Iterator from std::iter and replaces its hint with an `impl Iterator<Item = Ty>`.
 fn hint_iterator(
     sema: &Semantics<'_, RootDatabase>,
@@ -320,54 +1067,318 @@ fn hint_iterator(
     None
 }
 
+fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::IdentPat, pat_ty: &hir::Type) -> bool {
+    if let Some(hir::Adt::Enum(enum_data)) = pat_ty.as_adt() {
+        let pat_text = bind_pat.to_string();
+        enum_data
+            .variants(db)
+            .into_iter()
+            .map(|variant| variant.name(db).to_smol_str())
+            .any(|enum_name| enum_name == pat_text)
+    } else {
+        false
+    }
+}
+
+fn should_not_display_type_hint(
+    sema: &Semantics<'_, RootDatabase>,
+    config: &InlayHintsConfig,
+    bind_pat: &ast::IdentPat,
+    pat_ty: &hir::Type,
+) -> bool {
+    let db = sema.db;
+
+    if pat_ty.is_unknown() {
+        return true;
+    }
+
+    if let Some(hir::Adt::Struct(s)) = pat_ty.as_adt() {
+        if s.fields(db).is_empty() && s.name(db).to_smol_str() == bind_pat.to_string() {
+            return true;
+        }
+    }
+
+    if config.hide_closure_initialization_hints {
+        if let Some(parent) = bind_pat.syntax().parent() {
+            if let Some(it) = ast::LetStmt::cast(parent.clone()) {
+                if let Some(ast::Expr::ClosureExpr(closure)) = it.initializer() {
+                    if closure_has_block_body(&closure) {
+                        return true;
+                    }
+                }
+            }
+        }
+    }
+
+    for node in bind_pat.syntax().ancestors() {
+        match_ast! {
+            match node {
+                ast::LetStmt(it) => return it.ty().is_some(),
+                // FIXME: We might wanna show type hints in parameters for non-top level patterns as well
+                ast::Param(it) => return it.ty().is_some(),
+                ast::MatchArm(_) => return pat_is_enum_variant(db, bind_pat, pat_ty),
+                ast::LetExpr(_) => return pat_is_enum_variant(db, bind_pat, pat_ty),
+                ast::IfExpr(_) => return false,
+                ast::WhileExpr(_) => return false,
+                ast::ForExpr(it) => {
+                    // We *should* display hint only if user provided "in {expr}" and we know the type of expr (and it's not unit).
+                    // Type of expr should be iterable.
+                    return it.in_token().is_none() ||
+                        it.iterable()
+                            .and_then(|iterable_expr| sema.type_of_expr(&iterable_expr))
+                            .map(TypeInfo::original)
+                            .map_or(true, |iterable_ty| iterable_ty.is_unknown() || iterable_ty.is_unit())
+                },
+                _ => (),
+            }
+        }
+    }
+    false
+}
+
 fn closure_has_block_body(closure: &ast::ClosureExpr) -> bool {
     matches!(closure.body(), Some(ast::Expr::BlockExpr(_)))
 }
 
-#[cfg(test)]
-mod tests {
-    use expect_test::Expect;
-    use itertools::Itertools;
-    use test_utils::extract_annotations;
+fn should_hide_param_name_hint(
+    sema: &Semantics<'_, RootDatabase>,
+    callable: &hir::Callable,
+    param_name: &str,
+    argument: &ast::Expr,
+) -> bool {
+    // These are to be tested in the `parameter_hint_heuristics` test
+    // hide when:
+    // - the parameter name is a suffix of the function's name
+    // - the argument is a qualified constructing or call expression where the qualifier is an ADT
+    // - exact argument<->parameter match(ignoring leading underscore) or parameter is a prefix/suffix
+    //   of argument with _ splitting it off
+    // - param starts with `ra_fixture`
+    // - param is a well known name in a unary function
 
-    use crate::inlay_hints::AdjustmentHints;
-    use crate::{fixture, inlay_hints::InlayHintsConfig, LifetimeElisionHints};
+    let param_name = param_name.trim_start_matches('_');
+    if param_name.is_empty() {
+        return true;
+    }
 
-    use super::ClosureReturnTypeHints;
+    if matches!(argument, ast::Expr::PrefixExpr(prefix) if prefix.op_kind() == Some(UnaryOp::Not)) {
+        return false;
+    }
 
-    pub(super) const DISABLED_CONFIG: InlayHintsConfig = InlayHintsConfig {
-        render_colons: false,
-        type_hints: false,
-        parameter_hints: false,
-        chaining_hints: false,
-        lifetime_elision_hints: LifetimeElisionHints::Never,
-        closure_return_type_hints: ClosureReturnTypeHints::Never,
-        adjustment_hints: AdjustmentHints::Never,
-        binding_mode_hints: false,
-        hide_named_constructor_hints: false,
-        hide_closure_initialization_hints: false,
-        param_names_for_lifetime_elision_hints: false,
-        max_length: None,
-        closing_brace_hints_min_lines: None,
+    let fn_name = match callable.kind() {
+        hir::CallableKind::Function(it) => Some(it.name(sema.db).to_smol_str()),
+        _ => None,
     };
-    pub(super) const TEST_CONFIG: InlayHintsConfig = InlayHintsConfig {
-        type_hints: true,
-        parameter_hints: true,
-        chaining_hints: true,
-        closure_return_type_hints: ClosureReturnTypeHints::WithBlock,
-        binding_mode_hints: true,
-        lifetime_elision_hints: LifetimeElisionHints::Always,
-        ..DISABLED_CONFIG
+    let fn_name = fn_name.as_deref();
+    is_param_name_suffix_of_fn_name(param_name, callable, fn_name)
+        || is_argument_similar_to_param_name(argument, param_name)
+        || param_name.starts_with("ra_fixture")
+        || (callable.n_params() == 1 && is_obvious_param(param_name))
+        || is_adt_constructor_similar_to_param_name(sema, argument, param_name)
+}
+
+fn is_argument_similar_to_param_name(argument: &ast::Expr, param_name: &str) -> bool {
+    // check whether param_name and argument are the same or
+    // whether param_name is a prefix/suffix of argument(split at `_`)
+    let argument = match get_string_representation(argument) {
+        Some(argument) => argument,
+        None => return false,
     };
 
-    #[track_caller]
-    pub(super) fn check(ra_fixture: &str) {
-        check_with_config(TEST_CONFIG, ra_fixture);
-    }
+    // std is honestly too panic happy...
+    let str_split_at = |str: &str, at| str.is_char_boundary(at).then(|| argument.split_at(at));
 
-    #[track_caller]
-    pub(super) fn check_with_config(config: InlayHintsConfig, ra_fixture: &str) {
-        let (analysis, file_id) = fixture::file(ra_fixture);
+    let param_name = param_name.trim_start_matches('_');
+    let argument = argument.trim_start_matches('_');
+
+    match str_split_at(argument, param_name.len()) {
+        Some((prefix, rest)) if prefix.eq_ignore_ascii_case(param_name) => {
+            return rest.is_empty() || rest.starts_with('_');
+        }
+        _ => (),
+    }
+    match argument.len().checked_sub(param_name.len()).and_then(|at| str_split_at(argument, at)) {
+        Some((rest, suffix)) if param_name.eq_ignore_ascii_case(suffix) => {
+            return rest.is_empty() || rest.ends_with('_');
+        }
+        _ => (),
+    }
+    false
+}
+
+/// Hide the parameter name of a unary function if it is a `_` - prefixed suffix of the function's name, or equal.
+///
+/// `fn strip_suffix(suffix)` will be hidden.
+/// `fn stripsuffix(suffix)` will not be hidden.
+fn is_param_name_suffix_of_fn_name(
+    param_name: &str,
+    callable: &Callable,
+    fn_name: Option<&str>,
+) -> bool {
+    match (callable.n_params(), fn_name) {
+        (1, Some(function)) => {
+            function == param_name
+                || function
+                    .len()
+                    .checked_sub(param_name.len())
+                    .and_then(|at| function.is_char_boundary(at).then(|| function.split_at(at)))
+                    .map_or(false, |(prefix, suffix)| {
+                        suffix.eq_ignore_ascii_case(param_name) && prefix.ends_with('_')
+                    })
+        }
+        _ => false,
+    }
+}
+
+fn is_adt_constructor_similar_to_param_name(
+    sema: &Semantics<'_, RootDatabase>,
+    argument: &ast::Expr,
+    param_name: &str,
+) -> bool {
+    let path = match argument {
+        ast::Expr::CallExpr(c) => c.expr().and_then(|e| match e {
+            ast::Expr::PathExpr(p) => p.path(),
+            _ => None,
+        }),
+        ast::Expr::PathExpr(p) => p.path(),
+        ast::Expr::RecordExpr(r) => r.path(),
+        _ => return false,
+    };
+    let path = match path {
+        Some(it) => it,
+        None => return false,
+    };
+    (|| match sema.resolve_path(&path)? {
+        hir::PathResolution::Def(hir::ModuleDef::Adt(_)) => {
+            Some(to_lower_snake_case(&path.segment()?.name_ref()?.text()) == param_name)
+        }
+        hir::PathResolution::Def(hir::ModuleDef::Function(_) | hir::ModuleDef::Variant(_)) => {
+            if to_lower_snake_case(&path.segment()?.name_ref()?.text()) == param_name {
+                return Some(true);
+            }
+            let qual = path.qualifier()?;
+            match sema.resolve_path(&qual)? {
+                hir::PathResolution::Def(hir::ModuleDef::Adt(_)) => {
+                    Some(to_lower_snake_case(&qual.segment()?.name_ref()?.text()) == param_name)
+                }
+                _ => None,
+            }
+        }
+        _ => None,
+    })()
+    .unwrap_or(false)
+}
+
+fn get_string_representation(expr: &ast::Expr) -> Option<String> {
+    match expr {
+        ast::Expr::MethodCallExpr(method_call_expr) => {
+            let name_ref = method_call_expr.name_ref()?;
+            match name_ref.text().as_str() {
+                "clone" | "as_ref" => method_call_expr.receiver().map(|rec| rec.to_string()),
+                name_ref => Some(name_ref.to_owned()),
+            }
+        }
+        ast::Expr::MacroExpr(macro_expr) => {
+            Some(macro_expr.macro_call()?.path()?.segment()?.to_string())
+        }
+        ast::Expr::FieldExpr(field_expr) => Some(field_expr.name_ref()?.to_string()),
+        ast::Expr::PathExpr(path_expr) => Some(path_expr.path()?.segment()?.to_string()),
+        ast::Expr::PrefixExpr(prefix_expr) => get_string_representation(&prefix_expr.expr()?),
+        ast::Expr::RefExpr(ref_expr) => get_string_representation(&ref_expr.expr()?),
+        ast::Expr::CastExpr(cast_expr) => get_string_representation(&cast_expr.expr()?),
+        _ => None,
+    }
+}
+
+fn is_obvious_param(param_name: &str) -> bool {
+    // avoid displaying hints for common functions like map, filter, etc.
+    // or other obvious words used in std
+    let is_obvious_param_name =
+        matches!(param_name, "predicate" | "value" | "pat" | "rhs" | "other");
+    param_name.len() == 1 || is_obvious_param_name
+}
+
+fn get_callable(
+    sema: &Semantics<'_, RootDatabase>,
+    expr: &ast::Expr,
+) -> Option<(hir::Callable, ast::ArgList)> {
+    match expr {
+        ast::Expr::CallExpr(expr) => {
+            let descended = sema.descend_node_into_attributes(expr.clone()).pop();
+            let expr = descended.as_ref().unwrap_or(expr);
+            sema.type_of_expr(&expr.expr()?)?.original.as_callable(sema.db).zip(expr.arg_list())
+        }
+        ast::Expr::MethodCallExpr(expr) => {
+            let descended = sema.descend_node_into_attributes(expr.clone()).pop();
+            let expr = descended.as_ref().unwrap_or(expr);
+            sema.resolve_method_call_as_callable(expr).zip(expr.arg_list())
+        }
+        _ => None,
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use expect_test::{expect, Expect};
+    use itertools::Itertools;
+    use syntax::{TextRange, TextSize};
+    use test_utils::extract_annotations;
+
+    use crate::inlay_hints::AdjustmentHints;
+    use crate::{fixture, inlay_hints::InlayHintsConfig, LifetimeElisionHints};
+
+    use super::ClosureReturnTypeHints;
+
+    const DISABLED_CONFIG: InlayHintsConfig = InlayHintsConfig {
+        render_colons: false,
+        type_hints: false,
+        parameter_hints: false,
+        chaining_hints: false,
+        lifetime_elision_hints: LifetimeElisionHints::Never,
+        closure_return_type_hints: ClosureReturnTypeHints::Never,
+        adjustment_hints: AdjustmentHints::Never,
+        binding_mode_hints: false,
+        hide_named_constructor_hints: false,
+        hide_closure_initialization_hints: false,
+        param_names_for_lifetime_elision_hints: false,
+        max_length: None,
+        closing_brace_hints_min_lines: None,
+    };
+    const TEST_CONFIG: InlayHintsConfig = InlayHintsConfig {
+        type_hints: true,
+        parameter_hints: true,
+        chaining_hints: true,
+        closure_return_type_hints: ClosureReturnTypeHints::WithBlock,
+        binding_mode_hints: true,
+        lifetime_elision_hints: LifetimeElisionHints::Always,
+        ..DISABLED_CONFIG
+    };
+
+    #[track_caller]
+    fn check(ra_fixture: &str) {
+        check_with_config(TEST_CONFIG, ra_fixture);
+    }
+
+    #[track_caller]
+    fn check_params(ra_fixture: &str) {
+        check_with_config(
+            InlayHintsConfig { parameter_hints: true, ..DISABLED_CONFIG },
+            ra_fixture,
+        );
+    }
+
+    #[track_caller]
+    fn check_types(ra_fixture: &str) {
+        check_with_config(InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG }, ra_fixture);
+    }
+
+    #[track_caller]
+    fn check_chains(ra_fixture: &str) {
+        check_with_config(InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG }, ra_fixture);
+    }
+
+    #[track_caller]
+    fn check_with_config(config: InlayHintsConfig, ra_fixture: &str) {
+        let (analysis, file_id) = fixture::file(ra_fixture);
         let mut expected = extract_annotations(&*analysis.file_text(file_id).unwrap());
         let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
         let actual = inlay_hints
@@ -381,7 +1392,7 @@ mod tests {
     }
 
     #[track_caller]
-    pub(super) fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
+    fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) {
         let (analysis, file_id) = fixture::file(ra_fixture);
         let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
         expect.assert_debug_eq(&inlay_hints)
@@ -398,4 +1409,1756 @@ fn main() {
 }"#,
         );
     }
+
+    // Parameter hint tests
+
+    #[test]
+    fn param_hints_only() {
+        check_params(
+            r#"
+fn foo(a: i32, b: i32) -> i32 { a + b }
+fn main() {
+    let _x = foo(
+        4,
+      //^ a
+        4,
+      //^ b
+    );
+}"#,
+        );
+    }
+
+    #[test]
+    fn param_hints_on_closure() {
+        check_params(
+            r#"
+fn main() {
+    let clo = |a: u8, b: u8| a + b;
+    clo(
+        1,
+      //^ a
+        2,
+      //^ b
+    );
+}
+            "#,
+        );
+    }
+
+    #[test]
+    fn param_name_similar_to_fn_name_still_hints() {
+        check_params(
+            r#"
+fn max(x: i32, y: i32) -> i32 { x + y }
+fn main() {
+    let _x = max(
+        4,
+      //^ x
+        4,
+      //^ y
+    );
+}"#,
+        );
+    }
+
+    #[test]
+    fn param_name_similar_to_fn_name() {
+        check_params(
+            r#"
+fn param_with_underscore(with_underscore: i32) -> i32 { with_underscore }
+fn main() {
+    let _x = param_with_underscore(
+        4,
+    );
+}"#,
+        );
+        check_params(
+            r#"
+fn param_with_underscore(underscore: i32) -> i32 { underscore }
+fn main() {
+    let _x = param_with_underscore(
+        4,
+    );
+}"#,
+        );
+    }
+
+    #[test]
+    fn param_name_same_as_fn_name() {
+        check_params(
+            r#"
+fn foo(foo: i32) -> i32 { foo }
+fn main() {
+    let _x = foo(
+        4,
+    );
+}"#,
+        );
+    }
+
+    #[test]
+    fn never_hide_param_when_multiple_params() {
+        check_params(
+            r#"
+fn foo(foo: i32, bar: i32) -> i32 { bar + baz }
+fn main() {
+    let _x = foo(
+        4,
+      //^ foo
+        8,
+      //^ bar
+    );
+}"#,
+        );
+    }
+
+    #[test]
+    fn param_hints_look_through_as_ref_and_clone() {
+        check_params(
+            r#"
+fn foo(bar: i32, baz: f32) {}
+
+fn main() {
+    let bar = 3;
+    let baz = &"baz";
+    let fez = 1.0;
+    foo(bar.clone(), bar.clone());
+                   //^^^^^^^^^^^ baz
+    foo(bar.as_ref(), bar.as_ref());
+                    //^^^^^^^^^^^^ baz
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn self_param_hints() {
+        check_params(
+            r#"
+struct Foo;
+
+impl Foo {
+    fn foo(self: Self) {}
+    fn bar(self: &Self) {}
+}
+
+fn main() {
+    Foo::foo(Foo);
+           //^^^ self
+    Foo::bar(&Foo);
+           //^^^^ self
+}
+"#,
+        )
+    }
+
+    #[test]
+    fn param_name_hints_show_for_literals() {
+        check_params(
+            r#"pub fn test(a: i32, b: i32) -> [i32; 2] { [a, b] }
+fn main() {
+    test(
+        0xa_b,
+      //^^^^^ a
+        0xa_b,
+      //^^^^^ b
+    );
+}"#,
+        )
+    }
+
+    #[test]
+    fn function_call_parameter_hint() {
+        check_params(
+            r#"
+//- minicore: option
+struct FileId {}
+struct SmolStr {}
+
+struct TextRange {}
+struct SyntaxKind {}
+struct NavigationTarget {}
+
+struct Test {}
+
+impl Test {
+    fn method(&self, mut param: i32) -> i32 { param * 2 }
+
+    fn from_syntax(
+        file_id: FileId,
+        name: SmolStr,
+        focus_range: Option<TextRange>,
+        full_range: TextRange,
+        kind: SyntaxKind,
+        docs: Option<String>,
+    ) -> NavigationTarget {
+        NavigationTarget {}
+    }
+}
+
+fn test_func(mut foo: i32, bar: i32, msg: &str, _: i32, last: i32) -> i32 {
+    foo + bar
+}
+
+fn main() {
+    let not_literal = 1;
+    let _: i32 = test_func(1,    2,      "hello", 3,  not_literal);
+                         //^ foo ^ bar   ^^^^^^^ msg  ^^^^^^^^^^^ last
+    let t: Test = Test {};
+    t.method(123);
+           //^^^ param
+    Test::method(&t,      3456);
+               //^^ self  ^^^^ param
+    Test::from_syntax(
+        FileId {},
+        "impl".into(),
+      //^^^^^^^^^^^^^ name
+        None,
+      //^^^^ focus_range
+        TextRange {},
+      //^^^^^^^^^^^^ full_range
+        SyntaxKind {},
+      //^^^^^^^^^^^^^ kind
+        None,
+      //^^^^ docs
+    );
+}"#,
+        );
+    }
+
+    #[test]
+    fn parameter_hint_heuristics() {
+        check_params(
+            r#"
+fn check(ra_fixture_thing: &str) {}
+
+fn map(f: i32) {}
+fn filter(predicate: i32) {}
+
+fn strip_suffix(suffix: &str) {}
+fn stripsuffix(suffix: &str) {}
+fn same(same: u32) {}
+fn same2(_same2: u32) {}
+
+fn enum_matches_param_name(completion_kind: CompletionKind) {}
+
+fn foo(param: u32) {}
+fn bar(param_eter: u32) {}
+
+enum CompletionKind {
+    Keyword,
+}
+
+fn non_ident_pat((a, b): (u32, u32)) {}
+
+fn main() {
+    const PARAM: u32 = 0;
+    foo(PARAM);
+    foo(!PARAM);
+     // ^^^^^^ param
+    check("");
+
+    map(0);
+    filter(0);
+
+    strip_suffix("");
+    stripsuffix("");
+              //^^ suffix
+    same(0);
+    same2(0);
+
+    enum_matches_param_name(CompletionKind::Keyword);
+
+    let param = 0;
+    foo(param);
+    foo(param as _);
+    let param_end = 0;
+    foo(param_end);
+    let start_param = 0;
+    foo(start_param);
+    let param2 = 0;
+    foo(param2);
+      //^^^^^^ param
+
+    macro_rules! param {
+        () => {};
+    };
+    foo(param!());
+
+    let param_eter = 0;
+    bar(param_eter);
+    let param_eter_end = 0;
+    bar(param_eter_end);
+    let start_param_eter = 0;
+    bar(start_param_eter);
+    let param_eter2 = 0;
+    bar(param_eter2);
+      //^^^^^^^^^^^ param_eter
+
+    non_ident_pat((0, 0));
+}"#,
+        );
+    }
+
+    // Type-Hint tests
+
+    #[test]
+    fn type_hints_only() {
+        check_types(
+            r#"
+fn foo(a: i32, b: i32) -> i32 { a + b }
+fn main() {
+    let _x = foo(4, 4);
+      //^^ i32
+}"#,
+        );
+    }
+
+    #[test]
+    fn type_hints_bindings_after_at() {
+        check_types(
+            r#"
+//- minicore: option
+fn main() {
+    let ref foo @ bar @ ref mut baz = 0;
+          //^^^ &i32
+                //^^^ i32
+                              //^^^ &mut i32
+    let [x @ ..] = [0];
+       //^ [i32; 1]
+    if let x @ Some(_) = Some(0) {}
+         //^ Option<i32>
+    let foo @ (bar, baz) = (3, 3);
+      //^^^ (i32, i32)
+             //^^^ i32
+                  //^^^ i32
+}"#,
+        );
+    }
+
+    #[test]
+    fn default_generic_types_should_not_be_displayed() {
+        check(
+            r#"
+struct Test<K, T = u8> { k: K, t: T }
+
+fn main() {
+    let zz = Test { t: 23u8, k: 33 };
+      //^^ Test<i32>
+    let zz_ref = &zz;
+      //^^^^^^ &Test<i32>
+    let test = || zz;
+      //^^^^ || -> Test<i32>
+}"#,
+        );
+    }
+
+    #[test]
+    fn shorten_iterators_in_associated_params() {
+        check_types(
+            r#"
+//- minicore: iterators
+use core::iter;
+
+pub struct SomeIter<T> {}
+
+impl<T> SomeIter<T> {
+    pub fn new() -> Self { SomeIter {} }
+    pub fn push(&mut self, t: T) {}
+}
+
+impl<T> Iterator for SomeIter<T> {
+    type Item = T;
+    fn next(&mut self) -> Option<Self::Item> {
+        None
+    }
+}
+
+fn main() {
+    let mut some_iter = SomeIter::new();
+          //^^^^^^^^^ SomeIter<Take<Repeat<i32>>>
+      some_iter.push(iter::repeat(2).take(2));
+    let iter_of_iters = some_iter.take(2);
+      //^^^^^^^^^^^^^ impl Iterator<Item = impl Iterator<Item = i32>>
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn iterator_hint_regression_issue_12674() {
+        // Ensure we don't crash while solving the projection type of iterators.
+        check_expect(
+            InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
+            r#"
+//- minicore: iterators
+struct S<T>(T);
+impl<T> S<T> {
+    fn iter(&self) -> Iter<'_, T> { loop {} }
+}
+struct Iter<'a, T: 'a>(&'a T);
+impl<'a, T> Iterator for Iter<'a, T> {
+    type Item = &'a T;
+    fn next(&mut self) -> Option<Self::Item> { loop {} }
+}
+struct Container<'a> {
+    elements: S<&'a str>,
+}
+struct SliceIter<'a, T>(&'a T);
+impl<'a, T> Iterator for SliceIter<'a, T> {
+    type Item = &'a T;
+    fn next(&mut self) -> Option<Self::Item> { loop {} }
+}
+
+fn main(a: SliceIter<'_, Container>) {
+    a
+    .filter_map(|c| Some(c.elements.iter().filter_map(|v| Some(v))))
+    .map(|e| e);
+}
+            "#,
+            expect![[r#"
+                [
+                    InlayHint {
+                        range: 484..554,
+                        kind: ChainingHint,
+                        label: [
+                            "impl Iterator<Item = impl Iterator<Item = &&str>>",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                484..554,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 484..485,
+                        kind: ChainingHint,
+                        label: [
+                            "SliceIter<Container>",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                484..485,
+                            ),
+                        ),
+                    },
+                ]
+            "#]],
+        );
+    }
+
+    #[test]
+    fn infer_call_method_return_associated_types_with_generic() {
+        check_types(
+            r#"
+            pub trait Default {
+                fn default() -> Self;
+            }
+            pub trait Foo {
+                type Bar: Default;
+            }
+
+            pub fn quux<T: Foo>() -> T::Bar {
+                let y = Default::default();
+                  //^ <T as Foo>::Bar
+
+                y
+            }
+            "#,
+        );
+    }
+
+    #[test]
+    fn fn_hints() {
+        check_types(
+            r#"
+//- minicore: fn, sized
+fn foo() -> impl Fn() { loop {} }
+fn foo1() -> impl Fn(f64) { loop {} }
+fn foo2() -> impl Fn(f64, f64) { loop {} }
+fn foo3() -> impl Fn(f64, f64) -> u32 { loop {} }
+fn foo4() -> &'static dyn Fn(f64, f64) -> u32 { loop {} }
+fn foo5() -> &'static dyn Fn(&'static dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
+fn foo6() -> impl Fn(f64, f64) -> u32 + Sized { loop {} }
+fn foo7() -> *const (impl Fn(f64, f64) -> u32 + Sized) { loop {} }
+
+fn main() {
+    let foo = foo();
+     // ^^^ impl Fn()
+    let foo = foo1();
+     // ^^^ impl Fn(f64)
+    let foo = foo2();
+     // ^^^ impl Fn(f64, f64)
+    let foo = foo3();
+     // ^^^ impl Fn(f64, f64) -> u32
+    let foo = foo4();
+     // ^^^ &dyn Fn(f64, f64) -> u32
+    let foo = foo5();
+     // ^^^ &dyn Fn(&dyn Fn(f64, f64) -> u32, f64) -> u32
+    let foo = foo6();
+     // ^^^ impl Fn(f64, f64) -> u32
+    let foo = foo7();
+     // ^^^ *const impl Fn(f64, f64) -> u32
+}
+"#,
+        )
+    }
+
+    #[test]
+    fn check_hint_range_limit() {
+        let fixture = r#"
+        //- minicore: fn, sized
+        fn foo() -> impl Fn() { loop {} }
+        fn foo1() -> impl Fn(f64) { loop {} }
+        fn foo2() -> impl Fn(f64, f64) { loop {} }
+        fn foo3() -> impl Fn(f64, f64) -> u32 { loop {} }
+        fn foo4() -> &'static dyn Fn(f64, f64) -> u32 { loop {} }
+        fn foo5() -> &'static dyn Fn(&'static dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
+        fn foo6() -> impl Fn(f64, f64) -> u32 + Sized { loop {} }
+        fn foo7() -> *const (impl Fn(f64, f64) -> u32 + Sized) { loop {} }
+
+        fn main() {
+            let foo = foo();
+            let foo = foo1();
+            let foo = foo2();
+             // ^^^ impl Fn(f64, f64)
+            let foo = foo3();
+             // ^^^ impl Fn(f64, f64) -> u32
+            let foo = foo4();
+            let foo = foo5();
+            let foo = foo6();
+            let foo = foo7();
+        }
+        "#;
+        let (analysis, file_id) = fixture::file(fixture);
+        let expected = extract_annotations(&*analysis.file_text(file_id).unwrap());
+        let inlay_hints = analysis
+            .inlay_hints(
+                &InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },
+                file_id,
+                Some(TextRange::new(TextSize::from(500), TextSize::from(600))),
+            )
+            .unwrap();
+        let actual =
+            inlay_hints.into_iter().map(|it| (it.range, it.label.to_string())).collect::<Vec<_>>();
+        assert_eq!(expected, actual, "\nExpected:\n{:#?}\n\nActual:\n{:#?}", expected, actual);
+    }
+
+    #[test]
+    fn fn_hints_ptr_rpit_fn_parentheses() {
+        check_types(
+            r#"
+//- minicore: fn, sized
+trait Trait {}
+
+fn foo1() -> *const impl Fn() { loop {} }
+fn foo2() -> *const (impl Fn() + Sized) { loop {} }
+fn foo3() -> *const (impl Fn() + ?Sized) { loop {} }
+fn foo4() -> *const (impl Sized + Fn()) { loop {} }
+fn foo5() -> *const (impl ?Sized + Fn()) { loop {} }
+fn foo6() -> *const (impl Fn() + Trait) { loop {} }
+fn foo7() -> *const (impl Fn() + Sized + Trait) { loop {} }
+fn foo8() -> *const (impl Fn() + ?Sized + Trait) { loop {} }
+fn foo9() -> *const (impl Fn() -> u8 + ?Sized) { loop {} }
+fn foo10() -> *const (impl Fn() + Sized + ?Sized) { loop {} }
+
+fn main() {
+    let foo = foo1();
+    //  ^^^ *const impl Fn()
+    let foo = foo2();
+    //  ^^^ *const impl Fn()
+    let foo = foo3();
+    //  ^^^ *const (impl Fn() + ?Sized)
+    let foo = foo4();
+    //  ^^^ *const impl Fn()
+    let foo = foo5();
+    //  ^^^ *const (impl Fn() + ?Sized)
+    let foo = foo6();
+    //  ^^^ *const (impl Fn() + Trait)
+    let foo = foo7();
+    //  ^^^ *const (impl Fn() + Trait)
+    let foo = foo8();
+    //  ^^^ *const (impl Fn() + Trait + ?Sized)
+    let foo = foo9();
+    //  ^^^ *const (impl Fn() -> u8 + ?Sized)
+    let foo = foo10();
+    //  ^^^ *const impl Fn()
+}
+"#,
+        )
+    }
+
+    #[test]
+    fn unit_structs_have_no_type_hints() {
+        check_types(
+            r#"
+//- minicore: result
+struct SyntheticSyntax;
+
+fn main() {
+    match Ok(()) {
+        Ok(_) => (),
+        Err(SyntheticSyntax) => (),
+    }
+}"#,
+        );
+    }
+
+    #[test]
+    fn let_statement() {
+        check_types(
+            r#"
+#[derive(PartialEq)]
+enum Option<T> { None, Some(T) }
+
+#[derive(PartialEq)]
+struct Test { a: Option<u32>, b: u8 }
+
+fn main() {
+    struct InnerStruct {}
+
+    let test = 54;
+      //^^^^ i32
+    let test: i32 = 33;
+    let mut test = 33;
+          //^^^^ i32
+    let _ = 22;
+    let test = "test";
+      //^^^^ &str
+    let test = InnerStruct {};
+      //^^^^ InnerStruct
+
+    let test = unresolved();
+
+    let test = (42, 'a');
+      //^^^^ (i32, char)
+    let (a,    (b,     (c,)) = (2, (3, (9.2,));
+       //^ i32  ^ i32   ^ f64
+    let &x = &92;
+       //^ i32
+}"#,
+        );
+    }
+
+    #[test]
+    fn if_expr() {
+        check_types(
+            r#"
+//- minicore: option
+struct Test { a: Option<u32>, b: u8 }
+
+fn main() {
+    let test = Some(Test { a: Some(3), b: 1 });
+      //^^^^ Option<Test>
+    if let None = &test {};
+    if let test = &test {};
+         //^^^^ &Option<Test>
+    if let Some(test) = &test {};
+              //^^^^ &Test
+    if let Some(Test { a,             b }) = &test {};
+                     //^ &Option<u32> ^ &u8
+    if let Some(Test { a: x,             b: y }) = &test {};
+                        //^ &Option<u32>    ^ &u8
+    if let Some(Test { a: Some(x),  b: y }) = &test {};
+                             //^ &u32  ^ &u8
+    if let Some(Test { a: None,  b: y }) = &test {};
+                                  //^ &u8
+    if let Some(Test { b: y, .. }) = &test {};
+                        //^ &u8
+    if test == None {}
+}"#,
+        );
+    }
+
+    #[test]
+    fn while_expr() {
+        check_types(
+            r#"
+//- minicore: option
+struct Test { a: Option<u32>, b: u8 }
+
+fn main() {
+    let test = Some(Test { a: Some(3), b: 1 });
+      //^^^^ Option<Test>
+    while let Some(Test { a: Some(x),  b: y }) = &test {};
+                                //^ &u32  ^ &u8
+}"#,
+        );
+    }
+
+    #[test]
+    fn match_arm_list() {
+        check_types(
+            r#"
+//- minicore: option
+struct Test { a: Option<u32>, b: u8 }
+
+fn main() {
+    match Some(Test { a: Some(3), b: 1 }) {
+        None => (),
+        test => (),
+      //^^^^ Option<Test>
+        Some(Test { a: Some(x), b: y }) => (),
+                          //^ u32  ^ u8
+        _ => {}
+    }
+}"#,
+        );
+    }
+
+    #[test]
+    fn complete_for_hint() {
+        check_types(
+            r#"
+//- minicore: iterator
+pub struct Vec<T> {}
+
+impl<T> Vec<T> {
+    pub fn new() -> Self { Vec {} }
+    pub fn push(&mut self, t: T) {}
+}
+
+impl<T> IntoIterator for Vec<T> {
+    type Item = T;
+    type IntoIter = IntoIter<T>;
+}
+
+struct IntoIter<T> {}
+
+impl<T> Iterator for IntoIter<T> {
+    type Item = T;
+}
+
+fn main() {
+    let mut data = Vec::new();
+          //^^^^ Vec<&str>
+    data.push("foo");
+    for i in data {
+      //^ &str
+      let z = i;
+        //^ &str
+    }
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn multi_dyn_trait_bounds() {
+        check_types(
+            r#"
+pub struct Vec<T> {}
+
+impl<T> Vec<T> {
+    pub fn new() -> Self { Vec {} }
+}
+
+pub struct Box<T> {}
+
+trait Display {}
+auto trait Sync {}
+
+fn main() {
+    // The block expression wrapping disables the constructor hint hiding logic
+    let _v = { Vec::<Box<&(dyn Display + Sync)>>::new() };
+      //^^ Vec<Box<&(dyn Display + Sync)>>
+    let _v = { Vec::<Box<*const (dyn Display + Sync)>>::new() };
+      //^^ Vec<Box<*const (dyn Display + Sync)>>
+    let _v = { Vec::<Box<dyn Display + Sync>>::new() };
+      //^^ Vec<Box<dyn Display + Sync>>
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn shorten_iterator_hints() {
+        check_types(
+            r#"
+//- minicore: iterators
+use core::iter;
+
+struct MyIter;
+
+impl Iterator for MyIter {
+    type Item = ();
+    fn next(&mut self) -> Option<Self::Item> {
+        None
+    }
+}
+
+fn main() {
+    let _x = MyIter;
+      //^^ MyIter
+    let _x = iter::repeat(0);
+      //^^ impl Iterator<Item = i32>
+    fn generic<T: Clone>(t: T) {
+        let _x = iter::repeat(t);
+          //^^ impl Iterator<Item = T>
+        let _chained = iter::repeat(t).take(10);
+          //^^^^^^^^ impl Iterator<Item = T>
+    }
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn skip_constructor_and_enum_type_hints() {
+        check_with_config(
+            InlayHintsConfig {
+                type_hints: true,
+                hide_named_constructor_hints: true,
+                ..DISABLED_CONFIG
+            },
+            r#"
+//- minicore: try, option
+use core::ops::ControlFlow;
+
+mod x {
+    pub mod y { pub struct Foo; }
+    pub struct Foo;
+    pub enum AnotherEnum {
+        Variant()
+    };
+}
+struct Struct;
+struct TupleStruct();
+
+impl Struct {
+    fn new() -> Self {
+        Struct
+    }
+    fn try_new() -> ControlFlow<(), Self> {
+        ControlFlow::Continue(Struct)
+    }
+}
+
+struct Generic<T>(T);
+impl Generic<i32> {
+    fn new() -> Self {
+        Generic(0)
+    }
+}
+
+enum Enum {
+    Variant(u32)
+}
+
+fn times2(value: i32) -> i32 {
+    2 * value
+}
+
+fn main() {
+    let enumb = Enum::Variant(0);
+
+    let strukt = x::Foo;
+    let strukt = x::y::Foo;
+    let strukt = Struct;
+    let strukt = Struct::new();
+
+    let tuple_struct = TupleStruct();
+
+    let generic0 = Generic::new();
+    //  ^^^^^^^^ Generic<i32>
+    let generic1 = Generic(0);
+    //  ^^^^^^^^ Generic<i32>
+    let generic2 = Generic::<i32>::new();
+    let generic3 = <Generic<i32>>::new();
+    let generic4 = Generic::<i32>(0);
+
+
+    let option = Some(0);
+    //  ^^^^^^ Option<i32>
+    let func = times2;
+    //  ^^^^ fn times2(i32) -> i32
+    let closure = |x: i32| x * 2;
+    //  ^^^^^^^ |i32| -> i32
+}
+
+fn fallible() -> ControlFlow<()> {
+    let strukt = Struct::try_new()?;
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn shows_constructor_type_hints_when_enabled() {
+        check_types(
+            r#"
+//- minicore: try
+use core::ops::ControlFlow;
+
+struct Struct;
+struct TupleStruct();
+
+impl Struct {
+    fn new() -> Self {
+        Struct
+    }
+    fn try_new() -> ControlFlow<(), Self> {
+        ControlFlow::Continue(Struct)
+    }
+}
+
+struct Generic<T>(T);
+impl Generic<i32> {
+    fn new() -> Self {
+        Generic(0)
+    }
+}
+
+fn main() {
+    let strukt = Struct::new();
+     // ^^^^^^ Struct
+    let tuple_struct = TupleStruct();
+     // ^^^^^^^^^^^^ TupleStruct
+    let generic0 = Generic::new();
+     // ^^^^^^^^ Generic<i32>
+    let generic1 = Generic::<i32>::new();
+     // ^^^^^^^^ Generic<i32>
+    let generic2 = <Generic<i32>>::new();
+     // ^^^^^^^^ Generic<i32>
+}
+
+fn fallible() -> ControlFlow<()> {
+    let strukt = Struct::try_new()?;
+     // ^^^^^^ Struct
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn closures() {
+        check(
+            r#"
+fn main() {
+    let mut start = 0;
+          //^^^^^ i32
+    (0..2).for_each(|increment      | { start += increment; });
+                   //^^^^^^^^^ i32
+
+    let multiply =
+      //^^^^^^^^ |i32, i32| -> i32
+      | a,     b| a * b
+      //^ i32  ^ i32
+
+    ;
+
+    let _: i32 = multiply(1,  2);
+                        //^ a ^ b
+    let multiply_ref = &multiply;
+      //^^^^^^^^^^^^ &|i32, i32| -> i32
+
+    let return_42 = || 42;
+      //^^^^^^^^^ || -> i32
+      || { 42 };
+    //^^ i32
+}"#,
+        );
+    }
+
+    #[test]
+    fn return_type_hints_for_closure_without_block() {
+        check_with_config(
+            InlayHintsConfig {
+                closure_return_type_hints: ClosureReturnTypeHints::Always,
+                ..DISABLED_CONFIG
+            },
+            r#"
+fn main() {
+    let a = || { 0 };
+          //^^ i32
+    let b = || 0;
+          //^^ i32
+}"#,
+        );
+    }
+
+    #[test]
+    fn skip_closure_type_hints() {
+        check_with_config(
+            InlayHintsConfig {
+                type_hints: true,
+                hide_closure_initialization_hints: true,
+                ..DISABLED_CONFIG
+            },
+            r#"
+//- minicore: fn
+fn main() {
+    let multiple_2 = |x: i32| { x * 2 };
+
+    let multiple_2 = |x: i32| x * 2;
+    //  ^^^^^^^^^^ |i32| -> i32
+
+    let (not) = (|x: bool| { !x });
+    //   ^^^ |bool| -> bool
+
+    let (is_zero, _b) = (|x: usize| { x == 0 }, false);
+    //   ^^^^^^^ |usize| -> bool
+    //            ^^ bool
+
+    let plus_one = |x| { x + 1 };
+    //              ^ u8
+    foo(plus_one);
+
+    let add_mul = bar(|x: u8| { x + 1 });
+    //  ^^^^^^^ impl FnOnce(u8) -> u8 + ?Sized
+
+    let closure = if let Some(6) = add_mul(2).checked_sub(1) {
+    //  ^^^^^^^ fn(i32) -> i32
+        |x: i32| { x * 2 }
+    } else {
+        |x: i32| { x * 3 }
+    };
+}
+
+fn foo(f: impl FnOnce(u8) -> u8) {}
+
+fn bar(f: impl FnOnce(u8) -> u8) -> impl FnOnce(u8) -> u8 {
+    move |x: u8| f(x) * 2
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn hint_truncation() {
+        check_with_config(
+            InlayHintsConfig { max_length: Some(8), ..TEST_CONFIG },
+            r#"
+struct Smol<T>(T);
+
+struct VeryLongOuterName<T>(T);
+
+fn main() {
+    let a = Smol(0u32);
+      //^ Smol<u32>
+    let b = VeryLongOuterName(0usize);
+      //^ VeryLongOuterName<…>
+    let c = Smol(Smol(0u32))
+      //^ Smol<Smol<…>>
+}"#,
+        );
+    }
+
+    // Chaining hint tests
+
+    #[test]
+    fn chaining_hints_ignore_comments() {
+        check_expect(
+            InlayHintsConfig { type_hints: false, chaining_hints: true, ..DISABLED_CONFIG },
+            r#"
+struct A(B);
+impl A { fn into_b(self) -> B { self.0 } }
+struct B(C);
+impl B { fn into_c(self) -> C { self.0 } }
+struct C;
+
+fn main() {
+    let c = A(B(C))
+        .into_b() // This is a comment
+        // This is another comment
+        .into_c();
+}
+"#,
+            expect![[r#"
+                [
+                    InlayHint {
+                        range: 147..172,
+                        kind: ChainingHint,
+                        label: [
+                            "B",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                147..172,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 147..154,
+                        kind: ChainingHint,
+                        label: [
+                            "A",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                147..154,
+                            ),
+                        ),
+                    },
+                ]
+            "#]],
+        );
+    }
+
+    #[test]
+    fn chaining_hints_without_newlines() {
+        check_chains(
+            r#"
+struct A(B);
+impl A { fn into_b(self) -> B { self.0 } }
+struct B(C);
+impl B { fn into_c(self) -> C { self.0 } }
+struct C;
+
+fn main() {
+    let c = A(B(C)).into_b().into_c();
+}"#,
+        );
+    }
+
+    #[test]
+    fn struct_access_chaining_hints() {
+        check_expect(
+            InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
+            r#"
+struct A { pub b: B }
+struct B { pub c: C }
+struct C(pub bool);
+struct D;
+
+impl D {
+    fn foo(&self) -> i32 { 42 }
+}
+
+fn main() {
+    let x = A { b: B { c: C(true) } }
+        .b
+        .c
+        .0;
+    let x = D
+        .foo();
+}"#,
+            expect![[r#"
+                [
+                    InlayHint {
+                        range: 143..190,
+                        kind: ChainingHint,
+                        label: [
+                            "C",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                143..190,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 143..179,
+                        kind: ChainingHint,
+                        label: [
+                            "B",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                143..179,
+                            ),
+                        ),
+                    },
+                ]
+            "#]],
+        );
+    }
+
+    #[test]
+    fn generic_chaining_hints() {
+        check_expect(
+            InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
+            r#"
+struct A<T>(T);
+struct B<T>(T);
+struct C<T>(T);
+struct X<T,R>(T, R);
+
+impl<T> A<T> {
+    fn new(t: T) -> Self { A(t) }
+    fn into_b(self) -> B<T> { B(self.0) }
+}
+impl<T> B<T> {
+    fn into_c(self) -> C<T> { C(self.0) }
+}
+fn main() {
+    let c = A::new(X(42, true))
+        .into_b()
+        .into_c();
+}
+"#,
+            expect![[r#"
+                [
+                    InlayHint {
+                        range: 246..283,
+                        kind: ChainingHint,
+                        label: [
+                            "B<X<i32, bool>>",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                246..283,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 246..265,
+                        kind: ChainingHint,
+                        label: [
+                            "A<X<i32, bool>>",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                246..265,
+                            ),
+                        ),
+                    },
+                ]
+            "#]],
+        );
+    }
+
+    #[test]
+    fn shorten_iterator_chaining_hints() {
+        check_expect(
+            InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
+            r#"
+//- minicore: iterators
+use core::iter;
+
+struct MyIter;
+
+impl Iterator for MyIter {
+    type Item = ();
+    fn next(&mut self) -> Option<Self::Item> {
+        None
+    }
+}
+
+fn main() {
+    let _x = MyIter.by_ref()
+        .take(5)
+        .by_ref()
+        .take(5)
+        .by_ref();
+}
+"#,
+            expect![[r#"
+                [
+                    InlayHint {
+                        range: 174..241,
+                        kind: ChainingHint,
+                        label: [
+                            "impl Iterator<Item = ()>",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                174..241,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 174..224,
+                        kind: ChainingHint,
+                        label: [
+                            "impl Iterator<Item = ()>",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                174..224,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 174..206,
+                        kind: ChainingHint,
+                        label: [
+                            "impl Iterator<Item = ()>",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                174..206,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 174..189,
+                        kind: ChainingHint,
+                        label: [
+                            "&mut MyIter",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                174..189,
+                            ),
+                        ),
+                    },
+                ]
+            "#]],
+        );
+    }
+
+    #[test]
+    fn hints_in_attr_call() {
+        check_expect(
+            TEST_CONFIG,
+            r#"
+//- proc_macros: identity, input_replace
+struct Struct;
+impl Struct {
+    fn chain(self) -> Self {
+        self
+    }
+}
+#[proc_macros::identity]
+fn main() {
+    let strukt = Struct;
+    strukt
+        .chain()
+        .chain()
+        .chain();
+    Struct::chain(strukt);
+}
+"#,
+            expect![[r#"
+                [
+                    InlayHint {
+                        range: 124..130,
+                        kind: TypeHint,
+                        label: [
+                            "Struct",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                124..130,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 145..185,
+                        kind: ChainingHint,
+                        label: [
+                            "Struct",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                145..185,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 145..168,
+                        kind: ChainingHint,
+                        label: [
+                            "Struct",
+                        ],
+                        tooltip: Some(
+                            HoverRanged(
+                                FileId(
+                                    0,
+                                ),
+                                145..168,
+                            ),
+                        ),
+                    },
+                    InlayHint {
+                        range: 222..228,
+                        kind: ParameterHint,
+                        label: [
+                            "self",
+                        ],
+                        tooltip: Some(
+                            HoverOffset(
+                                FileId(
+                                    0,
+                                ),
+                                42,
+                            ),
+                        ),
+                    },
+                ]
+            "#]],
+        );
+    }
+
+    #[test]
+    fn hints_lifetimes() {
+        check(
+            r#"
+fn empty() {}
+
+fn no_gpl(a: &()) {}
+ //^^^^^^<'0>
+          // ^'0
+fn empty_gpl<>(a: &()) {}
+      //    ^'0   ^'0
+fn partial<'b>(a: &(), b: &'b ()) {}
+//        ^'0, $  ^'0
+fn partial<'a>(a: &'a (), b: &()) {}
+//        ^'0, $             ^'0
+
+fn single_ret(a: &()) -> &() {}
+// ^^^^^^^^^^<'0>
+              // ^'0     ^'0
+fn full_mul(a: &(), b: &()) {}
+// ^^^^^^^^<'0, '1>
+            // ^'0     ^'1
+
+fn foo<'c>(a: &'c ()) -> &() {}
+                      // ^'c
+
+fn nested_in(a: &   &X< &()>) {}
+// ^^^^^^^^^<'0, '1, '2>
+              //^'0 ^'1 ^'2
+fn nested_out(a: &()) -> &   &X< &()>{}
+// ^^^^^^^^^^<'0>
+               //^'0     ^'0 ^'0 ^'0
+
+impl () {
+    fn foo(&self) {}
+    // ^^^<'0>
+        // ^'0
+    fn foo(&self) -> &() {}
+    // ^^^<'0>
+        // ^'0       ^'0
+    fn foo(&self, a: &()) -> &() {}
+    // ^^^<'0, '1>
+        // ^'0       ^'1     ^'0
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn hints_lifetimes_named() {
+        check_with_config(
+            InlayHintsConfig { param_names_for_lifetime_elision_hints: true, ..TEST_CONFIG },
+            r#"
+fn nested_in<'named>(named: &        &X<      &()>) {}
+//          ^'named1, 'named2, 'named3, $
+                          //^'named1 ^'named2 ^'named3
+"#,
+        );
+    }
+
+    #[test]
+    fn hints_lifetimes_trivial_skip() {
+        check_with_config(
+            InlayHintsConfig {
+                lifetime_elision_hints: LifetimeElisionHints::SkipTrivial,
+                ..TEST_CONFIG
+            },
+            r#"
+fn no_gpl(a: &()) {}
+fn empty_gpl<>(a: &()) {}
+fn partial<'b>(a: &(), b: &'b ()) {}
+fn partial<'a>(a: &'a (), b: &()) {}
+
+fn single_ret(a: &()) -> &() {}
+// ^^^^^^^^^^<'0>
+              // ^'0     ^'0
+fn full_mul(a: &(), b: &()) {}
+
+fn foo<'c>(a: &'c ()) -> &() {}
+                      // ^'c
+
+fn nested_in(a: &   &X< &()>) {}
+fn nested_out(a: &()) -> &   &X< &()>{}
+// ^^^^^^^^^^<'0>
+               //^'0     ^'0 ^'0 ^'0
+
+impl () {
+    fn foo(&self) {}
+    fn foo(&self) -> &() {}
+    // ^^^<'0>
+        // ^'0       ^'0
+    fn foo(&self, a: &()) -> &() {}
+    // ^^^<'0, '1>
+        // ^'0       ^'1     ^'0
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn hints_lifetimes_static() {
+        check_with_config(
+            InlayHintsConfig {
+                lifetime_elision_hints: LifetimeElisionHints::Always,
+                ..TEST_CONFIG
+            },
+            r#"
+trait Trait {}
+static S: &str = "";
+//        ^'static
+const C: &str = "";
+//       ^'static
+const C: &dyn Trait = panic!();
+//       ^'static
+
+impl () {
+    const C: &str = "";
+    const C: &dyn Trait = panic!();
+}
+"#,
+        );
+    }
+
+    #[test]
+    fn hints_binding_modes() {
+        check_with_config(
+            InlayHintsConfig { binding_mode_hints: true, ..DISABLED_CONFIG },
+            r#"
+fn __(
+    (x,): (u32,),
+    (x,): &(u32,),
+  //^^^^&
+   //^ ref
+    (x,): &mut (u32,)
+  //^^^^&mut
+   //^ ref mut
+) {
+    let (x,) = (0,);
+    let (x,) = &(0,);
+      //^^^^ &
+       //^ ref
+    let (x,) = &mut (0,);
+      //^^^^ &mut
+       //^ ref mut
+    let &mut (x,) = &mut (0,);
+    let (ref mut x,) = &mut (0,);
+      //^^^^^^^^^^^^ &mut
+    let &mut (ref mut x,) = &mut (0,);
+    let (mut x,) = &mut (0,);
+      //^^^^^^^^ &mut
+    match (0,) {
+        (x,) => ()
+    }
+    match &(0,) {
+        (x,) | (x,) => (),
+      //^^^^^^^^^^^&
+       //^ ref
+              //^ ref
+      //^^^^^^^^^^^(
+      //^^^^^^^^^^^)
+        ((x,) | (x,)) => (),
+      //^^^^^^^^^^^^^&
+        //^ ref
+               //^ ref
+    }
+    match &mut (0,) {
+        (x,) => ()
+      //^^^^ &mut
+       //^ ref mut
+    }
+}"#,
+        );
+    }
+
+    #[test]
+    fn hints_closing_brace() {
+        check_with_config(
+            InlayHintsConfig { closing_brace_hints_min_lines: Some(2), ..DISABLED_CONFIG },
+            r#"
+fn a() {}
+
+fn f() {
+} // no hint unless `}` is the last token on the line
+
+fn g() {
+  }
+//^ fn g
+
+fn h<T>(with: T, arguments: u8, ...) {
+  }
+//^ fn h
+
+trait Tr {
+    fn f();
+    fn g() {
+    }
+  //^ fn g
+  }
+//^ trait Tr
+impl Tr for () {
+  }
+//^ impl Tr for ()
+impl dyn Tr {
+  }
+//^ impl dyn Tr
+
+static S0: () = 0;
+static S1: () = {};
+static S2: () = {
+ };
+//^ static S2
+const _: () = {
+ };
+//^ const _
+
+mod m {
+  }
+//^ mod m
+
+m! {}
+m!();
+m!(
+ );
+//^ m!
+
+m! {
+  }
+//^ m!
+
+fn f() {
+    let v = vec![
+    ];
+  }
+//^ fn f
+"#,
+        );
+    }
+
+    #[test]
+    fn adjustment_hints() {
+        check_with_config(
+            InlayHintsConfig { adjustment_hints: AdjustmentHints::Always, ..DISABLED_CONFIG },
+            r#"
+//- minicore: coerce_unsized
+fn main() {
+    let _: u32         = loop {};
+                       //^^^^^^^<never-to-any>
+    let _: &u32        = &mut 0;
+                       //^^^^^^&
+                       //^^^^^^*
+    let _: &mut u32    = &mut 0;
+                       //^^^^^^&mut $
+                       //^^^^^^*
+    let _: *const u32  = &mut 0;
+                       //^^^^^^&raw const $
+                       //^^^^^^*
+    let _: *mut u32    = &mut 0;
+                       //^^^^^^&raw mut $
+                       //^^^^^^*
+    let _: fn()        = main;
+                       //^^^^<fn-item-to-fn-pointer>
+    let _: unsafe fn() = main;
+                       //^^^^<safe-fn-pointer-to-unsafe-fn-pointer>
+                       //^^^^<fn-item-to-fn-pointer>
+    let _: unsafe fn() = main as fn();
+                       //^^^^^^^^^^^^<safe-fn-pointer-to-unsafe-fn-pointer>
+    let _: fn()        = || {};
+                       //^^^^^<closure-to-fn-pointer>
+    let _: unsafe fn() = || {};
+                       //^^^^^<closure-to-unsafe-fn-pointer>
+    let _: *const u32  = &mut 0u32 as *mut u32;
+                       //^^^^^^^^^^^^^^^^^^^^^<mut-ptr-to-const-ptr>
+    let _: &mut [_]    = &mut [0; 0];
+                       //^^^^^^^^^^^<unsize>
+                       //^^^^^^^^^^^&mut $
+                       //^^^^^^^^^^^*
+
+    Struct.consume();
+    Struct.by_ref();
+  //^^^^^^(
+  //^^^^^^&
+  //^^^^^^)
+    Struct.by_ref_mut();
+  //^^^^^^(
+  //^^^^^^&mut $
+  //^^^^^^)
+
+    (&Struct).consume();
+   //^^^^^^^*
+    (&Struct).by_ref();
+
+    (&mut Struct).consume();
+   //^^^^^^^^^^^*
+    (&mut Struct).by_ref();
+   //^^^^^^^^^^^&
+   //^^^^^^^^^^^*
+    (&mut Struct).by_ref_mut();
+
+    // Check that block-like expressions don't duplicate hints
+    let _: &mut [u32] = (&mut []);
+                       //^^^^^^^<unsize>
+                       //^^^^^^^&mut $
+                       //^^^^^^^*
+    let _: &mut [u32] = { &mut [] };
+                        //^^^^^^^<unsize>
+                        //^^^^^^^&mut $
+                        //^^^^^^^*
+    let _: &mut [u32] = unsafe { &mut [] };
+                               //^^^^^^^<unsize>
+                               //^^^^^^^&mut $
+                               //^^^^^^^*
+    let _: &mut [u32] = if true {
+        &mut []
+      //^^^^^^^<unsize>
+      //^^^^^^^&mut $
+      //^^^^^^^*
+    } else {
+        loop {}
+      //^^^^^^^<never-to-any>
+    };
+    let _: &mut [u32] = match () { () => &mut [] }
+                                       //^^^^^^^<unsize>
+                                       //^^^^^^^&mut $
+                                       //^^^^^^^*
+}
+
+#[derive(Copy, Clone)]
+struct Struct;
+impl Struct {
+    fn consume(self) {}
+    fn by_ref(&self) {}
+    fn by_ref_mut(&mut self) {}
+}
+trait Trait {}
+impl Trait for Struct {}
+"#,
+        )
+    }
 }
diff --git a/crates/ide/src/inlay_hints/adjustment.rs b/crates/ide/src/inlay_hints/adjustment.rs
deleted file mode 100644
index b2bec10d05..0000000000
--- a/crates/ide/src/inlay_hints/adjustment.rs
+++ /dev/null
@@ -1,236 +0,0 @@
-//! Implementation of "adjustment" inlay hints:
-//! ```no_run
-//! let _: u32  = /* <never-to-any> */ loop {};
-//! let _: &u32 = /* &* */ &mut 0;
-//! ```
-use hir::{Adjust, AutoBorrow, Mutability, OverloadedDeref, PointerCast, Safety, Semantics};
-use ide_db::RootDatabase;
-
-use syntax::ast::{self, AstNode};
-
-use crate::{AdjustmentHints, InlayHint, InlayHintsConfig, InlayKind};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    sema: &Semantics<'_, RootDatabase>,
-    config: &InlayHintsConfig,
-    expr: &ast::Expr,
-) -> Option<()> {
-    if config.adjustment_hints == AdjustmentHints::Never {
-        return None;
-    }
-
-    // These inherit from the inner expression which would result in duplicate hints
-    if let ast::Expr::ParenExpr(_)
-    | ast::Expr::IfExpr(_)
-    | ast::Expr::BlockExpr(_)
-    | ast::Expr::MatchExpr(_) = expr
-    {
-        return None;
-    }
-
-    let parent = expr.syntax().parent().and_then(ast::Expr::cast);
-    let descended = sema.descend_node_into_attributes(expr.clone()).pop();
-    let desc_expr = descended.as_ref().unwrap_or(expr);
-    let adjustments = sema.expr_adjustments(desc_expr).filter(|it| !it.is_empty())?;
-    let needs_parens = match parent {
-        Some(parent) => {
-            match parent {
-                ast::Expr::AwaitExpr(_)
-                | ast::Expr::CallExpr(_)
-                | ast::Expr::CastExpr(_)
-                | ast::Expr::FieldExpr(_)
-                | ast::Expr::MethodCallExpr(_)
-                | ast::Expr::TryExpr(_) => true,
-                // FIXME: shorthands need special casing, though not sure if adjustments are even valid there
-                ast::Expr::RecordExpr(_) => false,
-                ast::Expr::IndexExpr(index) => index.base().as_ref() == Some(expr),
-                _ => false,
-            }
-        }
-        None => false,
-    };
-    if needs_parens {
-        acc.push(InlayHint {
-            range: expr.syntax().text_range(),
-            kind: InlayKind::OpeningParenthesis,
-            label: "(".into(),
-            tooltip: None,
-        });
-    }
-    for adjustment in adjustments.into_iter().rev() {
-        if adjustment.source == adjustment.target {
-            continue;
-        }
-
-        // FIXME: Add some nicer tooltips to each of these
-        let text = match adjustment.kind {
-            Adjust::NeverToAny if config.adjustment_hints == AdjustmentHints::Always => {
-                "<never-to-any>"
-            }
-            Adjust::Deref(None) => "*",
-            Adjust::Deref(Some(OverloadedDeref(Mutability::Mut))) => "*",
-            Adjust::Deref(Some(OverloadedDeref(Mutability::Shared))) => "*",
-            Adjust::Borrow(AutoBorrow::Ref(Mutability::Shared)) => "&",
-            Adjust::Borrow(AutoBorrow::Ref(Mutability::Mut)) => "&mut ",
-            Adjust::Borrow(AutoBorrow::RawPtr(Mutability::Shared)) => "&raw const ",
-            Adjust::Borrow(AutoBorrow::RawPtr(Mutability::Mut)) => "&raw mut ",
-            // some of these could be represented via `as` casts, but that's not too nice and
-            // handling everything as a prefix expr makes the `(` and `)` insertion easier
-            Adjust::Pointer(cast) if config.adjustment_hints == AdjustmentHints::Always => {
-                match cast {
-                    PointerCast::ReifyFnPointer => "<fn-item-to-fn-pointer>",
-                    PointerCast::UnsafeFnPointer => "<safe-fn-pointer-to-unsafe-fn-pointer>",
-                    PointerCast::ClosureFnPointer(Safety::Unsafe) => {
-                        "<closure-to-unsafe-fn-pointer>"
-                    }
-                    PointerCast::ClosureFnPointer(Safety::Safe) => "<closure-to-fn-pointer>",
-                    PointerCast::MutToConstPointer => "<mut-ptr-to-const-ptr>",
-                    PointerCast::ArrayToPointer => "<array-ptr-to-element-ptr>",
-                    PointerCast::Unsize => "<unsize>",
-                }
-            }
-            _ => continue,
-        };
-        acc.push(InlayHint {
-            range: expr.syntax().text_range(),
-            kind: InlayKind::AdjustmentHint,
-            label: text.into(),
-            tooltip: None,
-        });
-    }
-    if needs_parens {
-        acc.push(InlayHint {
-            range: expr.syntax().text_range(),
-            kind: InlayKind::ClosingParenthesis,
-            label: ")".into(),
-            tooltip: None,
-        });
-    }
-    Some(())
-}
-
-#[cfg(test)]
-mod tests {
-    use crate::{
-        inlay_hints::tests::{check_with_config, DISABLED_CONFIG},
-        AdjustmentHints, InlayHintsConfig,
-    };
-
-    #[test]
-    fn adjustment_hints() {
-        check_with_config(
-            InlayHintsConfig { adjustment_hints: AdjustmentHints::Always, ..DISABLED_CONFIG },
-            r#"
-//- minicore: coerce_unsized
-fn main() {
-    let _: u32         = loop {};
-                       //^^^^^^^<never-to-any>
-    let _: &u32        = &mut 0;
-                       //^^^^^^&
-                       //^^^^^^*
-    let _: &mut u32    = &mut 0;
-                       //^^^^^^&mut $
-                       //^^^^^^*
-    let _: *const u32  = &mut 0;
-                       //^^^^^^&raw const $
-                       //^^^^^^*
-    let _: *mut u32    = &mut 0;
-                       //^^^^^^&raw mut $
-                       //^^^^^^*
-    let _: fn()        = main;
-                       //^^^^<fn-item-to-fn-pointer>
-    let _: unsafe fn() = main;
-                       //^^^^<safe-fn-pointer-to-unsafe-fn-pointer>
-                       //^^^^<fn-item-to-fn-pointer>
-    let _: unsafe fn() = main as fn();
-                       //^^^^^^^^^^^^<safe-fn-pointer-to-unsafe-fn-pointer>
-    let _: fn()        = || {};
-                       //^^^^^<closure-to-fn-pointer>
-    let _: unsafe fn() = || {};
-                       //^^^^^<closure-to-unsafe-fn-pointer>
-    let _: *const u32  = &mut 0u32 as *mut u32;
-                       //^^^^^^^^^^^^^^^^^^^^^<mut-ptr-to-const-ptr>
-    let _: &mut [_]    = &mut [0; 0];
-                       //^^^^^^^^^^^<unsize>
-                       //^^^^^^^^^^^&mut $
-                       //^^^^^^^^^^^*
-
-    Struct.consume();
-    Struct.by_ref();
-  //^^^^^^(
-  //^^^^^^&
-  //^^^^^^)
-    Struct.by_ref_mut();
-  //^^^^^^(
-  //^^^^^^&mut $
-  //^^^^^^)
-
-    (&Struct).consume();
-   //^^^^^^^*
-    (&Struct).by_ref();
-
-    (&mut Struct).consume();
-   //^^^^^^^^^^^*
-    (&mut Struct).by_ref();
-   //^^^^^^^^^^^&
-   //^^^^^^^^^^^*
-    (&mut Struct).by_ref_mut();
-
-    // Check that block-like expressions don't duplicate hints
-    let _: &mut [u32] = (&mut []);
-                       //^^^^^^^<unsize>
-                       //^^^^^^^&mut $
-                       //^^^^^^^*
-    let _: &mut [u32] = { &mut [] };
-                        //^^^^^^^<unsize>
-                        //^^^^^^^&mut $
-                        //^^^^^^^*
-    let _: &mut [u32] = unsafe { &mut [] };
-                               //^^^^^^^<unsize>
-                               //^^^^^^^&mut $
-                               //^^^^^^^*
-    let _: &mut [u32] = if true {
-        &mut []
-      //^^^^^^^<unsize>
-      //^^^^^^^&mut $
-      //^^^^^^^*
-    } else {
-        loop {}
-      //^^^^^^^<never-to-any>
-    };
-    let _: &mut [u32] = match () { () => &mut [] }
-                                       //^^^^^^^<unsize>
-                                       //^^^^^^^&mut $
-                                       //^^^^^^^*
-}
-
-#[derive(Copy, Clone)]
-struct Struct;
-impl Struct {
-    fn consume(self) {}
-    fn by_ref(&self) {}
-    fn by_ref_mut(&mut self) {}
-}
-trait Trait {}
-impl Trait for Struct {}
-"#,
-        )
-    }
-
-    #[test]
-    fn never_to_never_is_never_shown() {
-        check_with_config(
-            InlayHintsConfig { adjustment_hints: AdjustmentHints::Always, ..DISABLED_CONFIG },
-            r#"
-fn never() -> ! {
-    return loop {};
-}
-
-fn or_else() {
-    let () = () else { return };
-}
-            "#,
-        )
-    }
-}
diff --git a/crates/ide/src/inlay_hints/bind_pat.rs b/crates/ide/src/inlay_hints/bind_pat.rs
deleted file mode 100644
index 754df09df1..0000000000
--- a/crates/ide/src/inlay_hints/bind_pat.rs
+++ /dev/null
@@ -1,961 +0,0 @@
-//! Implementation of "type" inlay hints:
-//! ```no_run
-//! fn f(a: i32, b: i32) -> i32 { a + b }
-//! let _x /* i32 */= f(4, 4);
-//! ```
-use hir::{HirDisplay, Semantics, TypeInfo};
-use ide_db::{base_db::FileId, famous_defs::FamousDefs, RootDatabase};
-
-use itertools::Itertools;
-use syntax::{
-    ast::{self, AstNode, HasName},
-    match_ast,
-};
-
-use crate::{
-    inlay_hints::{closure_has_block_body, hint_iterator},
-    InlayHint, InlayHintsConfig, InlayKind, InlayTooltip,
-};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    sema: &Semantics<'_, RootDatabase>,
-    config: &InlayHintsConfig,
-    file_id: FileId,
-    pat: &ast::IdentPat,
-) -> Option<()> {
-    if !config.type_hints {
-        return None;
-    }
-
-    let descended = sema.descend_node_into_attributes(pat.clone()).pop();
-    let desc_pat = descended.as_ref().unwrap_or(pat);
-    let ty = sema.type_of_pat(&desc_pat.clone().into())?.original;
-
-    if should_not_display_type_hint(sema, config, pat, &ty) {
-        return None;
-    }
-
-    let krate = sema.scope(desc_pat.syntax())?.krate();
-    let famous_defs = FamousDefs(sema, krate);
-    let label = hint_iterator(sema, &famous_defs, config, &ty);
-
-    let label = match label {
-        Some(label) => label,
-        None => {
-            let ty_name = ty.display_truncated(sema.db, config.max_length).to_string();
-            if config.hide_named_constructor_hints
-                && is_named_constructor(sema, pat, &ty_name).is_some()
-            {
-                return None;
-            }
-            ty_name
-        }
-    };
-
-    acc.push(InlayHint {
-        range: match pat.name() {
-            Some(name) => name.syntax().text_range(),
-            None => pat.syntax().text_range(),
-        },
-        kind: InlayKind::TypeHint,
-        label: label.into(),
-        tooltip: pat
-            .name()
-            .map(|it| it.syntax().text_range())
-            .map(|it| InlayTooltip::HoverRanged(file_id, it)),
-    });
-
-    Some(())
-}
-
-fn should_not_display_type_hint(
-    sema: &Semantics<'_, RootDatabase>,
-    config: &InlayHintsConfig,
-    bind_pat: &ast::IdentPat,
-    pat_ty: &hir::Type,
-) -> bool {
-    let db = sema.db;
-
-    if pat_ty.is_unknown() {
-        return true;
-    }
-
-    if let Some(hir::Adt::Struct(s)) = pat_ty.as_adt() {
-        if s.fields(db).is_empty() && s.name(db).to_smol_str() == bind_pat.to_string() {
-            return true;
-        }
-    }
-
-    if config.hide_closure_initialization_hints {
-        if let Some(parent) = bind_pat.syntax().parent() {
-            if let Some(it) = ast::LetStmt::cast(parent.clone()) {
-                if let Some(ast::Expr::ClosureExpr(closure)) = it.initializer() {
-                    if closure_has_block_body(&closure) {
-                        return true;
-                    }
-                }
-            }
-        }
-    }
-
-    for node in bind_pat.syntax().ancestors() {
-        match_ast! {
-            match node {
-                ast::LetStmt(it) => return it.ty().is_some(),
-                // FIXME: We might wanna show type hints in parameters for non-top level patterns as well
-                ast::Param(it) => return it.ty().is_some(),
-                ast::MatchArm(_) => return pat_is_enum_variant(db, bind_pat, pat_ty),
-                ast::LetExpr(_) => return pat_is_enum_variant(db, bind_pat, pat_ty),
-                ast::IfExpr(_) => return false,
-                ast::WhileExpr(_) => return false,
-                ast::ForExpr(it) => {
-                    // We *should* display hint only if user provided "in {expr}" and we know the type of expr (and it's not unit).
-                    // Type of expr should be iterable.
-                    return it.in_token().is_none() ||
-                        it.iterable()
-                            .and_then(|iterable_expr| sema.type_of_expr(&iterable_expr))
-                            .map(TypeInfo::original)
-                            .map_or(true, |iterable_ty| iterable_ty.is_unknown() || iterable_ty.is_unit())
-                },
-                _ => (),
-            }
-        }
-    }
-    false
-}
-
-fn is_named_constructor(
-    sema: &Semantics<'_, RootDatabase>,
-    pat: &ast::IdentPat,
-    ty_name: &str,
-) -> Option<()> {
-    let let_node = pat.syntax().parent()?;
-    let expr = match_ast! {
-        match let_node {
-            ast::LetStmt(it) => it.initializer(),
-            ast::LetExpr(it) => it.expr(),
-            _ => None,
-        }
-    }?;
-
-    let expr = sema.descend_node_into_attributes(expr.clone()).pop().unwrap_or(expr);
-    // unwrap postfix expressions
-    let expr = match expr {
-        ast::Expr::TryExpr(it) => it.expr(),
-        ast::Expr::AwaitExpr(it) => it.expr(),
-        expr => Some(expr),
-    }?;
-    let expr = match expr {
-        ast::Expr::CallExpr(call) => match call.expr()? {
-            ast::Expr::PathExpr(path) => path,
-            _ => return None,
-        },
-        ast::Expr::PathExpr(path) => path,
-        _ => return None,
-    };
-    let path = expr.path()?;
-
-    let callable = sema.type_of_expr(&ast::Expr::PathExpr(expr))?.original.as_callable(sema.db);
-    let callable_kind = callable.map(|it| it.kind());
-    let qual_seg = match callable_kind {
-        Some(hir::CallableKind::Function(_) | hir::CallableKind::TupleEnumVariant(_)) => {
-            path.qualifier()?.segment()
-        }
-        _ => path.segment(),
-    }?;
-
-    let ctor_name = match qual_seg.kind()? {
-        ast::PathSegmentKind::Name(name_ref) => {
-            match qual_seg.generic_arg_list().map(|it| it.generic_args()) {
-                Some(generics) => format!("{}<{}>", name_ref, generics.format(", ")),
-                None => name_ref.to_string(),
-            }
-        }
-        ast::PathSegmentKind::Type { type_ref: Some(ty), trait_ref: None } => ty.to_string(),
-        _ => return None,
-    };
-    (ctor_name == ty_name).then(|| ())
-}
-
-fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::IdentPat, pat_ty: &hir::Type) -> bool {
-    if let Some(hir::Adt::Enum(enum_data)) = pat_ty.as_adt() {
-        let pat_text = bind_pat.to_string();
-        enum_data
-            .variants(db)
-            .into_iter()
-            .map(|variant| variant.name(db).to_smol_str())
-            .any(|enum_name| enum_name == pat_text)
-    } else {
-        false
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    // This module also contains tests for super::closure_ret
-
-    use expect_test::expect;
-    use syntax::{TextRange, TextSize};
-    use test_utils::extract_annotations;
-
-    use crate::{fixture, inlay_hints::InlayHintsConfig};
-
-    use crate::inlay_hints::tests::{
-        check, check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG,
-    };
-    use crate::ClosureReturnTypeHints;
-
-    #[track_caller]
-    fn check_types(ra_fixture: &str) {
-        check_with_config(InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG }, ra_fixture);
-    }
-
-    #[test]
-    fn type_hints_only() {
-        check_types(
-            r#"
-fn foo(a: i32, b: i32) -> i32 { a + b }
-fn main() {
-    let _x = foo(4, 4);
-      //^^ i32
-}"#,
-        );
-    }
-
-    #[test]
-    fn type_hints_bindings_after_at() {
-        check_types(
-            r#"
-//- minicore: option
-fn main() {
-    let ref foo @ bar @ ref mut baz = 0;
-          //^^^ &i32
-                //^^^ i32
-                              //^^^ &mut i32
-    let [x @ ..] = [0];
-       //^ [i32; 1]
-    if let x @ Some(_) = Some(0) {}
-         //^ Option<i32>
-    let foo @ (bar, baz) = (3, 3);
-      //^^^ (i32, i32)
-             //^^^ i32
-                  //^^^ i32
-}"#,
-        );
-    }
-
-    #[test]
-    fn default_generic_types_should_not_be_displayed() {
-        check(
-            r#"
-struct Test<K, T = u8> { k: K, t: T }
-
-fn main() {
-    let zz = Test { t: 23u8, k: 33 };
-      //^^ Test<i32>
-    let zz_ref = &zz;
-      //^^^^^^ &Test<i32>
-    let test = || zz;
-      //^^^^ || -> Test<i32>
-}"#,
-        );
-    }
-
-    #[test]
-    fn shorten_iterators_in_associated_params() {
-        check_types(
-            r#"
-//- minicore: iterators
-use core::iter;
-
-pub struct SomeIter<T> {}
-
-impl<T> SomeIter<T> {
-    pub fn new() -> Self { SomeIter {} }
-    pub fn push(&mut self, t: T) {}
-}
-
-impl<T> Iterator for SomeIter<T> {
-    type Item = T;
-    fn next(&mut self) -> Option<Self::Item> {
-        None
-    }
-}
-
-fn main() {
-    let mut some_iter = SomeIter::new();
-          //^^^^^^^^^ SomeIter<Take<Repeat<i32>>>
-      some_iter.push(iter::repeat(2).take(2));
-    let iter_of_iters = some_iter.take(2);
-      //^^^^^^^^^^^^^ impl Iterator<Item = impl Iterator<Item = i32>>
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn iterator_hint_regression_issue_12674() {
-        // Ensure we don't crash while solving the projection type of iterators.
-        check_expect(
-            InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
-            r#"
-//- minicore: iterators
-struct S<T>(T);
-impl<T> S<T> {
-    fn iter(&self) -> Iter<'_, T> { loop {} }
-}
-struct Iter<'a, T: 'a>(&'a T);
-impl<'a, T> Iterator for Iter<'a, T> {
-    type Item = &'a T;
-    fn next(&mut self) -> Option<Self::Item> { loop {} }
-}
-struct Container<'a> {
-    elements: S<&'a str>,
-}
-struct SliceIter<'a, T>(&'a T);
-impl<'a, T> Iterator for SliceIter<'a, T> {
-    type Item = &'a T;
-    fn next(&mut self) -> Option<Self::Item> { loop {} }
-}
-
-fn main(a: SliceIter<'_, Container>) {
-    a
-    .filter_map(|c| Some(c.elements.iter().filter_map(|v| Some(v))))
-    .map(|e| e);
-}
-            "#,
-            expect![[r#"
-                [
-                    InlayHint {
-                        range: 484..554,
-                        kind: ChainingHint,
-                        label: [
-                            "impl Iterator<Item = impl Iterator<Item = &&str>>",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                484..554,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 484..485,
-                        kind: ChainingHint,
-                        label: [
-                            "SliceIter<Container>",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                484..485,
-                            ),
-                        ),
-                    },
-                ]
-            "#]],
-        );
-    }
-
-    #[test]
-    fn infer_call_method_return_associated_types_with_generic() {
-        check_types(
-            r#"
-            pub trait Default {
-                fn default() -> Self;
-            }
-            pub trait Foo {
-                type Bar: Default;
-            }
-
-            pub fn quux<T: Foo>() -> T::Bar {
-                let y = Default::default();
-                  //^ <T as Foo>::Bar
-
-                y
-            }
-            "#,
-        );
-    }
-
-    #[test]
-    fn fn_hints() {
-        check_types(
-            r#"
-//- minicore: fn, sized
-fn foo() -> impl Fn() { loop {} }
-fn foo1() -> impl Fn(f64) { loop {} }
-fn foo2() -> impl Fn(f64, f64) { loop {} }
-fn foo3() -> impl Fn(f64, f64) -> u32 { loop {} }
-fn foo4() -> &'static dyn Fn(f64, f64) -> u32 { loop {} }
-fn foo5() -> &'static dyn Fn(&'static dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
-fn foo6() -> impl Fn(f64, f64) -> u32 + Sized { loop {} }
-fn foo7() -> *const (impl Fn(f64, f64) -> u32 + Sized) { loop {} }
-
-fn main() {
-    let foo = foo();
-     // ^^^ impl Fn()
-    let foo = foo1();
-     // ^^^ impl Fn(f64)
-    let foo = foo2();
-     // ^^^ impl Fn(f64, f64)
-    let foo = foo3();
-     // ^^^ impl Fn(f64, f64) -> u32
-    let foo = foo4();
-     // ^^^ &dyn Fn(f64, f64) -> u32
-    let foo = foo5();
-     // ^^^ &dyn Fn(&dyn Fn(f64, f64) -> u32, f64) -> u32
-    let foo = foo6();
-     // ^^^ impl Fn(f64, f64) -> u32
-    let foo = foo7();
-     // ^^^ *const impl Fn(f64, f64) -> u32
-}
-"#,
-        )
-    }
-
-    #[test]
-    fn check_hint_range_limit() {
-        let fixture = r#"
-        //- minicore: fn, sized
-        fn foo() -> impl Fn() { loop {} }
-        fn foo1() -> impl Fn(f64) { loop {} }
-        fn foo2() -> impl Fn(f64, f64) { loop {} }
-        fn foo3() -> impl Fn(f64, f64) -> u32 { loop {} }
-        fn foo4() -> &'static dyn Fn(f64, f64) -> u32 { loop {} }
-        fn foo5() -> &'static dyn Fn(&'static dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
-        fn foo6() -> impl Fn(f64, f64) -> u32 + Sized { loop {} }
-        fn foo7() -> *const (impl Fn(f64, f64) -> u32 + Sized) { loop {} }
-
-        fn main() {
-            let foo = foo();
-            let foo = foo1();
-            let foo = foo2();
-             // ^^^ impl Fn(f64, f64)
-            let foo = foo3();
-             // ^^^ impl Fn(f64, f64) -> u32
-            let foo = foo4();
-            let foo = foo5();
-            let foo = foo6();
-            let foo = foo7();
-        }
-        "#;
-        let (analysis, file_id) = fixture::file(fixture);
-        let expected = extract_annotations(&*analysis.file_text(file_id).unwrap());
-        let inlay_hints = analysis
-            .inlay_hints(
-                &InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },
-                file_id,
-                Some(TextRange::new(TextSize::from(500), TextSize::from(600))),
-            )
-            .unwrap();
-        let actual =
-            inlay_hints.into_iter().map(|it| (it.range, it.label.to_string())).collect::<Vec<_>>();
-        assert_eq!(expected, actual, "\nExpected:\n{:#?}\n\nActual:\n{:#?}", expected, actual);
-    }
-
-    #[test]
-    fn fn_hints_ptr_rpit_fn_parentheses() {
-        check_types(
-            r#"
-//- minicore: fn, sized
-trait Trait {}
-
-fn foo1() -> *const impl Fn() { loop {} }
-fn foo2() -> *const (impl Fn() + Sized) { loop {} }
-fn foo3() -> *const (impl Fn() + ?Sized) { loop {} }
-fn foo4() -> *const (impl Sized + Fn()) { loop {} }
-fn foo5() -> *const (impl ?Sized + Fn()) { loop {} }
-fn foo6() -> *const (impl Fn() + Trait) { loop {} }
-fn foo7() -> *const (impl Fn() + Sized + Trait) { loop {} }
-fn foo8() -> *const (impl Fn() + ?Sized + Trait) { loop {} }
-fn foo9() -> *const (impl Fn() -> u8 + ?Sized) { loop {} }
-fn foo10() -> *const (impl Fn() + Sized + ?Sized) { loop {} }
-
-fn main() {
-    let foo = foo1();
-    //  ^^^ *const impl Fn()
-    let foo = foo2();
-    //  ^^^ *const impl Fn()
-    let foo = foo3();
-    //  ^^^ *const (impl Fn() + ?Sized)
-    let foo = foo4();
-    //  ^^^ *const impl Fn()
-    let foo = foo5();
-    //  ^^^ *const (impl Fn() + ?Sized)
-    let foo = foo6();
-    //  ^^^ *const (impl Fn() + Trait)
-    let foo = foo7();
-    //  ^^^ *const (impl Fn() + Trait)
-    let foo = foo8();
-    //  ^^^ *const (impl Fn() + Trait + ?Sized)
-    let foo = foo9();
-    //  ^^^ *const (impl Fn() -> u8 + ?Sized)
-    let foo = foo10();
-    //  ^^^ *const impl Fn()
-}
-"#,
-        )
-    }
-
-    #[test]
-    fn unit_structs_have_no_type_hints() {
-        check_types(
-            r#"
-//- minicore: result
-struct SyntheticSyntax;
-
-fn main() {
-    match Ok(()) {
-        Ok(_) => (),
-        Err(SyntheticSyntax) => (),
-    }
-}"#,
-        );
-    }
-
-    #[test]
-    fn let_statement() {
-        check_types(
-            r#"
-#[derive(PartialEq)]
-enum Option<T> { None, Some(T) }
-
-#[derive(PartialEq)]
-struct Test { a: Option<u32>, b: u8 }
-
-fn main() {
-    struct InnerStruct {}
-
-    let test = 54;
-      //^^^^ i32
-    let test: i32 = 33;
-    let mut test = 33;
-          //^^^^ i32
-    let _ = 22;
-    let test = "test";
-      //^^^^ &str
-    let test = InnerStruct {};
-      //^^^^ InnerStruct
-
-    let test = unresolved();
-
-    let test = (42, 'a');
-      //^^^^ (i32, char)
-    let (a,    (b,     (c,)) = (2, (3, (9.2,));
-       //^ i32  ^ i32   ^ f64
-    let &x = &92;
-       //^ i32
-}"#,
-        );
-    }
-
-    #[test]
-    fn if_expr() {
-        check_types(
-            r#"
-//- minicore: option
-struct Test { a: Option<u32>, b: u8 }
-
-fn main() {
-    let test = Some(Test { a: Some(3), b: 1 });
-      //^^^^ Option<Test>
-    if let None = &test {};
-    if let test = &test {};
-         //^^^^ &Option<Test>
-    if let Some(test) = &test {};
-              //^^^^ &Test
-    if let Some(Test { a,             b }) = &test {};
-                     //^ &Option<u32> ^ &u8
-    if let Some(Test { a: x,             b: y }) = &test {};
-                        //^ &Option<u32>    ^ &u8
-    if let Some(Test { a: Some(x),  b: y }) = &test {};
-                             //^ &u32  ^ &u8
-    if let Some(Test { a: None,  b: y }) = &test {};
-                                  //^ &u8
-    if let Some(Test { b: y, .. }) = &test {};
-                        //^ &u8
-    if test == None {}
-}"#,
-        );
-    }
-
-    #[test]
-    fn while_expr() {
-        check_types(
-            r#"
-//- minicore: option
-struct Test { a: Option<u32>, b: u8 }
-
-fn main() {
-    let test = Some(Test { a: Some(3), b: 1 });
-      //^^^^ Option<Test>
-    while let Some(Test { a: Some(x),  b: y }) = &test {};
-                                //^ &u32  ^ &u8
-}"#,
-        );
-    }
-
-    #[test]
-    fn match_arm_list() {
-        check_types(
-            r#"
-//- minicore: option
-struct Test { a: Option<u32>, b: u8 }
-
-fn main() {
-    match Some(Test { a: Some(3), b: 1 }) {
-        None => (),
-        test => (),
-      //^^^^ Option<Test>
-        Some(Test { a: Some(x), b: y }) => (),
-                          //^ u32  ^ u8
-        _ => {}
-    }
-}"#,
-        );
-    }
-
-    #[test]
-    fn complete_for_hint() {
-        check_types(
-            r#"
-//- minicore: iterator
-pub struct Vec<T> {}
-
-impl<T> Vec<T> {
-    pub fn new() -> Self { Vec {} }
-    pub fn push(&mut self, t: T) {}
-}
-
-impl<T> IntoIterator for Vec<T> {
-    type Item = T;
-    type IntoIter = IntoIter<T>;
-}
-
-struct IntoIter<T> {}
-
-impl<T> Iterator for IntoIter<T> {
-    type Item = T;
-}
-
-fn main() {
-    let mut data = Vec::new();
-          //^^^^ Vec<&str>
-    data.push("foo");
-    for i in data {
-      //^ &str
-      let z = i;
-        //^ &str
-    }
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn multi_dyn_trait_bounds() {
-        check_types(
-            r#"
-pub struct Vec<T> {}
-
-impl<T> Vec<T> {
-    pub fn new() -> Self { Vec {} }
-}
-
-pub struct Box<T> {}
-
-trait Display {}
-auto trait Sync {}
-
-fn main() {
-    // The block expression wrapping disables the constructor hint hiding logic
-    let _v = { Vec::<Box<&(dyn Display + Sync)>>::new() };
-      //^^ Vec<Box<&(dyn Display + Sync)>>
-    let _v = { Vec::<Box<*const (dyn Display + Sync)>>::new() };
-      //^^ Vec<Box<*const (dyn Display + Sync)>>
-    let _v = { Vec::<Box<dyn Display + Sync>>::new() };
-      //^^ Vec<Box<dyn Display + Sync>>
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn shorten_iterator_hints() {
-        check_types(
-            r#"
-//- minicore: iterators
-use core::iter;
-
-struct MyIter;
-
-impl Iterator for MyIter {
-    type Item = ();
-    fn next(&mut self) -> Option<Self::Item> {
-        None
-    }
-}
-
-fn main() {
-    let _x = MyIter;
-      //^^ MyIter
-    let _x = iter::repeat(0);
-      //^^ impl Iterator<Item = i32>
-    fn generic<T: Clone>(t: T) {
-        let _x = iter::repeat(t);
-          //^^ impl Iterator<Item = T>
-        let _chained = iter::repeat(t).take(10);
-          //^^^^^^^^ impl Iterator<Item = T>
-    }
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn skip_constructor_and_enum_type_hints() {
-        check_with_config(
-            InlayHintsConfig {
-                type_hints: true,
-                hide_named_constructor_hints: true,
-                ..DISABLED_CONFIG
-            },
-            r#"
-//- minicore: try, option
-use core::ops::ControlFlow;
-
-mod x {
-    pub mod y { pub struct Foo; }
-    pub struct Foo;
-    pub enum AnotherEnum {
-        Variant()
-    };
-}
-struct Struct;
-struct TupleStruct();
-
-impl Struct {
-    fn new() -> Self {
-        Struct
-    }
-    fn try_new() -> ControlFlow<(), Self> {
-        ControlFlow::Continue(Struct)
-    }
-}
-
-struct Generic<T>(T);
-impl Generic<i32> {
-    fn new() -> Self {
-        Generic(0)
-    }
-}
-
-enum Enum {
-    Variant(u32)
-}
-
-fn times2(value: i32) -> i32 {
-    2 * value
-}
-
-fn main() {
-    let enumb = Enum::Variant(0);
-
-    let strukt = x::Foo;
-    let strukt = x::y::Foo;
-    let strukt = Struct;
-    let strukt = Struct::new();
-
-    let tuple_struct = TupleStruct();
-
-    let generic0 = Generic::new();
-    //  ^^^^^^^^ Generic<i32>
-    let generic1 = Generic(0);
-    //  ^^^^^^^^ Generic<i32>
-    let generic2 = Generic::<i32>::new();
-    let generic3 = <Generic<i32>>::new();
-    let generic4 = Generic::<i32>(0);
-
-
-    let option = Some(0);
-    //  ^^^^^^ Option<i32>
-    let func = times2;
-    //  ^^^^ fn times2(i32) -> i32
-    let closure = |x: i32| x * 2;
-    //  ^^^^^^^ |i32| -> i32
-}
-
-fn fallible() -> ControlFlow<()> {
-    let strukt = Struct::try_new()?;
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn shows_constructor_type_hints_when_enabled() {
-        check_types(
-            r#"
-//- minicore: try
-use core::ops::ControlFlow;
-
-struct Struct;
-struct TupleStruct();
-
-impl Struct {
-    fn new() -> Self {
-        Struct
-    }
-    fn try_new() -> ControlFlow<(), Self> {
-        ControlFlow::Continue(Struct)
-    }
-}
-
-struct Generic<T>(T);
-impl Generic<i32> {
-    fn new() -> Self {
-        Generic(0)
-    }
-}
-
-fn main() {
-    let strukt = Struct::new();
-     // ^^^^^^ Struct
-    let tuple_struct = TupleStruct();
-     // ^^^^^^^^^^^^ TupleStruct
-    let generic0 = Generic::new();
-     // ^^^^^^^^ Generic<i32>
-    let generic1 = Generic::<i32>::new();
-     // ^^^^^^^^ Generic<i32>
-    let generic2 = <Generic<i32>>::new();
-     // ^^^^^^^^ Generic<i32>
-}
-
-fn fallible() -> ControlFlow<()> {
-    let strukt = Struct::try_new()?;
-     // ^^^^^^ Struct
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn closures() {
-        check(
-            r#"
-fn main() {
-    let mut start = 0;
-          //^^^^^ i32
-    (0..2).for_each(|increment      | { start += increment; });
-                   //^^^^^^^^^ i32
-
-    let multiply =
-      //^^^^^^^^ |i32, i32| -> i32
-      | a,     b| a * b
-      //^ i32  ^ i32
-
-    ;
-
-    let _: i32 = multiply(1,  2);
-                        //^ a ^ b
-    let multiply_ref = &multiply;
-      //^^^^^^^^^^^^ &|i32, i32| -> i32
-
-    let return_42 = || 42;
-      //^^^^^^^^^ || -> i32
-      || { 42 };
-    //^^ i32
-}"#,
-        );
-    }
-
-    #[test]
-    fn return_type_hints_for_closure_without_block() {
-        check_with_config(
-            InlayHintsConfig {
-                closure_return_type_hints: ClosureReturnTypeHints::Always,
-                ..DISABLED_CONFIG
-            },
-            r#"
-fn main() {
-    let a = || { 0 };
-          //^^ i32
-    let b = || 0;
-          //^^ i32
-}"#,
-        );
-    }
-
-    #[test]
-    fn skip_closure_type_hints() {
-        check_with_config(
-            InlayHintsConfig {
-                type_hints: true,
-                hide_closure_initialization_hints: true,
-                ..DISABLED_CONFIG
-            },
-            r#"
-//- minicore: fn
-fn main() {
-    let multiple_2 = |x: i32| { x * 2 };
-
-    let multiple_2 = |x: i32| x * 2;
-    //  ^^^^^^^^^^ |i32| -> i32
-
-    let (not) = (|x: bool| { !x });
-    //   ^^^ |bool| -> bool
-
-    let (is_zero, _b) = (|x: usize| { x == 0 }, false);
-    //   ^^^^^^^ |usize| -> bool
-    //            ^^ bool
-
-    let plus_one = |x| { x + 1 };
-    //              ^ u8
-    foo(plus_one);
-
-    let add_mul = bar(|x: u8| { x + 1 });
-    //  ^^^^^^^ impl FnOnce(u8) -> u8 + ?Sized
-
-    let closure = if let Some(6) = add_mul(2).checked_sub(1) {
-    //  ^^^^^^^ fn(i32) -> i32
-        |x: i32| { x * 2 }
-    } else {
-        |x: i32| { x * 3 }
-    };
-}
-
-fn foo(f: impl FnOnce(u8) -> u8) {}
-
-fn bar(f: impl FnOnce(u8) -> u8) -> impl FnOnce(u8) -> u8 {
-    move |x: u8| f(x) * 2
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn hint_truncation() {
-        check_with_config(
-            InlayHintsConfig { max_length: Some(8), ..TEST_CONFIG },
-            r#"
-struct Smol<T>(T);
-
-struct VeryLongOuterName<T>(T);
-
-fn main() {
-    let a = Smol(0u32);
-      //^ Smol<u32>
-    let b = VeryLongOuterName(0usize);
-      //^ VeryLongOuterName<…>
-    let c = Smol(Smol(0u32))
-      //^ Smol<Smol<…>>
-}"#,
-        );
-    }
-}
diff --git a/crates/ide/src/inlay_hints/binding_mode.rs b/crates/ide/src/inlay_hints/binding_mode.rs
deleted file mode 100644
index 846f0a4e0c..0000000000
--- a/crates/ide/src/inlay_hints/binding_mode.rs
+++ /dev/null
@@ -1,141 +0,0 @@
-//! Implementation of "binding mode" inlay hints:
-//! ```no_run
-//! let /* & */ (/* ref */ x,) = &(0,);
-//! ```
-use hir::{Mutability, Semantics};
-use ide_db::RootDatabase;
-
-use syntax::ast::{self, AstNode};
-
-use crate::{InlayHint, InlayHintsConfig, InlayKind, InlayTooltip};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    sema: &Semantics<'_, RootDatabase>,
-    config: &InlayHintsConfig,
-    pat: &ast::Pat,
-) -> Option<()> {
-    if !config.binding_mode_hints {
-        return None;
-    }
-
-    let outer_paren_pat = pat
-        .syntax()
-        .ancestors()
-        .skip(1)
-        .map_while(ast::Pat::cast)
-        .map_while(|pat| match pat {
-            ast::Pat::ParenPat(pat) => Some(pat),
-            _ => None,
-        })
-        .last();
-    let range =
-        outer_paren_pat.as_ref().map_or_else(|| pat.syntax(), |it| it.syntax()).text_range();
-    sema.pattern_adjustments(&pat).iter().for_each(|ty| {
-        let reference = ty.is_reference();
-        let mut_reference = ty.is_mutable_reference();
-        let r = match (reference, mut_reference) {
-            (true, true) => "&mut",
-            (true, false) => "&",
-            _ => return,
-        };
-        acc.push(InlayHint {
-            range,
-            kind: InlayKind::BindingModeHint,
-            label: r.to_string().into(),
-            tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
-        });
-    });
-    match pat {
-        ast::Pat::IdentPat(pat) if pat.ref_token().is_none() && pat.mut_token().is_none() => {
-            let bm = sema.binding_mode_of_pat(pat)?;
-            let bm = match bm {
-                hir::BindingMode::Move => return None,
-                hir::BindingMode::Ref(Mutability::Mut) => "ref mut",
-                hir::BindingMode::Ref(Mutability::Shared) => "ref",
-            };
-            acc.push(InlayHint {
-                range: pat.syntax().text_range(),
-                kind: InlayKind::BindingModeHint,
-                label: bm.to_string().into(),
-                tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
-            });
-        }
-        ast::Pat::OrPat(pat) if outer_paren_pat.is_none() => {
-            acc.push(InlayHint {
-                range: pat.syntax().text_range(),
-                kind: InlayKind::OpeningParenthesis,
-                label: "(".into(),
-                tooltip: None,
-            });
-            acc.push(InlayHint {
-                range: pat.syntax().text_range(),
-                kind: InlayKind::ClosingParenthesis,
-                label: ")".into(),
-                tooltip: None,
-            });
-        }
-        _ => (),
-    }
-
-    Some(())
-}
-
-#[cfg(test)]
-mod tests {
-    use crate::{
-        inlay_hints::tests::{check_with_config, DISABLED_CONFIG},
-        InlayHintsConfig,
-    };
-
-    #[test]
-    fn hints_binding_modes() {
-        check_with_config(
-            InlayHintsConfig { binding_mode_hints: true, ..DISABLED_CONFIG },
-            r#"
-fn __(
-    (x,): (u32,),
-    (x,): &(u32,),
-  //^^^^&
-   //^ ref
-    (x,): &mut (u32,)
-  //^^^^&mut
-   //^ ref mut
-) {
-    let (x,) = (0,);
-    let (x,) = &(0,);
-      //^^^^ &
-       //^ ref
-    let (x,) = &mut (0,);
-      //^^^^ &mut
-       //^ ref mut
-    let &mut (x,) = &mut (0,);
-    let (ref mut x,) = &mut (0,);
-      //^^^^^^^^^^^^ &mut
-    let &mut (ref mut x,) = &mut (0,);
-    let (mut x,) = &mut (0,);
-      //^^^^^^^^ &mut
-    match (0,) {
-        (x,) => ()
-    }
-    match &(0,) {
-        (x,) | (x,) => (),
-      //^^^^^^^^^^^&
-       //^ ref
-              //^ ref
-      //^^^^^^^^^^^(
-      //^^^^^^^^^^^)
-        ((x,) | (x,)) => (),
-      //^^^^^^^^^^^^^&
-        //^ ref
-               //^ ref
-    }
-    match &mut (0,) {
-        (x,) => ()
-      //^^^^ &mut
-       //^ ref mut
-    }
-}"#,
-        );
-    }
-}
diff --git a/crates/ide/src/inlay_hints/chaining.rs b/crates/ide/src/inlay_hints/chaining.rs
deleted file mode 100644
index 32421afd39..0000000000
--- a/crates/ide/src/inlay_hints/chaining.rs
+++ /dev/null
@@ -1,459 +0,0 @@
-//! Implementation of "chaining" inlay hints.
-use hir::{HirDisplay, Semantics};
-use ide_db::{famous_defs::FamousDefs, RootDatabase};
-use syntax::{
-    ast::{self, AstNode},
-    Direction, NodeOrToken, SyntaxKind, T,
-};
-
-use crate::{
-    inlay_hints::hint_iterator, FileId, InlayHint, InlayHintsConfig, InlayKind, InlayTooltip,
-};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    sema: &Semantics<'_, RootDatabase>,
-    famous_defs: &FamousDefs<'_, '_>,
-    config: &InlayHintsConfig,
-    file_id: FileId,
-    expr: &ast::Expr,
-) -> Option<()> {
-    if !config.chaining_hints {
-        return None;
-    }
-
-    if matches!(expr, ast::Expr::RecordExpr(_)) {
-        return None;
-    }
-
-    let descended = sema.descend_node_into_attributes(expr.clone()).pop();
-    let desc_expr = descended.as_ref().unwrap_or(expr);
-
-    let mut tokens = expr
-        .syntax()
-        .siblings_with_tokens(Direction::Next)
-        .filter_map(NodeOrToken::into_token)
-        .filter(|t| match t.kind() {
-            SyntaxKind::WHITESPACE if !t.text().contains('\n') => false,
-            SyntaxKind::COMMENT => false,
-            _ => true,
-        });
-
-    // Chaining can be defined as an expression whose next sibling tokens are newline and dot
-    // Ignoring extra whitespace and comments
-    let next = tokens.next()?.kind();
-    if next == SyntaxKind::WHITESPACE {
-        let mut next_next = tokens.next()?.kind();
-        while next_next == SyntaxKind::WHITESPACE {
-            next_next = tokens.next()?.kind();
-        }
-        if next_next == T![.] {
-            let ty = sema.type_of_expr(desc_expr)?.original;
-            if ty.is_unknown() {
-                return None;
-            }
-            if matches!(expr, ast::Expr::PathExpr(_)) {
-                if let Some(hir::Adt::Struct(st)) = ty.as_adt() {
-                    if st.fields(sema.db).is_empty() {
-                        return None;
-                    }
-                }
-            }
-            acc.push(InlayHint {
-                range: expr.syntax().text_range(),
-                kind: InlayKind::ChainingHint,
-                label: hint_iterator(sema, &famous_defs, config, &ty)
-                    .unwrap_or_else(|| ty.display_truncated(sema.db, config.max_length).to_string())
-                    .into(),
-                tooltip: Some(InlayTooltip::HoverRanged(file_id, expr.syntax().text_range())),
-            });
-        }
-    }
-    Some(())
-}
-
-#[cfg(test)]
-mod tests {
-    use expect_test::expect;
-
-    use crate::{
-        inlay_hints::tests::{check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG},
-        InlayHintsConfig,
-    };
-
-    #[track_caller]
-    fn check_chains(ra_fixture: &str) {
-        check_with_config(InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG }, ra_fixture);
-    }
-
-    #[test]
-    fn chaining_hints_ignore_comments() {
-        check_expect(
-            InlayHintsConfig { type_hints: false, chaining_hints: true, ..DISABLED_CONFIG },
-            r#"
-struct A(B);
-impl A { fn into_b(self) -> B { self.0 } }
-struct B(C);
-impl B { fn into_c(self) -> C { self.0 } }
-struct C;
-
-fn main() {
-    let c = A(B(C))
-        .into_b() // This is a comment
-        // This is another comment
-        .into_c();
-}
-"#,
-            expect![[r#"
-                [
-                    InlayHint {
-                        range: 147..172,
-                        kind: ChainingHint,
-                        label: [
-                            "B",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                147..172,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 147..154,
-                        kind: ChainingHint,
-                        label: [
-                            "A",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                147..154,
-                            ),
-                        ),
-                    },
-                ]
-            "#]],
-        );
-    }
-
-    #[test]
-    fn chaining_hints_without_newlines() {
-        check_chains(
-            r#"
-struct A(B);
-impl A { fn into_b(self) -> B { self.0 } }
-struct B(C);
-impl B { fn into_c(self) -> C { self.0 } }
-struct C;
-
-fn main() {
-    let c = A(B(C)).into_b().into_c();
-}"#,
-        );
-    }
-
-    #[test]
-    fn struct_access_chaining_hints() {
-        check_expect(
-            InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
-            r#"
-struct A { pub b: B }
-struct B { pub c: C }
-struct C(pub bool);
-struct D;
-
-impl D {
-    fn foo(&self) -> i32 { 42 }
-}
-
-fn main() {
-    let x = A { b: B { c: C(true) } }
-        .b
-        .c
-        .0;
-    let x = D
-        .foo();
-}"#,
-            expect![[r#"
-                [
-                    InlayHint {
-                        range: 143..190,
-                        kind: ChainingHint,
-                        label: [
-                            "C",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                143..190,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 143..179,
-                        kind: ChainingHint,
-                        label: [
-                            "B",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                143..179,
-                            ),
-                        ),
-                    },
-                ]
-            "#]],
-        );
-    }
-
-    #[test]
-    fn generic_chaining_hints() {
-        check_expect(
-            InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
-            r#"
-struct A<T>(T);
-struct B<T>(T);
-struct C<T>(T);
-struct X<T,R>(T, R);
-
-impl<T> A<T> {
-    fn new(t: T) -> Self { A(t) }
-    fn into_b(self) -> B<T> { B(self.0) }
-}
-impl<T> B<T> {
-    fn into_c(self) -> C<T> { C(self.0) }
-}
-fn main() {
-    let c = A::new(X(42, true))
-        .into_b()
-        .into_c();
-}
-"#,
-            expect![[r#"
-                [
-                    InlayHint {
-                        range: 246..283,
-                        kind: ChainingHint,
-                        label: [
-                            "B<X<i32, bool>>",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                246..283,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 246..265,
-                        kind: ChainingHint,
-                        label: [
-                            "A<X<i32, bool>>",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                246..265,
-                            ),
-                        ),
-                    },
-                ]
-            "#]],
-        );
-    }
-
-    #[test]
-    fn shorten_iterator_chaining_hints() {
-        check_expect(
-            InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
-            r#"
-//- minicore: iterators
-use core::iter;
-
-struct MyIter;
-
-impl Iterator for MyIter {
-    type Item = ();
-    fn next(&mut self) -> Option<Self::Item> {
-        None
-    }
-}
-
-fn main() {
-    let _x = MyIter.by_ref()
-        .take(5)
-        .by_ref()
-        .take(5)
-        .by_ref();
-}
-"#,
-            expect![[r#"
-                [
-                    InlayHint {
-                        range: 174..241,
-                        kind: ChainingHint,
-                        label: [
-                            "impl Iterator<Item = ()>",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                174..241,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 174..224,
-                        kind: ChainingHint,
-                        label: [
-                            "impl Iterator<Item = ()>",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                174..224,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 174..206,
-                        kind: ChainingHint,
-                        label: [
-                            "impl Iterator<Item = ()>",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                174..206,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 174..189,
-                        kind: ChainingHint,
-                        label: [
-                            "&mut MyIter",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                174..189,
-                            ),
-                        ),
-                    },
-                ]
-            "#]],
-        );
-    }
-
-    #[test]
-    fn hints_in_attr_call() {
-        check_expect(
-            TEST_CONFIG,
-            r#"
-//- proc_macros: identity, input_replace
-struct Struct;
-impl Struct {
-    fn chain(self) -> Self {
-        self
-    }
-}
-#[proc_macros::identity]
-fn main() {
-    let strukt = Struct;
-    strukt
-        .chain()
-        .chain()
-        .chain();
-    Struct::chain(strukt);
-}
-"#,
-            expect![[r#"
-                [
-                    InlayHint {
-                        range: 124..130,
-                        kind: TypeHint,
-                        label: [
-                            "Struct",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                124..130,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 145..185,
-                        kind: ChainingHint,
-                        label: [
-                            "Struct",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                145..185,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 145..168,
-                        kind: ChainingHint,
-                        label: [
-                            "Struct",
-                        ],
-                        tooltip: Some(
-                            HoverRanged(
-                                FileId(
-                                    0,
-                                ),
-                                145..168,
-                            ),
-                        ),
-                    },
-                    InlayHint {
-                        range: 222..228,
-                        kind: ParameterHint,
-                        label: [
-                            "self",
-                        ],
-                        tooltip: Some(
-                            HoverOffset(
-                                FileId(
-                                    0,
-                                ),
-                                42,
-                            ),
-                        ),
-                    },
-                ]
-            "#]],
-        );
-    }
-}
diff --git a/crates/ide/src/inlay_hints/closing_brace.rs b/crates/ide/src/inlay_hints/closing_brace.rs
deleted file mode 100644
index 57605b392a..0000000000
--- a/crates/ide/src/inlay_hints/closing_brace.rs
+++ /dev/null
@@ -1,193 +0,0 @@
-//! Implementation of "closing brace" inlay hints:
-//! ```no_run
-//! fn g() {
-//! } /* fn g */
-//! ```
-use hir::{HirDisplay, Semantics};
-use ide_db::{base_db::FileRange, RootDatabase};
-use syntax::{
-    ast::{self, AstNode, HasName},
-    match_ast, SyntaxKind, SyntaxNode, T,
-};
-
-use crate::{
-    inlay_hints::InlayHintLabelPart, FileId, InlayHint, InlayHintLabel, InlayHintsConfig, InlayKind,
-};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    sema: &Semantics<'_, RootDatabase>,
-    config: &InlayHintsConfig,
-    file_id: FileId,
-    node: SyntaxNode,
-) -> Option<()> {
-    let min_lines = config.closing_brace_hints_min_lines?;
-
-    let name = |it: ast::Name| it.syntax().text_range();
-
-    let mut closing_token;
-    let (label, name_range) = if let Some(item_list) = ast::AssocItemList::cast(node.clone()) {
-        closing_token = item_list.r_curly_token()?;
-
-        let parent = item_list.syntax().parent()?;
-        match_ast! {
-            match parent {
-                ast::Impl(imp) => {
-                    let imp = sema.to_def(&imp)?;
-                    let ty = imp.self_ty(sema.db);
-                    let trait_ = imp.trait_(sema.db);
-                    let hint_text = match trait_ {
-                        Some(tr) => format!("impl {} for {}", tr.name(sema.db), ty.display_truncated(sema.db, config.max_length)),
-                        None => format!("impl {}", ty.display_truncated(sema.db, config.max_length)),
-                    };
-                    (hint_text, None)
-                },
-                ast::Trait(tr) => {
-                    (format!("trait {}", tr.name()?), tr.name().map(name))
-                },
-                _ => return None,
-            }
-        }
-    } else if let Some(list) = ast::ItemList::cast(node.clone()) {
-        closing_token = list.r_curly_token()?;
-
-        let module = ast::Module::cast(list.syntax().parent()?)?;
-        (format!("mod {}", module.name()?), module.name().map(name))
-    } else if let Some(block) = ast::BlockExpr::cast(node.clone()) {
-        closing_token = block.stmt_list()?.r_curly_token()?;
-
-        let parent = block.syntax().parent()?;
-        match_ast! {
-            match parent {
-                ast::Fn(it) => {
-                    // FIXME: this could include parameters, but `HirDisplay` prints too much info
-                    // and doesn't respect the max length either, so the hints end up way too long
-                    (format!("fn {}", it.name()?), it.name().map(name))
-                },
-                ast::Static(it) => (format!("static {}", it.name()?), it.name().map(name)),
-                ast::Const(it) => {
-                    if it.underscore_token().is_some() {
-                        ("const _".into(), None)
-                    } else {
-                        (format!("const {}", it.name()?), it.name().map(name))
-                    }
-                },
-                _ => return None,
-            }
-        }
-    } else if let Some(mac) = ast::MacroCall::cast(node.clone()) {
-        let last_token = mac.syntax().last_token()?;
-        if last_token.kind() != T![;] && last_token.kind() != SyntaxKind::R_CURLY {
-            return None;
-        }
-        closing_token = last_token;
-
-        (
-            format!("{}!", mac.path()?),
-            mac.path().and_then(|it| it.segment()).map(|it| it.syntax().text_range()),
-        )
-    } else {
-        return None;
-    };
-
-    if let Some(mut next) = closing_token.next_token() {
-        if next.kind() == T![;] {
-            if let Some(tok) = next.next_token() {
-                closing_token = next;
-                next = tok;
-            }
-        }
-        if !(next.kind() == SyntaxKind::WHITESPACE && next.text().contains('\n')) {
-            // Only display the hint if the `}` is the last token on the line
-            return None;
-        }
-    }
-
-    let mut lines = 1;
-    node.text().for_each_chunk(|s| lines += s.matches('\n').count());
-    if lines < min_lines {
-        return None;
-    }
-
-    let linked_location = name_range.map(|range| FileRange { file_id, range });
-    acc.push(InlayHint {
-        range: closing_token.text_range(),
-        kind: InlayKind::ClosingBraceHint,
-        label: InlayHintLabel { parts: vec![InlayHintLabelPart { text: label, linked_location }] },
-        tooltip: None, // provided by label part location
-    });
-
-    None
-}
-
-#[cfg(test)]
-mod tests {
-    use crate::{
-        inlay_hints::tests::{check_with_config, DISABLED_CONFIG},
-        InlayHintsConfig,
-    };
-
-    #[test]
-    fn hints_closing_brace() {
-        check_with_config(
-            InlayHintsConfig { closing_brace_hints_min_lines: Some(2), ..DISABLED_CONFIG },
-            r#"
-fn a() {}
-
-fn f() {
-} // no hint unless `}` is the last token on the line
-
-fn g() {
-  }
-//^ fn g
-
-fn h<T>(with: T, arguments: u8, ...) {
-  }
-//^ fn h
-
-trait Tr {
-    fn f();
-    fn g() {
-    }
-  //^ fn g
-  }
-//^ trait Tr
-impl Tr for () {
-  }
-//^ impl Tr for ()
-impl dyn Tr {
-  }
-//^ impl dyn Tr
-
-static S0: () = 0;
-static S1: () = {};
-static S2: () = {
- };
-//^ static S2
-const _: () = {
- };
-//^ const _
-
-mod m {
-  }
-//^ mod m
-
-m! {}
-m!();
-m!(
- );
-//^ m!
-
-m! {
-  }
-//^ m!
-
-fn f() {
-    let v = vec![
-    ];
-  }
-//^ fn f
-"#,
-        );
-    }
-}
diff --git a/crates/ide/src/inlay_hints/closure_ret.rs b/crates/ide/src/inlay_hints/closure_ret.rs
deleted file mode 100644
index de04f3ac75..0000000000
--- a/crates/ide/src/inlay_hints/closure_ret.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-//! Implementation of "closure return type" inlay hints.
-use hir::{HirDisplay, Semantics};
-use ide_db::{base_db::FileId, famous_defs::FamousDefs, RootDatabase};
-use syntax::ast::{self, AstNode};
-
-use crate::{
-    inlay_hints::{closure_has_block_body, hint_iterator},
-    ClosureReturnTypeHints, InlayHint, InlayHintsConfig, InlayKind, InlayTooltip,
-};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    sema: &Semantics<'_, RootDatabase>,
-    famous_defs: &FamousDefs<'_, '_>,
-    config: &InlayHintsConfig,
-    file_id: FileId,
-    closure: ast::ClosureExpr,
-) -> Option<()> {
-    if config.closure_return_type_hints == ClosureReturnTypeHints::Never {
-        return None;
-    }
-
-    if closure.ret_type().is_some() {
-        return None;
-    }
-
-    if !closure_has_block_body(&closure)
-        && config.closure_return_type_hints == ClosureReturnTypeHints::WithBlock
-    {
-        return None;
-    }
-
-    let param_list = closure.param_list()?;
-
-    let closure = sema.descend_node_into_attributes(closure.clone()).pop()?;
-    let ty = sema.type_of_expr(&ast::Expr::ClosureExpr(closure))?.adjusted();
-    let callable = ty.as_callable(sema.db)?;
-    let ty = callable.return_type();
-    if ty.is_unit() {
-        return None;
-    }
-    acc.push(InlayHint {
-        range: param_list.syntax().text_range(),
-        kind: InlayKind::ClosureReturnTypeHint,
-        label: hint_iterator(sema, &famous_defs, config, &ty)
-            .unwrap_or_else(|| ty.display_truncated(sema.db, config.max_length).to_string())
-            .into(),
-        tooltip: Some(InlayTooltip::HoverRanged(file_id, param_list.syntax().text_range())),
-    });
-    Some(())
-}
diff --git a/crates/ide/src/inlay_hints/fn_lifetime_fn.rs b/crates/ide/src/inlay_hints/fn_lifetime_fn.rs
deleted file mode 100644
index 1f5bcea63a..0000000000
--- a/crates/ide/src/inlay_hints/fn_lifetime_fn.rs
+++ /dev/null
@@ -1,301 +0,0 @@
-//! Implementation of "lifetime elision" inlay hints:
-//! ```no_run
-//! fn example/* <'0> */(a: &/* '0 */()) {}
-//! ```
-use ide_db::{syntax_helpers::node_ext::walk_ty, FxHashMap};
-use itertools::Itertools;
-use syntax::SmolStr;
-use syntax::{
-    ast::{self, AstNode, HasGenericParams, HasName},
-    SyntaxToken,
-};
-
-use crate::{InlayHint, InlayHintsConfig, InlayKind, InlayTooltip, LifetimeElisionHints};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    config: &InlayHintsConfig,
-    func: ast::Fn,
-) -> Option<()> {
-    if config.lifetime_elision_hints == LifetimeElisionHints::Never {
-        return None;
-    }
-
-    let mk_lt_hint = |t: SyntaxToken, label: String| InlayHint {
-        range: t.text_range(),
-        kind: InlayKind::LifetimeHint,
-        label: label.into(),
-        tooltip: Some(InlayTooltip::String("Elided lifetime".into())),
-    };
-
-    let param_list = func.param_list()?;
-    let generic_param_list = func.generic_param_list();
-    let ret_type = func.ret_type();
-    let self_param = param_list.self_param().filter(|it| it.amp_token().is_some());
-
-    let is_elided = |lt: &Option<ast::Lifetime>| match lt {
-        Some(lt) => matches!(lt.text().as_str(), "'_"),
-        None => true,
-    };
-
-    let potential_lt_refs = {
-        let mut acc: Vec<_> = vec![];
-        if let Some(self_param) = &self_param {
-            let lifetime = self_param.lifetime();
-            let is_elided = is_elided(&lifetime);
-            acc.push((None, self_param.amp_token(), lifetime, is_elided));
-        }
-        param_list.params().filter_map(|it| Some((it.pat(), it.ty()?))).for_each(|(pat, ty)| {
-            // FIXME: check path types
-            walk_ty(&ty, &mut |ty| match ty {
-                ast::Type::RefType(r) => {
-                    let lifetime = r.lifetime();
-                    let is_elided = is_elided(&lifetime);
-                    acc.push((
-                        pat.as_ref().and_then(|it| match it {
-                            ast::Pat::IdentPat(p) => p.name(),
-                            _ => None,
-                        }),
-                        r.amp_token(),
-                        lifetime,
-                        is_elided,
-                    ))
-                }
-                _ => (),
-            })
-        });
-        acc
-    };
-
-    // allocate names
-    let mut gen_idx_name = {
-        let mut gen = (0u8..).map(|idx| match idx {
-            idx if idx < 10 => SmolStr::from_iter(['\'', (idx + 48) as char]),
-            idx => format!("'{idx}").into(),
-        });
-        move || gen.next().unwrap_or_default()
-    };
-    let mut allocated_lifetimes = vec![];
-
-    let mut used_names: FxHashMap<SmolStr, usize> =
-        match config.param_names_for_lifetime_elision_hints {
-            true => generic_param_list
-                .iter()
-                .flat_map(|gpl| gpl.lifetime_params())
-                .filter_map(|param| param.lifetime())
-                .filter_map(|lt| Some((SmolStr::from(lt.text().as_str().get(1..)?), 0)))
-                .collect(),
-            false => Default::default(),
-        };
-    {
-        let mut potential_lt_refs = potential_lt_refs.iter().filter(|&&(.., is_elided)| is_elided);
-        if let Some(_) = &self_param {
-            if let Some(_) = potential_lt_refs.next() {
-                allocated_lifetimes.push(if config.param_names_for_lifetime_elision_hints {
-                    // self can't be used as a lifetime, so no need to check for collisions
-                    "'self".into()
-                } else {
-                    gen_idx_name()
-                });
-            }
-        }
-        potential_lt_refs.for_each(|(name, ..)| {
-            let name = match name {
-                Some(it) if config.param_names_for_lifetime_elision_hints => {
-                    if let Some(c) = used_names.get_mut(it.text().as_str()) {
-                        *c += 1;
-                        SmolStr::from(format!("'{text}{c}", text = it.text().as_str()))
-                    } else {
-                        used_names.insert(it.text().as_str().into(), 0);
-                        SmolStr::from_iter(["\'", it.text().as_str()])
-                    }
-                }
-                _ => gen_idx_name(),
-            };
-            allocated_lifetimes.push(name);
-        });
-    }
-
-    // fetch output lifetime if elision rule applies
-    let output = match potential_lt_refs.as_slice() {
-        [(_, _, lifetime, _), ..] if self_param.is_some() || potential_lt_refs.len() == 1 => {
-            match lifetime {
-                Some(lt) => match lt.text().as_str() {
-                    "'_" => allocated_lifetimes.get(0).cloned(),
-                    "'static" => None,
-                    name => Some(name.into()),
-                },
-                None => allocated_lifetimes.get(0).cloned(),
-            }
-        }
-        [..] => None,
-    };
-
-    if allocated_lifetimes.is_empty() && output.is_none() {
-        return None;
-    }
-
-    // apply hints
-    // apply output if required
-    let mut is_trivial = true;
-    if let (Some(output_lt), Some(r)) = (&output, ret_type) {
-        if let Some(ty) = r.ty() {
-            walk_ty(&ty, &mut |ty| match ty {
-                ast::Type::RefType(ty) if ty.lifetime().is_none() => {
-                    if let Some(amp) = ty.amp_token() {
-                        is_trivial = false;
-                        acc.push(mk_lt_hint(amp, output_lt.to_string()));
-                    }
-                }
-                _ => (),
-            })
-        }
-    }
-
-    if config.lifetime_elision_hints == LifetimeElisionHints::SkipTrivial && is_trivial {
-        return None;
-    }
-
-    let mut a = allocated_lifetimes.iter();
-    for (_, amp_token, _, is_elided) in potential_lt_refs {
-        if is_elided {
-            let t = amp_token?;
-            let lt = a.next()?;
-            acc.push(mk_lt_hint(t, lt.to_string()));
-        }
-    }
-
-    // generate generic param list things
-    match (generic_param_list, allocated_lifetimes.as_slice()) {
-        (_, []) => (),
-        (Some(gpl), allocated_lifetimes) => {
-            let angle_tok = gpl.l_angle_token()?;
-            let is_empty = gpl.generic_params().next().is_none();
-            acc.push(InlayHint {
-                range: angle_tok.text_range(),
-                kind: InlayKind::LifetimeHint,
-                label: format!(
-                    "{}{}",
-                    allocated_lifetimes.iter().format(", "),
-                    if is_empty { "" } else { ", " }
-                )
-                .into(),
-                tooltip: Some(InlayTooltip::String("Elided lifetimes".into())),
-            });
-        }
-        (None, allocated_lifetimes) => acc.push(InlayHint {
-            range: func.name()?.syntax().text_range(),
-            kind: InlayKind::GenericParamListHint,
-            label: format!("<{}>", allocated_lifetimes.iter().format(", "),).into(),
-            tooltip: Some(InlayTooltip::String("Elided lifetimes".into())),
-        }),
-    }
-    Some(())
-}
-
-#[cfg(test)]
-mod tests {
-    use crate::{
-        inlay_hints::tests::{check, check_with_config, TEST_CONFIG},
-        InlayHintsConfig, LifetimeElisionHints,
-    };
-
-    #[test]
-    fn hints_lifetimes() {
-        check(
-            r#"
-fn empty() {}
-
-fn no_gpl(a: &()) {}
- //^^^^^^<'0>
-          // ^'0
-fn empty_gpl<>(a: &()) {}
-      //    ^'0   ^'0
-fn partial<'b>(a: &(), b: &'b ()) {}
-//        ^'0, $  ^'0
-fn partial<'a>(a: &'a (), b: &()) {}
-//        ^'0, $             ^'0
-
-fn single_ret(a: &()) -> &() {}
-// ^^^^^^^^^^<'0>
-              // ^'0     ^'0
-fn full_mul(a: &(), b: &()) {}
-// ^^^^^^^^<'0, '1>
-            // ^'0     ^'1
-
-fn foo<'c>(a: &'c ()) -> &() {}
-                      // ^'c
-
-fn nested_in(a: &   &X< &()>) {}
-// ^^^^^^^^^<'0, '1, '2>
-              //^'0 ^'1 ^'2
-fn nested_out(a: &()) -> &   &X< &()>{}
-// ^^^^^^^^^^<'0>
-               //^'0     ^'0 ^'0 ^'0
-
-impl () {
-    fn foo(&self) {}
-    // ^^^<'0>
-        // ^'0
-    fn foo(&self) -> &() {}
-    // ^^^<'0>
-        // ^'0       ^'0
-    fn foo(&self, a: &()) -> &() {}
-    // ^^^<'0, '1>
-        // ^'0       ^'1     ^'0
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn hints_lifetimes_named() {
-        check_with_config(
-            InlayHintsConfig { param_names_for_lifetime_elision_hints: true, ..TEST_CONFIG },
-            r#"
-fn nested_in<'named>(named: &        &X<      &()>) {}
-//          ^'named1, 'named2, 'named3, $
-                          //^'named1 ^'named2 ^'named3
-"#,
-        );
-    }
-
-    #[test]
-    fn hints_lifetimes_trivial_skip() {
-        check_with_config(
-            InlayHintsConfig {
-                lifetime_elision_hints: LifetimeElisionHints::SkipTrivial,
-                ..TEST_CONFIG
-            },
-            r#"
-fn no_gpl(a: &()) {}
-fn empty_gpl<>(a: &()) {}
-fn partial<'b>(a: &(), b: &'b ()) {}
-fn partial<'a>(a: &'a (), b: &()) {}
-
-fn single_ret(a: &()) -> &() {}
-// ^^^^^^^^^^<'0>
-              // ^'0     ^'0
-fn full_mul(a: &(), b: &()) {}
-
-fn foo<'c>(a: &'c ()) -> &() {}
-                      // ^'c
-
-fn nested_in(a: &   &X< &()>) {}
-fn nested_out(a: &()) -> &   &X< &()>{}
-// ^^^^^^^^^^<'0>
-               //^'0     ^'0 ^'0 ^'0
-
-impl () {
-    fn foo(&self) {}
-    fn foo(&self) -> &() {}
-    // ^^^<'0>
-        // ^'0       ^'0
-    fn foo(&self, a: &()) -> &() {}
-    // ^^^<'0, '1>
-        // ^'0       ^'1     ^'0
-}
-"#,
-        );
-    }
-}
diff --git a/crates/ide/src/inlay_hints/implicit_static.rs b/crates/ide/src/inlay_hints/implicit_static.rs
deleted file mode 100644
index 588a0e3b6a..0000000000
--- a/crates/ide/src/inlay_hints/implicit_static.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-//! Implementation of "implicit static" inlay hints:
-//! ```no_run
-//! static S: &/* 'static */str = "";
-//! ```
-use either::Either;
-use syntax::{
-    ast::{self, AstNode},
-    SyntaxKind,
-};
-
-use crate::{InlayHint, InlayHintsConfig, InlayKind, InlayTooltip, LifetimeElisionHints};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    config: &InlayHintsConfig,
-    statik_or_const: Either<ast::Static, ast::Const>,
-) -> Option<()> {
-    if config.lifetime_elision_hints != LifetimeElisionHints::Always {
-        return None;
-    }
-
-    if let Either::Right(it) = &statik_or_const {
-        if ast::AssocItemList::can_cast(
-            it.syntax().parent().map_or(SyntaxKind::EOF, |it| it.kind()),
-        ) {
-            return None;
-        }
-    }
-
-    if let Some(ast::Type::RefType(ty)) = statik_or_const.either(|it| it.ty(), |it| it.ty()) {
-        if ty.lifetime().is_none() {
-            let t = ty.amp_token()?;
-            acc.push(InlayHint {
-                range: t.text_range(),
-                kind: InlayKind::LifetimeHint,
-                label: "'static".to_owned().into(),
-                tooltip: Some(InlayTooltip::String("Elided static lifetime".into())),
-            });
-        }
-    }
-
-    Some(())
-}
-
-#[cfg(test)]
-mod tests {
-    use crate::{
-        inlay_hints::tests::{check_with_config, TEST_CONFIG},
-        InlayHintsConfig, LifetimeElisionHints,
-    };
-
-    #[test]
-    fn hints_lifetimes_static() {
-        check_with_config(
-            InlayHintsConfig {
-                lifetime_elision_hints: LifetimeElisionHints::Always,
-                ..TEST_CONFIG
-            },
-            r#"
-trait Trait {}
-static S: &str = "";
-//        ^'static
-const C: &str = "";
-//       ^'static
-const C: &dyn Trait = panic!();
-//       ^'static
-
-impl () {
-    const C: &str = "";
-    const C: &dyn Trait = panic!();
-}
-"#,
-        );
-    }
-}
diff --git a/crates/ide/src/inlay_hints/param_name.rs b/crates/ide/src/inlay_hints/param_name.rs
deleted file mode 100644
index ecee67632e..0000000000
--- a/crates/ide/src/inlay_hints/param_name.rs
+++ /dev/null
@@ -1,546 +0,0 @@
-//! Implementation of "param name" inlay hints:
-//! ```no_run
-//! fn max(x: i32, y: i32) -> i32 { x + y }
-//! _ = max(/*x*/4, /*y*/4);
-//! ```
-use either::Either;
-use hir::{Callable, Semantics};
-use ide_db::{base_db::FileRange, RootDatabase};
-
-use stdx::to_lower_snake_case;
-use syntax::ast::{self, AstNode, HasArgList, HasName, UnaryOp};
-
-use crate::{InlayHint, InlayHintsConfig, InlayKind, InlayTooltip};
-
-pub(super) fn hints(
-    acc: &mut Vec<InlayHint>,
-    sema: &Semantics<'_, RootDatabase>,
-    config: &InlayHintsConfig,
-    expr: ast::Expr,
-) -> Option<()> {
-    if !config.parameter_hints {
-        return None;
-    }
-
-    let (callable, arg_list) = get_callable(sema, &expr)?;
-    let hints = callable
-        .params(sema.db)
-        .into_iter()
-        .zip(arg_list.args())
-        .filter_map(|((param, _ty), arg)| {
-            // Only annotate hints for expressions that exist in the original file
-            let range = sema.original_range_opt(arg.syntax())?;
-            let (param_name, name_syntax) = match param.as_ref()? {
-                Either::Left(pat) => ("self".to_string(), pat.name()),
-                Either::Right(pat) => match pat {
-                    ast::Pat::IdentPat(it) => (it.name()?.to_string(), it.name()),
-                    _ => return None,
-                },
-            };
-            Some((name_syntax, param_name, arg, range))
-        })
-        .filter(|(_, param_name, arg, _)| {
-            !should_hide_param_name_hint(sema, &callable, param_name, arg)
-        })
-        .map(|(param, param_name, _, FileRange { range, .. })| {
-            let mut tooltip = None;
-            if let Some(name) = param {
-                if let hir::CallableKind::Function(f) = callable.kind() {
-                    // assert the file is cached so we can map out of macros
-                    if let Some(_) = sema.source(f) {
-                        tooltip = sema.original_range_opt(name.syntax());
-                    }
-                }
-            }
-
-            InlayHint {
-                range,
-                kind: InlayKind::ParameterHint,
-                label: param_name.into(),
-                tooltip: tooltip.map(|it| InlayTooltip::HoverOffset(it.file_id, it.range.start())),
-            }
-        });
-
-    acc.extend(hints);
-    Some(())
-}
-
-fn get_callable(
-    sema: &Semantics<'_, RootDatabase>,
-    expr: &ast::Expr,
-) -> Option<(hir::Callable, ast::ArgList)> {
-    match expr {
-        ast::Expr::CallExpr(expr) => {
-            let descended = sema.descend_node_into_attributes(expr.clone()).pop();
-            let expr = descended.as_ref().unwrap_or(expr);
-            sema.type_of_expr(&expr.expr()?)?.original.as_callable(sema.db).zip(expr.arg_list())
-        }
-        ast::Expr::MethodCallExpr(expr) => {
-            let descended = sema.descend_node_into_attributes(expr.clone()).pop();
-            let expr = descended.as_ref().unwrap_or(expr);
-            sema.resolve_method_call_as_callable(expr).zip(expr.arg_list())
-        }
-        _ => None,
-    }
-}
-
-fn should_hide_param_name_hint(
-    sema: &Semantics<'_, RootDatabase>,
-    callable: &hir::Callable,
-    param_name: &str,
-    argument: &ast::Expr,
-) -> bool {
-    // These are to be tested in the `parameter_hint_heuristics` test
-    // hide when:
-    // - the parameter name is a suffix of the function's name
-    // - the argument is a qualified constructing or call expression where the qualifier is an ADT
-    // - exact argument<->parameter match(ignoring leading underscore) or parameter is a prefix/suffix
-    //   of argument with _ splitting it off
-    // - param starts with `ra_fixture`
-    // - param is a well known name in a unary function
-
-    let param_name = param_name.trim_start_matches('_');
-    if param_name.is_empty() {
-        return true;
-    }
-
-    if matches!(argument, ast::Expr::PrefixExpr(prefix) if prefix.op_kind() == Some(UnaryOp::Not)) {
-        return false;
-    }
-
-    let fn_name = match callable.kind() {
-        hir::CallableKind::Function(it) => Some(it.name(sema.db).to_smol_str()),
-        _ => None,
-    };
-    let fn_name = fn_name.as_deref();
-    is_param_name_suffix_of_fn_name(param_name, callable, fn_name)
-        || is_argument_similar_to_param_name(argument, param_name)
-        || param_name.starts_with("ra_fixture")
-        || (callable.n_params() == 1 && is_obvious_param(param_name))
-        || is_adt_constructor_similar_to_param_name(sema, argument, param_name)
-}
-
-/// Hide the parameter name of a unary function if it is a `_` - prefixed suffix of the function's name, or equal.
-///
-/// `fn strip_suffix(suffix)` will be hidden.
-/// `fn stripsuffix(suffix)` will not be hidden.
-fn is_param_name_suffix_of_fn_name(
-    param_name: &str,
-    callable: &Callable,
-    fn_name: Option<&str>,
-) -> bool {
-    match (callable.n_params(), fn_name) {
-        (1, Some(function)) => {
-            function == param_name
-                || function
-                    .len()
-                    .checked_sub(param_name.len())
-                    .and_then(|at| function.is_char_boundary(at).then(|| function.split_at(at)))
-                    .map_or(false, |(prefix, suffix)| {
-                        suffix.eq_ignore_ascii_case(param_name) && prefix.ends_with('_')
-                    })
-        }
-        _ => false,
-    }
-}
-
-fn is_argument_similar_to_param_name(argument: &ast::Expr, param_name: &str) -> bool {
-    // check whether param_name and argument are the same or
-    // whether param_name is a prefix/suffix of argument(split at `_`)
-    let argument = match get_string_representation(argument) {
-        Some(argument) => argument,
-        None => return false,
-    };
-
-    // std is honestly too panic happy...
-    let str_split_at = |str: &str, at| str.is_char_boundary(at).then(|| argument.split_at(at));
-
-    let param_name = param_name.trim_start_matches('_');
-    let argument = argument.trim_start_matches('_');
-
-    match str_split_at(argument, param_name.len()) {
-        Some((prefix, rest)) if prefix.eq_ignore_ascii_case(param_name) => {
-            return rest.is_empty() || rest.starts_with('_');
-        }
-        _ => (),
-    }
-    match argument.len().checked_sub(param_name.len()).and_then(|at| str_split_at(argument, at)) {
-        Some((rest, suffix)) if param_name.eq_ignore_ascii_case(suffix) => {
-            return rest.is_empty() || rest.ends_with('_');
-        }
-        _ => (),
-    }
-    false
-}
-
-fn get_string_representation(expr: &ast::Expr) -> Option<String> {
-    match expr {
-        ast::Expr::MethodCallExpr(method_call_expr) => {
-            let name_ref = method_call_expr.name_ref()?;
-            match name_ref.text().as_str() {
-                "clone" | "as_ref" => method_call_expr.receiver().map(|rec| rec.to_string()),
-                name_ref => Some(name_ref.to_owned()),
-            }
-        }
-        ast::Expr::MacroExpr(macro_expr) => {
-            Some(macro_expr.macro_call()?.path()?.segment()?.to_string())
-        }
-        ast::Expr::FieldExpr(field_expr) => Some(field_expr.name_ref()?.to_string()),
-        ast::Expr::PathExpr(path_expr) => Some(path_expr.path()?.segment()?.to_string()),
-        ast::Expr::PrefixExpr(prefix_expr) => get_string_representation(&prefix_expr.expr()?),
-        ast::Expr::RefExpr(ref_expr) => get_string_representation(&ref_expr.expr()?),
-        ast::Expr::CastExpr(cast_expr) => get_string_representation(&cast_expr.expr()?),
-        _ => None,
-    }
-}
-
-fn is_obvious_param(param_name: &str) -> bool {
-    // avoid displaying hints for common functions like map, filter, etc.
-    // or other obvious words used in std
-    let is_obvious_param_name =
-        matches!(param_name, "predicate" | "value" | "pat" | "rhs" | "other");
-    param_name.len() == 1 || is_obvious_param_name
-}
-
-fn is_adt_constructor_similar_to_param_name(
-    sema: &Semantics<'_, RootDatabase>,
-    argument: &ast::Expr,
-    param_name: &str,
-) -> bool {
-    let path = match argument {
-        ast::Expr::CallExpr(c) => c.expr().and_then(|e| match e {
-            ast::Expr::PathExpr(p) => p.path(),
-            _ => None,
-        }),
-        ast::Expr::PathExpr(p) => p.path(),
-        ast::Expr::RecordExpr(r) => r.path(),
-        _ => return false,
-    };
-    let path = match path {
-        Some(it) => it,
-        None => return false,
-    };
-    (|| match sema.resolve_path(&path)? {
-        hir::PathResolution::Def(hir::ModuleDef::Adt(_)) => {
-            Some(to_lower_snake_case(&path.segment()?.name_ref()?.text()) == param_name)
-        }
-        hir::PathResolution::Def(hir::ModuleDef::Function(_) | hir::ModuleDef::Variant(_)) => {
-            if to_lower_snake_case(&path.segment()?.name_ref()?.text()) == param_name {
-                return Some(true);
-            }
-            let qual = path.qualifier()?;
-            match sema.resolve_path(&qual)? {
-                hir::PathResolution::Def(hir::ModuleDef::Adt(_)) => {
-                    Some(to_lower_snake_case(&qual.segment()?.name_ref()?.text()) == param_name)
-                }
-                _ => None,
-            }
-        }
-        _ => None,
-    })()
-    .unwrap_or(false)
-}
-
-#[cfg(test)]
-mod tests {
-    use crate::{
-        inlay_hints::tests::{check_with_config, DISABLED_CONFIG},
-        InlayHintsConfig,
-    };
-
-    #[track_caller]
-    fn check_params(ra_fixture: &str) {
-        check_with_config(
-            InlayHintsConfig { parameter_hints: true, ..DISABLED_CONFIG },
-            ra_fixture,
-        );
-    }
-
-    #[test]
-    fn param_hints_only() {
-        check_params(
-            r#"
-fn foo(a: i32, b: i32) -> i32 { a + b }
-fn main() {
-    let _x = foo(
-        4,
-      //^ a
-        4,
-      //^ b
-    );
-}"#,
-        );
-    }
-
-    #[test]
-    fn param_hints_on_closure() {
-        check_params(
-            r#"
-fn main() {
-    let clo = |a: u8, b: u8| a + b;
-    clo(
-        1,
-      //^ a
-        2,
-      //^ b
-    );
-}
-            "#,
-        );
-    }
-
-    #[test]
-    fn param_name_similar_to_fn_name_still_hints() {
-        check_params(
-            r#"
-fn max(x: i32, y: i32) -> i32 { x + y }
-fn main() {
-    let _x = max(
-        4,
-      //^ x
-        4,
-      //^ y
-    );
-}"#,
-        );
-    }
-
-    #[test]
-    fn param_name_similar_to_fn_name() {
-        check_params(
-            r#"
-fn param_with_underscore(with_underscore: i32) -> i32 { with_underscore }
-fn main() {
-    let _x = param_with_underscore(
-        4,
-    );
-}"#,
-        );
-        check_params(
-            r#"
-fn param_with_underscore(underscore: i32) -> i32 { underscore }
-fn main() {
-    let _x = param_with_underscore(
-        4,
-    );
-}"#,
-        );
-    }
-
-    #[test]
-    fn param_name_same_as_fn_name() {
-        check_params(
-            r#"
-fn foo(foo: i32) -> i32 { foo }
-fn main() {
-    let _x = foo(
-        4,
-    );
-}"#,
-        );
-    }
-
-    #[test]
-    fn never_hide_param_when_multiple_params() {
-        check_params(
-            r#"
-fn foo(foo: i32, bar: i32) -> i32 { bar + baz }
-fn main() {
-    let _x = foo(
-        4,
-      //^ foo
-        8,
-      //^ bar
-    );
-}"#,
-        );
-    }
-
-    #[test]
-    fn param_hints_look_through_as_ref_and_clone() {
-        check_params(
-            r#"
-fn foo(bar: i32, baz: f32) {}
-
-fn main() {
-    let bar = 3;
-    let baz = &"baz";
-    let fez = 1.0;
-    foo(bar.clone(), bar.clone());
-                   //^^^^^^^^^^^ baz
-    foo(bar.as_ref(), bar.as_ref());
-                    //^^^^^^^^^^^^ baz
-}
-"#,
-        );
-    }
-
-    #[test]
-    fn self_param_hints() {
-        check_params(
-            r#"
-struct Foo;
-
-impl Foo {
-    fn foo(self: Self) {}
-    fn bar(self: &Self) {}
-}
-
-fn main() {
-    Foo::foo(Foo);
-           //^^^ self
-    Foo::bar(&Foo);
-           //^^^^ self
-}
-"#,
-        )
-    }
-
-    #[test]
-    fn param_name_hints_show_for_literals() {
-        check_params(
-            r#"pub fn test(a: i32, b: i32) -> [i32; 2] { [a, b] }
-fn main() {
-    test(
-        0xa_b,
-      //^^^^^ a
-        0xa_b,
-      //^^^^^ b
-    );
-}"#,
-        )
-    }
-
-    #[test]
-    fn function_call_parameter_hint() {
-        check_params(
-            r#"
-//- minicore: option
-struct FileId {}
-struct SmolStr {}
-
-struct TextRange {}
-struct SyntaxKind {}
-struct NavigationTarget {}
-
-struct Test {}
-
-impl Test {
-    fn method(&self, mut param: i32) -> i32 { param * 2 }
-
-    fn from_syntax(
-        file_id: FileId,
-        name: SmolStr,
-        focus_range: Option<TextRange>,
-        full_range: TextRange,
-        kind: SyntaxKind,
-        docs: Option<String>,
-    ) -> NavigationTarget {
-        NavigationTarget {}
-    }
-}
-
-fn test_func(mut foo: i32, bar: i32, msg: &str, _: i32, last: i32) -> i32 {
-    foo + bar
-}
-
-fn main() {
-    let not_literal = 1;
-    let _: i32 = test_func(1,    2,      "hello", 3,  not_literal);
-                         //^ foo ^ bar   ^^^^^^^ msg  ^^^^^^^^^^^ last
-    let t: Test = Test {};
-    t.method(123);
-           //^^^ param
-    Test::method(&t,      3456);
-               //^^ self  ^^^^ param
-    Test::from_syntax(
-        FileId {},
-        "impl".into(),
-      //^^^^^^^^^^^^^ name
-        None,
-      //^^^^ focus_range
-        TextRange {},
-      //^^^^^^^^^^^^ full_range
-        SyntaxKind {},
-      //^^^^^^^^^^^^^ kind
-        None,
-      //^^^^ docs
-    );
-}"#,
-        );
-    }
-
-    #[test]
-    fn parameter_hint_heuristics() {
-        check_params(
-            r#"
-fn check(ra_fixture_thing: &str) {}
-
-fn map(f: i32) {}
-fn filter(predicate: i32) {}
-
-fn strip_suffix(suffix: &str) {}
-fn stripsuffix(suffix: &str) {}
-fn same(same: u32) {}
-fn same2(_same2: u32) {}
-
-fn enum_matches_param_name(completion_kind: CompletionKind) {}
-
-fn foo(param: u32) {}
-fn bar(param_eter: u32) {}
-
-enum CompletionKind {
-    Keyword,
-}
-
-fn non_ident_pat((a, b): (u32, u32)) {}
-
-fn main() {
-    const PARAM: u32 = 0;
-    foo(PARAM);
-    foo(!PARAM);
-     // ^^^^^^ param
-    check("");
-
-    map(0);
-    filter(0);
-
-    strip_suffix("");
-    stripsuffix("");
-              //^^ suffix
-    same(0);
-    same2(0);
-
-    enum_matches_param_name(CompletionKind::Keyword);
-
-    let param = 0;
-    foo(param);
-    foo(param as _);
-    let param_end = 0;
-    foo(param_end);
-    let start_param = 0;
-    foo(start_param);
-    let param2 = 0;
-    foo(param2);
-      //^^^^^^ param
-
-    macro_rules! param {
-        () => {};
-    };
-    foo(param!());
-
-    let param_eter = 0;
-    bar(param_eter);
-    let param_eter_end = 0;
-    bar(param_eter_end);
-    let start_param_eter = 0;
-    bar(start_param_eter);
-    let param_eter2 = 0;
-    bar(param_eter2);
-      //^^^^^^^^^^^ param_eter
-
-    non_ident_pat((0, 0));
-}"#,
-        );
-    }
-}
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index b6c5c1026e..3f656df25f 100644
--- a/crates/mbe/src/expander/matcher.rs
+++ b/crates/mbe/src/expander/matcher.rs
@@ -698,16 +698,12 @@ fn match_meta_var(kind: MetaVarKind, input: &mut TtIter<'_>) -> ExpandResult<Opt
         MetaVarKind::Item => parser::PrefixEntryPoint::Item,
         MetaVarKind::Vis => parser::PrefixEntryPoint::Vis,
         MetaVarKind::Expr => {
-            // `expr` should not match underscores, let expressions, or inline const. The latter
-            // two are for [backwards compatibility][0].
+            // `expr` should not match underscores.
             // HACK: Macro expansion should not be done using "rollback and try another alternative".
-            // rustc [explicitly checks the next token][1].
-            // [0]: https://github.com/rust-lang/rust/issues/86730
-            // [1]: https://github.com/rust-lang/rust/blob/f0c4da499/compiler/rustc_expand/src/mbe/macro_parser.rs#L576
+            // rustc [explicitly checks the next token][0].
+            // [0]: https://github.com/rust-lang/rust/blob/f0c4da499/compiler/rustc_expand/src/mbe/macro_parser.rs#L576
             match input.peek_n(0) {
-                Some(tt::TokenTree::Leaf(tt::Leaf::Ident(it)))
-                    if it.text == "_" || it.text == "let" || it.text == "const" =>
-                {
+                Some(tt::TokenTree::Leaf(tt::Leaf::Ident(it))) if it.text == "_" => {
                     return ExpandResult::only_err(ExpandError::NoMatchingRule)
                 }
                 _ => {}
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index b621ebc37c..33d645b048 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -237,7 +237,6 @@ impl<'t> Parser<'t> {
 
     fn do_bump(&mut self, kind: SyntaxKind, n_raw_tokens: u8) {
         self.pos += n_raw_tokens as usize;
-        self.steps.set(0);
         self.push_event(Event::Token { kind, n_raw_tokens });
     }
 
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 2850bc2c3d..1604a02fb1 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1788,15 +1788,14 @@ fn run_rustfmt(
     let file_id = from_proto::file_id(snap, &text_document.uri)?;
     let file = snap.analysis.file_text(file_id)?;
 
-    // Determine the edition of the crate the file belongs to (if there's multiple, we pick the
-    // highest edition).
-    let editions = snap
+    // find the edition of the package the file belongs to
+    // (if it belongs to multiple we'll just pick the first one and pray)
+    let edition = snap
         .analysis
         .relevant_crates_for(file_id)?
         .into_iter()
-        .map(|crate_id| snap.analysis.crate_edition(crate_id))
-        .collect::<Result<Vec<_>, _>>()?;
-    let edition = editions.iter().copied().max();
+        .find_map(|crate_id| snap.cargo_target_for_crate_root(crate_id))
+        .map(|(ws, target)| ws[ws[target].package].edition);
 
     let line_index = snap.file_line_index(file_id)?;
 
diff --git a/crates/syntax/src/ast/prec.rs b/crates/syntax/src/ast/prec.rs
index ac7ef45c1d..6253c4dc3e 100644
--- a/crates/syntax/src/ast/prec.rs
+++ b/crates/syntax/src/ast/prec.rs
@@ -1,328 +1,115 @@
 //! Precedence representation.
 
-use crate::{
-    ast::{self, BinaryOp, Expr, HasArgList},
-    match_ast, AstNode, SyntaxNode,
-};
-
-impl Expr {
-    // Implementation is based on
-    // - https://doc.rust-lang.org/reference/expressions.html#expression-precedence
-    // - https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html
-    // - rustc source, including, but not limited to
-    //   - https://github.com/rust-lang/rust/blob/b6852428a8ea9728369b64b9964cad8e258403d3/compiler/rustc_ast/src/util/parser.rs#L296
-
-    /// Returns `true` if `self` would need to be wrapped in parentheses given that its parent is `parent`.
-    pub fn needs_parens_in(&self, parent: SyntaxNode) -> bool {
-        match_ast! {
-            match parent {
-                ast::Expr(e) => self.needs_parens_in_expr(&e),
-                ast::Stmt(e) => self.needs_parens_in_stmt(Some(&e)),
-                ast::StmtList(_) => self.needs_parens_in_stmt(None),
-                ast::ArgList(_) => false,
-                ast::MatchArm(_) => false,
-                _ => false,
-            }
-        }
-    }
-
-    fn needs_parens_in_expr(&self, parent: &Expr) -> bool {
-        // Special-case block weirdness
-        if parent.child_is_followed_by_a_block() {
-            use Expr::*;
-            match self {
-                // Cases like `if return {}` (need parens or else `{}` is returned, instead of being `if`'s body)
-                ReturnExpr(e) if e.expr().is_none() => return true,
-                BreakExpr(e) if e.expr().is_none() => return true,
-                YieldExpr(e) if e.expr().is_none() => return true,
-
-                // Same but with `..{}`
-                RangeExpr(e) if matches!(e.end(), Some(BlockExpr(..))) => return true,
-
-                // Similarly with struct literals, e.g. `if S{} == 1 {}`
-                _ if self.contains_exterior_struct_lit() => return true,
-                _ => {}
-            }
-        }
-
-        // Special-case `return.f()`
-        if self.is_ret_like_with_no_value() && parent.is_postfix() {
-            return false;
-        }
-
-        if self.is_paren_like()
-            || parent.is_paren_like()
-            || self.is_prefix() && (parent.is_prefix() || !self.is_ordered_before(parent))
-            || self.is_postfix() && (parent.is_postfix() || self.is_ordered_before(parent))
-        {
-            return false;
-        }
-
-        let (left, right, inv) = match self.is_ordered_before(parent) {
-            true => (self, parent, false),
-            false => (parent, self, true),
-        };
-
-        let (_, left_right_bp) = left.binding_power();
-        let (right_left_bp, _) = right.binding_power();
+use crate::ast::{self, BinExpr, Expr};
+
+/// Precedence of an expression.
+#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
+pub enum ExprPrecedence {
+    // N.B.: Order is important
+    Closure,
+    Jump,
+    Range,
+    Bin(BinOpPresedence),
+    Prefix,
+    Postfix,
+    Paren,
+}
 
-        (left_right_bp < right_left_bp) ^ inv
-    }
+/// Precedence of a binary operator.
+#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
+pub enum BinOpPresedence {
+    // N.B.: Order is important
+    /// `=`, `+=`, `-=`, `*=`, `/=`, `%=`, `|=`, `&=`
+    Assign,
+    /// `||`
+    LOr,
+    /// `&&`
+    LAnd,
+    /// `<`, `<=`, `>`, `>=`, `==` and `!=`
+    Cmp,
+    /// `|`
+    BitOr,
+    /// `^`
+    BitXor,
+    /// `&`
+    BitAnd,
+    /// `<<` and `>>`
+    Shift,
+    /// `+` and `-`
+    Add,
+    /// `*`, `/` and `%`
+    Mul,
+    /// `as`
+    As,
+}
 
-    fn needs_parens_in_stmt(&self, stmt: Option<&ast::Stmt>) -> bool {
+impl Expr {
+    /// Returns precedence of this expression.
+    /// Usefull to preserve semantics in assists.
+    ///
+    /// Returns `None` if this is a [`BinExpr`] and its [`op_kind`] returns `None`.
+    ///
+    /// [`op_kind`]: BinExpr::op_kind
+    /// [`BinExpr`]: Expr::BinExpr
+    pub fn precedence(&self) -> Option<ExprPrecedence> {
+        // Copied from <https://github.com/rust-lang/rust/blob/b6852428a8ea9728369b64b9964cad8e258403d3/compiler/rustc_ast/src/util/parser.rs#L296>
         use Expr::*;
 
-        // Prevent false-positives in cases like `fn x() -> u8 { ({ 0 } + 1) }`,
-        // `{ { 0 } + 1 }` won't parse -- `{ 0 }` would be parsed as a self-contained stmt,
-        // leaving `+ 1` as a parse error.
-        let mut innermost = self.clone();
-        loop {
-            let next = match &innermost {
-                BinExpr(e) => e.lhs(),
-                CallExpr(e) => e.expr(),
-                CastExpr(e) => e.expr(),
-                IndexExpr(e) => e.base(),
-                _ => break,
-            };
+        let prec = match self {
+            ClosureExpr(_) => ExprPrecedence::Closure,
 
-            if let Some(next) = next {
-                innermost = next;
-                if !innermost.requires_semi_to_be_stmt() {
-                    return true;
-                }
-            } else {
-                break;
-            }
-        }
+            ContinueExpr(_) | ReturnExpr(_) | YieldExpr(_) | BreakExpr(_) => ExprPrecedence::Jump,
 
-        // Not every expression can be followed by `else` in the `let-else`
-        if let Some(ast::Stmt::LetStmt(e)) = stmt {
-            if e.let_else().is_some() {
-                match self {
-                    BinExpr(e)
-                        if e.op_kind()
-                            .map(|op| matches!(op, BinaryOp::LogicOp(_)))
-                            .unwrap_or(false) =>
-                    {
-                        return true
-                    }
-                    _ if self.clone().trailing_brace().is_some() => return true,
-                    _ => {}
-                }
-            }
-        }
+            RangeExpr(_) => ExprPrecedence::Range,
 
-        false
-    }
-
-    /// Returns left and right so-called "binding powers" of this expression.
-    fn binding_power(&self) -> (u8, u8) {
-        use ast::{ArithOp::*, BinaryOp::*, Expr::*, LogicOp::*};
-
-        let dps = match self {
-            // (0, 0)   -- paren-like/nullary
-            // (0, N)   -- prefix
-            // (N, 0)   -- postfix
-            // (N, N)   -- infix, requires parens
-            // (N, N+1) -- infix, left to right associative
-            // (N+1, N) -- infix, right to left associative
-            // N is odd
-            //
-            ContinueExpr(_) => (0, 0),
-
-            ClosureExpr(_) | ReturnExpr(_) | YieldExpr(_) | BreakExpr(_) => (0, 1),
-
-            RangeExpr(_) => (5, 5),
-
-            BinExpr(e) => {
-                // Return a dummy value if we don't know the op
-                let Some(op) = e.op_kind() else { return (0, 0) };
-                match op {
-                    Assignment { .. } => (4, 3),
-                    //
-                    // Ranges are here in order :)
-                    //
-                    LogicOp(op) => match op {
-                        Or => (7, 8),
-                        And => (9, 10),
-                    },
-                    CmpOp(_) => (11, 11),
-                    ArithOp(op) => match op {
-                        BitOr => (13, 14),
-                        BitXor => (15, 16),
-                        BitAnd => (17, 18),
-                        Shl | Shr => (19, 20),
-                        Add | Sub => (21, 22),
-                        Mul | Div | Rem => (23, 24),
-                    },
-                }
-            }
-
-            CastExpr(_) => (25, 26),
-
-            BoxExpr(_) | RefExpr(_) | LetExpr(_) | PrefixExpr(_) => (0, 27),
+            BinExpr(bin_expr) => return bin_expr.precedence().map(ExprPrecedence::Bin),
+            CastExpr(_) => ExprPrecedence::Bin(BinOpPresedence::As),
 
-            AwaitExpr(_) | CallExpr(_) | MethodCallExpr(_) | IndexExpr(_) | TryExpr(_)
-            | MacroExpr(_) => (29, 0),
+            BoxExpr(_) | RefExpr(_) | LetExpr(_) | PrefixExpr(_) => ExprPrecedence::Prefix,
 
-            FieldExpr(_) => (31, 32),
+            AwaitExpr(_) | CallExpr(_) | MethodCallExpr(_) | FieldExpr(_) | IndexExpr(_)
+            | TryExpr(_) | MacroExpr(_) => ExprPrecedence::Postfix,
 
             ArrayExpr(_) | TupleExpr(_) | Literal(_) | PathExpr(_) | ParenExpr(_) | IfExpr(_)
             | WhileExpr(_) | ForExpr(_) | LoopExpr(_) | MatchExpr(_) | BlockExpr(_)
-            | RecordExpr(_) | UnderscoreExpr(_) => (0, 0),
+            | RecordExpr(_) | UnderscoreExpr(_) => ExprPrecedence::Paren,
         };
 
-        dps
-    }
-
-    fn is_paren_like(&self) -> bool {
-        matches!(self.binding_power(), (0, 0))
-    }
-
-    fn is_prefix(&self) -> bool {
-        matches!(self.binding_power(), (0, 1..))
-    }
-
-    fn is_postfix(&self) -> bool {
-        matches!(self.binding_power(), (1.., 0))
-    }
-
-    /// Returns `true` if this expression can't be a standalone statement.
-    fn requires_semi_to_be_stmt(&self) -> bool {
-        use Expr::*;
-        !matches!(
-            self,
-            IfExpr(..) | MatchExpr(..) | BlockExpr(..) | WhileExpr(..) | LoopExpr(..) | ForExpr(..)
-        )
-    }
-
-    /// If an expression ends with `}`, returns the innermost expression ending in this `}`.
-    fn trailing_brace(mut self) -> Option<Expr> {
-        use Expr::*;
-
-        loop {
-            let rhs = match self {
-                RefExpr(e) => e.expr(),
-                BinExpr(e) => e.rhs(),
-                BoxExpr(e) => e.expr(),
-                BreakExpr(e) => e.expr(),
-                LetExpr(e) => e.expr(),
-                RangeExpr(e) => e.end(),
-                ReturnExpr(e) => e.expr(),
-                PrefixExpr(e) => e.expr(),
-                YieldExpr(e) => e.expr(),
-                ClosureExpr(e) => e.body(),
-
-                BlockExpr(..) | ForExpr(..) | IfExpr(..) | LoopExpr(..) | MatchExpr(..)
-                | RecordExpr(..) | WhileExpr(..) => break Some(self),
-                _ => break None,
-            };
-
-            self = rhs?;
-        }
+        Some(prec)
     }
+}
 
-    /// Expressions that syntactically contain an "exterior" struct literal i.e., not surrounded by any
-    /// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and
-    /// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.
-    fn contains_exterior_struct_lit(&self) -> bool {
-        return contains_exterior_struct_lit_inner(self).is_some();
-
-        fn contains_exterior_struct_lit_inner(expr: &Expr) -> Option<()> {
-            use Expr::*;
-
-            match expr {
-                RecordExpr(..) => Some(()),
-
-                // X { y: 1 } + X { y: 2 }
-                BinExpr(e) => e
-                    .lhs()
-                    .as_ref()
-                    .and_then(contains_exterior_struct_lit_inner)
-                    .or_else(|| e.rhs().as_ref().and_then(contains_exterior_struct_lit_inner)),
-
-                // `&X { y: 1 }`, `X { y: 1 }.y`, `X { y: 1 }.bar(...)`, etc
-                IndexExpr(e) => contains_exterior_struct_lit_inner(&e.base()?),
-                AwaitExpr(e) => contains_exterior_struct_lit_inner(&e.expr()?),
-                PrefixExpr(e) => contains_exterior_struct_lit_inner(&e.expr()?),
-                CastExpr(e) => contains_exterior_struct_lit_inner(&e.expr()?),
-                FieldExpr(e) => contains_exterior_struct_lit_inner(&e.expr()?),
-                MethodCallExpr(e) => contains_exterior_struct_lit_inner(&e.receiver()?),
-
-                _ => None,
-            }
-        }
-    }
-
-    /// Returns true if self is one of `return`, `break`, `continue` or `yield` with **no associated value**.
-    fn is_ret_like_with_no_value(&self) -> bool {
-        use Expr::*;
-
-        match self {
-            ReturnExpr(e) => e.expr().is_none(),
-            BreakExpr(e) => e.expr().is_none(),
-            ContinueExpr(_) => true,
-            YieldExpr(e) => e.expr().is_none(),
-            _ => false,
-        }
-    }
-
-    fn is_ordered_before(&self, other: &Expr) -> bool {
-        use Expr::*;
-
-        return order(self) < order(other);
-
-        /// Returns text range that can be used to compare two expression for order (which goes first).
-        fn order(this: &Expr) -> rowan::TextSize {
-            // For non-paren-like operators: get the operator itself
-            let token = match this {
-                RangeExpr(e) => e.op_token(),
-                BinExpr(e) => e.op_token(),
-                CastExpr(e) => e.as_token(),
-                FieldExpr(e) => e.dot_token(),
-                AwaitExpr(e) => e.dot_token(),
-                BoxExpr(e) => e.box_token(),
-                BreakExpr(e) => e.break_token(),
-                CallExpr(e) => e.arg_list().and_then(|args| args.l_paren_token()),
-                ClosureExpr(e) => e.param_list().and_then(|params| params.l_paren_token()),
-                ContinueExpr(e) => e.continue_token(),
-                IndexExpr(e) => e.l_brack_token(),
-                MethodCallExpr(e) => e.dot_token(),
-                PrefixExpr(e) => e.op_token(),
-                RefExpr(e) => e.amp_token(),
-                ReturnExpr(e) => e.return_token(),
-                TryExpr(e) => e.question_mark_token(),
-                YieldExpr(e) => e.yield_token(),
-                LetExpr(e) => e.let_token(),
-
-                ArrayExpr(_) | TupleExpr(_) | Literal(_) | PathExpr(_) | ParenExpr(_)
-                | IfExpr(_) | WhileExpr(_) | ForExpr(_) | LoopExpr(_) | MatchExpr(_)
-                | BlockExpr(_) | RecordExpr(_) | UnderscoreExpr(_) | MacroExpr(_) => None,
-            };
-
-            token.map(|t| t.text_range()).unwrap_or_else(|| this.syntax().text_range()).start()
-        }
-    }
-
-    fn child_is_followed_by_a_block(&self) -> bool {
-        use Expr::*;
-
-        match self {
-            ArrayExpr(_) | AwaitExpr(_) | BlockExpr(_) | CallExpr(_) | CastExpr(_)
-            | ClosureExpr(_) | FieldExpr(_) | IndexExpr(_) | Literal(_) | LoopExpr(_)
-            | MacroExpr(_) | MethodCallExpr(_) | ParenExpr(_) | PathExpr(_) | RecordExpr(_)
-            | TryExpr(_) | TupleExpr(_) | UnderscoreExpr(_) => false,
-
-            // For BinExpr and RangeExpr this is technically wrong -- the child can be on the left...
-            BinExpr(_) | RangeExpr(_) | BoxExpr(_) | BreakExpr(_) | ContinueExpr(_)
-            | PrefixExpr(_) | RefExpr(_) | ReturnExpr(_) | YieldExpr(_) | LetExpr(_) => self
-                .syntax()
-                .parent()
-                .and_then(Expr::cast)
-                .map(|e| e.child_is_followed_by_a_block())
-                .unwrap_or(false),
+impl BinExpr {
+    /// Returns precedence of this binary expression.
+    /// Usefull to preserve semantics in assists.
+    ///
+    /// Returns `None` if [`op_kind`] returns `None`.
+    ///
+    /// [`op_kind`]: BinExpr::op_kind
+    pub fn precedence(&self) -> Option<BinOpPresedence> {
+        use ast::{ArithOp::*, BinaryOp::*, LogicOp::*};
+
+        let prec = match self.op_kind()? {
+            LogicOp(op) => match op {
+                And => BinOpPresedence::LAnd,
+                Or => BinOpPresedence::LOr,
+            },
+            ArithOp(op) => match op {
+                Add => BinOpPresedence::Add,
+                Mul => BinOpPresedence::Mul,
+                Sub => BinOpPresedence::Add,
+                Div => BinOpPresedence::Mul,
+                Rem => BinOpPresedence::Mul,
+                Shl => BinOpPresedence::Shift,
+                Shr => BinOpPresedence::Shift,
+                BitXor => BinOpPresedence::BitXor,
+                BitOr => BinOpPresedence::BitOr,
+                BitAnd => BinOpPresedence::BitAnd,
+            },
+            CmpOp(_) => BinOpPresedence::Cmp,
+            Assignment { .. } => BinOpPresedence::Assign,
+        };
 
-            ForExpr(_) | IfExpr(_) | MatchExpr(_) | WhileExpr(_) => true,
-        }
+        Some(prec)
     }
 }
diff --git a/docs/dev/README.md b/docs/dev/README.md
index cdab6b0992..4ac75b4bbf 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -200,7 +200,7 @@ Look for `fn benchmark_xxx` tests for a quick way to reproduce performance probl
 
 ## Release Process
 
-Release process is handled by `release`, `dist`, `publish-release-notes` and `promote` xtasks, `release` being the main one.
+Release process is handled by `release`, `dist` and `promote` xtasks, `release` being the main one.
 
 `release` assumes that you have checkouts of `rust-analyzer`, `rust-analyzer.github.io`, and `rust-lang/rust` in the same directory:
 
@@ -231,9 +231,8 @@ Release steps:
    * create a new changelog in `rust-analyzer.github.io`
 3. While the release is in progress, fill in the changelog
 4. Commit & push the changelog
-5. Run `cargo xtask publish-release-notes <CHANGELOG>` -- this will convert the changelog entry in AsciiDoc to Markdown and update the body of GitHub Releases entry.
-6. Tweet
-7. Inside `rust-analyzer`, run `cargo xtask promote` -- this will create a PR to rust-lang/rust updating rust-analyzer's subtree.
+5. Tweet
+6. Inside `rust-analyzer`, run `cargo xtask promote` -- this will create a PR to rust-lang/rust updating rust-analyzer's subtree.
    Self-approve the PR.
 
 If the GitHub Actions release fails because of a transient problem like a timeout, you can re-run the job from the Actions console.
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs
index 2100479701..0fce488983 100644
--- a/xtask/src/flags.rs
+++ b/xtask/src/flags.rs
@@ -34,13 +34,6 @@ xflags::xflags! {
         cmd dist {
             optional --client-patch-version version: String
         }
-        /// Read a changelog AsciiDoc file and update the GitHub Releases entry in Markdown.
-        cmd publish-release-notes {
-            /// Only run conversion and show the result.
-            optional --dry-run
-            /// Target changelog file.
-            required changelog: String
-        }
         cmd metrics {
             optional --dry-run
         }
@@ -66,7 +59,6 @@ pub enum XtaskCmd {
     Release(Release),
     Promote(Promote),
     Dist(Dist),
-    PublishReleaseNotes(PublishReleaseNotes),
     Metrics(Metrics),
     Bb(Bb),
 }
@@ -98,13 +90,6 @@ pub struct Dist {
     pub client_patch_version: Option<String>,
 }
 
-#[derive(Debug)]
-pub struct PublishReleaseNotes {
-    pub changelog: String,
-
-    pub dry_run: bool,
-}
-
 #[derive(Debug)]
 pub struct Metrics {
     pub dry_run: bool,
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 6a45033ada..a37f469adc 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -15,7 +15,6 @@ mod flags;
 mod install;
 mod release;
 mod dist;
-mod publish;
 mod metrics;
 
 use anyhow::bail;
@@ -37,7 +36,6 @@ fn main() -> anyhow::Result<()> {
         flags::XtaskCmd::Release(cmd) => cmd.run(sh),
         flags::XtaskCmd::Promote(cmd) => cmd.run(sh),
         flags::XtaskCmd::Dist(cmd) => cmd.run(sh),
-        flags::XtaskCmd::PublishReleaseNotes(cmd) => cmd.run(sh),
         flags::XtaskCmd::Metrics(cmd) => cmd.run(sh),
         flags::XtaskCmd::Bb(cmd) => {
             {
diff --git a/xtask/src/publish.rs b/xtask/src/publish.rs
deleted file mode 100644
index 79b5f3d2f6..0000000000
--- a/xtask/src/publish.rs
+++ /dev/null
@@ -1,109 +0,0 @@
-mod notes;
-
-use crate::flags;
-use anyhow::{anyhow, bail, Result};
-use std::env;
-use xshell::{cmd, Shell};
-
-impl flags::PublishReleaseNotes {
-    pub(crate) fn run(self, sh: &Shell) -> Result<()> {
-        let asciidoc = sh.read_file(&self.changelog)?;
-        let mut markdown = notes::convert_asciidoc_to_markdown(std::io::Cursor::new(&asciidoc))?;
-        let file_name = check_file_name(self.changelog)?;
-        let tag_name = &file_name[0..10];
-        let original_changelog_url = create_original_changelog_url(&file_name);
-        let additional_paragraph =
-            format!("\nSee also [original changelog]({original_changelog_url}).");
-        markdown.push_str(&additional_paragraph);
-        if self.dry_run {
-            println!("{markdown}");
-        } else {
-            update_release(sh, tag_name, &markdown)?;
-        }
-        Ok(())
-    }
-}
-
-fn check_file_name<P: AsRef<std::path::Path>>(path: P) -> Result<String> {
-    let file_name = path
-        .as_ref()
-        .file_name()
-        .ok_or_else(|| anyhow!("file name is not specified as `changelog`"))?
-        .to_string_lossy();
-
-    let mut chars = file_name.chars();
-    if file_name.len() >= 10
-        && chars.next().unwrap().is_ascii_digit()
-        && chars.next().unwrap().is_ascii_digit()
-        && chars.next().unwrap().is_ascii_digit()
-        && chars.next().unwrap().is_ascii_digit()
-        && chars.next().unwrap() == '-'
-        && chars.next().unwrap().is_ascii_digit()
-        && chars.next().unwrap().is_ascii_digit()
-        && chars.next().unwrap() == '-'
-        && chars.next().unwrap().is_ascii_digit()
-        && chars.next().unwrap().is_ascii_digit()
-    {
-        Ok(file_name.to_string())
-    } else {
-        bail!("unexpected file name format; no date information prefixed")
-    }
-}
-
-fn create_original_changelog_url(file_name: &str) -> String {
-    let year = &file_name[0..4];
-    let month = &file_name[5..7];
-    let day = &file_name[8..10];
-    let mut stem = &file_name[11..];
-    if let Some(stripped) = stem.strip_suffix(".adoc") {
-        stem = stripped;
-    }
-    format!("https://rust-analyzer.github.io/thisweek/{year}/{month}/{day}/{stem}.html")
-}
-
-fn update_release(sh: &Shell, tag_name: &str, release_notes: &str) -> Result<()> {
-    let token = match env::var("GITHUB_TOKEN") {
-        Ok(token) => token,
-        Err(_) => bail!("Please obtain a personal access token from https://github.com/settings/tokens and set the `GITHUB_TOKEN` environment variable."),
-    };
-    let accept = "Accept: application/vnd.github+json";
-    let authorization = format!("Authorization: Bearer {token}");
-    let api_version = "X-GitHub-Api-Version: 2022-11-28";
-    let release_url = "https://api.github.com/repos/rust-lang/rust-analyzer/releases";
-
-    let release_json = cmd!(
-        sh,
-        "curl -sf -H {accept} -H {authorization} -H {api_version} {release_url}/tags/{tag_name}"
-    )
-    .read()?;
-    let release_id = cmd!(sh, "jq .id").stdin(release_json).read()?;
-
-    let mut patch = String::new();
-    write_json::object(&mut patch)
-        .string("tag_name", tag_name)
-        .string("target_commitish", "master")
-        .string("name", tag_name)
-        .string("body", release_notes)
-        .bool("draft", false)
-        .bool("prerelease", false);
-    let _ = cmd!(
-        sh,
-        "curl -sf -X PATCH -H {accept} -H {authorization} -H {api_version} {release_url}/{release_id} -d {patch}"
-    )
-    .read()?;
-
-    Ok(())
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    #[test]
-    fn original_changelog_url_creation() {
-        let input = "2019-07-24-changelog-0.adoc";
-        let actual = create_original_changelog_url(input);
-        let expected = "https://rust-analyzer.github.io/thisweek/2019/07/24/changelog-0.html";
-        assert_eq!(actual, expected);
-    }
-}
diff --git a/xtask/src/publish/notes.rs b/xtask/src/publish/notes.rs
deleted file mode 100644
index c30267295b..0000000000
--- a/xtask/src/publish/notes.rs
+++ /dev/null
@@ -1,631 +0,0 @@
-use anyhow::{anyhow, bail};
-use std::{
-    borrow::Cow,
-    io::{BufRead, Lines},
-    iter::Peekable,
-};
-
-const LISTING_DELIMITER: &str = "----";
-const IMAGE_BLOCK_PREFIX: &str = "image::";
-const VIDEO_BLOCK_PREFIX: &str = "video::";
-
-struct Converter<'a, 'b, R: BufRead> {
-    iter: &'a mut Peekable<Lines<R>>,
-    output: &'b mut String,
-}
-
-impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
-    fn new(iter: &'a mut Peekable<Lines<R>>, output: &'b mut String) -> Self {
-        Self { iter, output }
-    }
-
-    fn process(&mut self) -> anyhow::Result<()> {
-        self.process_document_header()?;
-        self.skip_blank_lines()?;
-        self.output.push('\n');
-
-        loop {
-            let line = self.iter.peek().unwrap().as_deref().map_err(|e| anyhow!("{e}"))?;
-            if get_title(line).is_some() {
-                let line = self.iter.next().unwrap().unwrap();
-                let (level, title) = get_title(&line).unwrap();
-                self.write_title(level, title);
-            } else if get_list_item(line).is_some() {
-                self.process_list()?;
-            } else if line.starts_with('[') {
-                self.process_source_code_block(0)?;
-            } else if line.starts_with(LISTING_DELIMITER) {
-                self.process_listing_block(None, 0)?;
-            } else if line.starts_with('.') {
-                self.process_block_with_title(0)?;
-            } else if line.starts_with(IMAGE_BLOCK_PREFIX) {
-                self.process_image_block(None, 0)?;
-            } else if line.starts_with(VIDEO_BLOCK_PREFIX) {
-                self.process_video_block(None, 0)?;
-            } else {
-                self.process_paragraph(0, |line| line.is_empty())?;
-            }
-
-            self.skip_blank_lines()?;
-            if self.iter.peek().is_none() {
-                break;
-            }
-            self.output.push('\n');
-        }
-        Ok(())
-    }
-
-    fn process_document_header(&mut self) -> anyhow::Result<()> {
-        self.process_document_title()?;
-
-        while let Some(line) = self.iter.next() {
-            let line = line?;
-            if line.is_empty() {
-                break;
-            }
-            if !line.starts_with(':') {
-                self.write_line(&line, 0)
-            }
-        }
-
-        Ok(())
-    }
-
-    fn process_document_title(&mut self) -> anyhow::Result<()> {
-        if let Some(Ok(line)) = self.iter.next() {
-            if let Some((level, title)) = get_title(&line) {
-                let title = process_inline_macros(title)?;
-                if level == 1 {
-                    self.write_title(level, &title);
-                    return Ok(());
-                }
-            }
-        }
-        bail!("document title not found")
-    }
-
-    fn process_list(&mut self) -> anyhow::Result<()> {
-        let mut nesting = ListNesting::new();
-        while let Some(line) = self.iter.peek() {
-            let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
-
-            if get_list_item(line).is_some() {
-                let line = self.iter.next().unwrap()?;
-                let line = process_inline_macros(&line)?;
-                let (marker, item) = get_list_item(&line).unwrap();
-                nesting.set_current(marker);
-                self.write_list_item(item, &nesting);
-                self.process_paragraph(nesting.indent(), |line| {
-                    line.is_empty() || get_list_item(line).is_some() || line == "+"
-                })?;
-            } else if line == "+" {
-                let _ = self.iter.next().unwrap()?;
-                let line = self
-                    .iter
-                    .peek()
-                    .ok_or_else(|| anyhow!("list continuation unexpectedly terminated"))?;
-                let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
-
-                let indent = nesting.indent();
-                if line.starts_with('[') {
-                    self.write_line("", 0);
-                    self.process_source_code_block(indent)?;
-                } else if line.starts_with(LISTING_DELIMITER) {
-                    self.write_line("", 0);
-                    self.process_listing_block(None, indent)?;
-                } else if line.starts_with('.') {
-                    self.write_line("", 0);
-                    self.process_block_with_title(indent)?;
-                } else if line.starts_with(IMAGE_BLOCK_PREFIX) {
-                    self.write_line("", 0);
-                    self.process_image_block(None, indent)?;
-                } else if line.starts_with(VIDEO_BLOCK_PREFIX) {
-                    self.write_line("", 0);
-                    self.process_video_block(None, indent)?;
-                } else {
-                    self.write_line("", 0);
-                    let current = nesting.current().unwrap();
-                    self.process_paragraph(indent, |line| {
-                        line.is_empty()
-                            || get_list_item(line).filter(|(m, _)| m == current).is_some()
-                            || line == "+"
-                    })?;
-                }
-            } else {
-                break;
-            }
-            self.skip_blank_lines()?;
-        }
-
-        Ok(())
-    }
-
-    fn process_source_code_block(&mut self, level: usize) -> anyhow::Result<()> {
-        if let Some(Ok(line)) = self.iter.next() {
-            if let Some(styles) = line.strip_prefix("[source").and_then(|s| s.strip_suffix(']')) {
-                let mut styles = styles.split(',');
-                if !styles.next().unwrap().is_empty() {
-                    bail!("not a source code block");
-                }
-                let language = styles.next();
-                return self.process_listing_block(language, level);
-            }
-        }
-        bail!("not a source code block")
-    }
-
-    fn process_listing_block(&mut self, style: Option<&str>, level: usize) -> anyhow::Result<()> {
-        if let Some(Ok(line)) = self.iter.next() {
-            if line == LISTING_DELIMITER {
-                self.write_indent(level);
-                self.output.push_str("```");
-                if let Some(style) = style {
-                    self.output.push_str(style);
-                }
-                self.output.push('\n');
-                while let Some(line) = self.iter.next() {
-                    let line = line?;
-                    if line == LISTING_DELIMITER {
-                        self.write_line("```", level);
-                        return Ok(());
-                    } else {
-                        self.write_line(&line, level);
-                    }
-                }
-                bail!("listing block is not terminated")
-            }
-        }
-        bail!("not a listing block")
-    }
-
-    fn process_block_with_title(&mut self, level: usize) -> anyhow::Result<()> {
-        if let Some(Ok(line)) = self.iter.next() {
-            let title =
-                line.strip_prefix('.').ok_or_else(|| anyhow!("extraction of the title failed"))?;
-
-            let line = self
-                .iter
-                .peek()
-                .ok_or_else(|| anyhow!("target block for the title is not found"))?;
-            let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
-            if line.starts_with(IMAGE_BLOCK_PREFIX) {
-                return self.process_image_block(Some(title), level);
-            } else if line.starts_with(VIDEO_BLOCK_PREFIX) {
-                return self.process_video_block(Some(title), level);
-            } else {
-                bail!("title for that block type is not supported");
-            }
-        }
-        bail!("not a title")
-    }
-
-    fn process_image_block(&mut self, caption: Option<&str>, level: usize) -> anyhow::Result<()> {
-        if let Some(Ok(line)) = self.iter.next() {
-            if let Some((url, attrs)) = parse_media_block(&line, IMAGE_BLOCK_PREFIX) {
-                let alt = if let Some(stripped) =
-                    attrs.strip_prefix('"').and_then(|s| s.strip_suffix('"'))
-                {
-                    stripped
-                } else {
-                    attrs
-                };
-                if let Some(caption) = caption {
-                    self.write_caption_line(caption, level);
-                }
-                self.write_indent(level);
-                self.output.push_str("![");
-                self.output.push_str(alt);
-                self.output.push_str("](");
-                self.output.push_str(url);
-                self.output.push_str(")\n");
-                return Ok(());
-            }
-        }
-        bail!("not a image block")
-    }
-
-    fn process_video_block(&mut self, caption: Option<&str>, level: usize) -> anyhow::Result<()> {
-        if let Some(Ok(line)) = self.iter.next() {
-            if let Some((url, attrs)) = parse_media_block(&line, VIDEO_BLOCK_PREFIX) {
-                let html_attrs = match attrs {
-                    "options=loop" => "controls loop",
-                    r#"options="autoplay,loop""# => "autoplay controls loop",
-                    _ => bail!("unsupported video syntax"),
-                };
-                if let Some(caption) = caption {
-                    self.write_caption_line(caption, level);
-                }
-                self.write_indent(level);
-                self.output.push_str(r#"<video src=""#);
-                self.output.push_str(url);
-                self.output.push_str(r#"" "#);
-                self.output.push_str(html_attrs);
-                self.output.push_str(">Your browser does not support the video tag.</video>\n");
-                return Ok(());
-            }
-        }
-        bail!("not a video block")
-    }
-
-    fn process_paragraph<P>(&mut self, level: usize, predicate: P) -> anyhow::Result<()>
-    where
-        P: Fn(&str) -> bool,
-    {
-        while let Some(line) = self.iter.peek() {
-            let line = line.as_deref().map_err(|e| anyhow!("{e}"))?;
-            if predicate(line) {
-                break;
-            }
-
-            self.write_indent(level);
-            let line = self.iter.next().unwrap()?;
-            let line = line.trim_start();
-            let line = process_inline_macros(line)?;
-            if let Some(stripped) = line.strip_suffix('+') {
-                self.output.push_str(stripped);
-                self.output.push('\\');
-            } else {
-                self.output.push_str(&line);
-            }
-            self.output.push('\n');
-        }
-
-        Ok(())
-    }
-
-    fn skip_blank_lines(&mut self) -> anyhow::Result<()> {
-        while let Some(line) = self.iter.peek() {
-            if !line.as_deref().unwrap().is_empty() {
-                break;
-            }
-            self.iter.next().unwrap()?;
-        }
-        Ok(())
-    }
-
-    fn write_title(&mut self, indent: usize, title: &str) {
-        for _ in 0..indent {
-            self.output.push('#');
-        }
-        self.output.push(' ');
-        self.output.push_str(title);
-        self.output.push('\n');
-    }
-
-    fn write_list_item(&mut self, item: &str, nesting: &ListNesting) {
-        let (marker, indent) = nesting.marker();
-        self.write_indent(indent);
-        self.output.push_str(marker);
-        self.output.push_str(item);
-        self.output.push('\n');
-    }
-
-    fn write_caption_line(&mut self, caption: &str, indent: usize) {
-        self.write_indent(indent);
-        self.output.push('_');
-        self.output.push_str(caption);
-        self.output.push_str("_\\\n");
-    }
-
-    fn write_indent(&mut self, indent: usize) {
-        for _ in 0..indent {
-            self.output.push(' ');
-        }
-    }
-
-    fn write_line(&mut self, line: &str, indent: usize) {
-        self.write_indent(indent);
-        self.output.push_str(line);
-        self.output.push('\n');
-    }
-}
-
-pub(crate) fn convert_asciidoc_to_markdown<R>(input: R) -> anyhow::Result<String>
-where
-    R: BufRead,
-{
-    let mut output = String::new();
-    let mut iter = input.lines().peekable();
-
-    let mut converter = Converter::new(&mut iter, &mut output);
-    converter.process()?;
-
-    Ok(output)
-}
-
-fn get_title(line: &str) -> Option<(usize, &str)> {
-    strip_prefix_symbol(line, '=')
-}
-
-fn get_list_item(line: &str) -> Option<(ListMarker, &str)> {
-    const HYPHEN_MARKER: &str = "- ";
-    if let Some(text) = line.strip_prefix(HYPHEN_MARKER) {
-        Some((ListMarker::Hyphen, text))
-    } else if let Some((count, text)) = strip_prefix_symbol(line, '*') {
-        Some((ListMarker::Asterisk(count), text))
-    } else if let Some((count, text)) = strip_prefix_symbol(line, '.') {
-        Some((ListMarker::Dot(count), text))
-    } else {
-        None
-    }
-}
-
-fn strip_prefix_symbol(line: &str, symbol: char) -> Option<(usize, &str)> {
-    let mut iter = line.chars();
-    if iter.next()? != symbol {
-        return None;
-    }
-    let mut count = 1;
-    loop {
-        match iter.next() {
-            Some(ch) if ch == symbol => {
-                count += 1;
-            }
-            Some(' ') => {
-                break;
-            }
-            _ => return None,
-        }
-    }
-    Some((count, iter.as_str()))
-}
-
-fn parse_media_block<'a>(line: &'a str, prefix: &str) -> Option<(&'a str, &'a str)> {
-    if let Some(line) = line.strip_prefix(prefix) {
-        if let Some((url, rest)) = line.split_once('[') {
-            if let Some(attrs) = rest.strip_suffix(']') {
-                return Some((url, attrs));
-            }
-        }
-    }
-    None
-}
-
-#[derive(Debug)]
-struct ListNesting(Vec<ListMarker>);
-
-impl ListNesting {
-    fn new() -> Self {
-        Self(Vec::<ListMarker>::with_capacity(6))
-    }
-
-    fn current(&mut self) -> Option<&ListMarker> {
-        self.0.last()
-    }
-
-    fn set_current(&mut self, marker: ListMarker) {
-        let Self(markers) = self;
-        if let Some(index) = markers.iter().position(|m| *m == marker) {
-            markers.truncate(index + 1);
-        } else {
-            markers.push(marker);
-        }
-    }
-
-    fn indent(&self) -> usize {
-        self.0.iter().map(|m| m.in_markdown().len()).sum()
-    }
-
-    fn marker(&self) -> (&str, usize) {
-        let Self(markers) = self;
-        let indent = markers.iter().take(markers.len() - 1).map(|m| m.in_markdown().len()).sum();
-        let marker = match markers.last() {
-            None => "",
-            Some(marker) => marker.in_markdown(),
-        };
-        (marker, indent)
-    }
-}
-
-#[derive(Debug, PartialEq, Eq)]
-enum ListMarker {
-    Asterisk(usize),
-    Hyphen,
-    Dot(usize),
-}
-
-impl ListMarker {
-    fn in_markdown(&self) -> &str {
-        match self {
-            ListMarker::Asterisk(_) => "- ",
-            ListMarker::Hyphen => "- ",
-            ListMarker::Dot(_) => "1. ",
-        }
-    }
-}
-
-fn process_inline_macros(line: &str) -> anyhow::Result<Cow<'_, str>> {
-    let mut chars = line.char_indices();
-    loop {
-        let (start, end, a_macro) = match get_next_line_component(&mut chars) {
-            Component::None => break,
-            Component::Text => continue,
-            Component::Macro(s, e, m) => (s, e, m),
-        };
-        let mut src = line.chars();
-        let mut processed = String::new();
-        for _ in 0..start {
-            processed.push(src.next().unwrap());
-        }
-        processed.push_str(a_macro.process()?.as_str());
-        for _ in start..end {
-            let _ = src.next().unwrap();
-        }
-        let mut pos = end;
-
-        loop {
-            let (start, end, a_macro) = match get_next_line_component(&mut chars) {
-                Component::None => break,
-                Component::Text => continue,
-                Component::Macro(s, e, m) => (s, e, m),
-            };
-            for _ in pos..start {
-                processed.push(src.next().unwrap());
-            }
-            processed.push_str(a_macro.process()?.as_str());
-            for _ in start..end {
-                let _ = src.next().unwrap();
-            }
-            pos = end;
-        }
-        for ch in src {
-            processed.push(ch);
-        }
-        return Ok(Cow::Owned(processed));
-    }
-    Ok(Cow::Borrowed(line))
-}
-
-fn get_next_line_component(chars: &mut std::str::CharIndices<'_>) -> Component {
-    let (start, mut macro_name) = match chars.next() {
-        None => return Component::None,
-        Some((_, ch)) if ch == ' ' || !ch.is_ascii() => return Component::Text,
-        Some((pos, ch)) => (pos, String::from(ch)),
-    };
-    loop {
-        match chars.next() {
-            None => return Component::None,
-            Some((_, ch)) if ch == ' ' || !ch.is_ascii() => return Component::Text,
-            Some((_, ':')) => break,
-            Some((_, ch)) => macro_name.push(ch),
-        }
-    }
-
-    let mut macro_target = String::new();
-    loop {
-        match chars.next() {
-            None => return Component::None,
-            Some((_, ' ')) => return Component::Text,
-            Some((_, '[')) => break,
-            Some((_, ch)) => macro_target.push(ch),
-        }
-    }
-
-    let mut attr_value = String::new();
-    let end = loop {
-        match chars.next() {
-            None => return Component::None,
-            Some((pos, ']')) => break pos + 1,
-            Some((_, ch)) => attr_value.push(ch),
-        }
-    };
-
-    Component::Macro(start, end, Macro::new(macro_name, macro_target, attr_value))
-}
-
-enum Component {
-    None,
-    Text,
-    Macro(usize, usize, Macro),
-}
-
-struct Macro {
-    name: String,
-    target: String,
-    attrs: String,
-}
-
-impl Macro {
-    fn new(name: String, target: String, attrs: String) -> Self {
-        Self { name, target, attrs }
-    }
-
-    fn process(&self) -> anyhow::Result<String> {
-        let name = &self.name;
-        let text = match name.as_str() {
-            "https" => {
-                let url = &self.target;
-                let anchor_text = &self.attrs;
-                format!("[{anchor_text}](https:{url})")
-            }
-            "image" => {
-                let url = &self.target;
-                let alt = &self.attrs;
-                format!("![{alt}]({url})")
-            }
-            "kbd" => {
-                let keys = self.attrs.split('+').map(|k| Cow::Owned(format!("<kbd>{k}</kbd>")));
-                keys.collect::<Vec<_>>().join("+")
-            }
-            "pr" => {
-                let pr = &self.target;
-                let url = format!("https://github.com/rust-analyzer/rust-analyzer/pull/{pr}");
-                format!("[`#{pr}`]({url})")
-            }
-            "commit" => {
-                let hash = &self.target;
-                let short = &hash[0..7];
-                let url = format!("https://github.com/rust-analyzer/rust-analyzer/commit/{hash}");
-                format!("[`{short}`]({url})")
-            }
-            "release" => {
-                let date = &self.target;
-                let url = format!("https://github.com/rust-analyzer/rust-analyzer/releases/{date}");
-                format!("[`{date}`]({url})")
-            }
-            _ => bail!("macro not supported: {name}"),
-        };
-        Ok(text)
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use std::fs::read_to_string;
-
-    #[test]
-    fn test_asciidoc_to_markdown_conversion() {
-        let input = read_to_string("test_data/input.adoc").unwrap();
-        let expected = read_to_string("test_data/expected.md").unwrap();
-        let actual = convert_asciidoc_to_markdown(std::io::Cursor::new(&input)).unwrap();
-
-        assert_eq!(actual, expected);
-    }
-
-    macro_rules! test_inline_macro_processing {
-        ($((
-            $name:ident,
-            $input:expr,
-            $expected:expr
-        ),)*) => ($(
-            #[test]
-            fn $name() {
-                let input = $input;
-                let actual = process_inline_macros(&input).unwrap();
-                let expected = $expected;
-                assert_eq!(actual, expected)
-            }
-        )*);
-    }
-
-    test_inline_macro_processing! {
-        (inline_macro_processing_for_empty_line, "", ""),
-        (inline_macro_processing_for_line_with_no_macro, "foo bar", "foo bar"),
-        (
-            inline_macro_processing_for_macro_in_line_start,
-            "kbd::[Ctrl+T] foo",
-            "<kbd>Ctrl</kbd>+<kbd>T</kbd> foo"
-        ),
-        (
-            inline_macro_processing_for_macro_in_line_end,
-            "foo kbd::[Ctrl+T]",
-            "foo <kbd>Ctrl</kbd>+<kbd>T</kbd>"
-        ),
-        (
-            inline_macro_processing_for_macro_in_the_middle_of_line,
-            "foo kbd::[Ctrl+T] foo",
-            "foo <kbd>Ctrl</kbd>+<kbd>T</kbd> foo"
-        ),
-        (
-            inline_macro_processing_for_several_macros,
-            "foo kbd::[Ctrl+T] foo kbd::[Enter] foo",
-            "foo <kbd>Ctrl</kbd>+<kbd>T</kbd> foo <kbd>Enter</kbd> foo"
-        ),
-        (
-            inline_macro_processing_for_several_macros_without_text_in_between,
-            "foo kbd::[Ctrl+T]kbd::[Enter] foo",
-            "foo <kbd>Ctrl</kbd>+<kbd>T</kbd><kbd>Enter</kbd> foo"
-        ),
-    }
-}


Test patch:
diff --git a/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs b/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
index 26f16542cb..fc90c6e9f3 100644
--- a/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
+++ b/crates/hir-def/src/macro_expansion_tests/mbe/matching.rs
@@ -136,52 +136,3 @@ macro_rules! m { ($($i:ident)? $vis:vis) => () }
 "#]],
     )
 }
-
-// For this test and the one below, see rust-lang/rust#86730.
-#[test]
-fn expr_dont_match_let_expr() {
-    check(
-        r#"
-macro_rules! foo {
-    ($e:expr) => { $e }
-}
-
-fn test() {
-    foo!(let a = 3);
-}
-"#,
-        expect![[r#"
-macro_rules! foo {
-    ($e:expr) => { $e }
-}
-
-fn test() {
-    /* error: no rule matches input tokens */missing;
-}
-"#]],
-    );
-}
-
-#[test]
-fn expr_dont_match_inline_const() {
-    check(
-        r#"
-macro_rules! foo {
-    ($e:expr) => { $e }
-}
-
-fn test() {
-    foo!(const { 3 });
-}
-"#,
-        expect![[r#"
-macro_rules! foo {
-    ($e:expr) => { $e }
-}
-
-fn test() {
-    /* error: no rule matches input tokens */missing;
-}
-"#]],
-    );
-}
diff --git a/xtask/test_data/expected.md b/xtask/test_data/expected.md
deleted file mode 100644
index 19c940c67b..0000000000
--- a/xtask/test_data/expected.md
+++ /dev/null
@@ -1,81 +0,0 @@
-# Changelog #256
-
-Hello!
-
-Commit: [`0123456`](https://github.com/rust-analyzer/rust-analyzer/commit/0123456789abcdef0123456789abcdef01234567) \
-Release: [`2022-01-01`](https://github.com/rust-analyzer/rust-analyzer/releases/2022-01-01)
-
-## New Features
-
-- **BREAKING** [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111) shortcut <kbd>ctrl</kbd>+<kbd>r</kbd>
-  - hyphen-prefixed list item
-- nested list item
-  - `foo` -> `foofoo`
-  - `bar` -> `barbar`
-- listing in the secondary level
-  1. install
-  1. add to config
-
-     ```json
-     {"foo":"bar"}
-     ```
-- list item with continuation
-
-  ![](https://example.com/animation.gif)
-
-  ![alt text](https://example.com/animation.gif)
-
-  <video src="https://example.com/movie.mp4" controls loop>Your browser does not support the video tag.</video>
-
-  <video src="https://example.com/movie.mp4" autoplay controls loop>Your browser does not support the video tag.</video>
-
-  _Image_\
-  ![](https://example.com/animation.gif)
-
-  _Video_\
-  <video src="https://example.com/movie.mp4" controls loop>Your browser does not support the video tag.</video>
-
-  ```bash
-  rustup update nightly
-  ```
-
-  ```
-  This is a plain listing.
-  ```
-- single line item followed by empty lines
-- multiline list
-  item followed by empty lines
-- multiline list
-  item with indent
-- multiline list
-  item not followed by empty lines
-- multiline list
-  item followed by different marker
-  - foo
-  - bar
-- multiline list
-  item followed by list continuation
-
-  paragraph
-  paragraph
-
-## Another Section
-
-- foo bar baz
-- list item with an inline image
-  ![](https://example.com/animation.gif)
-
-The highlight of the month is probably [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111).
-See [online manual](https://example.com/manual) for more information.
-
-```bash
-rustup update nightly
-```
-
-```
-rustup update nightly
-```
-
-```
-This is a plain listing.
-```
diff --git a/xtask/test_data/input.adoc b/xtask/test_data/input.adoc
deleted file mode 100644
index 105bd8df0d..0000000000
--- a/xtask/test_data/input.adoc
+++ /dev/null
@@ -1,90 +0,0 @@
-= Changelog #256
-:sectanchors:
-:page-layout: post
-
-Hello!
-
-Commit: commit:0123456789abcdef0123456789abcdef01234567[] +
-Release: release:2022-01-01[]
-
-== New Features
-
-* **BREAKING** pr:1111[] shortcut kbd:[ctrl+r]
-- hyphen-prefixed list item
-* nested list item
-** `foo` -> `foofoo`
-** `bar` -> `barbar`
-* listing in the secondary level
-. install
-. add to config
-+
-[source,json]
-----
-{"foo":"bar"}
-----
-* list item with continuation
-+
-image::https://example.com/animation.gif[]
-+
-image::https://example.com/animation.gif["alt text"]
-+
-video::https://example.com/movie.mp4[options=loop]
-+
-video::https://example.com/movie.mp4[options="autoplay,loop"]
-+
-.Image
-image::https://example.com/animation.gif[]
-+
-.Video
-video::https://example.com/movie.mp4[options=loop]
-+
-[source,bash]
-----
-rustup update nightly
-----
-+
-----
-This is a plain listing.
-----
-* single line item followed by empty lines
-
-* multiline list
-item followed by empty lines
-
-* multiline list
-  item with indent
-
-* multiline list
-item not followed by empty lines
-* multiline list
-item followed by different marker
-** foo
-** bar
-* multiline list
-item followed by list continuation
-+
-paragraph
-paragraph
-
-== Another Section
-
-* foo bar baz
-* list item with an inline image
-  image:https://example.com/animation.gif[]
-
-The highlight of the month is probably pr:1111[].
-See https://example.com/manual[online manual] for more information.
-
-[source,bash]
-----
-rustup update nightly
-----
-
-[source]
-----
-rustup update nightly
-----
-
-----
-This is a plain listing.
-----