Skip to content

Commit

Permalink
Auto merge of #51653 - mglagla:option-unreachable, r=dtolnay
Browse files Browse the repository at this point in the history
Option::get_or_insert(_with): Replace unreachable! with unreachable_unchecked

Optimize codegen for both functions as the None branch is trivially not reachable.
  • Loading branch information
bors committed Jun 23, 2018
2 parents 4fe88c0 + 11341e2 commit 60efbde
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
#![stable(feature = "rust1", since = "1.0.0")]

use iter::{FromIterator, FusedIterator, TrustedLen};
use {mem, ops};
use {hint, mem, ops};
use mem::PinMut;

// Note that this is not a lang item per se, but it has a hidden dependency on
Expand Down Expand Up @@ -784,7 +784,7 @@ impl<T> Option<T> {

match *self {
Some(ref mut v) => v,
_ => unreachable!(),
None => unsafe { hint::unreachable_unchecked() },
}
}

Expand Down Expand Up @@ -817,7 +817,7 @@ impl<T> Option<T> {

match *self {
Some(ref mut v) => v,
_ => unreachable!(),
None => unsafe { hint::unreachable_unchecked() },
}
}

Expand Down

0 comments on commit 60efbde

Please sign in to comment.