Refactor away AttributeMethods
.
This commit is contained in:
parent
4eb08bb2ab
commit
e264828b27
@ -37,7 +37,7 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
|
|||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr::{AttributeMethods, AttrMetaMethods};
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use errors::DiagnosticBuilder;
|
use errors::DiagnosticBuilder;
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
//! at the beginning.
|
//! at the beginning.
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr::AttributeMethods;
|
|
||||||
use std::hash::{Hash, SipHasher, Hasher};
|
use std::hash::{Hash, SipHasher, Hasher};
|
||||||
use rustc::dep_graph::DepNode;
|
use rustc::dep_graph::DepNode;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
|
@ -44,7 +44,7 @@ use lint::{LintPass, LateLintPass};
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use syntax::{ast};
|
use syntax::{ast};
|
||||||
use syntax::attr::{self, AttrMetaMethods, AttributeMethods};
|
use syntax::attr::{self, AttrMetaMethods};
|
||||||
use syntax_pos::{Span};
|
use syntax_pos::{Span};
|
||||||
|
|
||||||
use rustc::hir::{self, PatKind};
|
use rustc::hir::{self, PatKind};
|
||||||
|
@ -26,7 +26,7 @@ pub use self::Visibility::*;
|
|||||||
use syntax::abi::Abi;
|
use syntax::abi::Abi;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::attr::{AttributeMethods, AttrMetaMethods};
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::codemap::Spanned;
|
use syntax::codemap::Spanned;
|
||||||
use syntax::parse::token::{self, InternedString, keywords};
|
use syntax::parse::token::{self, InternedString, keywords};
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
@ -267,23 +267,16 @@ impl AttrMetaMethods for P<MetaItem> {
|
|||||||
fn span(&self) -> Span { (**self).span() }
|
fn span(&self) -> Span { (**self).span() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Attribute {
|
||||||
pub trait AttributeMethods {
|
|
||||||
fn meta(&self) -> &MetaItem;
|
|
||||||
fn with_desugared_doc<T, F>(&self, f: F) -> T where
|
|
||||||
F: FnOnce(&Attribute) -> T;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AttributeMethods for Attribute {
|
|
||||||
/// Extract the MetaItem from inside this Attribute.
|
/// Extract the MetaItem from inside this Attribute.
|
||||||
fn meta(&self) -> &MetaItem {
|
pub fn meta(&self) -> &MetaItem {
|
||||||
&self.node.value
|
&self.node.value
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert self to a normal #[doc="foo"] comment, if it is a
|
/// Convert self to a normal #[doc="foo"] comment, if it is a
|
||||||
/// comment like `///` or `/** */`. (Returns self unchanged for
|
/// comment like `///` or `/** */`. (Returns self unchanged for
|
||||||
/// non-sugared doc attributes.)
|
/// non-sugared doc attributes.)
|
||||||
fn with_desugared_doc<T, F>(&self, f: F) -> T where
|
pub fn with_desugared_doc<T, F>(&self, f: F) -> T where
|
||||||
F: FnOnce(&Attribute) -> T,
|
F: FnOnce(&Attribute) -> T,
|
||||||
{
|
{
|
||||||
if self.node.is_sugared_doc {
|
if self.node.is_sugared_doc {
|
||||||
|
@ -16,7 +16,7 @@ use ast::{SelfKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
|
|||||||
use ast::Attribute;
|
use ast::Attribute;
|
||||||
use util::parser::AssocOp;
|
use util::parser::AssocOp;
|
||||||
use attr;
|
use attr;
|
||||||
use attr::{AttrMetaMethods, AttributeMethods};
|
use attr::AttrMetaMethods;
|
||||||
use codemap::{self, CodeMap};
|
use codemap::{self, CodeMap};
|
||||||
use syntax_pos::{self, BytePos};
|
use syntax_pos::{self, BytePos};
|
||||||
use errors;
|
use errors;
|
||||||
|
Loading…
Reference in New Issue
Block a user