about summary refs log tree commit diff
path: root/compiler/rustc_session/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-14 09:16:15 +0000
committerbors <bors@rust-lang.org>2023-12-14 09:16:15 +0000
commit9d49eb76c47a139ef71da4ab56aa9aeca5f24913 (patch)
treee3b338c0d0a863ffe99b05e38897ddbd66c8f925 /compiler/rustc_session/src
parent1a8afa0e748008708950e1a9ff62c598e2cfb3ea (diff)
parent981c4e3ce6f3d89f681fbb0de753d03425c6a209 (diff)
downloadrust-9d49eb76c47a139ef71da4ab56aa9aeca5f24913.tar.gz
rust-9d49eb76c47a139ef71da4ab56aa9aeca5f24913.zip
Auto merge of #118417 - anforowicz:default-hidden-visibility, r=TaKO8Ki
Add unstable `-Zdefault-hidden-visibility` cmdline flag for `rustc`.

The new flag has been described in the Major Change Proposal at
https://github.com/rust-lang/compiler-team/issues/656
Diffstat (limited to 'compiler/rustc_session/src')
-rw-r--r--compiler/rustc_session/src/options.rs2
-rw-r--r--compiler/rustc_session/src/session.rs8
2 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index d666c5d4d70..a3835c085da 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1552,6 +1552,8 @@ options! {
         "compress debug info sections (none, zlib, zstd, default: none)"),
     deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
         "deduplicate identical diagnostics (default: yes)"),
+    default_hidden_visibility: Option<bool> = (None, parse_opt_bool, [TRACKED],
+        "overrides the `default_hidden_visibility` setting of the target"),
     dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
         "in dep-info output, omit targets for tracking dependencies of the dep-info files \
         themselves (default: no)"),
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index 24c7459392a..69b861ea380 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -961,6 +961,14 @@ impl Session {
             termize::dimensions().map_or(default_column_width, |(w, _)| w)
         }
     }
+
+    /// Whether the default visibility of symbols should be "hidden" rather than "default".
+    pub fn default_hidden_visibility(&self) -> bool {
+        self.opts
+            .unstable_opts
+            .default_hidden_visibility
+            .unwrap_or(self.target.options.default_hidden_visibility)
+    }
 }
 
 // JUSTIFICATION: defn of the suggested wrapper fns