From ab28f6c24909f2424c6f1d85d1518fa4269fbaae Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 29 May 2020 16:49:52 +0200 Subject: [PATCH] Upgrade Chalk Fixes #4072. --- Cargo.lock | 20 +++-------- crates/ra_hir_ty/Cargo.toml | 4 +-- crates/ra_hir_ty/src/tests/traits.rs | 54 +++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1159d0f1d5..def4ed45e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,18 +111,10 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -[[package]] -name = "chalk-base" -version = "0.10.1-dev" -source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb" -dependencies = [ - "lazy_static", -] - [[package]] name = "chalk-derive" version = "0.10.1-dev" -source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb" +source = "git+https://github.com/rust-lang/chalk.git?rev=329b7f3fdd2431ed6f6778cde53f22374c7d094c#329b7f3fdd2431ed6f6778cde53f22374c7d094c" dependencies = [ "proc-macro2", "quote", @@ -133,9 +125,8 @@ dependencies = [ [[package]] name = "chalk-engine" version = "0.10.1-dev" -source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb" +source = "git+https://github.com/rust-lang/chalk.git?rev=329b7f3fdd2431ed6f6778cde53f22374c7d094c#329b7f3fdd2431ed6f6778cde53f22374c7d094c" dependencies = [ - "chalk-base", "chalk-derive", "chalk-ir", "rustc-hash", @@ -144,18 +135,17 @@ dependencies = [ [[package]] name = "chalk-ir" version = "0.10.1-dev" -source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb" +source = "git+https://github.com/rust-lang/chalk.git?rev=329b7f3fdd2431ed6f6778cde53f22374c7d094c#329b7f3fdd2431ed6f6778cde53f22374c7d094c" dependencies = [ - "chalk-base", "chalk-derive", + "lazy_static", ] [[package]] name = "chalk-solve" version = "0.10.1-dev" -source = "git+https://github.com/rust-lang/chalk.git?rev=5a3b871ca17529ab5aa5787594fabad1634936cb#5a3b871ca17529ab5aa5787594fabad1634936cb" +source = "git+https://github.com/rust-lang/chalk.git?rev=329b7f3fdd2431ed6f6778cde53f22374c7d094c#329b7f3fdd2431ed6f6778cde53f22374c7d094c" dependencies = [ - "chalk-base", "chalk-derive", "chalk-engine", "chalk-ir", diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 6afed58a11..4b8dcdc07f 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -27,8 +27,8 @@ test_utils = { path = "../test_utils" } scoped-tls = "1" -chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "5a3b871ca17529ab5aa5787594fabad1634936cb" } -chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "5a3b871ca17529ab5aa5787594fabad1634936cb" } +chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "329b7f3fdd2431ed6f6778cde53f22374c7d094c" } +chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "329b7f3fdd2431ed6f6778cde53f22374c7d094c" } [dev-dependencies] insta = "0.16.0" diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 0419bc751b..e8778d419b 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"); +}