diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-14 11:12:51 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-06 18:59:45 +0000 |
| commit | b9bf119c4f98f40eb84b385a6d3239c358b054cb (patch) | |
| tree | 9192adf11294d03f7a1818bb4f4582ac2e4f2b11 /compiler/rustc_errors | |
| parent | e60fbaf4ce768d13a6abc048bd34ee12995d18dc (diff) | |
| download | rust-b9bf119c4f98f40eb84b385a6d3239c358b054cb.tar.gz rust-b9bf119c4f98f40eb84b385a6d3239c358b054cb.zip | |
Simplify some nested conditions
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index db595df8ec1..98639434d8c 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1386,20 +1386,13 @@ impl EmitterWriter { let mut annotated_files = FileWithAnnotatedLines::collect_annotations(self, args, msp); // Make sure our primary file comes first - let (primary_lo, sm) = if let (Some(sm), Some(ref primary_span)) = - (self.sm.as_ref(), msp.primary_span().as_ref()) - { - if !primary_span.is_dummy() { - (sm.lookup_char_pos(primary_span.lo()), sm) - } else { - emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?; - return Ok(()); - } - } else { + let primary_span = msp.primary_span().unwrap_or_default(); + let (Some(sm), false) = (self.sm.as_ref(), primary_span.is_dummy()) else { // If we don't have span information, emit and exit emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?; return Ok(()); }; + let primary_lo = sm.lookup_char_pos(primary_span.lo()); if let Ok(pos) = annotated_files.binary_search_by(|x| x.file.name.cmp(&primary_lo.file.name)) { |
