Skip to content

compiletest string_enums have no error reporting #135392

Closed
@lolbinarycat

Description

@lolbinarycat

in common.rs:

        impl FromStr for $name {
            type Err = ();

            fn from_str(s: &str) -> Result<Self, ()> {
                match s {
                    $($repr => Ok(Self::$variant),)*
                    _ => Err(()),
                }
            }
        }

the error type being unit means if you pass an unrecognized option to any string enum flag, you get a very unhelpful error (it just prints ()).

if it was changed to the following:

        impl FromStr for $name {
            type Err = String;

            fn from_str(s: &str) -> Result<Self, String> {
                match s {
                    $($repr => Ok(Self::$variant),)*
                    _ => Err(s.to_string()),
                }
            }
        }

you would at least get an error message that says what the unrecognized argument is.

i would file a PR myself but the build system seems to be falling apart at the seams for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-compiletestArea: The compiletest test runnerC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions