Skip to content

Commit b9bf119

Browse files
committed
Simplify some nested conditions
1 parent e60fbaf commit b9bf119

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,20 +1386,13 @@ impl EmitterWriter {
13861386
let mut annotated_files = FileWithAnnotatedLines::collect_annotations(self, args, msp);
13871387

13881388
// Make sure our primary file comes first
1389-
let (primary_lo, sm) = if let (Some(sm), Some(ref primary_span)) =
1390-
(self.sm.as_ref(), msp.primary_span().as_ref())
1391-
{
1392-
if !primary_span.is_dummy() {
1393-
(sm.lookup_char_pos(primary_span.lo()), sm)
1394-
} else {
1395-
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
1396-
return Ok(());
1397-
}
1398-
} else {
1389+
let primary_span = msp.primary_span().unwrap_or_default();
1390+
let (Some(sm), false) = (self.sm.as_ref(), primary_span.is_dummy()) else {
13991391
// If we don't have span information, emit and exit
14001392
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
14011393
return Ok(());
14021394
};
1395+
let primary_lo = sm.lookup_char_pos(primary_span.lo());
14031396
if let Ok(pos) =
14041397
annotated_files.binary_search_by(|x| x.file.name.cmp(&primary_lo.file.name))
14051398
{

0 commit comments

Comments
 (0)