Rename debugging_opts to unstable_opts

This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
This commit is contained in:
Joshua Nelson
2022-07-06 07:44:47 -05:00
parent c80dde43f9
commit 3c9765cff1
125 changed files with 396 additions and 394 deletions

View File

@@ -722,7 +722,7 @@ impl Default for Options {
target_triple: TargetTriple::from_triple(host_triple()),
test: false,
incremental: None,
debugging_opts: Default::default(),
unstable_opts: Default::default(),
prints: Vec::new(),
cg: Default::default(),
error_format: ErrorOutputType::default(),
@@ -752,8 +752,8 @@ impl Options {
/// Returns `true` if there is a reason to build the dep graph.
pub fn build_dep_graph(&self) -> bool {
self.incremental.is_some()
|| self.debugging_opts.dump_dep_graph
|| self.debugging_opts.query_dep_graph
|| self.unstable_opts.dump_dep_graph
|| self.unstable_opts.query_dep_graph
}
pub fn file_path_mapping(&self) -> FilePathMapping {
@@ -762,13 +762,13 @@ impl Options {
/// Returns `true` if there will be an output file generated.
pub fn will_create_output_file(&self) -> bool {
!self.debugging_opts.parse_only && // The file is just being parsed
!self.debugging_opts.ls // The file is just being queried
!self.unstable_opts.parse_only && // The file is just being parsed
!self.unstable_opts.ls // The file is just being queried
}
#[inline]
pub fn share_generics(&self) -> bool {
match self.debugging_opts.share_generics {
match self.unstable_opts.share_generics {
Some(setting) => setting,
None => match self.optimize {
OptLevel::No | OptLevel::Less | OptLevel::Size | OptLevel::SizeMin => true,
@@ -782,7 +782,7 @@ impl Options {
}
}
impl DebuggingOptions {
impl UnstableOptions {
pub fn diagnostic_handler_flags(&self, can_emit_warnings: bool) -> HandlerFlags {
HandlerFlags {
can_emit_warnings,
@@ -940,7 +940,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
let panic_strategy = sess.panic_strategy();
ret.insert((sym::panic, Some(panic_strategy.desc_symbol())));
for s in sess.opts.debugging_opts.sanitizer {
for s in sess.opts.unstable_opts.sanitizer {
let symbol = Symbol::intern(&s.to_string());
ret.insert((sym::sanitize, Some(symbol)));
}
@@ -1403,6 +1403,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
/// long-term interface for rustc.
pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
let mut opts = rustc_short_optgroups();
// FIXME: none of these descriptions are actually used
opts.extend(vec![
opt::multi_s(
"",
@@ -1411,7 +1412,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"NAME[=PATH]",
),
opt::opt_s("", "sysroot", "Override the system root", "PATH"),
opt::multi("Z", "", "Set internal debugging options", "FLAG"),
opt::multi("Z", "", "Set unstable / perma-unstable options", "FLAG"),
opt::opt_s(
"",
"error-format",
@@ -1659,12 +1660,12 @@ pub fn parse_crate_edition(matches: &getopts::Matches) -> Edition {
edition
}
fn check_debug_option_stability(
debugging_opts: &DebuggingOptions,
fn check_error_format_stability(
unstable_opts: &UnstableOptions,
error_format: ErrorOutputType,
json_rendered: HumanReadableErrorType,
) {
if !debugging_opts.unstable_options {
if !unstable_opts.unstable_options {
if let ErrorOutputType::Json { pretty: true, json_rendered } = error_format {
early_error(
ErrorOutputType::Json { pretty: false, json_rendered },
@@ -1683,12 +1684,12 @@ fn check_debug_option_stability(
}
fn parse_output_types(
debugging_opts: &DebuggingOptions,
unstable_opts: &UnstableOptions,
matches: &getopts::Matches,
error_format: ErrorOutputType,
) -> OutputTypes {
let mut output_types = BTreeMap::new();
if !debugging_opts.parse_only {
if !unstable_opts.parse_only {
for list in matches.opt_strs("emit") {
for output_type in list.split(',') {
let (shorthand, path) = match output_type.split_once('=') {
@@ -1762,19 +1763,19 @@ fn should_override_cgus_and_disable_thinlto(
(disable_thinlto, codegen_units)
}
fn check_thread_count(debugging_opts: &DebuggingOptions, error_format: ErrorOutputType) {
if debugging_opts.threads == 0 {
fn check_thread_count(unstable_opts: &UnstableOptions, error_format: ErrorOutputType) {
if unstable_opts.threads == 0 {
early_error(error_format, "value for threads must be a positive non-zero integer");
}
if debugging_opts.threads > 1 && debugging_opts.fuel.is_some() {
if unstable_opts.threads > 1 && unstable_opts.fuel.is_some() {
early_error(error_format, "optimization fuel is incompatible with multiple threads");
}
}
fn collect_print_requests(
cg: &mut CodegenOptions,
dopts: &mut DebuggingOptions,
unstable_opts: &mut UnstableOptions,
matches: &getopts::Matches,
error_format: ErrorOutputType,
) -> Vec<PrintRequest> {
@@ -1803,7 +1804,7 @@ fn collect_print_requests(
"native-static-libs" => PrintRequest::NativeStaticLibs,
"stack-protector-strategies" => PrintRequest::StackProtectorStrategies,
"target-spec-json" => {
if dopts.unstable_options {
if unstable_opts.unstable_options {
PrintRequest::TargetSpec
} else {
early_error(
@@ -2069,10 +2070,10 @@ fn parse_libs(matches: &getopts::Matches, error_format: ErrorOutputType) -> Vec<
pub fn parse_externs(
matches: &getopts::Matches,
debugging_opts: &DebuggingOptions,
unstable_opts: &UnstableOptions,
error_format: ErrorOutputType,
) -> Externs {
let is_unstable_enabled = debugging_opts.unstable_options;
let is_unstable_enabled = unstable_opts.unstable_options;
let mut externs: BTreeMap<String, ExternEntry> = BTreeMap::new();
for arg in matches.opt_strs("extern") {
let (name, path) = match arg.split_once('=') {
@@ -2171,7 +2172,7 @@ pub fn parse_externs(
fn parse_remap_path_prefix(
matches: &getopts::Matches,
debugging_opts: &DebuggingOptions,
unstable_opts: &UnstableOptions,
error_format: ErrorOutputType,
) -> Vec<(PathBuf, PathBuf)> {
let mut mapping: Vec<(PathBuf, PathBuf)> = matches
@@ -2185,7 +2186,7 @@ fn parse_remap_path_prefix(
Some((from, to)) => (PathBuf::from(from), PathBuf::from(to)),
})
.collect();
match &debugging_opts.remap_cwd_prefix {
match &unstable_opts.remap_cwd_prefix {
Some(to) => match std::env::current_dir() {
Ok(cwd) => mapping.push((cwd, to.clone())),
Err(_) => (),
@@ -2217,12 +2218,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
.unwrap_or_else(|e| early_error(error_format, &e));
let mut debugging_opts = DebuggingOptions::build(matches, error_format);
let mut unstable_opts = UnstableOptions::build(matches, error_format);
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
check_debug_option_stability(&debugging_opts, error_format, json_rendered);
check_error_format_stability(&unstable_opts, error_format, json_rendered);
if !debugging_opts.unstable_options && json_unused_externs.is_enabled() {
if !unstable_opts.unstable_options && json_unused_externs.is_enabled() {
early_error(
error_format,
"the `-Z unstable-options` flag must also be passed to enable \
@@ -2230,7 +2231,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
);
}
let output_types = parse_output_types(&debugging_opts, matches, error_format);
let output_types = parse_output_types(&unstable_opts, matches, error_format);
let mut cg = CodegenOptions::build(matches, error_format);
let (disable_thinlto, mut codegen_units) = should_override_cgus_and_disable_thinlto(
@@ -2240,20 +2241,19 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
cg.codegen_units,
);
check_thread_count(&debugging_opts, error_format);
check_thread_count(&unstable_opts, error_format);
let incremental = cg.incremental.as_ref().map(PathBuf::from);
let assert_incr_state =
parse_assert_incr_state(&debugging_opts.assert_incr_state, error_format);
let assert_incr_state = parse_assert_incr_state(&unstable_opts.assert_incr_state, error_format);
if debugging_opts.profile && incremental.is_some() {
if unstable_opts.profile && incremental.is_some() {
early_error(
error_format,
"can't instrument with gcov profiling when compiling incrementally",
);
}
if debugging_opts.profile {
if unstable_opts.profile {
match codegen_units {
Some(1) => {}
None => codegen_units = Some(1),
@@ -2271,7 +2271,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
);
}
if debugging_opts.profile_sample_use.is_some()
if unstable_opts.profile_sample_use.is_some()
&& (cg.profile_generate.enabled() || cg.profile_use.is_some())
{
early_error(
@@ -2282,7 +2282,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
// Handle both `-Z symbol-mangling-version` and `-C symbol-mangling-version`; the latter takes
// precedence.
match (cg.symbol_mangling_version, debugging_opts.symbol_mangling_version) {
match (cg.symbol_mangling_version, unstable_opts.symbol_mangling_version) {
(Some(smv_c), Some(smv_z)) if smv_c != smv_z => {
early_error(
error_format,
@@ -2291,7 +2291,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
);
}
(Some(SymbolManglingVersion::V0), _) => {}
(Some(_), _) if !debugging_opts.unstable_options => {
(Some(_), _) if !unstable_opts.unstable_options => {
early_error(
error_format,
"`-C symbol-mangling-version=legacy` requires `-Z unstable-options`",
@@ -2310,7 +2310,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
// Handle both `-Z instrument-coverage` and `-C instrument-coverage`; the latter takes
// precedence.
match (cg.instrument_coverage, debugging_opts.instrument_coverage) {
match (cg.instrument_coverage, unstable_opts.instrument_coverage) {
(Some(ic_c), Some(ic_z)) if ic_c != ic_z => {
early_error(
error_format,
@@ -2319,7 +2319,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
);
}
(Some(InstrumentCoverage::Off | InstrumentCoverage::All), _) => {}
(Some(_), _) if !debugging_opts.unstable_options => {
(Some(_), _) if !unstable_opts.unstable_options => {
early_error(
error_format,
"`-C instrument-coverage=except-*` requires `-Z unstable-options`",
@@ -2363,7 +2363,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}
if let Ok(graphviz_font) = std::env::var("RUSTC_GRAPHVIZ_FONT") {
debugging_opts.graphviz_font = graphviz_font;
unstable_opts.graphviz_font = graphviz_font;
}
if !cg.embed_bitcode {
@@ -2386,7 +2386,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
);
}
let prints = collect_print_requests(&mut cg, &mut debugging_opts, matches, error_format);
let prints = collect_print_requests(&mut cg, &mut unstable_opts, matches, error_format);
let cg = cg;
@@ -2412,15 +2412,15 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
early_warn(error_format, "-C remark requires \"-C debuginfo=n\" to show source locations");
}
let externs = parse_externs(matches, &debugging_opts, error_format);
let externs = parse_externs(matches, &unstable_opts, error_format);
let crate_name = matches.opt_str("crate-name");
let remap_path_prefix = parse_remap_path_prefix(matches, &debugging_opts, error_format);
let remap_path_prefix = parse_remap_path_prefix(matches, &unstable_opts, error_format);
let pretty = parse_pretty(&debugging_opts, error_format);
let pretty = parse_pretty(&unstable_opts, error_format);
if !debugging_opts.unstable_options
if !unstable_opts.unstable_options
&& !target_triple.triple().contains("apple")
&& cg.split_debuginfo.is_some()
{
@@ -2481,7 +2481,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
target_triple,
test,
incremental,
debugging_opts,
unstable_opts,
prints,
cg,
error_format,
@@ -2506,10 +2506,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}
}
fn parse_pretty(debugging_opts: &DebuggingOptions, efmt: ErrorOutputType) -> Option<PpMode> {
fn parse_pretty(unstable_opts: &UnstableOptions, efmt: ErrorOutputType) -> Option<PpMode> {
use PpMode::*;
let first = match debugging_opts.unpretty.as_deref()? {
let first = match unstable_opts.unpretty.as_deref()? {
"normal" => Source(PpSourceMode::Normal),
"identified" => Source(PpSourceMode::Identified),
"expanded" => Source(PpSourceMode::Expanded),