pub(crate) fn compile_pat_offset(
        &mut self,
        pat: &ast::Pat,
        offset: usize,
    ) -> CompileResult<()> {
        let span = pat.span();

        let load = |c: &mut Compiler, needs: Needs| {
            if needs.value() {
                c.asm.push(Inst::Copy { offset }, span);
            }

            Ok(())
        };

        let false_label = self.asm.new_label("let_panic");

        if self.compile_pat(pat, false_label, &load)? {
            self.diagnostics
                .let_pattern_might_panic(self.source_id, span, self.context());

            let ok_label = self.asm.new_label("let_ok");
            self.asm.jump(ok_label, span);
            self.asm.label(false_label)?;
            self.asm.push(
                Inst::Panic {
                    reason: runestick::PanicReason::UnmatchedPattern,
                },
                span,
            );

            self.asm.label(ok_label)?;
        }

        Ok(())
    }
/// Compile a pattern based on the given offset.
Compile a pattern based on the given offset.
Compile a pattern based on the given offset .
pub(crate) fn compile_pat_offset(
        &mut self,
        pat: &ast::Pat,
        offset: usize,
    ) -> CompileResult<()> {
        let span = pat.span();
        let load = |c: &mut Compiler, needs: Needs| {
            if needs.value() {
                c.asm.push(Inst::Copy { offset }, span);
            }
            Ok(())
        };
        let false_label = self.asm.new_label("let_panic");
        if self.compile_pat(pat, false_label, &load)? {
            self.diagnostics
                .let_pattern_might_panic(self.source_id, span, self.context());
            let ok_label = self.asm.new_label("let_ok");
            self.asm.jump(ok_label, span);
            self.asm.label(false_label)?;
            self.asm.push(
                Inst::Panic {
                    reason: runestick::PanicReason::UnmatchedPattern,
                },
                span,
            );
            self.asm.label(ok_label)?;
        }
        Ok(())
    }
pub ( crate ) fn compile_pat_offset ( & mut self , pat : & ast :: Pat , offset : usize , ) -> CompileResult < ( ) > { let span = pat . span ( ) ; let load = | c : & mut Compiler , needs : Needs | { if needs . value ( ) { c . asm . push ( Inst :: Copy { offset } , span ) ; } Ok ( ( ) ) } ; let false_label = self . asm . new_label ( " " ) ; if self . compile_pat ( pat , false_label , & load ) ? { self . diagnostics . let_pattern_might_panic ( self . source_id , span , self . context ( ) ) ; let ok_label = self . asm . new_label ( " " ) ; self . asm . jump ( ok_label , span ) ; self . asm . label ( false_label ) ? ; self . asm . push ( Inst :: Panic { reason : runestick :: PanicReason :: UnmatchedPattern , } , span , ) ; self . asm . label ( ok_label ) ? ; } Ok ( ( ) ) }
Compile a pattern based on the given offset.
Compile a pattern based on the given offset .
&mut self
pat
&ast::Pat
offset
usize
&mut self
pat
&ast::Pat
offset
usize