Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nightly build #90 #91

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]

name = "stainless"
version = "0.1.12"
name = "stainless2"
version = "0.1.14"
authors = [
"Pascal Seitz <[email protected]>",
"Jonathan Reem <[email protected]>",
"Aleksey Kuznetsov <[email protected]>",
"Alex Diez <[email protected]>",
Expand All @@ -20,12 +20,12 @@ authors = [
"Roman Pearah <[email protected]>",
]
description = "Organized, flexible testing framework."
repository = "https:/reem/stainless"
repository = "https:/PSeitz/stainless"
license = "MIT"
keywords = ["testing", "bdd", "tdd"]
categories = ["development-tools", "development-tools::testing", "development-tools::profiling"]
[lib]

[lib]
name = "stainless"
path = "src/lib.rs"
plugin = true
8 changes: 4 additions & 4 deletions src/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
/// modules respectively.
///

use syntax::{ast, codemap, parse, tokenstream};
use syntax::{ast, source_map, parse, tokenstream};
use syntax::ptr::P;
use syntax::ext::base;
use syntax::util::small_vector::SmallVector;
use rustc_data_structures::small_vec::OneVector;

use parse::Parse;
use generate::Generate;
Expand Down Expand Up @@ -60,11 +60,11 @@ pub enum SubBlock {
/// All other macros in stainless are actually "fake" in the sense
/// that they are detected and expanded inside of the implementation
/// of `describe!`.
pub fn describe<'a>(cx: &'a mut base::ExtCtxt, sp: codemap::Span,
pub fn describe<'a>(cx: &'a mut base::ExtCtxt, sp: source_map::Span,
name: ast::Ident, tokens: Vec<tokenstream::TokenTree>) -> Box<base::MacResult + 'a> {
// Parse a full DescribeState from the input, emitting errors if used incorrectly.
let state: DescribeState = Parse::parse(&mut parse::stream_to_parser(cx.parse_sess(), tokens.into_iter().collect()), (sp, &mut*cx, Some(name)));

// Export the new module.
base::MacEager::items(SmallVector::one(state.generate(sp, cx, None)))
base::MacEager::items(OneVector::from_vec(vec![state.generate(sp, cx, None)]))
}
28 changes: 12 additions & 16 deletions src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::ops::Deref;

use syntax::{ast, abi, codemap};
use syntax::{ast, source_map};
use syntax::ptr::P;
use syntax::ext::base;
use syntax::symbol::Symbol;
Expand All @@ -21,11 +21,11 @@ use describe::{DescribeState, SubBlock};
/// Trait meaning something can be turned into an ast::Item with configuration.
pub trait Generate<Cfg> {
/// Turn Self into an ast::Item with a configuration object.
fn generate(self, codemap::Span, &mut base::ExtCtxt, Cfg) -> P<ast::Item>;
fn generate(self, source_map::Span, &mut base::ExtCtxt, Cfg) -> P<ast::Item>;
}

impl<'a> Generate<&'a DescribeState> for Test {
fn generate(self, sp: codemap::Span, cx: &mut base::ExtCtxt, state: &'a DescribeState) -> P<ast::Item> {
fn generate(self, sp: source_map::Span, cx: &mut base::ExtCtxt, state: &'a DescribeState) -> P<ast::Item> {
let Test { description, block, test_config } = self;

// Create the #[test] attribute.
Expand Down Expand Up @@ -93,7 +93,7 @@ impl<'a> Generate<&'a DescribeState> for Test {
expected_str,
ast::LitKind::Str(msg.0, msg.1)
);
let nested_expected_name_value = codemap::respan(
let nested_expected_name_value = source_map::respan(
sp,
ast::NestedMetaItemKind::MetaItem(expected_name_value));
attrs.push(cx.attribute(sp, cx.meta_list(
Expand Down Expand Up @@ -123,24 +123,22 @@ impl<'a> Generate<&'a DescribeState> for Test {
variadic: false
}),
// All the usual types.
ast::Unsafety::Normal,
codemap::respan(sp, ast::Constness::NotConst),
abi::Abi::Rust,
ast::FnHeader::default(),
ast::Generics::default(),

// Add the body of the function.
test_body
),
// Inherited visibility (not pub)
vis: ast::Visibility::Inherited,
vis: ast::Visibility{node:ast::VisibilityKind::Inherited, span:sp},
span: sp,
tokens: None,
})
}
}

impl Generate<()> for Bench {
fn generate(self, sp: codemap::Span, cx: &mut base::ExtCtxt, _: ()) -> P<ast::Item> {
fn generate(self, sp: source_map::Span, cx: &mut base::ExtCtxt, _: ()) -> P<ast::Item> {
let Bench { bench, description, block } = self;

// Create the #[bench] attribute.
Expand All @@ -167,24 +165,22 @@ impl Generate<()> for Bench {
}),

// All the usual types.
ast::Unsafety::Normal,
codemap::respan(sp, ast::Constness::NotConst),
abi::Abi::Rust,
ast::FnHeader::default(),
ast::Generics::default(),

// Add the body of the function.
block
),
// Inherited visibility (not pub)
vis: ast::Visibility::Inherited,
vis: ast::Visibility{node:ast::VisibilityKind::Inherited, span:sp},
span: sp,
tokens: None,
})
}
}

