Skip to content

Unexpected cfg condition name diagnostic is sometimes confusing #141440

@jieyouxu

Description

@jieyouxu

Discussion (not in scope for this PR): Maybe this diagnostic is a bit misleading? version is a condition name, but just that the parenthesized name-value form (forgot what that form is called technically) is what's considered valid cfg, and not the version = ".." name-with-literal-value form.

Originally posted by @jieyouxu in #141413 (comment)


If a cfg by the name-with-parenthesized-value form exists (e.g. cfg(version(..))) and the user writes the meta literal(?) form e.g. cfg(version = ".."), we currently produce a diagnostic that says

warning: unexpected `cfg` condition name: `version`

This is technically true, because we don't expect the version = ".." form, we expect the version(..) form.

I wonder if we could clarify the diagnostic here if the version(..) form is a thing but not the version = ".." form.

(Picked version as an example, this is generally applicable.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cfgArea: `cfg` conditional compilationA-diagnosticsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions