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

find_deprecation: deprecation attr may be ill-formed meta. #66381

Merged
merged 1 commit into from
Nov 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/libsyntax/attr/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,10 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess,
break
}

let meta = attr.meta().unwrap();
let meta = match attr.meta() {
Some(meta) => meta,
None => continue,
};
Centril marked this conversation as resolved.
Show resolved Hide resolved
depr = match &meta.kind {
MetaItemKind::Word => Some(Deprecation { since: None, note: None }),
MetaItemKind::NameValue(..) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// The original problem in #66340 was that `find_deprecation_generic`
// called `attr.meta().unwrap()` under the assumption that the attribute
// was a well-formed `MetaItem`.

fn main() {
foo()
}

#[deprecated(note = test)]
//~^ ERROR expected unsuffixed literal or identifier, found `test`
fn foo() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected unsuffixed literal or identifier, found `test`
--> $DIR/issue-66340-deprecated-attr-non-meta-grammar.rs:9:21
|
LL | #[deprecated(note = test)]
| ^^^^

error: aborting due to previous error