Skip to content

don't allow unknown values in allow annotations #2372

Description

@brady-stacks
#[test]
fn parse_allow_rejects_unknown_warning_kind() {
    // If the user includes an unknown warning kind alongside a valid one,
    // parsing should fail rather than silently dropping the unknown name and
    // accepting only the recognized parts. Today the `filter_map(.. .ok())`
    // in the `allow` arm hides the typo.
    let result = "#[allow(unused_const, not_a_real_warning)]".parse::<AnnotationKind>();
    assert!(
        result.is_err(),
        "expected Err for unknown warning kind, got {result:?} \
         (the unknown kind 'not_a_real_warning' was silently dropped)"
    );
}

context: #2371

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions