nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: lambda-fairy/maud
Pull request #317 (2021-11-07 12:27:56)

Update slash error message to point to #315


Patch:
diff --git a/maud_macros/src/parse.rs b/maud_macros/src/parse.rs
index a20bc31..dee037e 100644
--- a/maud_macros/src/parse.rs
+++ b/maud_macros/src/parse.rs
@@ -543,7 +543,7 @@ impl Parser {
                         punct,
                         "void elements must use `;`, not `/`";
                         help = "change this to `;`";
-                        help = "see https://github.com/lambda-fairy/maud/pull/96 for details";
+                        help = "see https://github.com/lambda-fairy/maud/pull/315 for details";
                     );
                 }
                 ast::ElementBody::Void {


Test patch:
diff --git a/maud/tests/warnings/void-element-slash.stderr b/maud/tests/warnings/void-element-slash.stderr
index 7d28413..eb0f6d3 100644
--- a/maud/tests/warnings/void-element-slash.stderr
+++ b/maud/tests/warnings/void-element-slash.stderr
@@ -5,7 +5,7 @@ error: void elements must use `;`, not `/`
   |            ^
   |
   = help: change this to `;`
-  = help: see https://github.com/lambda-fairy/maud/pull/96 for details
+  = help: see https://github.com/lambda-fairy/maud/pull/315 for details
 
 error: void elements must use `;`, not `/`
  --> $DIR/void-element-slash.rs:7:27
@@ -14,4 +14,4 @@ error: void elements must use `;`, not `/`
   |                           ^
   |
   = help: change this to `;`
-  = help: see https://github.com/lambda-fairy/maud/pull/96 for details
+  = help: see https://github.com/lambda-fairy/maud/pull/315 for details
Repository: rust-analyzer/rust-analyzer
Pull request #452 (2019-01-07 20:31:06)

Process explicit type hints for str, bool and char


Patch:
diff --git a/crates/ra_hir/src/name.rs b/crates/ra_hir/src/name.rs
index 90229bc540..5992853467 100644
--- a/crates/ra_hir/src/name.rs
+++ b/crates/ra_hir/src/name.rs
@@ -59,6 +59,9 @@ impl Name {
             "u128" => KnownName::U128,
             "f32" => KnownName::F32,
             "f64" => KnownName::F64,
+            "bool" => KnownName::Bool,
+            "char" => KnownName::Char,
+            "str" => KnownName::Str,
             "Self" => KnownName::SelfType,
             "self" => KnownName::SelfParam,
             _ => return None,
@@ -113,6 +116,10 @@ pub(crate) enum KnownName {
     F32,
     F64,
 
+    Bool,
+    Char,
+    Str,
+
     SelfType,
     SelfParam,
 }
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 7827e82c4d..8adeedddb3 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -308,7 +308,13 @@ impl Ty {
         path: &Path,
     ) -> Cancelable<Self> {
         if let Some(name) = path.as_ident() {
-            if let Some(int_ty) = primitive::IntTy::from_name(name) {
+            if let Some(KnownName::Bool) = name.as_known_name() {
+                return Ok(Ty::Bool);
+            } else if let Some(KnownName::Char) = name.as_known_name() {
+                return Ok(Ty::Char);
+            } else if let Some(KnownName::Str) = name.as_known_name() {
+                return Ok(Ty::Str);
+            } else if let Some(int_ty) = primitive::IntTy::from_name(name) {
                 return Ok(Ty::Int(int_ty));
             } else if let Some(uint_ty) = primitive::UintTy::from_name(name) {
                 return Ok(Ty::Uint(uint_ty));


Test patch:
diff --git a/crates/ra_hir/src/ty/tests/data/basics.txt b/crates/ra_hir/src/ty/tests/data/basics.txt
index 8ea244ba87..ac7faae0ac 100644
--- a/crates/ra_hir/src/ty/tests/data/basics.txt
+++ b/crates/ra_hir/src/ty/tests/data/basics.txt
@@ -1,12 +1,12 @@
 [9; 10) 'a': u32
 [17; 18) 'b': isize
 [27; 28) 'c': !
-[33; 34) 'd': &[unknown]
+[33; 34) 'd': &str
 [42; 121) '{     ...f32; }': ()
 [48; 49) 'a': u32
 [55; 56) 'b': isize
 [62; 63) 'c': !
-[69; 70) 'd': &[unknown]
+[69; 70) 'd': &str
 [76; 82) '1usize': [unknown]
 [88; 94) '1isize': [unknown]
 [100; 106) '"test"': [unknown]
diff --git a/crates/ra_hir/src/ty/tests/data/binary_op.txt b/crates/ra_hir/src/ty/tests/data/binary_op.txt
index 59c07ff434..0fb9dc0976 100644
--- a/crates/ra_hir/src/ty/tests/data/binary_op.txt
+++ b/crates/ra_hir/src/ty/tests/data/binary_op.txt
@@ -1,4 +1,4 @@
-[6; 7) 'x': [unknown]
+[6; 7) 'x': bool
 [22; 34) '{     0i32 }': i32
 [28; 32) '0i32': i32
 [46; 342) '{     ... < 3 }': bool
@@ -22,7 +22,7 @@
 [166; 188) 'minus_...ONST_2': bool
 [181; 188) 'CONST_2': isize
 [198; 199) 'c': i32
-[202; 203) 'f': fn([unknown],) -> i32
+[202; 203) 'f': fn(bool,) -> i32
 [202; 211) 'f(z || y)': i32
 [202; 215) 'f(z || y) + 5': i32
 [204; 205) 'z': bool
Repository: rust-analyzer/rust-analyzer
Pull request #579 (2019-01-20 17:10:07)

Fix panic on inferring field access on an enum
Seen while skipping through https://youtu.be/ANKBNiSWyfc ;)


Patch:
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 9b71824859..c602450e1c 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -688,9 +688,13 @@ pub(super) fn type_for_field(db: &impl HirDatabase, def_id: DefId, field: Name)
         Def::Struct(s) => (s.variant_data(db), s.generic_params(db)),
         Def::EnumVariant(ev) => (ev.variant_data(db), ev.parent_enum(db).generic_params(db)),
         // TODO: unions
+        Def::Enum(_) => {
+            // this can happen in (invalid) code, but enums don't have fields themselves
+            return None;
+        }
         _ => panic!(
-            "trying to get type for field in non-struct/variant {:?}",
-            def_id
+            "trying to get type for field {:?} in non-struct/variant {:?}",
+            field, def_id
         ),
     };
     let module = def_id.module(db);


Test patch:
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 06e32df597..5aa24a29bf 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -507,6 +507,20 @@ fn test() -> i128 {
     );
 }
 
+#[test]
+fn no_panic_on_field_of_enum() {
+    check_inference(
+        r#"
+enum X {}
+
+fn test(x: X) {
+    x.some_field;
+}
+"#,
+        "no_panic_on_field_of_enum.txt",
+    );
+}
+
 fn infer(content: &str) -> String {
     let (db, _, file_id) = MockDatabase::with_single_file(content);
     let source_file = db.source_file(file_id);
diff --git a/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt b/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt
new file mode 100644
index 0000000000..4dca0b7f44
--- /dev/null
+++ b/crates/ra_hir/src/ty/tests/data/no_panic_on_field_of_enum.txt
@@ -0,0 +1,4 @@
+[20; 21) 'x': X
+[26; 47) '{     ...eld; }': ()
+[32; 33) 'x': X
+[32; 44) 'x.some_field': [unknown]