Skip to content

Commit

Permalink
Add more debugging to syntax::feature_gate.
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Mar 5, 2015
1 parent ab7ef74 commit 10426f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -285,7 +285,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[
("recursion_limit", CrateLevel),
];

#[derive(PartialEq, Copy)]
#[derive(PartialEq, Copy, Debug)]
pub enum AttributeType {
/// Normal, builtin attribute that is consumed
/// by the compiler before the unused_attribute check
Expand Down Expand Up @@ -353,7 +353,9 @@ struct Context<'a> {

impl<'a> Context<'a> {
fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
if !self.has_feature(feature) {
let has_feature = self.has_feature(feature);
debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", feature, span, has_feature);
if !has_feature {
emit_feature_err(self.span_handler, feature, span, explain);
}
}
Expand Down Expand Up @@ -634,12 +636,14 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
}

fn visit_attribute(&mut self, attr: &ast::Attribute) {
debug!("visit_attribute(attr = {:?})", attr);
let name = &*attr.name();
for &(n, ty) in KNOWN_ATTRIBUTES {
if n == name {
if let Gated(gate, desc) = ty {
self.gate_feature(gate, attr.span, desc);
}
debug!("visit_attribute: {:?} is known, {:?}", name, ty);
return;
}
}
Expand Down

0 comments on commit 10426f6

Please sign in to comment.