fn codegen_assert_intrinsic(
        &mut self,
        instance: Instance<'tcx>,
        intrinsic: &str,
        span: Option<Span>,
    ) -> Stmt {
        let ty = instance.substs.type_at(0);
        let layout = self.layout_of(ty);
        // Note: We follow the pattern seen in `codegen_panic_intrinsic` from `rustc_codegen_ssa`
        // https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_ssa/src/mir/block.rs

        // For all intrinsics we first check `is_uninhabited` to give a more
        // precise error message
        if layout.abi.is_uninhabited() {
            return self.codegen_fatal_error(
                PropertyClass::DefaultAssertion,
                &format!("attempted to instantiate uninhabited type `{}`", ty),
                span,
            );
        }

        // Then we check if the type allows "raw" initialization for the cases
        // where memory is zero-initialized or entirely uninitialized
        if intrinsic == "assert_zero_valid" && !layout.might_permit_raw_init(self, true) {
            return self.codegen_fatal_error(
                PropertyClass::DefaultAssertion,
                &format!("attempted to zero-initialize type `{}`, which is invalid", ty),
                span,
            );
        }

        if intrinsic == "assert_uninit_valid" && !layout.might_permit_raw_init(self, false) {
            return self.codegen_fatal_error(
                PropertyClass::DefaultAssertion,
                &format!("attempted to leave type `{}` uninitialized, which is invalid", ty),
                span,
            );
        }

        // Otherwise we generate a no-op statement
        let loc = self.codegen_span_option(span);
        return Stmt::skip(loc);
    }
/// Generates either a panic or no-op for `assert_*` intrinsics.
/// These are intrinsics that statically compile to panics if the type
/// layout is invalid so we get a message that mentions the offending type.
///
/// https://doc.rust-lang.org/std/intrinsics/fn.assert_inhabited.html
/// https://doc.rust-lang.org/std/intrinsics/fn.assert_uninit_valid.html
/// https://doc.rust-lang.org/std/intrinsics/fn.assert_zero_valid.html
Generates either a panic or no-op for `assert_*` intrinsics.
These are intrinsics that statically compile to panics if the type
layout is invalid so we get a message that mentions the offending type.


Generates either a panic or no - op for ` assert_ * ` intrinsics . These are intrinsics that statically compile to panics if the type layout is invalid so we get a message that mentions the offending type .
fn codegen_assert_intrinsic(
        &mut self,
        instance: Instance<'tcx>,
        intrinsic: &str,
        span: Option<Span>,
    ) -> Stmt {
        let ty = instance.substs.type_at(0);
        let layout = self.layout_of(ty);
        // Note: We follow the pattern seen in `codegen_panic_intrinsic` from `rustc_codegen_ssa`
        // https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_ssa/src/mir/block.rs
        // For all intrinsics we first check `is_uninhabited` to give a more
        // precise error message
        if layout.abi.is_uninhabited() {
            return self.codegen_fatal_error(
                PropertyClass::DefaultAssertion,
                &format!("attempted to instantiate uninhabited type `{}`", ty),
                span,
            );
        }
        // Then we check if the type allows "raw" initialization for the cases
        // where memory is zero-initialized or entirely uninitialized
        if intrinsic == "assert_zero_valid" && !layout.might_permit_raw_init(self, true) {
            return self.codegen_fatal_error(
                PropertyClass::DefaultAssertion,
                &format!("attempted to zero-initialize type `{}`, which is invalid", ty),
                span,
            );
        }
        if intrinsic == "assert_uninit_valid" && !layout.might_permit_raw_init(self, false) {
            return self.codegen_fatal_error(
                PropertyClass::DefaultAssertion,
                &format!("attempted to leave type `{}` uninitialized, which is invalid", ty),
                span,
            );
        }
        // Otherwise we generate a no-op statement
        let loc = self.codegen_span_option(span);
        return Stmt::skip(loc);
    }
fn codegen_assert_intrinsic ( & mut self , instance : Instance < ' tcx > , intrinsic : & str , span : Option < Span > , ) -> Stmt { let ty = instance . substs . type_at ( 0 ) ; let layout = self . layout_of ( ty ) ; // Note: We follow the pattern seen in `codegen_panic_intrinsic` from `rustc_codegen_ssa` // https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_ssa/src/mir/block.rs // For all intrinsics we first check `is_uninhabited` to give a more // precise error message if layout . abi . is_uninhabited ( ) { return self . codegen_fatal_error ( PropertyClass :: DefaultAssertion , & format ! ( " " ty ) , span , ) ; } // Then we check if the type allows "raw" initialization for the cases // where memory is zero-initialized or entirely uninitialized if intrinsic == " " && ! layout . might_permit_raw_init ( self , true ) { return self . codegen_fatal_error ( PropertyClass :: DefaultAssertion , & format ! ( " " ty ) , span , ) ; } if intrinsic == " " && ! layout . might_permit_raw_init ( self , false ) { return self . codegen_fatal_error ( PropertyClass :: DefaultAssertion , & format ! ( " " ty ) , span , ) ; } // Otherwise we generate a no-op statement let loc = self . codegen_span_option ( span ) ; return Stmt :: skip ( loc ) ; }
Generates either a panic or no-op for `assert_*` intrinsics.
Generates either a panic or no - op for ` assert_ * ` intrinsics .
&mut self
instance
Instance<'tcx>
intrinsic
&str
span
Option<Span>