|
10 | 10 |
|
11 | 11 | //! Parsing and validation of builtin attributes
|
12 | 12 |
|
13 |
| -use ast::{self, Attribute, MetaItem, Name, NestedMetaItemKind}; |
| 13 | +use ast::{self, Attribute, LitKind, MetaItem, Name, NestedMetaItemKind}; |
14 | 14 | use errors::{Applicability, Handler};
|
15 | 15 | use feature_gate::{Features, GatedCfg};
|
16 | 16 | use parse::ParseSess;
|
@@ -598,12 +598,10 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess,
|
598 | 598 | let diagnostic = &sess.span_diagnostic;
|
599 | 599 |
|
600 | 600 | 'outer: for attr in attrs_iter {
|
601 |
| - if attr.path != "deprecated" { |
| 601 | + if !attr.check_name("deprecated") { |
602 | 602 | continue
|
603 | 603 | }
|
604 | 604 |
|
605 |
| - mark_used(attr); |
606 |
| - |
607 | 605 | if depr.is_some() {
|
608 | 606 | span_err!(diagnostic, item_sp, E0550, "multiple deprecated attributes");
|
609 | 607 | break
|
@@ -670,6 +668,28 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess,
|
670 | 668 | }
|
671 | 669 |
|
672 | 670 | Some(Deprecation {since: since, note: note})
|
| 671 | + } else if let Some(lit) = attr |
| 672 | + .meta() |
| 673 | + .as_ref() |
| 674 | + .and_then(|meta| meta.name_value_literal()) |
| 675 | + { |
| 676 | + let mut err = sess |
| 677 | + .span_diagnostic |
| 678 | + .struct_span_err(attr.span, "expected meta item sequence"); |
| 679 | + |
| 680 | + if let LitKind::Str(s, _) = lit.node { |
| 681 | + let sp = attr.path.span.to(lit.span); |
| 682 | + err.span_suggestion_with_applicability( |
| 683 | + sp, |
| 684 | + "use the `note` key", |
| 685 | + format!("deprecated(note = \"{}\")", s), |
| 686 | + Applicability::MachineApplicable, |
| 687 | + ); |
| 688 | + } |
| 689 | + |
| 690 | + err.emit(); |
| 691 | + |
| 692 | + continue 'outer; |
673 | 693 | } else {
|
674 | 694 | Some(Deprecation{since: None, note: None})
|
675 | 695 | }
|
|
0 commit comments