From 6e085904362198666016f6705735c2653e252f85 Mon Sep 17 00:00:00 2001 From: Young-Flash Date: Sun, 9 Jun 2024 20:55:40 +0800 Subject: [PATCH] internal: tweak test case --- src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs | 4 +++- src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs b/src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs index 9aff712f4ce5..16e409dfe60b 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs @@ -69,7 +69,9 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo p.buf.push(' '); }); // remove the last ", " in param list - p.buf.truncate(p.buf.len() - 2); + if body.params.len() > 0 { + p.buf.truncate(p.buf.len() - 2); + } p.buf.push(')'); p.buf.push(' '); // return type diff --git a/src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs b/src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs index e8b26d537345..0011d3a20c2a 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs @@ -156,7 +156,7 @@ fn main() { ); expect![[r#" - fn main() { + fn main() -> () { let are = "are"; let count = 10; builtin#lang(Arguments::new_v1_formatted)( @@ -258,7 +258,7 @@ impl SsrError { assert_eq!(db.body_with_source_map(def).1.diagnostics(), &[]); expect![[r#" - fn main() { + fn main() -> () { _ = $crate::error::SsrError::new( builtin#lang(Arguments::new_v1_formatted)( &[ @@ -303,7 +303,7 @@ macro_rules! m { }; } -fn f() { +fn f(a: i32, b: u32) -> String { m!(); } "#, @@ -317,7 +317,7 @@ fn f() { } expect![[r#" - fn f() { + fn f(a: i32, b: u32) -> String { { $crate::panicking::panic_fmt( builtin#lang(Arguments::new_v1_formatted)(