From 28e3e683b204050e532f49f84f2ec887f19cc91c Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 3 Jun 2021 14:26:26 +0200 Subject: ItemTree: make variant fields inherit the enum's visibility --- crates/hir_def/src/item_tree/tests.rs | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crates/hir_def/src/item_tree/tests.rs') diff --git a/crates/hir_def/src/item_tree/tests.rs b/crates/hir_def/src/item_tree/tests.rs index b362add5c..57686dc6e 100644 --- a/crates/hir_def/src/item_tree/tests.rs +++ b/crates/hir_def/src/item_tree/tests.rs @@ -359,3 +359,41 @@ trait Tr<'a, T: 'a>: Super {} "#]], ) } + +#[test] +fn inherit_visibility() { + check( + r#" +pub(crate) enum En { + Var1(u8), + Var2 { + fld: u8, + }, +} + +pub(crate) trait Tr { + fn f(); + fn method(&self) {} +} + "#, + expect![[r#" + pub(crate) enum En { + Var1( + pub(crate) 0: u8, + ), + Var2 { + pub(crate) fld: u8, + }, + } + + pub(crate) trait Tr { + pub(crate) fn f() -> (); + + // flags = 0x3 + pub(crate) fn method( + _: &Self, + ) -> (); + } + "#]], + ) +} -- cgit v1.2.3