nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: edgedb/edgedb-cli
Pull request #1162 (2023-10-30 21:08:50)

Bump edgedb-rust and shared-client-testcases
Picks up edgedb/edgedb-rust#235



Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 4ccaea5..3e43263 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1132,7 +1132,7 @@ dependencies = [
 [[package]]
 name = "edgedb-derive"
 version = "0.5.1"
-source = "git+https://github.com/edgedb/edgedb-rust/#9ba86e843e8ec88140a98f9a0ef20752cf019bd0"
+source = "git+https://github.com/edgedb/edgedb-rust/#a1094916fe28d090156c006722ca660cc29e06ad"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -1143,7 +1143,7 @@ dependencies = [
 [[package]]
 name = "edgedb-errors"
 version = "0.4.1"
-source = "git+https://github.com/edgedb/edgedb-rust/#9ba86e843e8ec88140a98f9a0ef20752cf019bd0"
+source = "git+https://github.com/edgedb/edgedb-rust/#a1094916fe28d090156c006722ca660cc29e06ad"
 dependencies = [
  "bytes",
 ]
@@ -1151,7 +1151,7 @@ dependencies = [
 [[package]]
 name = "edgedb-protocol"
 version = "0.6.0"
-source = "git+https://github.com/edgedb/edgedb-rust/#9ba86e843e8ec88140a98f9a0ef20752cf019bd0"
+source = "git+https://github.com/edgedb/edgedb-rust/#a1094916fe28d090156c006722ca660cc29e06ad"
 dependencies = [
  "bigdecimal",
  "bitflags 2.4.0",
@@ -1167,7 +1167,7 @@ dependencies = [
 [[package]]
 name = "edgedb-tokio"
 version = "0.5.0"
-source = "git+https://github.com/edgedb/edgedb-rust/#9ba86e843e8ec88140a98f9a0ef20752cf019bd0"
+source = "git+https://github.com/edgedb/edgedb-rust/#a1094916fe28d090156c006722ca660cc29e06ad"
 dependencies = [
  "anyhow",
  "arc-swap",


Test patch:
diff --git a/tests/shared-client-testcases b/tests/shared-client-testcases
index b8959be..b260ad9 160000
--- a/tests/shared-client-testcases
+++ b/tests/shared-client-testcases
@@ -1,1 +1,1 @@
-Subproject commit b8959be8968aceeeac2af3da7639de02b19d7030
+Subproject commit b260ad9b3fd0ddb6d4bc9174477fe8ad14220af3
Repository: rust-analyzer/rust-analyzer
Pull request #4225 (2020-04-30 14:09:20)

Special-case try macro_rules
Similar to #4221, but for `macro_rules! try {}`


Patch:
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 433ed6812f..1503a87300 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -415,6 +415,17 @@ pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
     if p.at(IDENT) {
         name(p);
     }
+    // Special-case `macro_rules! try`.
+    // This is a hack until we do proper edition support
+
+    // test try_macro_rules
+    // macro_rules! try { () => {} }
+    if p.at(T![try]) {
+        let m = p.start();
+        p.bump_remap(IDENT);
+        m.complete(p, NAME);
+    }
+
     match p.current() {
         T!['{'] => {
             token_tree(p);


Test patch:
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast b/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast
new file mode 100644
index 0000000000..05b89d1c36
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast
@@ -0,0 +1,27 @@
+SOURCE_FILE@0..30
+  MACRO_CALL@0..29
+    PATH@0..11
+      PATH_SEGMENT@0..11
+        NAME_REF@0..11
+          IDENT@0..11 "macro_rules"
+    BANG@11..12 "!"
+    WHITESPACE@12..13 " "
+    NAME@13..16
+      IDENT@13..16 "try"
+    WHITESPACE@16..17 " "
+    TOKEN_TREE@17..29
+      L_CURLY@17..18 "{"
+      WHITESPACE@18..19 " "
+      TOKEN_TREE@19..21
+        L_PAREN@19..20 "("
+        R_PAREN@20..21 ")"
+      WHITESPACE@21..22 " "
+      EQ@22..23 "="
+      R_ANGLE@23..24 ">"
+      WHITESPACE@24..25 " "
+      TOKEN_TREE@25..27
+        L_CURLY@25..26 "{"
+        R_CURLY@26..27 "}"
+      WHITESPACE@27..28 " "
+      R_CURLY@28..29 "}"
+  WHITESPACE@29..30 "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs b/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs
new file mode 100644
index 0000000000..2e2ab6e60b
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs
@@ -0,0 +1,1 @@
+macro_rules! try { () => {} }
Repository: rust-analyzer/rust-analyzer
Pull request #3336 (2020-02-27 02:07:38)

Use text_range::extend_to


Patch:
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 5b0b94e34d..c3d8ee1aef 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -388,7 +388,7 @@ fn original_range_and_origin(
     let single = skip_trivia_token(node.value.first_token()?, Direction::Next)?
         == skip_trivia_token(node.value.last_token()?, Direction::Prev)?;
 
-    return Some(node.value.descendants().find_map(|it| {
+    Some(node.value.descendants().find_map(|it| {
         let first = skip_trivia_token(it.first_token()?, Direction::Next)?;
         let last = skip_trivia_token(it.last_token()?, Direction::Prev)?;
 
@@ -404,16 +404,9 @@ fn original_range_and_origin(
             return None;
         }
 
-        // FIXME: Add union method in TextRange
         Some((
-            first.with_value(union_range(first.value.text_range(), last.value.text_range())),
+            first.with_value(first.value.text_range().extend_to(&last.value.text_range())),
             first_origin,
         ))
-    })?);
-
-    fn union_range(a: TextRange, b: TextRange) -> TextRange {
-        let start = a.start().min(b.start());
-        let end = a.end().max(b.end());
-        TextRange::from_to(start, end)
-    }
+    })?)
 }
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs
index 2e09bd1ec3..f5a0633512 100644
--- a/crates/ra_ide/src/extend_selection.rs
+++ b/crates/ra_ide/src/extend_selection.rs
@@ -161,7 +161,7 @@ fn extend_tokens_from_range(
     .take_while(validate)
     .last()?;
 
-    let range = union_range(first.text_range(), last.text_range());
+    let range = first.text_range().extend_to(&last.text_range());
     if original_range.is_subrange(&range) && original_range != range {
         Some(range)
     } else {
@@ -169,12 +169,6 @@ fn extend_tokens_from_range(
     }
 }
 
-fn union_range(range: TextRange, r: TextRange) -> TextRange {
-    let start = range.start().min(r.start());
-    let end = range.end().max(r.end());
-    TextRange::from_to(start, end)
-}
-
 /// Find the shallowest node with same range, which allows us to traverse siblings.
 fn shallowest_node(node: &SyntaxNode) -> SyntaxNode {
     node.ancestors().take_while(|n| n.text_range() == node.text_range()).last().unwrap()
diff --git a/crates/ra_text_edit/Cargo.toml b/crates/ra_text_edit/Cargo.toml
index a321492997..97280f8669 100644
--- a/crates/ra_text_edit/Cargo.toml
+++ b/crates/ra_text_edit/Cargo.toml
@@ -9,7 +9,7 @@ publish = false
 doctest = false
 
 [dependencies]
-text_unit = "0.1.9"
+text_unit = "0.1.10"
 
 [dev-dependencies]
 test_utils = { path = "../test_utils" }


Test patch:
diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml
index 971592b737..6a7c6d6f9e 100644
--- a/crates/test_utils/Cargo.toml
+++ b/crates/test_utils/Cargo.toml
@@ -9,5 +9,5 @@ doctest = false
 
 [dependencies]
 difference = "2.0.0"
-text_unit = "0.1.9"
+text_unit = "0.1.10"
 serde_json = "1.0.48"
Repository: rust-analyzer/rust-analyzer
Pull request #11402 (2022-02-03 16:02:37)

fix: Fix vis restriction path completions always using the parent module
bors r+


Patch:
diff --git a/crates/ide_completion/src/completions/vis.rs b/crates/ide_completion/src/completions/vis.rs
index 9cf9632658..c610dcd705 100644
--- a/crates/ide_completion/src/completions/vis.rs
+++ b/crates/ide_completion/src/completions/vis.rs
@@ -20,13 +20,14 @@ pub(crate) fn complete_vis(acc: &mut Completions, ctx: &CompletionContext) {
 
     match qualifier {
         Some(PathQualifierCtx { resolution, is_super_chain, .. }) => {
+            // Try completing next child module of the path that is still a parent of the current module
             if let Some(hir::PathResolution::Def(hir::ModuleDef::Module(module))) = resolution {
                 if let Some(current_module) = ctx.module {
                     let next_towards_current = current_module
                         .path_to_root(ctx.db)
                         .into_iter()
                         .take_while(|it| it != module)
-                        .next();
+                        .last();
                     if let Some(next) = next_towards_current {
                         if let Some(name) = next.name(ctx.db) {
                             cov_mark::hit!(visibility_qualified);


Test patch:
diff --git a/crates/ide_completion/src/tests/visibility.rs b/crates/ide_completion/src/tests/visibility.rs
index 2fd16235dc..970eb70719 100644
--- a/crates/ide_completion/src/tests/visibility.rs
+++ b/crates/ide_completion/src/tests/visibility.rs
@@ -55,6 +55,21 @@ mod bar {}
     );
     check(
         r#"
+mod qux {
+    mod foo {
+        pub(in crate::$0)
+    }
+    mod baz {}
+}
+
+mod bar {}
+"#,
+        expect![[r#"
+            md qux
+        "#]],
+    );
+    check(
+        r#"
 mod qux {
     mod foo {
         pub(in crate::qux::$0)
Repository: rust-analyzer/rust-analyzer
Pull request #11418 (2022-02-06 08:06:40)

fix: Update dependency, fix Markdown references
Stumbled across this accidentally while familiarizing myself with the code base.

Update `pulldown-cmark-to-cmark` Fix for #11008  


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 8457c43bb6..0ab9f89fd2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1245,9 +1245,9 @@ dependencies = [
 
 [[package]]
 name = "pulldown-cmark-to-cmark"
-version = "9.0.0"
+version = "10.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f94dc756ef5c50ad28ccea8428ba5de9f4dca1fff6516a26b85e0b125a70d17"
+checksum = "d1dd19382cbbcee6ce498f65d5acaa6016e41ec701c9b0aef29a689bd7062f88"
 dependencies = [
  "pulldown-cmark",
 ]
diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml
index 250673d3fe..1df2942bdc 100644
--- a/crates/ide/Cargo.toml
+++ b/crates/ide/Cargo.toml
@@ -17,7 +17,7 @@ itertools = "0.10.0"
 tracing = "0.1"
 rustc-hash = "1.1.0"
 oorandom = "11.1.2"
-pulldown-cmark-to-cmark = "9.0"
+pulldown-cmark-to-cmark = "10.0.0"
 pulldown-cmark = { version = "0.9", default-features = false }
 url = "2.1.1"
 dot = "0.1.4"
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index c8a645b032..00b33c834c 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -7,7 +7,7 @@ mod intra_doc_links;
 
 use either::Either;
 use pulldown_cmark::{BrokenLink, CowStr, Event, InlineStr, LinkType, Options, Parser, Tag};
-use pulldown_cmark_to_cmark::{cmark_with_options, Options as CMarkOptions};
+use pulldown_cmark_to_cmark::{cmark_resume_with_options, Options as CMarkOptions};
 use stdx::format_to;
 use url::Url;
 
@@ -61,7 +61,7 @@ pub(crate) fn rewrite_links(db: &RootDatabase, markdown: &str, definition: Defin
         }
     });
     let mut out = String::new();
-    cmark_with_options(
+    cmark_resume_with_options(
         doc,
         &mut out,
         None,
@@ -97,7 +97,7 @@ pub(crate) fn remove_links(markdown: &str) -> String {
     });
 
     let mut out = String::new();
-    cmark_with_options(
+    cmark_resume_with_options(
         doc,
         &mut out,
         None,


Test patch:
diff --git a/crates/ide/src/doc_links/tests.rs b/crates/ide/src/doc_links/tests.rs
index 27a70b18aa..477326c61f 100644
--- a/crates/ide/src/doc_links/tests.rs
+++ b/crates/ide/src/doc_links/tests.rs
@@ -394,7 +394,6 @@ pub struct $0Foo;
 "#,
         expect![[r#"[my Foo](https://docs.rs/foo/*/foo/struct.Foo.html)"#]],
     );
-    // FIXME #11008
     check_rewrite(
         r#"
 //- /main.rs crate:foo
@@ -403,9 +402,6 @@ pub struct $0Foo;
 /// [`foo`]: Foo
 pub struct $0Foo;
 "#,
-        expect![[r#"
-            [`foo`]
-
-            []: https://docs.rs/foo/*/foo/struct.Foo.html"#]],
+        expect![["[`foo`]"]],
     );
 }
Repository: rust-analyzer/rust-analyzer
Pull request #11552 (2022-02-25 17:40:50)

fix: properly display `$crate` in hovers
We used to print it as `{extern_crate}`, this PR resolves it to the crate's name, or falls back to `$crate` if the crate has no name.

bors r+


Patch:
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 0e75ddeabc..2020834fbc 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -1189,7 +1189,18 @@ impl HirDisplay for Path {
                     write!(f, "super")?;
                 }
             }
-            (_, PathKind::DollarCrate(_)) => write!(f, "{{extern_crate}}")?,
+            (_, PathKind::DollarCrate(id)) => {
+                // Resolve `$crate` to the crate's display name.
+                // FIXME: should use the dependency name instead if available, but that depends on
+                // the crate invoking `HirDisplay`
+                let crate_graph = f.db.crate_graph();
+                let name = crate_graph[*id]
+                    .display_name
+                    .as_ref()
+                    .map(|name| name.canonical_name())
+                    .unwrap_or("$crate");
+                write!(f, "{name}")?
+            }
         }
 
         for (seg_idx, segment) in self.segments().iter().enumerate() {


Test patch:
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index a232ebd4fb..df0ca941c9 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -4583,3 +4583,33 @@ pub struct Foo;
         "##]],
     );
 }
+
+#[test]
+fn hover_dollar_crate() {
+    // $crate should be resolved to the right crate name.
+
+    check(
+        r#"
+//- /main.rs crate:main deps:dep
+dep::m!(KONST$0);
+//- /dep.rs crate:dep
+#[macro_export]
+macro_rules! m {
+    ( $name:ident ) => { const $name: $crate::Type = $crate::Type; };
+}
+
+pub struct Type;
+"#,
+        expect![[r#"
+            *KONST*
+
+            ```rust
+            main
+            ```
+
+            ```rust
+            const KONST: dep::Type = $crate::Type
+            ```
+        "#]],
+    );
+}
Repository: rust-analyzer/rust-analyzer
Pull request #11622 (2022-03-04 21:46:17)

show variadic args in hover function signature
The current behavior is to ignore the ellipsis.


Patch:
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs
index d411b9d71b..b7ea42236e 100644
--- a/crates/hir/src/display.rs
+++ b/crates/hir/src/display.rs
@@ -86,6 +86,11 @@ impl HirDisplay for Function {
             // The former will ignore lifetime arguments currently.
             type_ref.hir_fmt(f)?;
         }
+
+        if data.is_varargs() {
+            write!(f, ", ...")?;
+        }
+
         write!(f, ")")?;
 
         // `FunctionData::ret_type` will be `::core::future::Future<Output = ...>` for async fns.


Test patch:
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 9d516fdd6f..e7fad48080 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -1757,6 +1757,30 @@ fn foo() { let bar = Bar; bar.fo$0o(); }
     );
 }
 
+#[test]
+fn test_hover_variadic_function() {
+    check(
+        r#"
+extern "C" {
+    pub fn foo(bar: i32, ...) -> i32;
+}
+
+fn main() { let foo_test = unsafe { fo$0o(1, 2, 3); } }
+"#,
+        expect![[r#"
+            *foo*
+
+            ```rust
+            test
+            ```
+
+            ```rust
+            pub unsafe fn foo(bar: i32, ...) -> i32
+            ```
+        "#]],
+    );
+}
+
 #[test]
 fn test_hover_trait_has_impl_action() {
     check_actions(
Repository: rust-analyzer/rust-analyzer
Pull request #11735 (2022-03-17 09:20:13)

Fix const generic panic, again
fix https://github.com/rust-analyzer/rust-analyzer/pull/11734#issuecomment-1070526085


Patch:
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 9e69785ac2..0854d06548 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -712,7 +712,7 @@ impl<'a> TyLoweringContext<'a> {
                 .filter(|arg| !matches!(arg, GenericArg::Lifetime(_)))
                 .skip(skip)
                 .take(expected_num)
-                .zip(def_generics.iter_id().skip(skip))
+                .zip(def_generics.iter_id().skip(parent_params + skip))
             {
                 if let Some(x) = generic_arg_to_chalk(
                     self.db,


Test patch:
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs
index 63faecbfaf..7a7470fd35 100644
--- a/crates/hir_ty/src/tests/regression.rs
+++ b/crates/hir_ty/src/tests/regression.rs
@@ -1454,3 +1454,26 @@ fn regression_11688_1() {
         "#,
     );
 }
+
+#[test]
+fn regression_11688_2() {
+    check_types(
+        r#"
+        union MaybeUninit<T> {
+            uninit: (),
+            value: T,
+        }
+
+        impl<T> MaybeUninit<T> {
+            fn uninit_array<const LEN: usize>() -> [Self; LEN] {
+                loop {}
+            }
+        }
+
+        fn main() {
+            let x = MaybeUninit::<i32>::uninit_array::<1>();
+              //^ [MaybeUninit<i32>; 1]
+        }
+        "#,
+    );
+}
Repository: rust-analyzer/rust-analyzer
Pull request #11753 (2022-03-18 14:37:45)

feat: Complete assoc const patterns on builtin types
followup to https://github.com/rust-analyzer/rust-analyzer/pull/11713

bors r+


Patch:
diff --git a/crates/ide_completion/src/completions/pattern.rs b/crates/ide_completion/src/completions/pattern.rs
index dac777a69b..0d3a49c668 100644
--- a/crates/ide_completion/src/completions/pattern.rs
+++ b/crates/ide_completion/src/completions/pattern.rs
@@ -141,7 +141,8 @@ fn pattern_path_completion(
                 | hir::PathResolution::SelfType(_)
                 | hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(_)))
                 | hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Enum(_)))
-                | hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Union(_)))) => {
+                | hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Union(_)))
+                | hir::PathResolution::Def(hir::ModuleDef::BuiltinType(_))) => {
                     let ty = match res {
                         hir::PathResolution::TypeParam(param) => param.ty(ctx.db),
                         hir::PathResolution::SelfType(impl_def) => impl_def.self_ty(ctx.db),
@@ -158,6 +159,13 @@ fn pattern_path_completion(
                         hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Union(u))) => {
                             u.ty(ctx.db)
                         }
+                        hir::PathResolution::Def(hir::ModuleDef::BuiltinType(ty)) => {
+                            let module = match ctx.module {
+                                Some(m) => m,
+                                None => return,
+                            };
+                            ty.ty(ctx.db, module)
+                        }
                         _ => return,
                     };
 


Test patch:
diff --git a/crates/ide_completion/src/tests/pattern.rs b/crates/ide_completion/src/tests/pattern.rs
index b2740d26ce..405a128b7e 100644
--- a/crates/ide_completion/src/tests/pattern.rs
+++ b/crates/ide_completion/src/tests/pattern.rs
@@ -493,7 +493,6 @@ fn f(e: MyEnum) {
 
     check_empty(
         r#"
-#[repr(C)]
 union U {
     i: i32,
     f: f32,
@@ -515,5 +514,23 @@ fn f(u: U) {
             ct C pub const C: i32
             ct D pub const D: i32
         "#]],
-    )
+    );
+
+    check_empty(
+        r#"
+#[lang = "u32"]
+impl u32 {
+    pub const MIN: Self = 0;
+}
+
+fn f(v: u32) {
+    match v {
+        u32::$0
+    }
+}
+        "#,
+        expect![[r#"
+            ct MIN pub const MIN: Self
+        "#]],
+    );
 }