Skip to content

Commit

Permalink
Don't test non-public constants
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Oct 30, 2015
1 parent f980e0f commit ec5cda4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,13 +813,14 @@ impl<'a> Generator<'a> {
impl<'a, 'v> Visitor<'v> for Generator<'a> {
fn visit_item(&mut self, i: &'v ast::Item) {
let prev_abi = self.abi;
let public = i.vis == ast::Public;
match i.node {
ast::ItemTy(_, ref generics) => {
ast::ItemTy(_, ref generics) if public => {
self.assert_no_generics(i.ident, generics);
self.test_type(&i.ident.to_string());
}

ast::ItemStruct(ref s, ref generics) => {
ast::ItemStruct(ref s, ref generics) if public => {
self.assert_no_generics(i.ident, generics);
let is_c = i.attrs.iter().any(|a| {
attr::find_repr_attrs(self.sh, a).iter().any(|a| {
Expand All @@ -832,12 +833,12 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
self.test_struct(&i.ident.to_string(), s);
}

ast::ItemConst(ref ty, _) => {
ast::ItemConst(ref ty, _) if public => {
let ty = self.ty2name(ty, true);
self.test_const(&i.ident.to_string(), &ty);
}

ast::ItemForeignMod(ref fm) => {
ast::ItemForeignMod(ref fm) if public => {
self.abi = fm.abi;
}

Expand Down
4 changes: 4 additions & 0 deletions testcrate/src/t1.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)]

use libc::*;

pub type T1Foo = i32;
Expand All @@ -18,6 +20,8 @@ pub struct T1Baz {

pub const T1C: u32 = 4;

const NOT_PRESENT: u32 = 5;

extern {
pub fn T1a();
pub fn T1b() -> *mut c_void;
Expand Down

0 comments on commit ec5cda4

Please sign in to comment.