aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-11-16 11:53:13 +0000
committerFlorian Diebold <[email protected]>2019-11-16 12:25:54 +0000
commit351c29d859d74f7a61e654bdbcad634bfb136225 (patch)
tree39289f3a5fd0d828780ffa3128317afc8a0598e4 /crates/ra_hir/src/ty/tests.rs
parent9c2a9a9a0635e53466749fdedcdc5a371e658cde (diff)
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.
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs43
1 files changed, 43 insertions, 0 deletions
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
@@ -4185,6 +4185,49 @@ fn test<T: Trait<Type = u32>>(x: T, y: impl Trait<Type = i64>) {
4185} 4185}
4186 4186
4187#[test] 4187#[test]
4188fn impl_trait_assoc_binding_projection_bug() {
4189 let (db, pos) = TestDB::with_position(
4190 r#"
4191//- /main.rs crate:main deps:std
4192pub trait Language {
4193 type Kind;
4194}
4195pub enum RustLanguage {}
4196impl Language for RustLanguage {
4197 type Kind = SyntaxKind;
4198}
4199struct SyntaxNode<L> {}
4200fn foo() -> impl Iterator<Item = SyntaxNode<RustLanguage>> {}
4201
4202trait Clone {
4203 fn clone(&self) -> Self;
4204}
4205
4206fn api_walkthrough() {
4207 for node in foo() {
4208 node.clone()<|>;
4209 }
4210}
4211
4212//- /std.rs crate:std
4213#[prelude_import] use iter::*;
4214mod iter {
4215 trait IntoIterator {
4216 type Item;
4217 }
4218 trait Iterator {
4219 type Item;
4220 }
4221 impl<T: Iterator> IntoIterator for T {
4222 type Item = <T as Iterator>::Item;
4223 }
4224}
4225"#,
4226 );
4227 assert_eq!("{unknown}", type_at_pos(&db, pos));
4228}
4229
4230#[test]
4188fn projection_eq_within_chalk() { 4231fn projection_eq_within_chalk() {
4189 // std::env::set_var("CHALK_DEBUG", "1"); 4232 // std::env::set_var("CHALK_DEBUG", "1");
4190 assert_snapshot!( 4233 assert_snapshot!(