From ab28f6c24909f2424c6f1d85d1518fa4269fbaae Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 29 May 2020 16:49:52 +0200 Subject: Upgrade Chalk Fixes #4072. --- crates/ra_hir_ty/src/tests/traits.rs | 54 ++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 0419bc751..e8778d419 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs @@ -2665,7 +2665,6 @@ fn test() { Enum::Variant.test(); } "#, true), - // wrong result, because the built-in Copy impl for fn defs doesn't exist in Chalk yet @r###" 42..44 '{}': () 61..62 'T': {unknown} @@ -2674,13 +2673,13 @@ fn test() { 146..150 'self': &Self 202..282 '{ ...t(); }': () 208..211 'foo': fn foo() - 208..218 'foo.test()': {unknown} + 208..218 'foo.test()': bool 224..227 'bar': fn bar<{unknown}>({unknown}) -> {unknown} - 224..234 'bar.test()': {unknown} + 224..234 'bar.test()': bool 240..246 'Struct': Struct(usize) -> Struct - 240..253 'Struct.test()': {unknown} + 240..253 'Struct.test()': bool 259..272 'Enum::Variant': Variant(usize) -> Enum - 259..279 'Enum::...test()': {unknown} + 259..279 'Enum::...test()': bool "### ); } @@ -2754,3 +2753,48 @@ fn test() { "### ); } + +#[test] +fn integer_range_iterate() { + let t = type_at( + r#" +//- /main.rs crate:main deps:std +fn test() { + for x in 0..100 { x<|>; } +} + +//- /std.rs crate:std +pub mod ops { + pub struct Range { + pub start: Idx, + pub end: Idx, + } +} + +pub mod iter { + pub trait Iterator { + type Item; + } + + pub trait IntoIterator { + type Item; + type IntoIter: Iterator; + } + + impl IntoIterator for T where T: Iterator { + type Item = ::Item; + type IntoIter = Self; + } +} + +trait Step {} +impl Step for i32 {} +impl Step for i64 {} + +impl iter::Iterator for ops::Range { + type Item = A; +} +"#, + ); + assert_eq!(t, "i32"); +} -- cgit v1.2.3