Skip to content

Commit b6144cd

Browse files
authored
Rollup merge of #112692 - jieyouxu:better-err-msg-for-unstable-options, r=davidtwco
Provide more context for `rustc +nightly -Zunstable-options` on stable <img width="724" alt="Screenshot 2023-06-16 123456" src="https://github.com/rust-lang/rust/assets/39484203/1933e172-cb9f-4e51-9540-ade803a88360"> Closes #110090.
2 parents 448d2a8 + cef812b commit b6144cd

File tree

19 files changed

+512
-474
lines changed

19 files changed

+512
-474
lines changed

Diff for: compiler/rustc_codegen_cranelift/src/pretty_clif.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ pub(crate) fn write_ir_file(
225225
let res = std::fs::File::create(clif_file_name).and_then(|mut file| write(&mut file));
226226
if let Err(err) = res {
227227
// Using early_warn as no Session is available here
228-
rustc_session::early_warn(
228+
let handler = rustc_session::EarlyErrorHandler::new(
229229
rustc_session::config::ErrorOutputType::default(),
230-
format!("error writing ir file: {}", err),
231230
);
231+
handler.early_warn(format!("error writing ir file: {}", err));
232232
}
233233
}
234234

Diff for: compiler/rustc_driver_impl/src/args.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::fmt;
33
use std::fs;
44
use std::io;
55

6+
use rustc_session::EarlyErrorHandler;
7+
68
fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
79
if let Some(path) = arg.strip_prefix('@') {
810
let file = match fs::read_to_string(path) {
@@ -21,15 +23,12 @@ fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
2123
/// **Note:** This function doesn't interpret argument 0 in any special way.
2224
/// If this function is intended to be used with command line arguments,
2325
/// `argv[0]` must be removed prior to calling it manually.
24-
pub fn arg_expand_all(at_args: &[String]) -> Vec<String> {
26+
pub fn arg_expand_all(handler: &EarlyErrorHandler, at_args: &[String]) -> Vec<String> {
2527
let mut args = Vec::new();
2628
for arg in at_args {
2729
match arg_expand(arg.clone()) {
2830
Ok(arg) => args.extend(arg),
29-
Err(err) => rustc_session::early_error(
30-
rustc_session::config::ErrorOutputType::default(),
31-
format!("Failed to load argument file: {err}"),
32-
),
31+
Err(err) => handler.early_error(format!("Failed to load argument file: {err}")),
3332
}
3433
}
3534
args

0 commit comments

Comments
 (0)