Skip to content

Commit 1785493

Browse files
committed
Add (failing) test for inherent array method resolution.
1 parent 3dae94b commit 1785493

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

crates/hir_ty/src/tests/method_resolution.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,35 @@ fn f() {
12831283
);
12841284
}
12851285

1286+
#[test]
1287+
fn resolve_const_generic_array_methods() {
1288+
check_types(
1289+
r#"
1290+
#[lang = "array"]
1291+
impl<T, const N: usize> [T; N] {
1292+
pub fn map<F, U>(self, f: F) -> [U; N]
1293+
where
1294+
F: FnMut(T) -> U,
1295+
{ loop {} }
1296+
}
1297+
1298+
#[lang = "slice"]
1299+
impl<T> [T] {
1300+
pub fn map<F, U>(self, f: F) -> &[U]
1301+
where
1302+
F: FnMut(T) -> U,
1303+
{ loop {} }
1304+
}
1305+
1306+
fn f() {
1307+
let v = [1, 2].map::<_, usize>(|x| -> x * 2);
1308+
v;
1309+
//^ [usize; _]
1310+
}
1311+
"#,
1312+
);
1313+
}
1314+
12861315
#[test]
12871316
fn skip_array_during_method_dispatch() {
12881317
check_types(

0 commit comments

Comments
 (0)