From c516c284755130dac7d3232b7c40567a57cfb936 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Mon, 29 Dec 2025 06:45:17 +0800 Subject: [PATCH] Add useless prefix `try_into_` for suggest_name Example --- ```rust enum Foo { Num(i32) } impl Foo { fn try_into_num(self) -> Result { if let Self::Num(v) = self { Ok(v) } else { Err(self) } } } fn handle(foo: Foo) { foo.try_into_num().$0 } ``` **Before this PR** ```rust fn handle(foo: Foo) { if let Ok(${1:try_into_num}) = foo.try_into_num() { $0 } } ``` **After this PR** ```rust fn handle(foo: Foo) { if let Ok(${1:num}) = foo.try_into_num() { $0 } } ``` --- .../crates/ide-db/src/syntax_helpers/suggest_name.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs b/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs index 273328a8d270..b8b9a7a76816 100644 --- a/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs +++ b/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/suggest_name.rs @@ -44,7 +44,7 @@ const SEQUENCE_TYPES: &[&str] = &["Vec", "VecDeque", "LinkedList"]; /// `vec.as_slice()` -> `slice` /// `args.into_config()` -> `config` /// `bytes.to_vec()` -> `vec` -const USELESS_METHOD_PREFIXES: &[&str] = &["into_", "as_", "to_"]; +const USELESS_METHOD_PREFIXES: &[&str] = &["try_into_", "into_", "as_", "to_"]; /// Useless methods that are stripped from expression ///