diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_ty/src/tests/method_resolution.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 23b2601e6..690f9d66e 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs | |||
@@ -1051,3 +1051,41 @@ fn dyn_trait_super_trait_not_in_scope() { | |||
1051 | "#]], | 1051 | "#]], |
1052 | ); | 1052 | ); |
1053 | } | 1053 | } |
1054 | |||
1055 | #[test] | ||
1056 | fn method_resolution_foreign_opaque_type() { | ||
1057 | check_infer( | ||
1058 | r#" | ||
1059 | extern "C" { | ||
1060 | type S; | ||
1061 | fn f() -> &'static S; | ||
1062 | } | ||
1063 | |||
1064 | impl S { | ||
1065 | fn foo(&self) -> bool { | ||
1066 | true | ||
1067 | } | ||
1068 | } | ||
1069 | |||
1070 | fn test() { | ||
1071 | let s = unsafe { f() }; | ||
1072 | s.foo(); | ||
1073 | } | ||
1074 | "#, | ||
1075 | // FIXME: 's.foo()' should be `bool`. | ||
1076 | expect![[r#" | ||
1077 | 75..79 'self': &S | ||
1078 | 89..109 '{ ... }': bool | ||
1079 | 99..103 'true': bool | ||
1080 | 123..167 '{ ...o(); }': () | ||
1081 | 133..134 's': &S | ||
1082 | 137..151 'unsafe { f() }': &S | ||
1083 | 144..151 '{ f() }': &S | ||
1084 | 146..147 'f': fn f() -> &S | ||
1085 | 146..149 'f()': &S | ||
1086 | 157..158 's': &S | ||
1087 | 157..164 's.foo()': {unknown} | ||
1088 | "#]], | ||
1089 | ); | ||
1090 | } | ||
1091 | |||