Rollup merge of #66381 - Centril:66340, r=petrochenkov
find_deprecation: deprecation attr may be ill-formed meta. Fixes #66340. r? @petrochenkov cc @pnkfelix
This commit is contained in:
commit
842612fcc0
3 changed files with 23 additions and 1 deletions
|
|
@ -667,7 +667,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,
|
||||
};
|
||||
depr = match &meta.kind {
|
||||
MetaItemKind::Word => Some(Deprecation { since: None, note: None }),
|
||||
MetaItemKind::NameValue(..) => {
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue