Understanding TerminatorKind::Resume

For example consider this cfg:

    #[inline]
    #[stable(feature = "rust1", since = "1.0.0")]
    pub fn ok_or<E>(self, err: E) -> Result<T, E> {
        match self {
            Some(v) => Ok(v),
            None => Err(err),
        }
    }

The way I handled resume previously for this case, was that I saw that there was a drop at 11 with an unwind, so I always unwind first and then resume at 7.

But if that is the case, why isn't there an edge from 1 -> 7 in the first place? I think that I just misunderstand Resume.

Consider this CFG

    #[inline]
    #[stable(feature = "rust1", since = "1.0.0")]
    pub fn unwrap(self) -> T {
        match self {
            Ok(t) => t,
            Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", e),
        }
    }

I see Resume in an Unwind only path, I don't see how we can resume from there at all. I kind of expected an abort instead of an resume.

1 Like

Resume means that the unwinding process is resumed, not the regular control flow of the function. So you leave the function and look for landing pads further up in the call stack.

2 Likes

Thanks, I’ll have a look at how the llvm backend handles all of this.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.