Skip to content

Commit 76adf05

Browse files
committed
Rename -Zparse-only.
I was surprised to find that running with `-Zparse-only` only parses the crate root file. Other files aren't parsed because that happens later during expansion. This commit renames the option and updates the help message to make this clearer.
1 parent 6b6a867 commit 76adf05

File tree

15 files changed

+20
-17
lines changed

15 files changed

+20
-17
lines changed

compiler/rustc_driver_impl/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,9 @@ fn run_compiler(
425425
return early_exit();
426426
}
427427

428-
if sess.opts.unstable_opts.parse_only || sess.opts.unstable_opts.show_span.is_some() {
428+
if sess.opts.unstable_opts.parse_crate_root_only
429+
|| sess.opts.unstable_opts.show_span.is_some()
430+
{
429431
return early_exit();
430432
}
431433

compiler/rustc_interface/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ fn test_unstable_options_tracking_hash() {
712712
untracked!(no_analysis, true);
713713
untracked!(no_leak_check, true);
714714
untracked!(no_parallel_backend, true);
715-
untracked!(parse_only, true);
715+
untracked!(parse_crate_root_only, true);
716716
// `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
717717
untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
718718
untracked!(print_codegen_stats, true);

compiler/rustc_session/src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ impl Options {
12081208

12091209
/// Returns `true` if there will be an output file generated.
12101210
pub fn will_create_output_file(&self) -> bool {
1211-
!self.unstable_opts.parse_only && // The file is just being parsed
1211+
!self.unstable_opts.parse_crate_root_only && // The file is just being parsed
12121212
self.unstable_opts.ls.is_empty() // The file is just being queried
12131213
}
12141214

@@ -1864,7 +1864,7 @@ fn parse_output_types(
18641864
matches: &getopts::Matches,
18651865
) -> OutputTypes {
18661866
let mut output_types = BTreeMap::new();
1867-
if !unstable_opts.parse_only {
1867+
if !unstable_opts.parse_crate_root_only {
18681868
for list in matches.opt_strs("emit") {
18691869
for output_type in list.split(',') {
18701870
let (shorthand, path) = split_out_file_name(output_type);

compiler/rustc_session/src/options.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1937,8 +1937,9 @@ options! {
19371937
"support compiling tests with panic=abort (default: no)"),
19381938
panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
19391939
"panic strategy for panics in drops"),
1940-
parse_only: bool = (false, parse_bool, [UNTRACKED],
1941-
"parse only; do not compile, assemble, or link (default: no)"),
1940+
parse_crate_root_only: bool = (false, parse_bool, [UNTRACKED],
1941+
"parse the crate root file only; do not parse other files, compile, assemble, or link \
1942+
(default: no)"),
19421943
patchable_function_entry: PatchableFunctionEntry = (PatchableFunctionEntry::default(), parse_patchable_function_entry, [TRACKED],
19431944
"nop padding at function entry"),
19441945
plt: Option<bool> = (None, parse_opt_bool, [TRACKED],

tests/ui/generic-associated-types/parse/in-trait-impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
//@ compile-flags: -Z parse-only
2+
//@ compile-flags: -Z parse-crate-root-only
33

44
impl<T> Baz for T where T: Foo {
55
type Quux<'a> = <T as Foo>::Bar<'a, 'static>;

tests/ui/generic-associated-types/parse/in-trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
//@ compile-flags: -Z parse-only
2+
//@ compile-flags: -Z parse-crate-root-only
33

44
use std::ops::Deref;
55
use std::fmt::Debug;

tests/ui/impl-trait/impl-trait-plus-priority.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z parse-only
1+
//@ compile-flags: -Z parse-crate-root-only
22

33
fn f() -> impl A + {} // OK
44
fn f() -> impl A + B {} // OK

tests/ui/parser/assoc/assoc-oddities-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z parse-only
1+
//@ compile-flags: -Z parse-crate-root-only
22

33
fn main() {
44
// following lines below parse and must not fail

tests/ui/parser/assoc/assoc-oddities-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z parse-only
1+
//@ compile-flags: -Z parse-crate-root-only
22

33
fn main() {
44
// see assoc-oddities-1 for explanation

tests/ui/parser/bounds-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z parse-only
1+
//@ compile-flags: -Z parse-crate-root-only
22
//@ edition: 2021
33

44
struct S<

tests/ui/parser/impl-qpath.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
//@ compile-flags: -Z parse-only
2+
//@ compile-flags: -Z parse-crate-root-only
33

44
impl <*const u8>::AssocTy {} // OK
55
impl <Type as Trait>::AssocTy {} // OK

tests/ui/parser/issues/issue-17904.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Zparse-only
1+
//@ compile-flags: -Zparse-crate-root-only
22

33
struct Baz<U> where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax.
44
struct Baz<U> where U: Eq(U) -> R; // Notice this parses as well.

tests/ui/traits/const-traits/syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z parse-only
1+
//@ compile-flags: -Z parse-crate-root-only
22
//@ check-pass
33

44
#![feature(const_trait_bound_opt_out)]

tests/ui/traits/const-traits/tilde-const-syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z parse-only
1+
//@ compile-flags: -Z parse-crate-root-only
22
//@ check-pass
33

44
#![feature(const_trait_impl)]

tests/ui/traits/const-traits/tilde-twice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z parse-only
1+
//@ compile-flags: -Z parse-crate-root-only
22

33
#![feature(const_trait_impl)]
44

0 commit comments

Comments
 (0)