Repository: rust-analyzer/rust-analyzer
Pull request #11896 (2022-04-04 13:54:48)

fix: Show the path to be created in the unresolved-module fix label
bors r+

bors[bot]: Build failed:
  * [Rust (ubuntu-latest)](https://github.com/rust-analyzer/rust-analyzer/runs/5817602039?check_suite_focus=true)

Patch:
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs
index 2031eef049..85014717d6 100644
--- a/crates/ide_completion/src/render/function.rs
+++ b/crates/ide_completion/src/render/function.rs
@@ -3,7 +3,7 @@
 use hir::{db::HirDatabase, AsAssocItem, HirDisplay};
 use ide_db::{SnippetCap, SymbolKind};
 use itertools::Itertools;
-use stdx::{format_to, to_lower_snake_case};
+use stdx::format_to;
 use syntax::SmolStr;
 
 use crate::{
@@ -135,17 +135,7 @@ pub(super) fn add_call_parens<'b>(
                             let ref_ = ref_of_param(ctx, text, param.ty());
                             f(&format_args!("${{{}:{}{}}}", index + offset, ref_, text))
                         }
-                        None => {
-                            let name = match param.ty().as_adt() {
-                                None => "_".to_string(),
-                                Some(adt) => adt
-                                    .name(ctx.db)
-                                    .as_text()
-                                    .map(|s| to_lower_snake_case(s.as_str()))
-                                    .unwrap_or_else(|| "_".to_string()),
-                            };
-                            f(&format_args!("${{{}:{}}}", index + offset, name))
-                        }
+                        None => f(&format_args!("${{{}:_}}", index + offset,)),
                     }
                 });
             match self_param {
@@ -526,39 +516,6 @@ fn take_mutably(mut x: &i32) {}
 fn main() {
     take_mutably(${1:x})$0
 }
-"#,
-        );
-    }
-
-    #[test]
-    fn complete_pattern_args_with_type_name_if_adt() {
-        check_edit(
-            "qux",
-            r#"
-struct Foo {
-    bar: i32
-}
-
-fn qux(Foo { bar }: Foo) {
-    println!("{}", bar);
-}
-
-fn main() {
-  qu$0
-}
-"#,
-            r#"
-struct Foo {
-    bar: i32
-}
-
-fn qux(Foo { bar }: Foo) {
-    println!("{}", bar);
-}
-
-fn main() {
-  qux(${1:foo})$0
-}
 "#,
         );
     }
diff --git a/crates/ide_diagnostics/src/handlers/unresolved_module.rs b/crates/ide_diagnostics/src/handlers/unresolved_module.rs
index 640ba38a28..587a3ee26d 100644
--- a/crates/ide_diagnostics/src/handlers/unresolved_module.rs
+++ b/crates/ide_diagnostics/src/handlers/unresolved_module.rs
@@ -39,7 +39,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedModule) -> Option<Vec<
             .map(|candidate| {
                 fix(
                     "create_module",
-                    "Create module",
+                    &format!("Create module at `{candidate}`"),
                     FileSystemEdit::CreateFile {
                         dst: AnchoredPathBuf {
                             anchor: d.decl.file_id.original_file(ctx.sema.db),
@@ -97,7 +97,7 @@ mod baz {}
                                         "create_module",
                                         QuickFix,
                                     ),
-                                    label: "Create module",
+                                    label: "Create module at `foo.rs`",
                                     group: None,
                                     target: 0..8,
                                     source_change: Some(
@@ -123,7 +123,7 @@ mod baz {}
                                         "create_module",
                                         QuickFix,
                                     ),
-                                    label: "Create module",
+                                    label: "Create module at `foo/mod.rs`",
                                     group: None,
                                     target: 0..8,
                                     source_change: Some(


Test patch:
diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs
index eb7e73236a..147e8c141a 100644
--- a/crates/rust-analyzer/tests/slow-tests/main.rs
+++ b/crates/rust-analyzer/tests/slow-tests/main.rs
@@ -465,7 +465,7 @@ fn main() {}
         },
         json!([
             {
-                "title": "Create module",
+                "title": "Create module at `bar.rs`",
                 "kind": "quickfix",
                 "edit": {
                 "documentChanges": [
@@ -477,7 +477,7 @@ fn main() {}
                 }
             },
             {
-                "title": "Create module",
+                "title": "Create module at `bar/mod.rs`",
                 "kind": "quickfix",
                 "edit": {
                 "documentChanges": [
@@ -549,7 +549,7 @@ fn main() {{}}
         },
         json!([
             {
-                "title": "Create module",
+                "title": "Create module at `bar.rs`",
                 "kind": "quickfix",
                 "edit": {
                 "documentChanges": [
@@ -561,7 +561,7 @@ fn main() {{}}
                 }
             },
             {
-                "title": "Create module",
+                "title": "Create module at `bar/mod.rs`",
                 "kind": "quickfix",
                 "edit": {
                 "documentChanges": [