diff options
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r-- | crates/hir_ty/src/tests/regression.rs | 38 | ||||
-rw-r--r-- | crates/hir_ty/src/tests/traits.rs | 30 |
2 files changed, 68 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index b69f86050..9cd9f473d 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs | |||
@@ -974,3 +974,41 @@ fn param_overrides_fn() { | |||
974 | "#, | 974 | "#, |
975 | ) | 975 | ) |
976 | } | 976 | } |
977 | |||
978 | #[test] | ||
979 | fn lifetime_from_chalk_during_deref() { | ||
980 | check_types( | ||
981 | r#" | ||
982 | #[lang = "deref"] | ||
983 | pub trait Deref { | ||
984 | type Target; | ||
985 | } | ||
986 | |||
987 | struct Box<T: ?Sized> {} | ||
988 | impl<T> Deref for Box<T> { | ||
989 | type Target = T; | ||
990 | |||
991 | fn deref(&self) -> &Self::Target { | ||
992 | loop {} | ||
993 | } | ||
994 | } | ||
995 | |||
996 | trait Iterator { | ||
997 | type Item; | ||
998 | } | ||
999 | |||
1000 | pub struct Iter<'a, T: 'a> { | ||
1001 | inner: Box<dyn IterTrait<'a, T, Item = &'a T> + 'a>, | ||
1002 | } | ||
1003 | |||
1004 | trait IterTrait<'a, T: 'a>: Iterator<Item = &'a T> { | ||
1005 | fn clone_box(&self); | ||
1006 | } | ||
1007 | |||
1008 | fn clone_iter<T>(s: Iter<T>) { | ||
1009 | s.inner.clone_box(); | ||
1010 | //^^^^^^^^^^^^^^^^^^^ () | ||
1011 | } | ||
1012 | "#, | ||
1013 | ) | ||
1014 | } | ||
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 65b71fdfa..1c1aa491d 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs | |||
@@ -3413,3 +3413,33 @@ fn foo() { | |||
3413 | "#]], | 3413 | "#]], |
3414 | ); | 3414 | ); |
3415 | } | 3415 | } |
3416 | |||
3417 | #[test] | ||
3418 | fn renamed_extern_crate_in_block() { | ||
3419 | check_types( | ||
3420 | r#" | ||
3421 | //- /lib.rs crate:lib deps:serde | ||
3422 | use serde::Deserialize; | ||
3423 | |||
3424 | struct Foo {} | ||
3425 | |||
3426 | const _ : () = { | ||
3427 | extern crate serde as _serde; | ||
3428 | impl _serde::Deserialize for Foo { | ||
3429 | fn deserialize() -> u8 { 0 } | ||
3430 | } | ||
3431 | }; | ||
3432 | |||
3433 | fn foo() { | ||
3434 | Foo::deserialize(); | ||
3435 | //^^^^^^^^^^^^^^^^^^ u8 | ||
3436 | } | ||
3437 | |||
3438 | //- /serde.rs crate:serde | ||
3439 | |||
3440 | pub trait Deserialize { | ||
3441 | fn deserialize() -> u8; | ||
3442 | } | ||
3443 | "#, | ||
3444 | ); | ||
3445 | } | ||