@@ -53,11 +53,12 @@ macro_rules! hash_substruct {
5353}
5454
5555macro_rules! top_level_options {
56- ( pub struct Options { $(
56+ ( $ ( # [ $top_level_attr : meta ] ) * pub struct Options { $(
5757 $( #[ $attr: meta] ) *
5858 $opt: ident : $t: ty [ $dep_tracking_marker: ident] ,
5959 ) * } ) => (
6060 #[ derive( Clone ) ]
61+ $( #[ $top_level_attr] ) *
6162 pub struct Options {
6263 $(
6364 $( #[ $attr] ) *
@@ -93,38 +94,38 @@ macro_rules! top_level_options {
9394 ) ;
9495}
9596
96- // The top-level command-line options struct.
97- //
98- // For each option, one has to specify how it behaves with regard to the
99- // dependency tracking system of incremental compilation. This is done via the
100- // square-bracketed directive after the field type. The options are:
101- //
102- // [TRACKED]
103- // A change in the given field will cause the compiler to completely clear the
104- // incremental compilation cache before proceeding.
105- //
106- // [TRACKED_NO_CRATE_HASH]
107- // Same as [TRACKED], but will not affect the crate hash. This is useful for options that only
108- // affect the incremental cache.
109- //
110- // [UNTRACKED]
111- // Incremental compilation is not influenced by this option.
112- //
113- // [SUBSTRUCT]
114- // Second-level sub-structs containing more options.
115- //
116- // If you add a new option to this struct or one of the sub-structs like
117- // `CodegenOptions`, think about how it influences incremental compilation. If in
118- // doubt, specify [TRACKED], which is always "correct" but might lead to
119- // unnecessary re-compilation.
12097top_level_options ! (
98+ /// The top-level command-line options struct.
99+ ///
100+ /// For each option, one has to specify how it behaves with regard to the
101+ /// dependency tracking system of incremental compilation. This is done via the
102+ /// square-bracketed directive after the field type. The options are:
103+ ///
104+ /// - `[TRACKED]`
105+ /// A change in the given field will cause the compiler to completely clear the
106+ /// incremental compilation cache before proceeding.
107+ ///
108+ /// - `[TRACKED_NO_CRATE_HASH]`
109+ /// Same as `[TRACKED]`, but will not affect the crate hash. This is useful for options that only
110+ /// affect the incremental cache.
111+ ///
112+ /// - `[UNTRACKED]`
113+ /// Incremental compilation is not influenced by this option.
114+ ///
115+ /// - `[SUBSTRUCT]`
116+ /// Second-level sub-structs containing more options.
117+ ///
118+ /// If you add a new option to this struct or one of the sub-structs like
119+ /// `CodegenOptions`, think about how it influences incremental compilation. If in
120+ /// doubt, specify `[TRACKED]`, which is always "correct" but might lead to
121+ /// unnecessary re-compilation.
121122 pub struct Options {
122- // The crate config requested for the session, which may be combined
123- // with additional crate configurations during the compile process.
123+ /// The crate config requested for the session, which may be combined
124+ /// with additional crate configurations during the compile process.
124125 crate_types: Vec <CrateType > [ TRACKED ] ,
125126 optimize: OptLevel [ TRACKED ] ,
126- // Include the `debug_assertions` flag in dependency tracking, since it
127- // can influence whether overflow checks are done or not.
127+ /// Include the `debug_assertions` flag in dependency tracking, since it
128+ /// can influence whether overflow checks are done or not.
128129 debug_assertions: bool [ TRACKED ] ,
129130 debuginfo: DebugInfo [ TRACKED ] ,
130131 lint_opts: Vec <( String , lint:: Level ) > [ TRACKED ] ,
@@ -140,43 +141,43 @@ top_level_options!(
140141 test: bool [ TRACKED ] ,
141142 error_format: ErrorOutputType [ UNTRACKED ] ,
142143
143- // If `Some`, enable incremental compilation, using the given
144- // directory to store intermediate results.
144+ /// If `Some`, enable incremental compilation, using the given
145+ /// directory to store intermediate results.
145146 incremental: Option <PathBuf > [ UNTRACKED ] ,
146147
147148 debugging_opts: DebuggingOptions [ SUBSTRUCT ] ,
148149 prints: Vec <PrintRequest > [ UNTRACKED ] ,
149- // Determines which borrow checker(s) to run. This is the parsed, sanitized
150- // version of `debugging_opts.borrowck`, which is just a plain string.
150+ /// Determines which borrow checker(s) to run. This is the parsed, sanitized
151+ /// version of `debugging_opts.borrowck`, which is just a plain string.
151152 borrowck_mode: BorrowckMode [ UNTRACKED ] ,
152153 cg: CodegenOptions [ SUBSTRUCT ] ,
153154 externs: Externs [ UNTRACKED ] ,
154155 extern_dep_specs: ExternDepSpecs [ UNTRACKED ] ,
155156 crate_name: Option <String > [ TRACKED ] ,
156- // An optional name to use as the crate for std during std injection,
157- // written `extern crate name as std`. Defaults to `std`. Used by
158- // out-of-tree drivers.
157+ /// An optional name to use as the crate for std during std injection,
158+ /// written `extern crate name as std`. Defaults to `std`. Used by
159+ /// out-of-tree drivers.
159160 alt_std_name: Option <String > [ TRACKED ] ,
160- // Indicates how the compiler should treat unstable features.
161+ /// Indicates how the compiler should treat unstable features.
161162 unstable_features: UnstableFeatures [ TRACKED ] ,
162163
163- // Indicates whether this run of the compiler is actually rustdoc. This
164- // is currently just a hack and will be removed eventually, so please
165- // try to not rely on this too much.
164+ /// Indicates whether this run of the compiler is actually rustdoc. This
165+ /// is currently just a hack and will be removed eventually, so please
166+ /// try to not rely on this too much.
166167 actually_rustdoc: bool [ TRACKED ] ,
167168
168- // Control path trimming.
169+ /// Control path trimming.
169170 trimmed_def_paths: TrimmedDefPaths [ TRACKED ] ,
170171
171- // Specifications of codegen units / ThinLTO which are forced as a
172- // result of parsing command line options. These are not necessarily
173- // what rustc was invoked with, but massaged a bit to agree with
174- // commands like `--emit llvm-ir` which they're often incompatible with
175- // if we otherwise use the defaults of rustc.
172+ /// Specifications of codegen units / ThinLTO which are forced as a
173+ /// result of parsing command line options. These are not necessarily
174+ /// what rustc was invoked with, but massaged a bit to agree with
175+ /// commands like `--emit llvm-ir` which they're often incompatible with
176+ /// if we otherwise use the defaults of rustc.
176177 cli_forced_codegen_units: Option <usize > [ UNTRACKED ] ,
177178 cli_forced_thinlto_off: bool [ UNTRACKED ] ,
178179
179- // Remap source path prefixes in all output (messages, object files, debug, etc.).
180+ /// Remap source path prefixes in all output (messages, object files, debug, etc.).
180181 remap_path_prefix: Vec <( PathBuf , PathBuf ) > [ TRACKED_NO_CRATE_HASH ] ,
181182 /// Base directory containing the `src/` for the Rust standard library, and
182183 /// potentially `rustc` as well, if we can can find it. Right now it's always
@@ -189,11 +190,11 @@ top_level_options!(
189190
190191 edition: Edition [ TRACKED ] ,
191192
192- // `true` if we're emitting JSON blobs about each artifact produced
193- // by the compiler.
193+ /// `true` if we're emitting JSON blobs about each artifact produced
194+ /// by the compiler.
194195 json_artifact_notifications: bool [ TRACKED ] ,
195196
196- // `true` if we're emitting a JSON blob containing the unused externs
197+ /// `true` if we're emitting a JSON blob containing the unused externs
197198 json_unused_externs: bool [ UNTRACKED ] ,
198199
199200 pretty: Option <PpMode > [ UNTRACKED ] ,
@@ -212,7 +213,7 @@ macro_rules! options {
212213 ( $struct_name: ident, $setter_name: ident, $defaultfn: ident,
213214 $buildfn: ident, $prefix: expr, $outputname: expr,
214215 $stat: ident, $mod_desc: ident, $mod_set: ident,
215- $( $opt: ident : $t: ty = (
216+ $( $( # [ $attr : meta ] ) * $ opt: ident : $t: ty = (
216217 $init: expr,
217218 $parse: ident,
218219 [ $dep_tracking_marker: ident] ,
@@ -223,7 +224,7 @@ macro_rules! options {
223224 pub struct $struct_name { $( pub $opt: $t) ,* }
224225
225226 pub fn $defaultfn( ) -> $struct_name {
226- $struct_name { $( $opt: $init) ,* }
227+ $struct_name { $( $ ( # [ $attr ] ) * $opt: $init) ,* }
227228 }
228229
229230 pub fn $buildfn( matches: & getopts:: Matches , error_format: ErrorOutputType ) -> $struct_name
@@ -1177,7 +1178,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11771178 self_profile: SwitchWithOptPath = ( SwitchWithOptPath :: Disabled ,
11781179 parse_switch_with_opt_path, [ UNTRACKED ] ,
11791180 "run the self profiler and output the raw event data" ) ,
1180- // keep this in sync with the event filter names in librustc_data_structures/profiling.rs
1181+ /// keep this in sync with the event filter names in librustc_data_structures/profiling.rs
11811182 self_profile_events: Option <Vec <String >> = ( None , parse_opt_comma_list, [ UNTRACKED ] ,
11821183 "specify the events recorded by the self profiler;
11831184 for example: `-Z self-profile-events=default,query-keys`
@@ -1189,7 +1190,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11891190 "show spans for compiler debugging (expr|pat|ty)" ) ,
11901191 span_debug: bool = ( false , parse_bool, [ UNTRACKED ] ,
11911192 "forward proc_macro::Span's `Debug` impl to `Span`" ) ,
1192- // o/w tests have closure@path
1193+ /// o/w tests have closure@path
11931194 span_free_formats: bool = ( false , parse_bool, [ UNTRACKED ] ,
11941195 "exclude spans when debug-printing compiler state (default: no)" ) ,
11951196 src_hash_algorithm: Option <SourceFileHashAlgorithm > = ( None , parse_src_file_hash, [ TRACKED ] ,
@@ -1210,10 +1211,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12101211 "select processor to schedule for (`rustc --print target-cpus` for details)" ) ,
12111212 thinlto: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
12121213 "enable ThinLTO when possible" ) ,
1213- // We default to 1 here since we want to behave like
1214- // a sequential compiler for now. This'll likely be adjusted
1215- // in the future. Note that -Zthreads=0 is the way to get
1216- // the num_cpus behavior.
1214+ /// We default to 1 here since we want to behave like
1215+ /// a sequential compiler for now. This'll likely be adjusted
1216+ /// in the future. Note that -Zthreads=0 is the way to get
1217+ /// the num_cpus behavior.
12171218 threads: usize = ( 1 , parse_threads, [ UNTRACKED ] ,
12181219 "use a thread pool with N threads" ) ,
12191220 time: bool = ( false , parse_bool, [ UNTRACKED ] ,
0 commit comments