Skip to content

Commit eb96964

Browse files
committed
Add a test.
1 parent 389d9a6 commit eb96964

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

crates/hir_ty/src/tests/method_resolution.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,3 +1051,41 @@ fn dyn_trait_super_trait_not_in_scope() {
10511051
"#]],
10521052
);
10531053
}
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+

0 commit comments

Comments
 (0)