Skip to content

Commit 953f294

Browse files
committed
rustc: Remove deprecated flags
This commit removes a number of deprecated flags from the compiler: * opt-level => -C opt-level * debuginfo => -C debuginfo * print-crate-name => --print crate-name * print-file-name => --print file-names * no-trans => -Z no-trans * no-analysis => -Z no-analysis * parse-only => -Z parse-only * dep-info => --emit dep-info This commit also moves the --pretty flag behind `-Z unstable-options` as the pretty printer will likely not be stable for 1.0 cc #19051
1 parent ffd8cb7 commit 953f294

File tree

22 files changed

+43
-193
lines changed

22 files changed

+43
-193
lines changed

src/compiletest/runtest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
294294
let aux_dir = aux_output_dir_name(config, testfile);
295295
// FIXME (#9639): This needs to handle non-utf8 paths
296296
let mut args = vec!("-".to_string(),
297+
"-Zunstable-options".to_string(),
297298
"--pretty".to_string(),
298299
pretty_type,
299300
format!("--target={}", config.target),
@@ -340,7 +341,7 @@ actual:\n\
340341
};
341342
// FIXME (#9639): This needs to handle non-utf8 paths
342343
let mut args = vec!("-".to_string(),
343-
"--no-trans".to_string(),
344+
"-Zno-trans".to_string(),
344345
"--crate-type=lib".to_string(),
345346
format!("--target={}", target),
346347
"-L".to_string(),

src/librustc/session/config.rs

Lines changed: 6 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -786,30 +786,14 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
786786
opt::multi("", "extern", "Specify where an external rust library is \
787787
located",
788788
"NAME=PATH"),
789-
opt::opt("", "opt-level", "Optimize with possible levels 0-3", "LEVEL"),
790789
opt::opt("", "sysroot", "Override the system root", "PATH"),
791790
opt::multi("Z", "", "Set internal debugging options", "FLAG"),
792791
opt::opt("", "color", "Configure coloring of output:
793792
auto = colorize, if output goes to a tty (default);
794793
always = always colorize output;
795794
never = never colorize output", "auto|always|never"),
796795

797-
// DEPRECATED
798-
opt::flag("", "print-crate-name", "Output the crate name and exit"),
799-
opt::flag("", "print-file-name", "Output the file(s) that would be \
800-
written if compilation \
801-
continued and exit"),
802-
opt::opt("", "debuginfo", "Emit DWARF debug info to the objects created:
803-
0 = no debug info,
804-
1 = line-tables only (for stacktraces and breakpoints),
805-
2 = full debug info with variable and type information \
806-
(same as -g)", "LEVEL"),
807-
opt::flag("", "no-trans", "Run all passes except translation; no output"),
808-
opt::flag("", "no-analysis", "Parse and expand the source, but run no \
809-
analysis and produce no output"),
810-
opt::flag("", "parse-only", "Parse only; do not compile, assemble, \
811-
or link"),
812-
opt::flagopt("", "pretty",
796+
opt::flagopt_u("", "pretty",
813797
"Pretty-print the input instead of compiling;
814798
valid types are: `normal` (un-annotated source),
815799
`expanded` (crates expanded),
@@ -823,9 +807,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
823807
`everybody_loops` (all function bodies replaced with `loop {}`).",
824808
"TYPE"),
825809
opt::opt_u("", "show-span", "Show spans for compiler debugging", "expr|pat|ty"),
826-
opt::flagopt("", "dep-info",
827-
"Output dependency info to <filename> after compiling, \
828-
in a format suitable for use by Makefiles", "FILENAME"),
829810
]);
830811
opts
831812
}
@@ -861,27 +842,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
861842

862843
let debugging_opts = build_debugging_options(matches);
863844

864-
let parse_only = if matches.opt_present("parse-only") {
865-
// FIXME(acrichto) remove this eventually
866-
early_warn("--parse-only is deprecated in favor of -Z parse-only");
867-
true
868-
} else {
869-
debugging_opts.parse_only
870-
};
871-
let no_trans = if matches.opt_present("no-trans") {
872-
// FIXME(acrichto) remove this eventually
873-
early_warn("--no-trans is deprecated in favor of -Z no-trans");
874-
true
875-
} else {
876-
debugging_opts.no_trans
877-
};
878-
let no_analysis = if matches.opt_present("no-analysis") {
879-
// FIXME(acrichto) remove this eventually
880-
early_warn("--no-analysis is deprecated in favor of -Z no-analysis");
881-
true
882-
} else {
883-
debugging_opts.no_analysis
884-
};
845+
let parse_only = debugging_opts.parse_only;
846+
let no_trans = debugging_opts.no_trans;
847+
let no_analysis = debugging_opts.no_analysis;
885848

886849
if debugging_opts.debug_llvm {
887850
unsafe { llvm::LLVMSetDebug(1); }
@@ -921,28 +884,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
921884
host_triple().to_string());
922885
let opt_level = {
923886
if matches.opt_present("O") {
924-
if matches.opt_present("opt-level") {
925-
early_error("-O and --opt-level both provided");
926-
}
927887
if cg.opt_level.is_some() {
928888
early_error("-O and -C opt-level both provided");
929889
}
930890
Default
931-
} else if matches.opt_present("opt-level") {
932-
// FIXME(acrichto) remove this eventually
933-
early_warn("--opt-level=N is deprecated in favor of -C opt-level=N");
934-
match matches.opt_str("opt-level").as_ref().map(|s| s.as_slice()) {
935-
None |
936-
Some("0") => No,
937-
Some("1") => Less,
938-
Some("2") => Default,
939-
Some("3") => Aggressive,
940-
Some(arg) => {
941-
early_error(&format!("optimization level needs to be \
942-
between 0-3 (instead was `{}`)",
943-
arg)[]);
944-
}
945-
}
946891
} else {
947892
match cg.opt_level {
948893
None => No,
@@ -960,27 +905,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
960905
};
961906
let gc = debugging_opts.gc;
962907
let debuginfo = if matches.opt_present("g") {
963-
if matches.opt_present("debuginfo") {
964-
early_error("-g and --debuginfo both provided");
965-
}
966908
if cg.debuginfo.is_some() {
967909
early_error("-g and -C debuginfo both provided");
968910
}
969911
FullDebugInfo
970-
} else if matches.opt_present("debuginfo") {
971-
// FIXME(acrichto) remove this eventually
972-
early_warn("--debuginfo=N is deprecated in favor of -C debuginfo=N");
973-
match matches.opt_str("debuginfo").as_ref().map(|s| s.as_slice()) {
974-
Some("0") => NoDebugInfo,
975-
Some("1") => LimitedDebugInfo,
976-
None |
977-
Some("2") => FullDebugInfo,
978-
Some(arg) => {
979-
early_error(&format!("debug info level needs to be between \
980-
0-2 (instead was `{}`)",
981-
arg)[]);
982-
}
983-
}
984912
} else {
985913
match cg.debuginfo {
986914
None | Some(0) => NoDebugInfo,
@@ -1036,15 +964,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1036964

1037965
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
1038966
let test = matches.opt_present("test");
1039-
let write_dependency_info = if matches.opt_present("dep-info") {
1040-
// FIXME(acrichto) remove this eventually
1041-
early_warn("--dep-info has been deprecated in favor of --emit");
1042-
(true, matches.opt_str("dep-info").map(|p| Path::new(p)))
1043-
} else {
1044-
(output_types.contains(&OutputTypeDepInfo), None)
1045-
};
967+
let write_dependency_info = (output_types.contains(&OutputTypeDepInfo), None);
1046968

1047-
let mut prints = matches.opt_strs("print").into_iter().map(|s| {
969+
let prints = matches.opt_strs("print").into_iter().map(|s| {
1048970
match s.as_slice() {
1049971
"crate-name" => PrintRequest::CrateName,
1050972
"file-names" => PrintRequest::FileNames,
@@ -1054,18 +976,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1054976
}
1055977
}
1056978
}).collect::<Vec<_>>();
1057-
if matches.opt_present("print-crate-name") {
1058-
// FIXME(acrichto) remove this eventually
1059-
early_warn("--print-crate-name has been deprecated in favor of \
1060-
--print crate-name");
1061-
prints.push(PrintRequest::CrateName);
1062-
}
1063-
if matches.opt_present("print-file-name") {
1064-
// FIXME(acrichto) remove this eventually
1065-
early_warn("--print-file-name has been deprecated in favor of \
1066-
--print file-names");
1067-
prints.push(PrintRequest::FileNames);
1068-
}
1069979

1070980
if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
1071981
early_warn("-C remark will not show source locations without \

src/librustc_driver/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,14 @@ fn run_compiler(args: &[String]) {
154154
return
155155
}
156156

157-
let pretty = matches.opt_default("pretty", "normal").map(|a| {
158-
// stable pretty-print variants only
159-
pretty::parse_pretty(&sess, a.as_slice(), false)
160-
});
157+
let pretty = if sess.opts.debugging_opts.unstable_options {
158+
matches.opt_default("pretty", "normal").map(|a| {
159+
// stable pretty-print variants only
160+
pretty::parse_pretty(&sess, a.as_slice(), false)
161+
})
162+
} else {
163+
None
164+
};
161165
let pretty = if pretty.is_none() &&
162166
sess.unstable_options() {
163167
matches.opt_str("xpretty").map(|a| {

src/test/debuginfo/issue7712.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags:--debuginfo=1
11+
// compile-flags:-C debuginfo=1
1212
// min-lldb-version: 310
1313

1414
pub trait TraitWithDefaultMethod : Sized {

src/test/debuginfo/lexical-scope-in-parameterless-closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// ignore-android: FIXME(#10381)
1212
// min-lldb-version: 310
1313

14-
// compile-flags:--debuginfo=1
14+
// compile-flags:-C debuginfo=1
1515

1616
// gdb-command:run
1717
// lldb-command:run

src/test/debuginfo/limited-debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// ignore-lldb
1414

15-
// compile-flags:--debuginfo=1
15+
// compile-flags:-C debuginfo=1
1616

1717
// Make sure functions have proper names
1818
// gdb-command:info functions
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
-include ../tools.mk
22

33
all:
4-
[ `$(RUSTC) --print-crate-name crate.rs` = "foo" ]
5-
[ `$(RUSTC) --print-file-name crate.rs` = "$(call BIN,foo)" ]
6-
[ `$(RUSTC) --print-file-name --crate-type=lib \
4+
[ `$(RUSTC) --print crate-name crate.rs` = "foo" ]
5+
[ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ]
6+
[ `$(RUSTC) --print file-names --crate-type=lib \
77
--test crate.rs` = "$(call BIN,foo)" ]
8-
[ `$(RUSTC) --print-file-name --test lib.rs` = "$(call BIN,mylib)" ]
9-
$(RUSTC) --print-file-name lib.rs
10-
$(RUSTC) --print-file-name rlib.rs
8+
[ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ]
9+
$(RUSTC) --print file-names lib.rs
10+
$(RUSTC) --print file-names rlib.rs

src/test/run-make/dep-info-custom/Makefile

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/test/run-make/dep-info-custom/Makefile.foo

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/test/run-make/dep-info-custom/bar.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)