Skip to content

Possible parse error / possible unused_parens false positive (explicit return UFCS) #37765

@withoutboats

Description

@withoutboats

This does not compile, because the open < is parsed as a comparison operator. Possibly, this is a bug, and it should be parsed as it is intended - opening a type scope. But I don't know.

pub fn stringify<T: ToString>(arg: T) -> String {
    return <T as ToString>::to_string(&arg);
}

If the current parse is correct, adding parens should not produce an unused_parens error, because these parens are necessary to make it parse as intended. However, it does:

pub fn stringify<T: ToString>(arg: T) -> String {
    return (<T as ToString>::to_string(&arg));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions