From 9c2a9a9a0635e53466749fdedcdc5a371e658cde Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 15 Nov 2019 21:00:27 +0100 Subject: Use Chalk's dyn/impl trait support --- 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 9a26e02fa..838cb4d23 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -3983,11 +3983,11 @@ fn test(x: impl Trait, y: &impl Trait) { [180; 183) 'bar': fn bar() -> impl Trait [180; 185) 'bar()': impl Trait [191; 192) 'x': impl Trait - [191; 198) 'x.foo()': {unknown} + [191; 198) 'x.foo()': u64 [204; 205) 'y': &impl Trait - [204; 211) 'y.foo()': {unknown} + [204; 211) 'y.foo()': u64 [217; 218) 'z': impl Trait - [217; 224) 'z.foo()': {unknown} + [217; 224) 'z.foo()': u64 [230; 231) 'x': impl Trait [230; 238) 'x.foo2()': i64 [244; 245) 'y': &impl Trait @@ -4033,11 +4033,11 @@ fn test(x: dyn Trait, y: &dyn Trait) { [177; 180) 'bar': fn bar() -> dyn Trait [177; 182) 'bar()': dyn Trait [188; 189) 'x': dyn Trait - [188; 195) 'x.foo()': {unknown} + [188; 195) 'x.foo()': u64 [201; 202) 'y': &dyn Trait - [201; 208) 'y.foo()': {unknown} + [201; 208) 'y.foo()': u64 [214; 215) 'z': dyn Trait - [214; 221) 'z.foo()': {unknown} + [214; 221) 'z.foo()': u64 [227; 228) 'x': dyn Trait [227; 235) 'x.foo2()': i64 [241; 242) 'y': &dyn Trait -- cgit v1.2.3 From 351c29d859d74f7a61e654bdbcad634bfb136225 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 16 Nov 2019 12:53:13 +0100 Subject: Fix handling of the binders in dyn/impl Trait We need to be more careful now when substituting bound variables (previously, we didn't have anything that used bound variables except Chalk, so it was not a problem). This is obviously quite ad-hoc; Chalk has more infrastructure for handling this in a principled way, which we maybe should adopt. --- crates/ra_hir/src/ty/tests.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 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 838cb4d23..ca1693679 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -4184,6 +4184,49 @@ fn test>(x: T, y: impl Trait) { ); } +#[test] +fn impl_trait_assoc_binding_projection_bug() { + let (db, pos) = TestDB::with_position( + r#" +//- /main.rs crate:main deps:std +pub trait Language { + type Kind; +} +pub enum RustLanguage {} +impl Language for RustLanguage { + type Kind = SyntaxKind; +} +struct SyntaxNode {} +fn foo() -> impl Iterator> {} + +trait Clone { + fn clone(&self) -> Self; +} + +fn api_walkthrough() { + for node in foo() { + node.clone()<|>; + } +} + +//- /std.rs crate:std +#[prelude_import] use iter::*; +mod iter { + trait IntoIterator { + type Item; + } + trait Iterator { + type Item; + } + impl IntoIterator for T { + type Item = ::Item; + } +} +"#, + ); + assert_eq!("{unknown}", type_at_pos(&db, pos)); +} + #[test] fn projection_eq_within_chalk() { // std::env::set_var("CHALK_DEBUG", "1"); -- cgit v1.2.3