Skip to main content

HasSafety

Trait HasSafety 

Source
pub trait HasSafety {
    // Required method
    fn safety(&self, krate: &TranslatedCrate) -> Safety;
}
Expand description

The safety of evaluating this, following the rules outlined in https://doc.rust-lang.org/book/ch20-01-unsafe-rust.html and https://doc.rust-lang.org/reference/unsafety.html.

This is computed on the translated (U)LLBC, so it can’t know exactly what the user wrote. For example, macros like println!("{x}") expand to unsafe operations inside their own unsafe blocks. Some safe operations like slice indexing also expand to a bounds check followed by an unchecked access. Dead code elimination may hide an unsafe operation. So all in all this will not report exactly the same safety as rustc sees in the surface code. It is however accurate if you treat (U)LLBC as its own language: we accurately flag operations that have soundness preconditions.

We currently don’t support unsafe fields and unsafe binders.

Required Methods§

Source

fn safety(&self, krate: &TranslatedCrate) -> Safety

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl HasSafety for AbortKind

Source§

impl HasSafety for BinOp

Source§

impl HasSafety for BorrowckStatement

Source§

impl HasSafety for Call

The safety of calling the function (see CallSafety) and of evaluating the function pointer, the operands and the destination.

Source§

impl HasSafety for FnOperand

Source§

impl HasSafety for FunSig

Source§

impl HasSafety for Operand

Source§

impl HasSafety for OverflowMode

Source§

impl HasSafety for Rvalue

Source§

impl HasSafety for charon_lib::ast::bodies::structured::Statement

This doesn’t look into nested blocks.

Source§

impl HasSafety for charon_lib::ast::bodies::unstructured::Statement

Note that calls are terminators.

Source§

impl HasSafety for SwitchData

Source§

impl HasSafety for Terminator

Source§

impl HasSafety for UnOp

Source§

impl<I: ?Sized, T: HasSafety> HasSafety for I
where for<'a> &'a I: IntoIterator<Item = &'a T>,

Source§

impl<T: HasSafety> HasSafety for RegionBinder<T>