impl<'a> Generate<&'a DescribeState> for SubBlock {
fn generate(self, sp: codemap::Span, cx: &mut base::ExtCtxt, state: &'a DescribeState) -> P<ast::Item> {
fn generate(self, sp: source_map::Span, cx: &mut base::ExtCtxt, state: &'a DescribeState) -> P<ast::Item> {
match self {
SubBlock::Test(test) => test.generate(sp, cx, state),
SubBlock::Bench(bench) => bench.generate(sp, cx, ()),
Expand All @@ -194,7 +190,7 @@ impl<'a> Generate<&'a DescribeState> for SubBlock {
}

impl<'a> Generate<Option<&'a DescribeState>> for DescribeState {
fn generate(mut self, sp: codemap::Span, cx: &mut base::ExtCtxt,
fn generate(mut self, sp: source_map::Span, cx: &mut base::ExtCtxt,
state: Option<&'a DescribeState>) -> P<ast::Item> {
// Get the name of this mod.
let name = self.name.clone().unwrap();
Expand Down Expand Up @@ -225,7 +221,7 @@ impl<'a> Generate<Option<&'a DescribeState>> for DescribeState {
//
// This glob is `pub use super::*` so that nested `describe!` blocks (which will also contain
// this glob) will be able to see all the symbols.
let super_glob = cx.item_use_glob(sp, ast::Visibility::Public, vec![cx.ident_of("super")]);
let super_glob = cx.item_use_glob(sp, ast::Visibility{node:ast::VisibilityKind::Inherited, span:sp}, vec![cx.ident_of("super")]);
let mut items = vec![super_glob];

// Create subblocks from a full DescribeState
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@
//! See Cargo.toml for the full list of authors.

extern crate syntax;
extern crate rustc_target;
extern crate rustc_plugin;
extern crate rustc_data_structures;

use self::describe::describe;
use rustc_plugin as plugin;
Expand Down
6 changes: 3 additions & 3 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Licensed under the MIT license. This file may not be copied, modified, or distributed except
// according to those terms.

use syntax::{ast, codemap};
use syntax::{ast, source_map};
use syntax::ext::base;
use syntax::parse::token;

Expand Down Expand Up @@ -83,9 +83,9 @@ const DESCRIBE: &'static str = "describe";
const FAILING: &'static str = "failing";
const BENCH: &'static str = "bench";

impl<'a, 'b> Parse<(codemap::Span, &'a mut base::ExtCtxt<'b>, Option<ast::Ident>)> for DescribeState {
impl<'a, 'b> Parse<(source_map::Span, &'a mut base::ExtCtxt<'b>, Option<ast::Ident>)> for DescribeState {
fn parse(parser: &mut Parser,
(sp, cx, name): (codemap::Span, &'a mut base::ExtCtxt, Option<ast::Ident>)) -> DescribeState {
(sp, cx, name): (source_map::Span, &'a mut base::ExtCtxt, Option<ast::Ident>)) -> DescribeState {
let mut state = DescribeState {
name: None,
before_each: None,
Expand Down