nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: rust-lang/rust-analyzer
Pull request #15173 (2023-06-29 20:10:03)

Fix data layout of reference to nested unsized structs


Patch:
diff --git a/crates/hir-ty/src/layout.rs b/crates/hir-ty/src/layout.rs
index 35d3407c16..a566c06a54 100644
--- a/crates/hir-ty/src/layout.rs
+++ b/crates/hir-ty/src/layout.rs
@@ -315,7 +315,10 @@ fn struct_tail_erasing_lifetimes(db: &dyn HirDatabase, pointee: Ty) -> Ty {
             let data = db.struct_data(*i);
             let mut it = data.variant_data.fields().iter().rev();
             match it.next() {
-                Some((f, _)) => field_ty(db, (*i).into(), f, subst),
+                Some((f, _)) => {
+                    let last_field_ty = field_ty(db, (*i).into(), f, subst);
+                    struct_tail_erasing_lifetimes(db, last_field_ty)
+                }
                 None => pointee,
             }
         }


Test patch:
diff --git a/crates/hir-ty/src/consteval/tests.rs b/crates/hir-ty/src/consteval/tests.rs
index de3a947f35..e50dfdf965 100644
--- a/crates/hir-ty/src/consteval/tests.rs
+++ b/crates/hir-ty/src/consteval/tests.rs
@@ -2490,6 +2490,37 @@ fn type_error() {
     );
 }
 
+#[test]
+fn unsized_field() {
+    check_number(
+        r#"
+    //- minicore: coerce_unsized, index, slice, transmute
+    use core::mem::transmute;
+
+    struct Slice([u8]);
+    struct Slice2(Slice);
+
+    impl Slice2 {
+        fn as_inner(&self) -> &Slice {
+            &self.0
+        }
+
+        fn as_bytes(&self) -> &[u8] {
+            &self.as_inner().0
+        }
+    }
+
+    const GOAL: u8 = unsafe {
+        let x: &[u8] = &[1, 2, 3];
+        let x: &Slice2 = transmute(x);
+        let x = x.as_bytes();
+        x[0] + x[1] + x[2]
+    };
+        "#,
+        6,
+    );
+}
+
 #[test]
 fn unsized_local() {
     check_fail(
diff --git a/crates/hir-ty/src/layout/tests.rs b/crates/hir-ty/src/layout/tests.rs
index b75f213df2..0257aef7a4 100644
--- a/crates/hir-ty/src/layout/tests.rs
+++ b/crates/hir-ty/src/layout/tests.rs
@@ -343,6 +343,24 @@ fn return_position_impl_trait() {
     }
 }
 
+#[test]
+fn unsized_ref() {
+    size_and_align! {
+        struct S1([u8]);
+        struct S2(S1);
+        struct S3(i32, str);
+        struct S4(u64, S3);
+        #[allow(dead_code)]
+        struct S5 {
+            field1: u8,
+            field2: i16,
+            field_last: S4,
+        }
+
+        struct Goal(&'static S1, &'static S2, &'static S3, &'static S4, &'static S5);
+    }
+}
+
 #[test]
 fn enums() {
     size_and_align! {
Repository: rust-lang/rust-analyzer
Pull request #15189 (2023-07-01 13:47:22)

Fix overflow checking in shift operator


Patch:
diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs
index dd23f1957c..1c52882072 100644
--- a/crates/hir-ty/src/mir/eval.rs
+++ b/crates/hir-ty/src/mir/eval.rs
@@ -1037,13 +1037,18 @@ impl Evaluator<'_> {
                                         BinOp::Shr => l128.checked_shr(shift_amount),
                                         _ => unreachable!(),
                                     };
+                                    if shift_amount as usize >= lc.len() * 8 {
+                                        return Err(MirEvalError::Panic(format!(
+                                            "Overflow in {op:?}"
+                                        )));
+                                    }
                                     if let Some(r) = r {
                                         break 'b r;
                                     }
                                 };
                                 return Err(MirEvalError::Panic(format!("Overflow in {op:?}")));
                             };
-                            check_overflow(r)?
+                            Owned(r.to_le_bytes()[..lc.len()].to_vec())
                         }
                         BinOp::Offset => not_supported!("offset binop"),
                     }


Test patch:
diff --git a/crates/hir-ty/src/consteval/tests.rs b/crates/hir-ty/src/consteval/tests.rs
index e50dfdf965..9baedc3fb7 100644
--- a/crates/hir-ty/src/consteval/tests.rs
+++ b/crates/hir-ty/src/consteval/tests.rs
@@ -108,6 +108,7 @@ fn bit_op() {
     check_fail(r#"const GOAL: i8 = 1 << 8"#, |e| {
         e == ConstEvalError::MirEvalError(MirEvalError::Panic("Overflow in Shl".to_string()))
     });
+    check_number(r#"const GOAL: i32 = 100000000i32 << 11"#, (100000000i32 << 11) as i128);
 }
 
 #[test]
Repository: rust-lang/rust-analyzer
Pull request #15244 (2023-07-09 19:48:38)

Support read_via_copy intrinsic


Patch:
diff --git a/crates/hir-ty/src/mir/eval/shim.rs b/crates/hir-ty/src/mir/eval/shim.rs
index 6cdf9f03c9..8f22bb3656 100644
--- a/crates/hir-ty/src/mir/eval/shim.rs
+++ b/crates/hir-ty/src/mir/eval/shim.rs
@@ -888,6 +888,13 @@ impl Evaluator<'_> {
                 }
                 not_supported!("FnOnce was not available for executing const_eval_select");
             }
+            "read_via_copy" | "volatile_load" => {
+                let [arg] = args else {
+                    return Err(MirEvalError::TypeError("read_via_copy args are not provided"));
+                };
+                let addr = Address::from_bytes(arg.interval.get(self)?)?;
+                destination.write_from_interval(self, Interval { addr, size: destination.size })
+            }
             _ => not_supported!("unknown intrinsic {name}"),
         }
     }


Test patch:
diff --git a/crates/hir-ty/src/consteval/tests/intrinsics.rs b/crates/hir-ty/src/consteval/tests/intrinsics.rs
index b74133e24f..89f3a6d490 100644
--- a/crates/hir-ty/src/consteval/tests/intrinsics.rs
+++ b/crates/hir-ty/src/consteval/tests/intrinsics.rs
@@ -163,6 +163,24 @@ fn transmute() {
     );
 }
 
+#[test]
+fn read_via_copy() {
+    check_number(
+        r#"
+        extern "rust-intrinsic" {
+            pub fn read_via_copy<T>(e: *const T) -> T;
+            pub fn volatile_load<T>(e: *const T) -> T;
+        }
+
+        const GOAL: i32 = {
+            let x = 2;
+            read_via_copy(&x) + volatile_load(&x)
+        };
+        "#,
+        4,
+    );
+}
+
 #[test]
 fn const_eval_select() {
     check_number(
Repository: conda-incubator/grayskull
Pull request #258 (2021-11-03 18:41:38)

fix a few typos
One of those is in a variable, hopefully I did not break anything.

marcelotrevisani: lol, I didn't pay attention to that :smile:  , what a mistake :facepalm: 
thanks for fixing it! :)

Patch:
diff --git a/grayskull/__main__.py b/grayskull/__main__.py
index a0f853c..3d3d148 100644
--- a/grayskull/__main__.py
+++ b/grayskull/__main__.py
@@ -132,7 +132,7 @@ def main(args=None):
                 f"{Fore.RED}Package seems to be missing on pypi.\nException: {err}\n\n"
             )
             continue
