From cd6c0e4e3b71cffd6e577146cbf989ad6ba29c63 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 28 Jul 2021 16:35:57 +0200 Subject: [PATCH 1/2] Fix typo in rustc_driver::version This caused rustc -Zcodegen-backend=foo.so -vV to look for oo.so instead of foo.so --- compiler/rustc_driver/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 326fefa59ab05..50932d498b317 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -766,7 +766,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) { let debug_flags = matches.opt_strs("Z"); let backend_name = debug_flags.iter().find_map(|x| { if x.starts_with("codegen-backend=") { - Some(&x["codegen-backends=".len()..]) + Some(&x["codegen-backend=".len()..]) } else { None } From 2f6662da85d47ebf89432c910a496812e9e2db12 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 29 Jul 2021 11:54:39 +0200 Subject: [PATCH 2/2] Use strip_prefix --- compiler/rustc_driver/src/lib.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 50932d498b317..84dd69ebd9634 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -764,13 +764,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) { println!("release: {}", unw(util::release_str())); let debug_flags = matches.opt_strs("Z"); - let backend_name = debug_flags.iter().find_map(|x| { - if x.starts_with("codegen-backend=") { - Some(&x["codegen-backend=".len()..]) - } else { - None - } - }); + let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); get_codegen_backend(&None, backend_name).print_version(); } }