Rollup merge of #134285 - oli-obk:push-vwrqsqlwnuxo, r=Urgau
Add some convenience helper methods on `hir::Safety` Makes a lot of call sites simpler and should make any refactorings needed for https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 simpler, as fewer sites have to be touched in case we end up storing some information in the variants of `hir::Safety`
This commit is contained in:
commit
d48af09ffd
28 changed files with 74 additions and 70 deletions
|
@ -3434,6 +3434,19 @@ impl Safety {
|
|||
Self::Safe => "",
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_unsafe(self) -> bool {
|
||||
!self.is_safe()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_safe(self) -> bool {
|
||||
match self {
|
||||
Self::Unsafe => false,
|
||||
Self::Safe => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Safety {
|
||||
|
@ -3478,7 +3491,7 @@ impl FnHeader {
|
|||
}
|
||||
|
||||
pub fn is_unsafe(&self) -> bool {
|
||||
matches!(&self.safety, Safety::Unsafe)
|
||||
self.safety.is_unsafe()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue