]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/checks/errors/privacy/rust-privacy-common.h
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 // This file is part of GCC.
5 // GCC is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 3, or (at your option) any later
10 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 // You should have received a copy of the GNU General Public License
16 // along with GCC; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
19 #include "rust-mapping-common.h"
25 * Visibility class related specifically to DefIds. This class allows defining
26 * the visibility of an item with regard to a specific module.
28 * Items are either public throughout a crate, or restricted to a specific
29 * module. Private items are simply restricted to the current module.
31 class ModuleVisibility
41 ModuleVisibility () : kind (Unknown
), module_id (UNKNOWN_DEFID
) {}
43 static ModuleVisibility
create_restricted (DefId module_id
)
45 return ModuleVisibility (Type::Restricted
, module_id
);
48 static ModuleVisibility
create_public ()
50 return ModuleVisibility (Type::Public
, UNKNOWN_DEFID
);
53 Type
get_kind () const { return kind
; }
55 const DefId
&get_module_id () const { return module_id
; }
56 DefId
&get_module_id () { return module_id
; }
59 ModuleVisibility (Type kind
, DefId module_id
)
60 : kind (kind
), module_id (module_id
)
66 } // namespace Privacy