diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-02-10 15:28:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-10 15:28:47 +0100 |
| commit | d494cd3eab38c319985e38f5fd43465391fa2bbe (patch) | |
| tree | 64ae71d86c346778201e8328c13e24677ea02a9f /compiler | |
| parent | dc7559b599d70419b079d4b97949dfe85d1c17ac (diff) | |
| parent | 257389882de113945d3f9f1abb9d0a431ca3cf92 (diff) | |
| download | rust-d494cd3eab38c319985e38f5fd43465391fa2bbe.tar.gz rust-d494cd3eab38c319985e38f5fd43465391fa2bbe.zip | |
Rollup merge of #107836 - chenyukang:yukang/fix-107822, r=oli-obk
Handle properly when there is no crate attrs Fixes #107822 r? `@oli-obk`
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index bdf2978cee2..37967bfdff5 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -624,7 +624,10 @@ fn print_crate_info( println!("{}", serde_json::to_string_pretty(&sess.target.to_json()).unwrap()); } FileNames | CrateName => { - let attrs = attrs.as_ref().unwrap(); + let Some(attrs) = attrs.as_ref() else { + // no crate attributes, print out an error and exit + return Compilation::Continue; + }; let t_outputs = rustc_interface::util::build_output_filenames(attrs, sess); let id = rustc_session::output::find_crate_name(sess, attrs); if *req == PrintRequest::CrateName { |
