diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-11 14:01:02 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-25 04:38:42 +0200 |
| commit | 0a5b38f9c3d5beb641b146b2a7c56c8b4257633e (patch) | |
| tree | 4b73662a7d501accb789d3bdbb15b656da94af96 /src/libsyntax/attr | |
| parent | 10a52c25cad963986cace7a22c167363afca0d74 (diff) | |
| download | rust-0a5b38f9c3d5beb641b146b2a7c56c8b4257633e.tar.gz rust-0a5b38f9c3d5beb641b146b2a7c56c8b4257633e.zip | |
move Attribute::with_desugared_doc to librustdoc
Diffstat (limited to 'src/libsyntax/attr')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 4aec5040881..27de084ae98 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -13,8 +13,8 @@ use crate::ast::{AttrItem, AttrId, AttrStyle, Name, Ident, Path, PathSegment}; use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem}; use crate::ast::{Lit, LitKind, Expr, Item, Local, Stmt, StmtKind, GenericParam}; use crate::mut_visit::visit_clobber; -use crate::source_map::{BytePos, Spanned, DUMMY_SP}; -use crate::parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; +use crate::source_map::{BytePos, Spanned}; +use crate::parse::lexer::comments::doc_comment_style; use crate::parse::parser::Parser; use crate::parse::PResult; use crate::parse::token::{self, Token}; @@ -312,31 +312,6 @@ impl Attribute { span: self.span, }) } - - /// Converts `self` to a normal `#[doc="foo"]` comment, if it is a - /// comment like `///` or `/** */`. (Returns `self` unchanged for - /// non-sugared doc attributes.) - pub fn with_desugared_doc<T, F>(&self, f: F) -> T where - F: FnOnce(&Attribute) -> T, - { - if self.is_sugared_doc { - let comment = self.value_str().unwrap(); - let meta = mk_name_value_item_str( - Ident::with_dummy_span(sym::doc), - Symbol::intern(&strip_doc_comment_decoration(&comment.as_str())), - DUMMY_SP, - ); - f(&Attribute { - item: AttrItem { path: meta.path, tokens: meta.kind.tokens(meta.span) }, - id: self.id, - style: self.style, - is_sugared_doc: true, - span: self.span, - }) - } else { - f(self) - } - } } /* Constructors */ |
