about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-01-10 14:45:38 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-01-11 16:55:10 +1100
commita0f5431e2385c08e40eb8c549249f4e94b32318c (patch)
tree28fa86b324a39d66503cf682d4fb7f2c5750ffff /compiler/rustc_errors/src
parent2aac288c18f96c55677d90262e068820caf310f3 (diff)
downloadrust-a0f5431e2385c08e40eb8c549249f4e94b32318c.tar.gz
rust-a0f5431e2385c08e40eb8c549249f4e94b32318c.zip
Move code around.
No point computing `warnings` and `errors` if we're going to return
early before they're used.
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/lib.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index e60300bc3eb..404c89ea01b 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -981,6 +981,10 @@ impl DiagCtxt {
 
         inner.emit_stashed_diagnostics();
 
+        if inner.treat_err_as_bug() {
+            return;
+        }
+
         let warnings = match inner.deduplicated_warn_count {
             0 => Cow::from(""),
             1 => Cow::from("1 warning emitted"),
@@ -991,9 +995,6 @@ impl DiagCtxt {
             1 => Cow::from("aborting due to 1 previous error"),
             count => Cow::from(format!("aborting due to {count} previous errors")),
         };
-        if inner.treat_err_as_bug() {
-            return;
-        }
 
         match (errors.len(), warnings.len()) {
             (0, 0) => return,