diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-03-17 14:17:47 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-03-17 17:04:58 +0300 |
| commit | db74efce69711fcee03d3338afcbca67c27ceee8 (patch) | |
| tree | ab54b453943a292c250b890140d431e99091be5e /src/libsyntax/attr/mod.rs | |
| parent | 7cf074a1e655ac07d04d045667278fa1a9970b93 (diff) | |
| download | rust-db74efce69711fcee03d3338afcbca67c27ceee8.tar.gz rust-db74efce69711fcee03d3338afcbca67c27ceee8.zip | |
Make meta-item API compatible with `LocalInternedString::get` soundness fix
Diffstat (limited to 'src/libsyntax/attr/mod.rs')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 1a8faa43fff..c0bd5c79b1d 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -22,7 +22,7 @@ use crate::parse::parser::Parser; use crate::parse::{self, ParseSess, PResult}; use crate::parse::token::{self, Token}; use crate::ptr::P; -use crate::symbol::Symbol; +use crate::symbol::{keywords, LocalInternedString, Symbol}; use crate::ThinVec; use crate::tokenstream::{TokenStream, TokenTree, DelimSpan}; use crate::GLOBALS; @@ -89,8 +89,8 @@ impl NestedMetaItem { pub fn ident(&self) -> Option<Ident> { self.meta_item().and_then(|meta_item| meta_item.ident()) } - pub fn ident_str(&self) -> Option<&str> { - self.ident().map(|name| name.as_str().get()) + pub fn name_or_empty(&self) -> LocalInternedString { + self.ident().unwrap_or(keywords::Invalid.ident()).name.as_str() } /// Gets the string value if self is a MetaItem and the MetaItem is a @@ -167,8 +167,8 @@ impl Attribute { None } } - pub fn ident_str(&self) -> Option<&str> { - self.ident().map(|name| name.as_str().get()) + pub fn name_or_empty(&self) -> LocalInternedString { + self.ident().unwrap_or(keywords::Invalid.ident()).name.as_str() } pub fn value_str(&self) -> Option<Symbol> { @@ -205,8 +205,8 @@ impl MetaItem { None } } - pub fn ident_str(&self) -> Option<&str> { - self.ident().map(|name| name.as_str().get()) + pub fn name_or_empty(&self) -> LocalInternedString { + self.ident().unwrap_or(keywords::Invalid.ident()).name.as_str() } // #[attribute(name = "value")] |
