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

Update for rust 1.10.0-nightly #374

Merged
merged 4 commits into from
May 16, 2016
Merged
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
1 change: 0 additions & 1 deletion ioreg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ plugin = true
path = "../volatile_cell"

[dependencies]
syntaxext_lint = "*"
1 change: 0 additions & 1 deletion ioreg/src/builder/accessors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use syntax::ast;
use syntax::ptr::P;
use syntax::ext::base::ExtCtxt;
use syntax::ext::build::AstBuilder;
use syntax::ext::quote::rt::ToTokens;

use super::Builder;
use super::utils;
Expand Down
8 changes: 3 additions & 5 deletions ioreg/src/builder/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use syntax::ptr::P;
use syntax::ext::base::ExtCtxt;
use syntax::codemap::{respan, Span};
use syntax::ext::build::AstBuilder;
use syntax::ext::quote::rt::ToTokens;

use super::Builder;
use super::super::node;
Expand Down Expand Up @@ -124,7 +123,7 @@ fn from_primitive(cx: &ExtCtxt, path: &Vec<String>, _: &node::Reg,
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 @@ -138,14 +137,14 @@ fn from_primitive(cx: &ExtCtxt, path: &Vec<String>, _: &node::Reg,
let val: u64 = v.value.node;
let lit = cx.expr_lit(
v.value.span,
ast::LitInt(val, ast::UnsuffixedIntLit(ast::Plus)));
ast::LitKind::Int(val, ast::LitIntType::Unsuffixed));
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 +195,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
10 changes: 4 additions & 6 deletions ioreg/src/builder/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ use syntax::ast;
use syntax::ptr::P;
use syntax::codemap::{respan, mk_sp};
use syntax::ext::base::ExtCtxt;
use syntax::ext::build::AstBuilder;
use syntax::ext::quote::rt::ToTokens;

use super::Builder;
use super::utils;
Expand Down Expand Up @@ -72,7 +70,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 +97,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 Expand Up @@ -164,7 +162,7 @@ fn build_enum_variant(cx: &ExtCtxt, variant: &node::Variant)
attrs: vec!(doc_attr),
data: ast::VariantData::Unit(ast::DUMMY_NODE_ID),
disr_expr: Some(utils::expr_int(cx, respan(variant.value.span,
variant.value.node as i64))),
variant.value.node))),
}
)
}
2 changes: 0 additions & 2 deletions ioreg/src/builder/setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use syntax::ast;
use syntax::ptr::P;
use syntax::ext::base::ExtCtxt;
use syntax::ext::build::AstBuilder;
use syntax::ext::quote::rt::ToTokens;

use super::Builder;
use super::super::node;
Expand Down Expand Up @@ -198,7 +197,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
50 changes: 22 additions & 28 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,21 +123,17 @@ 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
// Dummy spans allowed here because u8 doesn't come from anywhere
#[allow(dummy_span)]
fn build_pad_or_reg(&self, path: &Vec<String>, reg_or_pad: RegOrPadding,
index: usize) -> ast::StructField {
match reg_or_pad {
Expand All @@ -150,17 +146,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 +193,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
16 changes: 7 additions & 9 deletions ioreg/src/builder/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ use syntax::parse::token;
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)))
pub fn expr_int(cx: &ExtCtxt, n: Spanned<u64>) -> P<ast::Expr> {
cx.expr_lit(n.span, ast::LitKind::Int(n.node, ast::LitIntType::Unsuffixed))
}

/// The name of the structure representing a register
Expand Down Expand Up @@ -59,12 +58,11 @@ fn list_attribute_spanned(cx: &ExtCtxt, name: Spanned<&'static str>,
}

/// Generate a `#[doc="..."]` attribute of the given type
#[allow(dummy_span)]
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 = 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 +133,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 All @@ -152,11 +150,11 @@ pub fn mask(cx: &ExtCtxt, field: &node::Field) -> P<ast::Expr> {
/// index if necessary)
pub fn shift(cx: &ExtCtxt, idx: Option<P<ast::Expr>>,
field: &node::Field) -> P<ast::Expr> {
let low = expr_int(cx, respan(field.bit_range_span, field.low_bit as i64));
let low = expr_int(cx, respan(field.bit_range_span, field.low_bit as u64));
match idx {
Some(idx) => {
let width = expr_int(cx, respan(field.bit_range_span,
field.width as i64));
field.width as u64));
quote_expr!(cx, $low + $idx * $width)
},
None => low,
Expand Down
5 changes: 1 addition & 4 deletions ioreg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,7 @@ N => NAME

*/

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

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

extern crate rustc;
extern crate syntax;
Expand Down
12 changes: 6 additions & 6 deletions ioreg/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use syntax::ext::base::ExtCtxt;
use syntax::parse::{token, ParseSess, lexer};
use syntax::parse;
use syntax::print::pprust;
use syntax::parse::lexer::Reader;

use node;
use node::RegType;
Expand All @@ -39,7 +40,7 @@ enum Scope {
pub struct Parser<'a> {
cx: &'a ExtCtxt<'a>,
sess: &'a ParseSess,
reader: Box<lexer::Reader+'a>,
reader: lexer::TtReader<'a>,
token: token::Token,
span: Span,

Expand All @@ -51,8 +52,7 @@ impl<'a> Parser<'a> {
pub fn new(cx: &'a ExtCtxt<'a>, tts: &[TokenTree]) -> Parser<'a> {
let sess = cx.parse_sess();
let ttsvec = tts.iter().map(|x| (*x).clone()).collect();
let mut reader = Box::new(lexer::new_tt_reader(
&sess.span_diagnostic, None, None, ttsvec)) as Box<lexer::Reader>;
let mut reader = lexer::new_tt_reader(&sess.span_diagnostic, None, None, ttsvec);

let tok0 = reader.next_token();
let token = tok0.tok;
Expand Down Expand Up @@ -379,7 +379,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 +546,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 @@ -631,7 +631,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
8 changes: 4 additions & 4 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
Loading