nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: rust-analyzer/rust-analyzer
Pull request #11261 (2022-01-11 18:03:54)

fix: Don't complete attributes with existing expressions
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11254 due to the comment being lowered to an attribute
bors r+ 


Patch:
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs
index f67d7d56d8..2603ad2003 100644
--- a/crates/ide_completion/src/completions/attribute.rs
+++ b/crates/ide_completion/src/completions/attribute.rs
@@ -56,6 +56,7 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
             _ => (),
         },
         (_, Some(_)) => (),
+        (_, None) if attribute.expr().is_some() => (),
         (_, None) => complete_new_attribute(acc, ctx, attribute),
     }
     Some(())


Test patch:
diff --git a/crates/ide_completion/src/tests/attribute.rs b/crates/ide_completion/src/tests/attribute.rs
index c2bd26e2d8..2d2a1b867a 100644
--- a/crates/ide_completion/src/tests/attribute.rs
+++ b/crates/ide_completion/src/tests/attribute.rs
@@ -40,6 +40,19 @@ struct Foo;
     )
 }
 
+#[test]
+fn proc_macros_on_comment() {
+    check(
+        r#"
+//- proc_macros: identity
+/// $0
+#[proc_macros::identity]
+struct Foo;
+"#,
+        expect![[r#""#]],
+    )
+}
+
 #[test]
 fn proc_macros_qualified() {
     check(
Repository: rust-analyzer/rust-analyzer
Pull request #11263 (2022-01-12 11:37:02)

fix: Fix don't drop param completions when fully typing out a pattern
bors r+


Patch:
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs
index 2603ad2003..f67d7d56d8 100644
--- a/crates/ide_completion/src/completions/attribute.rs
+++ b/crates/ide_completion/src/completions/attribute.rs
@@ -56,7 +56,6 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
             _ => (),
         },
         (_, Some(_)) => (),
-        (_, None) if attribute.expr().is_some() => (),
         (_, None) => complete_new_attribute(acc, ctx, attribute),
     }
     Some(())
diff --git a/crates/ide_completion/src/completions/fn_param.rs b/crates/ide_completion/src/completions/fn_param.rs
index bb4ce0a24d..a55bab67e1 100644
--- a/crates/ide_completion/src/completions/fn_param.rs
+++ b/crates/ide_completion/src/completions/fn_param.rs
@@ -83,9 +83,15 @@ fn remove_duplicated(
         let whole_param = param.syntax().text().to_string();
         file_params.remove(&whole_param);
 
-        if let Some(pattern) = param.pat() {
-            let binding = pattern.syntax().text().to_string();
-            file_params.retain(|_, v| v != &binding);
+        match param.pat() {
+            // remove suggestions for patterns that already exist
+            // if the type is missing we are checking the current param to be completed
+            // in which case this would find itself removing the suggestions due to itself
+            Some(pattern) if param.ty().is_some() => {
+                let binding = pattern.syntax().text().to_string();
+                file_params.retain(|_, v| v != &binding);
+            }
+            _ => (),
         }
     })
 }


Test patch:
diff --git a/crates/ide_completion/src/tests/attribute.rs b/crates/ide_completion/src/tests/attribute.rs
index 2d2a1b867a..c2bd26e2d8 100644
--- a/crates/ide_completion/src/tests/attribute.rs
+++ b/crates/ide_completion/src/tests/attribute.rs
@@ -40,19 +40,6 @@ struct Foo;
     )
 }
 
-#[test]
-fn proc_macros_on_comment() {
-    check(
-        r#"
-//- proc_macros: identity
-/// $0
-#[proc_macros::identity]
-struct Foo;
-"#,
-        expect![[r#""#]],
-    )
-}
-
 #[test]
 fn proc_macros_qualified() {
     check(
diff --git a/crates/ide_completion/src/tests/pattern.rs b/crates/ide_completion/src/tests/pattern.rs
index c9a31eea84..7f437e1a07 100644
--- a/crates/ide_completion/src/tests/pattern.rs
+++ b/crates/ide_completion/src/tests/pattern.rs
@@ -368,3 +368,17 @@ fn foo() {
         "#]],
     )
 }
+
+#[test]
+fn completes_fully_equal() {
+    check_empty(
+        r#"
+fn foo(bar: u32) {}
+fn bar(bar$0) {}
+"#,
+        expect![[r#"
+            bn bar: u32
+            kw mut
+        "#]],
+    )
+}
Repository: rust-analyzer/rust-analyzer
Pull request #2388 (2019-11-24 16:38:42)

Show missing struct fields in the error message
This provides the most interesting information about the "missing structure fields" error directly to the user.


Patch:
diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs
index dafacba70c..6db499e060 100644
--- a/crates/ra_hir/src/diagnostics.rs
+++ b/crates/ra_hir/src/diagnostics.rs
@@ -39,7 +39,12 @@ pub struct MissingFields {
 
 impl Diagnostic for MissingFields {
     fn message(&self) -> String {
-        "fill structure fields".to_string()
+        use std::fmt::Write;
+        let mut message = String::from("Missing structure fields:\n");
+        for field in &self.missed_fields {
+            write!(message, "- {}\n", field).unwrap();
+        }
+        message
     }
     fn source(&self) -> Source<SyntaxNodePtr> {
         Source { file_id: self.file, value: self.field_list.into() }


Test patch:
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 3209c66bd0..98eb863cb9 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -4832,7 +4832,8 @@ fn no_such_field_diagnostics() {
 
     assert_snapshot!(diagnostics, @r###"
     "baz: 62": no such field
-    "{\n            foo: 92,\n            baz: 62,\n        }": fill structure fields
+    "{\n            foo: 92,\n            baz: 62,\n        }": Missing structure fields:
+    - bar
     "###
     );
 }
Repository: rust-analyzer/rust-analyzer
Pull request #4136 (2020-04-25 13:49:47)

add support for cfg feature attributes on expression #4063
close issue #4063


Patch:
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 0caedd8d85..5716038543 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -141,6 +141,10 @@ impl ExprCollector<'_> {
 
     fn collect_expr(&mut self, expr: ast::Expr) -> ExprId {
         let syntax_ptr = AstPtr::new(&expr);
+        let attrs = self.expander.parse_attrs(&expr);
+        if !self.expander.is_cfg_enabled(&attrs) {
+            return self.missing_expr();
+        }
         match expr {
             ast::Expr::IfExpr(e) => {
                 let then_branch = self.collect_block_opt(e.then_branch());


Test patch:
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index b6a96bb5ca..588d812820 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -390,6 +390,38 @@ fn no_such_field_with_feature_flag_diagnostics_on_struct_lit() {
     assert_snapshot!(diagnostics, @r###""###);
 }
 
+#[test]
+fn no_such_field_with_feature_flag_diagnostics_on_block_expr() {
+    let diagnostics = TestDB::with_files(
+        r#"
+        //- /lib.rs crate:foo cfg:feature=foo
+        struct S {
+            #[cfg(feature = "foo")]
+            foo: u32,
+            #[cfg(not(feature = "foo"))]
+            bar: u32,
+        }
+
+        impl S {
+            fn new(bar: u32) -> Self {
+                #[cfg(feature = "foo")]
+                {
+                Self { foo: bar }
+                }
+                #[cfg(not(feature = "foo"))]
+                {
+                Self { bar }
+                }
+            }
+        }
+        "#,
+    )
+    .diagnostics()
+    .0;
+
+    assert_snapshot!(diagnostics, @r###""###);
+}
+
 #[test]
 fn no_such_field_with_feature_flag_diagnostics_on_struct_fields() {
     let diagnostics = TestDB::with_files(