Skip to content

single_match_else suggestion introduces violation of semicolon_if_nothing_returned #16579

@xtqqczze

Description

@xtqqczze

Summary

When applying the single_match_else suggestion, the output introduces a violation of semicolon_if_nothing_returned.

Reproducer

Code:

            match parse_char_escape(line) {
                Some(decoded) => result.push(decoded),
                None => {
                    result.push('\\');
                    result.push(line.current());
                    line.advance();
                }
            }

Current output:

            if let Some(decoded) = parse_char_escape(line) {
                result.push(decoded) // semicolon_if_nothing_returned
            } else {
                result.push('\\');
                result.push(line.current());
                line.advance();
            }

Desired output:

            if let Some(decoded) = parse_char_escape(line) {
                result.push(decoded);
            } else {
                result.push('\\');
                result.push(line.current());
                line.advance();
            }

Version

nightly

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions