Skip to content

Fix handling of ? operator in Rust nexits metric #1123

Closed
@alexle0nte

Description

@alexle0nte

As pointed out by #1113, the ? operator can also represent an exit point within a Rust function, and therefore, it must be counted in the nexits metric.

However, not all Rust::QMARK nodes should be counted as exit points.
For example, in this code:

pub fn assert_ser_tokens<T: ?Sized>(value: &T, tokens: &[Token])
where
    T: Serialize,
{
    let mut ser = Serializer::new(tokens);
    match value.serialize(&mut ser) {
        Ok(_) => {}
        Err(err) => panic!("value failed to serialize: {}", err),
    }

    if ser.remaining() > 0 {
        panic!("{} remaining tokens", ser.remaining());
    }
}

the ? on the first line, inside <T: ?Sized>, doesn't represent an exit point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions