]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_ty/src/tests/method_resolution.rs
Merge #9007
[rust.git] / crates / hir_ty / src / tests / method_resolution.rs
index 4b2c82b417fe177ecaf5dc56f0469f63e4bdde51..a4c132bc5f206143e0c85543f6346a184fd89887 100644 (file)
@@ -1294,7 +1294,7 @@ fn foo() {
 }
 
 #[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
+}
+    "#,
+    );
+}