From 0d2328f3eaf69c6a50fe6c1e946257bd3503d751 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 5 Jun 2020 17:41:58 +0200 Subject: Review fixes --- crates/ra_hir_ty/src/tests/traits.rs | 73 ++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 15 deletions(-) (limited to 'crates/ra_hir_ty/src/tests') diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index d83dc6d79..0c538a62d 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs @@ -1160,7 +1160,37 @@ fn test(x: impl Trait, y: &impl Trait) { } #[test] -fn return_pos_impl_trait() { +fn simple_return_pos_impl_trait() { + mark::check!(lower_rpit); + assert_snapshot!( + infer(r#" +trait Trait { + fn foo(&self) -> T; +} +fn bar() -> impl Trait { loop {} } + +fn test() { + let a = bar(); + a.foo(); +} +"#), + @r###" + 30..34 'self': &Self + 72..83 '{ loop {} }': ! + 74..81 'loop {}': ! + 79..81 '{}': () + 95..130 '{ ...o(); }': () + 105..106 'a': impl Trait + 109..112 'bar': fn bar() -> impl Trait + 109..114 'bar()': impl Trait + 120..121 'a': impl Trait + 120..127 'a.foo()': u64 + "### + ); +} + +#[test] +fn more_return_pos_impl_trait() { assert_snapshot!( infer(r#" trait Iterator { @@ -1174,12 +1204,12 @@ fn bar() -> (impl Iterator>, impl Trait) { loop {} } fn baz(t: T) -> (impl Iterator>, impl Trait) { loop {} } fn test() { - // let (a, b) = bar(); - // a.next().foo(); - // b.foo(); + let (a, b) = bar(); + a.next().foo(); + b.foo(); let (c, d) = baz(1u128); - c.next();//.foo(); - // d.foo(); + c.next().foo(); + d.foo(); } "#), @r###" @@ -1192,15 +1222,28 @@ fn test() { 269..280 '{ loop {} }': ({unknown}, {unknown}) 271..278 'loop {}': ! 276..278 '{}': () - 292..429 '{ ...o(); }': () - 368..374 '(c, d)': (impl Iterator>, impl Trait) - 369..370 'c': impl Iterator> - 372..373 'd': impl Trait - 377..380 'baz': fn baz(u128) -> (impl Iterator>, impl Trait) - 377..387 'baz(1u128)': (impl Iterator>, impl Trait) - 381..386 '1u128': u128 - 393..394 'c': impl Iterator> - 393..401 'c.next()': impl Trait + 292..414 '{ ...o(); }': () + 302..308 '(a, b)': (impl Iterator>, impl Trait) + 303..304 'a': impl Iterator> + 306..307 'b': impl Trait + 311..314 'bar': fn bar() -> (impl Iterator>, impl Trait) + 311..316 'bar()': (impl Iterator>, impl Trait) + 322..323 'a': impl Iterator> + 322..330 'a.next()': impl Trait + 322..336 'a.next().foo()': u32 + 342..343 'b': impl Trait + 342..349 'b.foo()': u64 + 359..365 '(c, d)': (impl Iterator>, impl Trait) + 360..361 'c': impl Iterator> + 363..364 'd': impl Trait + 368..371 'baz': fn baz(u128) -> (impl Iterator>, impl Trait) + 368..378 'baz(1u128)': (impl Iterator>, impl Trait) + 372..377 '1u128': u128 + 384..385 'c': impl Iterator> + 384..392 'c.next()': impl Trait + 384..398 'c.next().foo()': u128 + 404..405 'd': impl Trait + 404..411 'd.foo()': u128 "### ); } -- cgit v1.2.3