From 367487fe88dca78cffad5138673d5259f7f7ba6b Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 28 May 2020 21:42:22 +0200 Subject: Support raw_ref_op's raw reference operator --- crates/ra_hir_ty/src/tests/simple.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'crates/ra_hir_ty/src/tests/simple.rs') diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index fd2208af2..f1db34160 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -384,6 +384,26 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { ); } +#[test] +fn infer_raw_ref() { + assert_snapshot!( + infer(r#" +fn test(a: i32) { + &raw mut a; + &raw const a; +} +"#), + @r###" + 9..10 'a': i32 + 17..54 '{ ...t a; }': () + 23..33 '&raw mut a': *mut i32 + 32..33 'a': i32 + 39..51 '&raw const a': *const i32 + 50..51 'a': i32 + "### + ); +} + #[test] fn infer_literals() { assert_snapshot!( -- cgit v1.2.3 From 7d0586cb15000193941f93d4b5281e56ef751edd Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 29 May 2020 16:03:06 +0200 Subject: Use first match branch in case of type mismatch, not last The comment says this was intentional, but I do agree with #4304 that it makes more sense the other way around (for if/else as well). Fixes #4304. --- crates/ra_hir_ty/src/tests/simple.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir_ty/src/tests/simple.rs') diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index fd2208af2..daa9cc953 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -937,7 +937,7 @@ fn main(foo: Foo) { 51..107 'if tru... }': () 54..58 'true': bool 59..67 '{ }': () - 73..107 'if fal... }': () + 73..107 'if fal... }': i32 76..81 'false': bool 82..107 '{ ... }': i32 92..95 'foo': Foo -- cgit v1.2.3 From fb469c3b31e7da962e91269b53b2f53d672cc4ba Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 30 May 2020 02:06:58 +0200 Subject: labelled break test --- crates/ra_hir_ty/src/tests/simple.rs | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'crates/ra_hir_ty/src/tests/simple.rs') diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index 839491b9e..beceb8634 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -1943,3 +1943,57 @@ fn test() { "### ); } + +#[test] +fn infer_labelled_break_with_val() { + assert_snapshot!( + infer(r#" +fn foo() { + let _x = || 'outer: loop { + let inner = 'inner: loop { + let i = Default::default(); + if (break 'outer i) { + loop { break 'inner 5i8; }; + } else if true { + break 'inner 6; + } + break 7; + }; + break inner < 8; + }; +} +"#), + @r###" + 10..336 '{ ... }; }': () + 20..22 '_x': || -> bool + 25..333 '|| 'ou... }': || -> bool + 28..333 ''outer... }': bool + 41..333 '{ ... }': () + 55..60 'inner': i32 + 63..301 ''inner... }': i32 + 76..301 '{ ... }': () + 94..95 'i': i32 + 98..114 'Defaul...efault': {unknown} + 98..116 'Defaul...ault()': i32 + 130..270 'if (br... }': () + 134..148 'break 'outer i': ! + 147..148 'i': i32 + 150..209 '{ ... }': () + 168..194 'loop {...5i8; }': i8 + 173..194 '{ brea...5i8; }': () + 175..191 'break ...er 5i8': ! + 188..191 '5i8': i8 + 215..270 'if tru... }': () + 218..222 'true': bool + 223..270 '{ ... }': () + 241..255 'break 'inner 6': ! + 254..255 '6': i32 + 283..290 'break 7': ! + 289..290 '7': i32 + 311..326 'break inner < 8': ! + 317..322 'inner': i32 + 317..326 'inner < 8': bool + 325..326 '8': i32 + "### + ); +} -- cgit v1.2.3 From 1cd78a3355ea70d3070cabb00c80a5d195499752 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 31 May 2020 10:59:40 +0200 Subject: correctly infer labelled breaks --- crates/ra_hir_ty/src/tests/simple.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/ra_hir_ty/src/tests/simple.rs') diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index beceb8634..88309157b 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -1969,17 +1969,17 @@ fn foo() { 25..333 '|| 'ou... }': || -> bool 28..333 ''outer... }': bool 41..333 '{ ... }': () - 55..60 'inner': i32 - 63..301 ''inner... }': i32 + 55..60 'inner': i8 + 63..301 ''inner... }': i8 76..301 '{ ... }': () - 94..95 'i': i32 + 94..95 'i': bool 98..114 'Defaul...efault': {unknown} - 98..116 'Defaul...ault()': i32 + 98..116 'Defaul...ault()': bool 130..270 'if (br... }': () 134..148 'break 'outer i': ! - 147..148 'i': i32 + 147..148 'i': bool 150..209 '{ ... }': () - 168..194 'loop {...5i8; }': i8 + 168..194 'loop {...5i8; }': ! 173..194 '{ brea...5i8; }': () 175..191 'break ...er 5i8': ! 188..191 '5i8': i8 @@ -1987,13 +1987,13 @@ fn foo() { 218..222 'true': bool 223..270 '{ ... }': () 241..255 'break 'inner 6': ! - 254..255 '6': i32 + 254..255 '6': i8 283..290 'break 7': ! - 289..290 '7': i32 + 289..290 '7': i8 311..326 'break inner < 8': ! - 317..322 'inner': i32 + 317..322 'inner': i8 317..326 'inner < 8': bool - 325..326 '8': i32 + 325..326 '8': i8 "### ); } -- cgit v1.2.3