From 20c27dbdbe3116be205d66af88e6f5ac88b862d3 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 19 Apr 2021 01:06:26 +0200 Subject: Collect inherent impls in unnamed consts --- crates/hir_ty/src/tests/method_resolution.rs | 37 +++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'crates/hir_ty/src/tests') diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 4b2c82b41..a4c132bc5 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -1294,7 +1294,7 @@ mod b { } #[test] -fn impl_in_unnamed_const() { +fn trait_impl_in_unnamed_const() { check_types( r#" struct S; @@ -1314,3 +1314,38 @@ fn f() { "#, ); } + +#[test] +fn inherent_impl_in_unnamed_const() { + check_types( + r#" +struct S; + +const _: () = { + impl S { + fn method(&self) -> u16 { 0 } + + pub(super) fn super_method(&self) -> u16 { 0 } + + pub(crate) fn crate_method(&self) -> u16 { 0 } + + pub fn pub_method(&self) -> u16 { 0 } + } +}; + +fn f() { + S.method(); + //^^^^^^^^^^ u16 + + S.super_method(); + //^^^^^^^^^^^^^^^^ u16 + + S.crate_method(); + //^^^^^^^^^^^^^^^^ u16 + + S.pub_method(); + //^^^^^^^^^^^^^^ u16 +} + "#, + ); +} -- cgit v1.2.3