Skip to content

WCA: We permit outer attributes that don't annotate anything at the end of where clauses #155073

@fmease

Description

@fmease

Note

Similar to #152820, this was found thanks to @matthiaskrgr fuzzing fmease/rasur versus rustc.
Downstream report: fmease/rasur#33.

We currently erroneously accept programs like the following:

#![feature(where_clause_attrs)]

struct S where #[allow()];
//             ~~~~~~~~~~ doesn't annotate anything; not present in the AST
#![feature(where_clause_attrs)]

fn f() where #[cfg(false)] {}
//           ~~~~~~~~~~~~~ doesn't annotate anything; not present in the AST
#![feature(where_clause_attrs)]

fn f<T>()
where
    T: Copy,
    #[cfg(true)]   // these two don't annotate anything;
    #[cfg(false)]  // they're absent from the AST
{}

Compare this with e.g.,

  • fn f(#[allow()]) {} where we emit expected parameter name, found ) or
  • struct X<#[allow()]>; which we reject with attribute without generic parameters or
  • fn f() { #[allow()] } for which we report expected statement after outer attribute and so on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.F-where_clause_attrs`#![feature(where_clause_attrs)]`S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    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