Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Updates for latest rust #371

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
67cd248
Hide lpc11xx behind a feature
richo Mar 15, 2016
60160d0
Updates for underlying rust changes
richo Mar 15, 2016
4fbc6a5
Whitespace
richo Mar 15, 2016
57e9081
Zinc builds on stable rust!
richo Mar 16, 2016
d509aac
Update platformtree for new rust
gyscos Mar 21, 2016
e09fa3c
Merge pull request #1 from Gyscos/latest
richo Apr 7, 2016
9ac5878
Update macro_platformtree to latest rust
gyscos Apr 7, 2016
6fe87b1
Remove obsolete lang items
gyscos Apr 7, 2016
ce87cbc
Remote unused features/import
gyscos Apr 7, 2016
5da42aa
Remove #[inline] annotation on impl blocks
gyscos Apr 7, 2016
7641778
Use u32 instead of usize in ioreg getter
gyscos Apr 7, 2016
66d05d3
Update for new StructField
gyscos Apr 7, 2016
b5a914f
More structfield fixes
gyscos Apr 8, 2016
1f7710c
Fix platformtree test for latest rust
gyscos Apr 8, 2016
51f3b4e
Add explicit python2.7 shebang
gyscos Apr 8, 2016
9294fda
Use cutting edge syntaxext_lint
gyscos Apr 8, 2016
9b00427
Remove deny missing docs
gyscos Apr 8, 2016
9637e56
Merge remote-tracking branch 'Gyscos/cutting_edge' into latest
richo Apr 15, 2016
5d1911b
Fix: Ident now only has 1 field
gyscos May 8, 2016
792ede3
Use `libsyntax::parse::lexer::Reader::try_next_token()`
gyscos May 8, 2016
2a75aaf
Update platformtree for new rust
gyscos May 8, 2016
7dff9e4
Fix "zero-sized fn" warning with new rust
gyscos May 8, 2016
0b389a3
Revert "Use u32 instead of usize in ioreg getter"
gyscos May 8, 2016
7bc084f
Update target definition for latest llvm
gyscos May 8, 2016
b077ec6
Use proper type value depending on register type
gyscos May 9, 2016
14dce59
Remove useless import
gyscos May 9, 2016
ca34f58
Merge pull request #4 from Gyscos/crazy
richo May 24, 2016
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
2 changes: 1 addition & 1 deletion ioreg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ plugin = true
path = "../volatile_cell"

[dependencies]
syntaxext_lint = "*"
syntaxext_lint = { git="https://github.com/Gyscos/syntaxext_lint", version="*" }
19 changes: 12 additions & 7 deletions ioreg/src/builder/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ fn build_new(cx: &ExtCtxt, path: &Vec<String>,

/// Given an `Expr` of the given register's primitive type, return
/// an `Expr` of the field type
fn from_primitive(cx: &ExtCtxt, path: &Vec<String>, _: &node::Reg,
fn from_primitive(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg,
field: &node::Field, prim: P<ast::Expr>)
-> P<ast::Expr> {
// Use bit_range_field for the span because it is to blame for the
// Use bit_range_field for the span because it is to blame for the
// type of the register
match field.ty.node {
node::FieldType::UIntField => prim,
node::FieldType::BoolField =>
cx.expr_binary(field.bit_range_span, ast::BiNe,
cx.expr_binary(field.bit_range_span, ast::BinOpKind::Ne,
prim, utils::expr_int(cx, respan(field.bit_range_span, 0))),
node::FieldType::EnumField {opt_name: _, variants: ref vars} => {
let mut arms: Vec<ast::Arm> = Vec::new();
Expand All @@ -137,15 +137,21 @@ fn from_primitive(cx: &ExtCtxt, path: &Vec<String>, _: &node::Reg,
cx.path(v.name.span, vec!(enum_ident, val_ident)));
let val: u64 = v.value.node;
let lit = cx.expr_lit(
v.value.span,
ast::LitInt(val, ast::UnsuffixedIntLit(ast::Plus)));
v.value.span,
ast::LitKind::Int(val, ast::LitIntType::Unsigned(match reg.ty.size() {
1 => ast::UintTy::U8,
2 => ast::UintTy::U16,
4 => ast::UintTy::U32,
8 => ast::UintTy::U64, // Is this even possible?
_ => panic!("Unknown reg size: {}", reg.ty.size()),
})));
let arm = ast::Arm {
attrs: vec!(),
pats: vec!(
P(ast::Pat {
id: ast::DUMMY_NODE_ID,
span: lit.span,
node: ast::PatLit(lit),
node: ast::PatKind::Lit(lit),
})
),
guard: None,
Expand Down Expand Up @@ -196,7 +202,6 @@ fn build_impl(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg,

let it = quote_item!(cx,
#[allow(dead_code)]
#[inline(always)]
impl $getter_ty {
$new
$getters
Expand Down
6 changes: 3 additions & 3 deletions ioreg/src/builder/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn build_field_type(cx: &ExtCtxt, path: &Vec<String>,
.segments.last().unwrap().identifier;
let enum_def: ast::EnumDef = ast::EnumDef {
variants: FromIterator::from_iter(
variants.iter().map(|v| P(build_enum_variant(cx, v)))),
variants.iter().map(|v| build_enum_variant(cx, v))),
};
let mut attrs: Vec<ast::Attribute> = vec!(
utils::list_attribute(cx, "derive",
Expand All @@ -99,8 +99,8 @@ fn build_field_type(cx: &ExtCtxt, path: &Vec<String>,
let ty_item: P<ast::Item> = P(ast::Item {
ident: name,
id: ast::DUMMY_NODE_ID,
node: ast::ItemEnum(enum_def, ast::Generics::default()),
vis: ast::Public,
node: ast::ItemKind::Enum(enum_def, ast::Generics::default()),
vis: ast::Visibility::Public,
attrs: attrs,
span: field.ty.span,
});
Expand Down
1 change: 0 additions & 1 deletion ioreg/src/builder/setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ fn build_impl(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg,
let done = build_done(cx, path);
quote_item!(cx,
#[allow(dead_code)]
#[inline(always)]
impl<'a> $setter_ident<'a> {
$new
$new_is
Expand Down
48 changes: 22 additions & 26 deletions ioreg/src/builder/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::rc::Rc;
use std::iter::FromIterator;
use syntax::ast;
use syntax::ptr::P;
use syntax::codemap::{DUMMY_SP, dummy_spanned, respan, Spanned};
use syntax::codemap::{DUMMY_SP, respan, Spanned};
use syntax::ext::base::ExtCtxt;
use syntax::ext::build::AstBuilder;

Expand Down Expand Up @@ -85,7 +85,7 @@ impl<'a> BuildUnionTypes<'a> {
}

fn expr_usize(cx: &ExtCtxt, n: Spanned<u64>) -> P<ast::Expr> {
cx.expr_lit(n.span, ast::LitInt(n.node as u64, ast::UnsignedIntLit(ast::TyUs)))
cx.expr_lit(n.span, ast::LitKind::Int(n.node as u64, ast::LitIntType::Unsigned(ast::UintTy::Us)))
}

/// Returns the type of the field representing the given register
Expand All @@ -98,7 +98,7 @@ fn reg_struct_type(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg)
1 => base_ty,
n =>
cx.ty(reg.count.span,
ast::TyFixedLengthVec(base_ty, expr_usize(cx, respan(reg.count.span, n as u64)))),
ast::TyKind::FixedLengthVec(base_ty, expr_usize(cx, respan(reg.count.span, n as u64)))),
}
}

Expand All @@ -123,16 +123,14 @@ impl<'a> BuildUnionTypes<'a> {
};
let mut field_path = path.clone();
field_path.push(reg.name.node.clone());
dummy_spanned(
ast::StructField_ {
kind: ast::NamedField(
self.cx.ident_of(reg.name.node.as_str()),
ast::Public),
id: ast::DUMMY_NODE_ID,
ty: reg_struct_type(self.cx, &field_path, reg),
attrs: attrs,
}
)
ast::StructField {
span: DUMMY_SP,
ident: Some(self.cx.ident_of(reg.name.node.as_str())),
vis: ast::Visibility::Public,
id: ast::DUMMY_NODE_ID,
ty: reg_struct_type(self.cx, &field_path, reg),
attrs: attrs,
}
}

/// Build field for padding or a register
Expand All @@ -150,17 +148,15 @@ impl<'a> BuildUnionTypes<'a> {
let ty: P<ast::Ty> =
self.cx.ty(
DUMMY_SP,
ast::TyFixedLengthVec(u8_ty, expr_usize(self.cx, respan(DUMMY_SP, length))));
dummy_spanned(
ast::StructField_ {
kind: ast::NamedField(
self.cx.ident_of(format!("_pad{}", index).as_str()),
ast::Inherited),
id: ast::DUMMY_NODE_ID,
ty: ty,
attrs: Vec::new(),
},
)
ast::TyKind::FixedLengthVec(u8_ty, expr_usize(self.cx, respan(DUMMY_SP, length))));
ast::StructField {
span: DUMMY_SP,
ident: Some(self.cx.ident_of(format!("_pad{}", index).as_str())),
vis: ast::Visibility::Inherited,
id: ast::DUMMY_NODE_ID,
ty: ty,
attrs: Vec::new(),
}
},
}
}
Expand Down Expand Up @@ -199,8 +195,8 @@ impl<'a> BuildUnionTypes<'a> {
ident: name,
attrs: attrs,
id: ast::DUMMY_NODE_ID,
node: ast::ItemStruct(struct_def, ast::Generics::default()),
vis: ast::Public,
node: ast::ItemKind::Struct(struct_def, ast::Generics::default()),
vis: ast::Visibility::Public,
span: reg.name.span,
});
let mut full_size: u64 = 0;
Expand Down
9 changes: 4 additions & 5 deletions ioreg/src/builder/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ use super::super::node;

/// Generate an unsuffixed integer literal expression with a dummy span
pub fn expr_int(cx: &ExtCtxt, n: Spanned<i64>) -> P<ast::Expr> {
let sign = if n.node < 0 {ast::Minus} else {ast::Plus};
cx.expr_lit(n.span, ast::LitInt(n.node as u64, ast::UnsuffixedIntLit(sign)))
cx.expr_lit(n.span, ast::LitKind::Int(n.node as u64, ast::LitIntType::Unsuffixed))
}

/// The name of the structure representing a register
Expand Down Expand Up @@ -64,7 +63,7 @@ pub fn doc_attribute(cx: &ExtCtxt, docstring: token::InternedString)
-> ast::Attribute {
use syntax::codemap::DUMMY_SP;

let s: ast::Lit_ = ast::LitStr(docstring, ast::CookedStr);
let s = ast::LitKind::Str(docstring, ast::StrStyle::Cooked);
let attr =
cx.meta_name_value(DUMMY_SP, token::InternedString::new("doc"), s);
cx.attribute(DUMMY_SP, attr)
Expand Down Expand Up @@ -135,8 +134,8 @@ pub fn field_type_path(cx: &ExtCtxt, path: &Vec<String>,

pub fn unwrap_impl_item(item: P<ast::Item>) -> P<ast::ImplItem> {
match item.node {
ast::ItemImpl(_, _, _, _, _, ref items) => {
items.clone().pop().expect("ImplItem not found")
ast::ItemKind::Impl(_, _, _, _, _, ref items) => {
P(items.clone().pop().expect("ImplItem not found"))
},
_ => panic!("Tried to unwrap ImplItem from Non-Impl")
}
Expand Down
2 changes: 1 addition & 1 deletion ioreg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ N => NAME

*/

#![feature(quote, plugin_registrar, rustc_private, convert)]
#![feature(quote, plugin_registrar, rustc_private)]
#![feature(plugin)]

#![plugin(syntaxext_lint)]
Expand Down
11 changes: 6 additions & 5 deletions ioreg/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use syntax::ast;
use syntax::codemap::{Span, Spanned, respan, dummy_spanned, mk_sp};
use syntax::ext::base::ExtCtxt;
use syntax::parse::{token, ParseSess, lexer};
use syntax::parse::lexer::Reader;
use syntax::parse;
use syntax::print::pprust;

Expand Down Expand Up @@ -54,7 +55,7 @@ impl<'a> Parser<'a> {
let mut reader = Box::new(lexer::new_tt_reader(
&sess.span_diagnostic, None, None, ttsvec)) as Box<lexer::Reader>;

let tok0 = reader.next_token();
let tok0 = reader.try_next_token().unwrap();
let token = tok0.tok;
let span = tok0.sp;

Expand Down Expand Up @@ -379,7 +380,7 @@ impl<'a> Parser<'a> {
token::Colon => {
self.bump();
match self.token.clone() {
ref t@token::Ident(_,_) => {
ref t@token::Ident(_) => {
match pprust::token_to_string(t) {
ref s if s.eq(&"rw") => { self.bump(); node::Access::ReadWrite },
ref s if s.eq(&"ro") => { self.bump(); node::Access::ReadOnly },
Expand Down Expand Up @@ -546,7 +547,7 @@ impl<'a> Parser<'a> {
&self.sess.span_diagnostic,
self.span);
match lit {
ast::LitInt(n, _) => Some(n),
ast::LitKind::Int(n, _) => Some(n),
_ => None,
}
},
Expand Down Expand Up @@ -604,7 +605,7 @@ impl<'a> Parser<'a> {
self.last_span = self.span;
self.last_token = Some(Box::new(tok.clone()));

let next = self.reader.next_token();
let next = self.reader.try_next_token().unwrap();

self.span = next.sp;
self.token = next.tok;
Expand All @@ -631,7 +632,7 @@ impl<'a> Parser<'a> {
fn expect_ident(&mut self) -> Option<String> {
let tok_str = pprust::token_to_string(&self.token);
match self.token {
token::Ident(_, _) => {
token::Ident(_) => {
self.bump();
Some(tok_str)
},
Expand Down
8 changes: 4 additions & 4 deletions macro_platformtree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![feature(rustc_private, plugin_registrar, quote, convert)]
#![feature(rustc_private, plugin_registrar, quote)]

extern crate platformtree;
extern crate rustc;
Expand Down Expand Up @@ -76,7 +76,7 @@ fn macro_zinc_task(cx: &mut ExtCtxt, _: Span, _: &ast::MetaItem,

fn macro_zinc_task_item(cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
match it.node {
ast::ItemFn(ref decl, style, constness, abi, _, ref block) => {
ast::ItemKind::Fn(ref decl, style, constness, abi, _, ref block) => {
let istr = it.ident.name.as_str();
let fn_name = &*istr;
let ty_params = platformtree::builder::meta_args::get_ty_params_for_task(cx, fn_name);
Expand All @@ -103,7 +103,7 @@ fn macro_zinc_task_item(cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
}).collect(),
vec!())),
None,
ast::MutImmutable));
ast::Mutability::Immutable));
let new_decl = P(ast::FnDecl {
inputs: vec!(new_arg),
..decl.deref().clone()
Expand All @@ -117,7 +117,7 @@ fn macro_zinc_task_item(cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
predicates: vec!(),
}
};
let new_node = ast::ItemFn(new_decl, style, constness, abi, new_generics, block.clone());
let new_node = ast::ItemKind::Fn(new_decl, style, constness, abi, new_generics, block.clone());

P(ast::Item {node: new_node, ..it.deref().clone() })
},
Expand Down
12 changes: 6 additions & 6 deletions platformtree/src/builder/meta_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn set_tasks(cx: &mut ExtCtxt, tasks: Vec<P<ast::MetaItem>>) {
let mut vec_clone = cx.cfg();
let maybe_pos = vec_clone.iter().position(|i| {
match i.node {
ast::MetaList(ref k, _) if *k == TAG => true,
ast::MetaItemKind::List(ref k, _) if *k == TAG => true,
_ => false,
}
});
Expand All @@ -80,7 +80,7 @@ fn set_tasks(cx: &mut ExtCtxt, tasks: Vec<P<ast::MetaItem>>) {
fn get_tasks(cx: &ExtCtxt) -> Vec<P<ast::MetaItem>> {
for i in cx.cfg.iter() {
match i.node {
ast::MetaList(ref k, ref v) if *k == TAG => return v.clone(),
ast::MetaItemKind::List(ref k, ref v) if *k == TAG => return v.clone(),
_ => (),
}
};
Expand All @@ -92,10 +92,10 @@ fn get_task(tasks: &Vec<P<ast::MetaItem>>, task: &str) -> Vec<String> {
let mut ty_params = vec!();
for mi in tasks.iter() {
match mi.node {
ast::MetaList(ref k, ref v) if *k == task => {
ast::MetaItemKind::List(ref k, ref v) if *k == task => {
for submi in v.iter() {
match submi.node {
ast::MetaWord(ref w) => ty_params.push((&*w).to_string()),
ast::MetaItemKind::Word(ref w) => ty_params.push((&*w).to_string()),
_ => panic!("unexpected node type"),
}
}
Expand Down Expand Up @@ -125,11 +125,11 @@ fn get_task(tasks: &Vec<P<ast::MetaItem>>, task: &str) -> Vec<String> {
// fn get_args(cx: &ExtCtxt) -> Option<Vec<MetaArgs>> {
// cx.cfg.iter().find(|i| {
// match i.node {
// ast::MetaList(ref k, _) => k.get() == TAG,
// ast::MetaItemKind::List(ref k, _) => k.get() == TAG,
// _ => false,
// }
// }).and_then(|i| match i.node {
// ast::MetaList(_, ref v) => Some(meta_item_to_meta_args(v)),
// ast::MetaItemKind::List(_, ref v) => Some(meta_item_to_meta_args(v)),
// _ => panic!(),
// })
// }
Expand Down
Loading