nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: rust-lang/rust-analyzer
Pull request #12185 (2022-05-07 10:52:42)

fix: Remap float parts as integers when parsed as indices
`NameRef`s should only contain integers and identifiers
cc https://github.com/rust-lang/rust-analyzer/pull/12149


Patch:
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs
index 92f3302538..f68d7196c8 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -323,8 +323,8 @@ fn name_ref_or_index(p: &mut Parser) {
         p.at(IDENT) || p.at(INT_NUMBER) || p.at(FLOAT_NUMBER_PART) || p.at_ts(FLOAT_LITERAL_FIRST)
     );
     let m = p.start();
-    if p.at_ts(FLOAT_LITERAL_FIRST) {
-        p.bump_remap(FLOAT_NUMBER_PART);
+    if p.at(FLOAT_NUMBER_PART) || p.at_ts(FLOAT_LITERAL_FIRST) {
+        p.bump_remap(INT_NUMBER);
     } else {
         p.bump_any();
     }


Test patch:
diff --git a/crates/parser/test_data/parser/inline/ok/0011_field_expr.rast b/crates/parser/test_data/parser/inline/ok/0011_field_expr.rast
index a1efb3a9fb..19fab593fa 100644
--- a/crates/parser/test_data/parser/inline/ok/0011_field_expr.rast
+++ b/crates/parser/test_data/parser/inline/ok/0011_field_expr.rast
@@ -50,7 +50,7 @@ SOURCE_FILE
                       IDENT "x"
               DOT "."
               NAME_REF
-                FLOAT_NUMBER_PART "0"
+                INT_NUMBER "0"
             DOT "."
             WHITESPACE " "
             NAME_REF
@@ -67,10 +67,10 @@ SOURCE_FILE
                       IDENT "x"
               DOT "."
               NAME_REF
-                FLOAT_NUMBER_PART "0"
+                INT_NUMBER "0"
             DOT "."
             NAME_REF
-              FLOAT_NUMBER_PART "1"
+              INT_NUMBER "1"
           SEMICOLON ";"
         WHITESPACE "\n    "
         EXPR_STMT
Repository: rust-lang/rust-analyzer
Pull request #12199 (2022-05-09 16:12:36)

fix: Don't show assoc. type binding completions when invalid
Fixes https://github.com/rust-lang/rust-analyzer/issues/12165


Patch:
diff --git a/crates/ide-completion/src/completions/type.rs b/crates/ide-completion/src/completions/type.rs
index 034a229702..91414c8bf6 100644
--- a/crates/ide-completion/src/completions/type.rs
+++ b/crates/ide-completion/src/completions/type.rs
@@ -165,15 +165,17 @@ pub(crate) fn complete_type_path(acc: &mut Completions, ctx: &CompletionContext)
             if let Some(ImmediateLocation::GenericArgList(arg_list)) = &ctx.completion_location {
                 if let Some(path_seg) = arg_list.syntax().parent().and_then(ast::PathSegment::cast)
                 {
-                    if let Some(hir::PathResolution::Def(hir::ModuleDef::Trait(trait_))) =
-                        ctx.sema.resolve_path(&path_seg.parent_path())
-                    {
-                        trait_.items_with_supertraits(ctx.sema.db).into_iter().for_each(|it| {
-                            if let hir::AssocItem::TypeAlias(alias) = it {
-                                cov_mark::hit!(complete_assoc_type_in_generics_list);
-                                acc.add_type_alias_with_eq(ctx, alias)
-                            }
-                        });
+                    if path_seg.syntax().ancestors().find_map(ast::TypeBound::cast).is_some() {
+                        if let Some(hir::PathResolution::Def(hir::ModuleDef::Trait(trait_))) =
+                            ctx.sema.resolve_path(&path_seg.parent_path())
+                        {
+                            trait_.items_with_supertraits(ctx.sema.db).into_iter().for_each(|it| {
+                                if let hir::AssocItem::TypeAlias(alias) = it {
+                                    cov_mark::hit!(complete_assoc_type_in_generics_list);
+                                    acc.add_type_alias_with_eq(ctx, alias)
+                                }
+                            });
+                        }
                     }
                 }
             }


Test patch:
diff --git a/crates/ide-completion/src/tests/type_pos.rs b/crates/ide-completion/src/tests/type_pos.rs
index 1e1b3f3efb..1e5e86eef5 100644
--- a/crates/ide-completion/src/tests/type_pos.rs
+++ b/crates/ide-completion/src/tests/type_pos.rs
@@ -393,6 +393,38 @@ fn foo<'lt, T: Trait2<self::$0>, const CONST_PARAM: usize>(_: T) {}
     );
 }
 
+#[test]
+fn no_assoc_completion_outside_type_bounds() {
+    check(
+        r#"
+struct S;
+trait Tr<T> {
+    type Ty;
+}
+
+impl Tr<$0
+    "#,
+        expect![[r#"
+            ct CONST
+            en Enum
+            ma makro!(…) macro_rules! makro
+            md module
+            sp Self
+            st Record
+            st S
+            st Tuple
+            st Unit
+            tt Tr
+            tt Trait
+            un Union
+            bt u32
+            kw crate::
+            kw self::
+            kw super::
+        "#]],
+    );
+}
+
 #[test]
 fn enum_qualified() {
     check(