Skip to content

Commit

Permalink
Refactor away AttributeMethods.
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Aug 25, 2016
1 parent 4eb08bb commit e264828
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Expand Up @@ -37,7 +37,7 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
use std::cmp;
use std::fmt;
use syntax::ast;
use syntax::attr::{AttributeMethods, AttrMetaMethods};
use syntax::attr::AttrMetaMethods;
use syntax_pos::Span;
use errors::DiagnosticBuilder;

Expand Down
1 change: 0 additions & 1 deletion src/librustc_incremental/calculate_svh/mod.rs
Expand Up @@ -28,7 +28,6 @@
//! at the beginning.

use syntax::ast;
use syntax::attr::AttributeMethods;
use std::hash::{Hash, SipHasher, Hasher};
use rustc::dep_graph::DepNode;
use rustc::hir;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Expand Up @@ -44,7 +44,7 @@ use lint::{LintPass, LateLintPass};
use std::collections::HashSet;

use syntax::{ast};
use syntax::attr::{self, AttrMetaMethods, AttributeMethods};
use syntax::attr::{self, AttrMetaMethods};
use syntax_pos::{Span};

use rustc::hir::{self, PatKind};
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Expand Up @@ -26,7 +26,7 @@ pub use self::Visibility::*;
use syntax::abi::Abi;
use syntax::ast;
use syntax::attr;
use syntax::attr::{AttributeMethods, AttrMetaMethods};
use syntax::attr::AttrMetaMethods;
use syntax::codemap::Spanned;
use syntax::parse::token::{self, InternedString, keywords};
use syntax::ptr::P;
Expand Down
13 changes: 3 additions & 10 deletions src/libsyntax/attr.rs
Expand Up @@ -267,23 +267,16 @@ impl AttrMetaMethods for P<MetaItem> {
fn span(&self) -> Span { (**self).span() }
}


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 {
impl Attribute {
/// Extract the MetaItem from inside this Attribute.
fn meta(&self) -> &MetaItem {
pub fn meta(&self) -> &MetaItem {
&self.node.value
}

/// Convert self to a normal #[doc="foo"] comment, if it is a
/// comment like `///` or `/** */`. (Returns self unchanged for
/// 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,
{
if self.node.is_sugared_doc {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/print/pprust.rs
Expand Up @@ -16,7 +16,7 @@ use ast::{SelfKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
use ast::Attribute;
use util::parser::AssocOp;
use attr;
use attr::{AttrMetaMethods, AttributeMethods};
use attr::AttrMetaMethods;
use codemap::{self, CodeMap};
use syntax_pos::{self, BytePos};
use errors;
Expand Down

0 comments on commit e264828

Please sign in to comment.