Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 19ff6e6

Browse files
committed
Add warn(unreachable_pub) to rustc_session.
1 parent 21a37da commit 19ff6e6

File tree

2 files changed

+74
-69
lines changed

2 files changed

+74
-69
lines changed

compiler/rustc_session/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![feature(map_many_mut)]
66
#![feature(option_get_or_insert_default)]
77
#![feature(rustc_attrs)]
8+
#![warn(unreachable_pub)]
89
// tidy-alphabetical-end
910

1011
pub mod errors;

compiler/rustc_session/src/options.rs

Lines changed: 73 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -358,94 +358,98 @@ fn build_options<O: Default>(
358358

359359
#[allow(non_upper_case_globals)]
360360
mod desc {
361-
pub const parse_no_flag: &str = "no value";
362-
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
363-
pub const parse_opt_bool: &str = parse_bool;
364-
pub const parse_string: &str = "a string";
365-
pub const parse_opt_string: &str = parse_string;
366-
pub const parse_string_push: &str = parse_string;
367-
pub const parse_opt_langid: &str = "a language identifier";
368-
pub const parse_opt_pathbuf: &str = "a path";
369-
pub const parse_list: &str = "a space-separated list of strings";
370-
pub const parse_list_with_polarity: &str =
361+
pub(crate) const parse_no_flag: &str = "no value";
362+
pub(crate) const parse_bool: &str =
363+
"one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
364+
pub(crate) const parse_opt_bool: &str = parse_bool;
365+
pub(crate) const parse_string: &str = "a string";
366+
pub(crate) const parse_opt_string: &str = parse_string;
367+
pub(crate) const parse_string_push: &str = parse_string;
368+
pub(crate) const parse_opt_langid: &str = "a language identifier";
369+
pub(crate) const parse_opt_pathbuf: &str = "a path";
370+
pub(crate) const parse_list: &str = "a space-separated list of strings";
371+
pub(crate) const parse_list_with_polarity: &str =
371372
"a comma-separated list of strings, with elements beginning with + or -";
372-
pub const parse_comma_list: &str = "a comma-separated list of strings";
373-
pub const parse_opt_comma_list: &str = parse_comma_list;
374-
pub const parse_number: &str = "a number";
375-
pub const parse_opt_number: &str = parse_number;
376-
pub const parse_frame_pointer: &str = "one of `true`/`yes`/`on`, `false`/`no`/`off`, or (with -Zunstable-options) `non-leaf` or `always`";
377-
pub const parse_threads: &str = parse_number;
378-
pub const parse_time_passes_format: &str = "`text` (default) or `json`";
379-
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
380-
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
381-
pub const parse_on_broken_pipe: &str = "either `kill`, `error`, or `inherit`";
382-
pub const parse_patchable_function_entry: &str = "either two comma separated integers (total_nops,prefix_nops), with prefix_nops <= total_nops, or one integer (total_nops)";
383-
pub const parse_opt_panic_strategy: &str = parse_panic_strategy;
384-
pub const parse_oom_strategy: &str = "either `panic` or `abort`";
385-
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
386-
pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, or `thread`";
387-
pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
388-
pub const parse_cfguard: &str =
373+
pub(crate) const parse_comma_list: &str = "a comma-separated list of strings";
374+
pub(crate) const parse_opt_comma_list: &str = parse_comma_list;
375+
pub(crate) const parse_number: &str = "a number";
376+
pub(crate) const parse_opt_number: &str = parse_number;
377+
pub(crate) const parse_frame_pointer: &str = "one of `true`/`yes`/`on`, `false`/`no`/`off`, or (with -Zunstable-options) `non-leaf` or `always`";
378+
pub(crate) const parse_threads: &str = parse_number;
379+
pub(crate) const parse_time_passes_format: &str = "`text` (default) or `json`";
380+
pub(crate) const parse_passes: &str = "a space-separated list of passes, or `all`";
381+
pub(crate) const parse_panic_strategy: &str = "either `unwind` or `abort`";
382+
pub(crate) const parse_on_broken_pipe: &str = "either `kill`, `error`, or `inherit`";
383+
pub(crate) const parse_patchable_function_entry: &str = "either two comma separated integers (total_nops,prefix_nops), with prefix_nops <= total_nops, or one integer (total_nops)";
384+
pub(crate) const parse_opt_panic_strategy: &str = parse_panic_strategy;
385+
pub(crate) const parse_oom_strategy: &str = "either `panic` or `abort`";
386+
pub(crate) const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
387+
pub(crate) const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, or `thread`";
388+
pub(crate) const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
389+
pub(crate) const parse_cfguard: &str =
389390
"either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
390-
pub const parse_cfprotection: &str = "`none`|`no`|`n` (default), `branch`, `return`, or `full`|`yes`|`y` (equivalent to `branch` and `return`)";
391-
pub const parse_debuginfo: &str = "either an integer (0, 1, 2), `none`, `line-directives-only`, `line-tables-only`, `limited`, or `full`";
392-
pub const parse_debuginfo_compression: &str = "one of `none`, `zlib`, or `zstd`";
393-
pub const parse_collapse_macro_debuginfo: &str = "one of `no`, `external`, or `yes`";
394-
pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
395-
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
396-
pub const parse_optimization_fuel: &str = "crate=integer";
397-
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
398-
pub const parse_instrument_coverage: &str = parse_bool;
399-
pub const parse_coverage_options: &str =
391+
pub(crate) const parse_cfprotection: &str = "`none`|`no`|`n` (default), `branch`, `return`, or `full`|`yes`|`y` (equivalent to `branch` and `return`)";
392+
pub(crate) const parse_debuginfo: &str = "either an integer (0, 1, 2), `none`, `line-directives-only`, `line-tables-only`, `limited`, or `full`";
393+
pub(crate) const parse_debuginfo_compression: &str = "one of `none`, `zlib`, or `zstd`";
394+
pub(crate) const parse_collapse_macro_debuginfo: &str = "one of `no`, `external`, or `yes`";
395+
pub(crate) const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
396+
pub(crate) const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
397+
pub(crate) const parse_optimization_fuel: &str = "crate=integer";
398+
pub(crate) const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
399+
pub(crate) const parse_instrument_coverage: &str = parse_bool;
400+
pub(crate) const parse_coverage_options: &str =
400401
"`block` | `branch` | `condition` | `mcdc` | `no-mir-spans`";
401-
pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
402-
pub const parse_unpretty: &str = "`string` or `string=string`";
403-
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
404-
pub const parse_next_solver_config: &str =
402+
pub(crate) const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
403+
pub(crate) const parse_unpretty: &str = "`string` or `string=string`";
404+
pub(crate) const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
405+
pub(crate) const parse_next_solver_config: &str =
405406
"a comma separated list of solver configurations: `globally` (default), and `coherence`";
406-
pub const parse_lto: &str =
407+
pub(crate) const parse_lto: &str =
407408
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
408-
pub const parse_linker_plugin_lto: &str =
409+
pub(crate) const parse_linker_plugin_lto: &str =
409410
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
410-
pub const parse_location_detail: &str = "either `none`, or a comma separated list of location details to track: `file`, `line`, or `column`";
411-
pub const parse_fmt_debug: &str = "either `full`, `shallow`, or `none`";
412-
pub const parse_switch_with_opt_path: &str =
411+
pub(crate) const parse_location_detail: &str = "either `none`, or a comma separated list of location details to track: `file`, `line`, or `column`";
412+
pub(crate) const parse_fmt_debug: &str = "either `full`, `shallow`, or `none`";
413+
pub(crate) const parse_switch_with_opt_path: &str =
413414
"an optional path to the profiling data output directory";
414-
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
415-
pub const parse_symbol_mangling_version: &str =
415+
pub(crate) const parse_merge_functions: &str =
416+
"one of: `disabled`, `trampolines`, or `aliases`";
417+
pub(crate) const parse_symbol_mangling_version: &str =
416418
"one of: `legacy`, `v0` (RFC 2603), or `hashed`";
417-
pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
418-
pub const parse_relocation_model: &str =
419+
pub(crate) const parse_src_file_hash: &str = "either `md5` or `sha1`";
420+
pub(crate) const parse_relocation_model: &str =
419421
"one of supported relocation models (`rustc --print relocation-models`)";
420-
pub const parse_code_model: &str = "one of supported code models (`rustc --print code-models`)";
421-
pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)";
422-
pub const parse_target_feature: &str = parse_string;
423-
pub const parse_terminal_url: &str =
422+
pub(crate) const parse_code_model: &str =
423+
"one of supported code models (`rustc --print code-models`)";
424+
pub(crate) const parse_tls_model: &str =
425+
"one of supported TLS models (`rustc --print tls-models`)";
426+
pub(crate) const parse_target_feature: &str = parse_string;
427+
pub(crate) const parse_terminal_url: &str =
424428
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `auto`";
425-
pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
426-
pub const parse_split_debuginfo: &str =
429+
pub(crate) const parse_wasi_exec_model: &str = "either `command` or `reactor`";
430+
pub(crate) const parse_split_debuginfo: &str =
427431
"one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
428-
pub const parse_split_dwarf_kind: &str =
432+
pub(crate) const parse_split_dwarf_kind: &str =
429433
"one of supported split dwarf modes (`split` or `single`)";
430-
pub const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \
434+
pub(crate) const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \
431435
components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw`";
432-
pub const parse_linker_features: &str =
436+
pub(crate) const parse_linker_features: &str =
433437
"a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld`";
434-
pub const parse_polonius: &str = "either no value or `legacy` (the default), or `next`";
435-
pub const parse_stack_protector: &str =
438+
pub(crate) const parse_polonius: &str = "either no value or `legacy` (the default), or `next`";
439+
pub(crate) const parse_stack_protector: &str =
436440
"one of (`none` (default), `basic`, `strong`, or `all`)";
437-
pub const parse_branch_protection: &str =
441+
pub(crate) const parse_branch_protection: &str =
438442
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
439-
pub const parse_proc_macro_execution_strategy: &str =
443+
pub(crate) const parse_proc_macro_execution_strategy: &str =
440444
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
441-
pub const parse_remap_path_scope: &str =
445+
pub(crate) const parse_remap_path_scope: &str =
442446
"comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`";
443-
pub const parse_inlining_threshold: &str =
447+
pub(crate) const parse_inlining_threshold: &str =
444448
"either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
445-
pub const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
446-
pub const parse_function_return: &str = "`keep` or `thunk-extern`";
447-
pub const parse_wasm_c_abi: &str = "`legacy` or `spec`";
448-
pub const parse_mir_include_spans: &str =
449+
pub(crate) const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
450+
pub(crate) const parse_function_return: &str = "`keep` or `thunk-extern`";
451+
pub(crate) const parse_wasm_c_abi: &str = "`legacy` or `spec`";
452+
pub(crate) const parse_mir_include_spans: &str =
449453
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)";
450454
}
451455

0 commit comments

Comments
 (0)