-        recipe.generate_recipe(args.output, mantainers=args.maintainers)
+        recipe.generate_recipe(args.output, maintainers=args.maintainers)
         print_msg(
             f"\n{Fore.GREEN}#### Recipe generated on "
             f"{os.path.realpath(args.output)} for {pkg_name} ####\n"
diff --git a/grayskull/base/base_recipe.py b/grayskull/base/base_recipe.py
index fb3777c..ff0a920 100644
--- a/grayskull/base/base_recipe.py
+++ b/grayskull/base/base_recipe.py
@@ -171,7 +171,7 @@ class AbstractRecipeModel(ABC):
     def generate_recipe(
         self,
         folder_path: Union[str, Path] = ".",
-        mantainers: Optional[List] = None,
+        maintainers: Optional[List] = None,
         disable_extra: bool = False,
     ):
         """Write the recipe in a location. It will create a folder with the
@@ -189,7 +189,7 @@ class AbstractRecipeModel(ABC):
         recipe_path = recipe_dir / "meta.yaml"
 
         if not disable_extra:
-            self._add_extra_section(mantainers)
+            self._add_extra_section(maintainers)
 
         with recipe_path.open("w") as recipe:
             yaml.dump(self.get_clean_yaml(self._yaml), recipe)
diff --git a/grayskull/pypi/pypi.py b/grayskull/pypi/pypi.py
index f394b06..9d71576 100644
--- a/grayskull/pypi/pypi.py
+++ b/grayskull/pypi/pypi.py
@@ -768,7 +768,7 @@ class PyPi(AbstractRecipeModel):
         right license for the package
 
         :param metadata: metadata
-        :return: Return an object which contains relevant informations regarding
+        :return: Return an object which contains relevant information regarding
         the license.
         """
         git_url = metadata.get("dev_url", None)


Test patch:
diff --git a/tests/base/test_base_recipe.py b/tests/base/test_base_recipe.py
index 67db445..8df1d7d 100644
--- a/tests/base/test_base_recipe.py
+++ b/tests/base/test_base_recipe.py
@@ -45,7 +45,7 @@ def test_refresh_section(data_recipes):
 def test_generate_recipe(tmpdir, data_recipes):
     recipe = EmptyGray(name="pkg1", version="1.0.0")
     recipe.update_all_recipe()
-    recipe.generate_recipe(tmpdir, mantainers=["marcelotrevisani"])
+    recipe.generate_recipe(tmpdir, maintainers=["marcelotrevisani"])
 
     with open(tmpdir / "pkg1" / "meta.yaml") as recipe_file:
         generated_recipe = recipe_file.read()
Repository: rust-lang/rust-analyzer
Pull request #15312 (2023-07-19 17:50:02)

Don't follow raw pointer derefs when considering method receiver candidates
In https://github.com/rust-lang/rust-analyzer/pull/15118, I enabled following raw pointer derefs when considering self type candidates. However, I also inadvertently enabled it for receiver type candidates, which is invalid and causes false positives (see new test).




Patch:
diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs
index 5e1040bc6a..bc65fd5bac 100644
--- a/crates/hir-ty/src/method_resolution.rs
+++ b/crates/hir-ty/src/method_resolution.rs
@@ -1504,7 +1504,7 @@ fn autoderef_method_receiver(
     ty: Ty,
 ) -> Vec<(Canonical<Ty>, ReceiverAdjustments)> {
     let mut deref_chain: Vec<_> = Vec::new();
-    let mut autoderef = autoderef::Autoderef::new(table, ty, true);
+    let mut autoderef = autoderef::Autoderef::new(table, ty, false);
     while let Some((ty, derefs)) = autoderef.next() {
         deref_chain.push((
             autoderef.table.canonicalize(ty).value,


Test patch:
diff --git a/crates/hir-ty/src/tests/method_resolution.rs b/crates/hir-ty/src/tests/method_resolution.rs
index a8e146b096..c837fae3fe 100644
--- a/crates/hir-ty/src/tests/method_resolution.rs
+++ b/crates/hir-ty/src/tests/method_resolution.rs
@@ -1236,6 +1236,27 @@ fn main() {
     );
 }
 
+#[test]
+fn inherent_method_ref_self_deref_raw() {
+    check_types(
+        r#"
+struct Val;
+
+impl Val {
+    pub fn method(&self) -> u32 {
+        0
+    }
+}
+
+fn main() {
+    let foo: *const Val;
+    foo.method();
+ // ^^^^^^^^^^^^ {unknown}
+}
+"#,
+    );
+}
+
 #[test]
 fn trait_method_deref_raw() {
     check_types(