suggest to trim prefix in nested meta items
This commit is contained in:
parent
30c6698193
commit
d3b018ccdb
2 changed files with 27 additions and 3 deletions
|
@ -596,7 +596,17 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess,
|
||||||
*item = Some(v);
|
*item = Some(v);
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
span_err!(diagnostic, meta.span, E0551, "incorrect meta item");
|
if let Some(lit) = meta.name_value_literal() {
|
||||||
|
handle_errors(
|
||||||
|
sess,
|
||||||
|
lit.span,
|
||||||
|
AttrError::UnsupportedLiteral,
|
||||||
|
lit.node.is_bytestr(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
span_err!(diagnostic, meta.span, E0551, "incorrect meta item");
|
||||||
|
}
|
||||||
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -622,7 +632,7 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess,
|
||||||
}
|
}
|
||||||
NestedMetaItemKind::Literal(lit) => {
|
NestedMetaItemKind::Literal(lit) => {
|
||||||
let is_bytestr = lit.node.is_bytestr();
|
let is_bytestr = lit.node.is_bytestr();
|
||||||
handle_errors(sess, meta.span, AttrError::UnsupportedLiteral, is_bytestr);
|
handle_errors(sess, lit.span, AttrError::UnsupportedLiteral, is_bytestr);
|
||||||
continue 'outer
|
continue 'outer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,7 +692,12 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
|
||||||
mark_used(attr);
|
mark_used(attr);
|
||||||
for item in items {
|
for item in items {
|
||||||
if !item.is_meta_item() {
|
if !item.is_meta_item() {
|
||||||
handle_errors(sess, item.span, AttrError::UnsupportedLiteral, false);
|
let (span, is_bytestr) = if let Some(lit) = item.literal() {
|
||||||
|
(lit.span, lit.node.is_bytestr())
|
||||||
|
} else {
|
||||||
|
(item.span, false)
|
||||||
|
};
|
||||||
|
handle_errors(sess, span, AttrError::UnsupportedLiteral, is_bytestr);
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,15 @@ impl MetaItem {
|
||||||
name_from_path(&self.ident)
|
name_from_path(&self.ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #[attribute(name = "value")]
|
||||||
|
// ^^^^^^^^^^^^^^
|
||||||
|
pub fn name_value_literal(&self) -> Option<&Lit> {
|
||||||
|
match &self.node {
|
||||||
|
MetaItemKind::NameValue(v) => Some(v),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn value_str(&self) -> Option<Symbol> {
|
pub fn value_str(&self) -> Option<Symbol> {
|
||||||
match self.node {
|
match self.node {
|
||||||
MetaItemKind::NameValue(ref v) => {
|
MetaItemKind::NameValue(ref v) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue