From 4c4a714328490d7f2626272663827fd51dfab0bd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Mar 2019 11:39:47 +0300 Subject: test diagnostics --- crates/ra_hir/src/ty/tests.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'crates/ra_hir/src/ty/tests.rs') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 5d8ad4aa7..3aedba243 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -2319,3 +2319,27 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() { assert!(!format!("{:?}", events).contains("infer"), "{:#?}", events) } } + +#[test] +fn no_such_field_diagnostics() { + let diagnostics = MockDatabase::with_files( + r" + //- /lib.rs + struct S { foo: i32, bar: () } + impl S { + fn new() -> S { + S { + foo: 92, + baz: 62, + } + } + } + ", + ) + .diagnostics(); + + assert_snapshot_matches!(diagnostics, @r###" +"baz: 62": no such field +"### + ); +} -- cgit v1.2.3 From c947c15ce1ec02261803f10568e4659e9396109e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 24 Mar 2019 17:36:15 +0100 Subject: Basics for trait method resolution --- crates/ra_hir/src/ty/tests.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/ty/tests.rs') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 3aedba243..971043266 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -1272,8 +1272,8 @@ fn test() { [241; 252) 'Struct::FOO': u32 [262; 263) 'y': u32 [266; 275) 'Enum::BAR': u32 -[285; 286) 'z': u32 -[289; 302) 'TraitTest::ID': u32"### +[285; 286) 'z': {unknown} +[289; 302) 'TraitTest::ID': {unknown}"### ); } @@ -1918,9 +1918,9 @@ fn test() { [110; 114) 'self': &{unknown} [170; 228) '{ ...i128 }': () [176; 178) 'S1': S1 -[176; 187) 'S1.method()': {unknown} +[176; 187) 'S1.method()': u32 [203; 205) 'S2': S2 -[203; 214) 'S2.method()': {unknown}"### +[203; 214) 'S2.method()': u32"### ); } @@ -1964,10 +1964,10 @@ mod bar_test { [169; 173) 'self': &{unknown} [300; 337) '{ ... }': () [310; 311) 'S': S -[310; 320) 'S.method()': {unknown} +[310; 320) 'S.method()': u32 [416; 454) '{ ... }': () [426; 427) 'S': S -[426; 436) 'S.method()': {unknown}"### +[426; 436) 'S.method()': i128"### ); } -- cgit v1.2.3 From 0f7e4a7d2440e7e13a5cdf7e91f262426f0d0d18 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 24 Mar 2019 17:37:27 +0100 Subject: Implement a very naive implements check ... to make the infer_trait_method_simple test have the correct result. --- crates/ra_hir/src/ty/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir/src/ty/tests.rs') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 971043266..655f3c522 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -1920,7 +1920,7 @@ fn test() { [176; 178) 'S1': S1 [176; 187) 'S1.method()': u32 [203; 205) 'S2': S2 -[203; 214) 'S2.method()': u32"### +[203; 214) 'S2.method()': i128"### ); } -- cgit v1.2.3