Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse error in #[feature(...)] discards all mentioned features. #80227

Open
lcnr opened this issue Dec 20, 2020 · 1 comment
Open

parse error in #[feature(...)] discards all mentioned features. #80227

lcnr opened this issue Dec 20, 2020 · 1 comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug.

Comments

@lcnr
Copy link
Contributor

lcnr commented Dec 20, 2020

#![feature(const_generics, use std::mem)]

pub struct Bar<const N: usize>;

and

#![feature(const_generics, 'other_feature)]

pub struct Bar<const N: usize>;

Both emit both a parse error and

error[E0658]: const generics are unstable
 --> src/lib.rs:3:22
  |
3 | pub struct Bar<const N: usize>;
  |                      ^
  |
  = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
  = help: add `#![feature(min_const_generics)]` to the crate attributes to enable

Ideally we should still accept the features parsed before that error, so it would be nice to only emit the parse error here.

Split out from #80077, thanks @leonardo-m for opening that issue.

@varkor
Copy link
Member

varkor commented Dec 20, 2020

Presumably this is the behaviour for attributes in general: if a single item is malformed, the entire attribute won't be parsed. I wonder whether resolving this in general might lead to unexpected behaviour for other attributes.

@camelid camelid added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-parser Area: The parsing of Rust source code to an AST labels Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants