Skip to content

Commit 842612f

Browse files
authored
Rollup merge of #66381 - Centril:66340, r=petrochenkov
find_deprecation: deprecation attr may be ill-formed meta. Fixes #66340. r? @petrochenkov cc @pnkfelix
2 parents 54998d1 + 91aadf0 commit 842612f

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/libsyntax/attr/builtin.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,10 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess,
667667
break
668668
}
669669

670-
let meta = attr.meta().unwrap();
670+
let meta = match attr.meta() {
671+
Some(meta) => meta,
672+
None => continue,
673+
};
671674
depr = match &meta.kind {
672675
MetaItemKind::Word => Some(Deprecation { since: None, note: None }),
673676
MetaItemKind::NameValue(..) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// The original problem in #66340 was that `find_deprecation_generic`
2+
// called `attr.meta().unwrap()` under the assumption that the attribute
3+
// was a well-formed `MetaItem`.
4+
5+
fn main() {
6+
foo()
7+
}
8+
9+
#[deprecated(note = test)]
10+
//~^ ERROR expected unsuffixed literal or identifier, found `test`
11+
fn foo() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected unsuffixed literal or identifier, found `test`
2+
--> $DIR/issue-66340-deprecated-attr-non-meta-grammar.rs:9:21
3+
|
4+
LL | #[deprecated(note = test)]
5+
| ^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)