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

Commit 45123e4

Browse files
committed
Merge pull request #374 from agalakhov/master
Update for rust 1.10.0-nightly
2 parents 935e8c8 + f5a3a0d commit 45123e4

File tree

24 files changed

+100
-136
lines changed

24 files changed

+100
-136
lines changed

ioreg/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ plugin = true
1111
path = "../volatile_cell"
1212

1313
[dependencies]
14-
syntaxext_lint = "*"

ioreg/src/builder/accessors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use syntax::ast;
1717
use syntax::ptr::P;
1818
use syntax::ext::base::ExtCtxt;
1919
use syntax::ext::build::AstBuilder;
20-
use syntax::ext::quote::rt::ToTokens;
2120

2221
use super::Builder;
2322
use super::utils;

ioreg/src/builder/getter.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use syntax::ptr::P;
2121
use syntax::ext::base::ExtCtxt;
2222
use syntax::codemap::{respan, Span};
2323
use syntax::ext::build::AstBuilder;
24-
use syntax::ext::quote::rt::ToTokens;
2524

2625
use super::Builder;
2726
use super::super::node;
@@ -124,7 +123,7 @@ fn from_primitive(cx: &ExtCtxt, path: &Vec<String>, _: &node::Reg,
124123
match field.ty.node {
125124
node::FieldType::UIntField => prim,
126125
node::FieldType::BoolField =>
127-
cx.expr_binary(field.bit_range_span, ast::BiNe,
126+
cx.expr_binary(field.bit_range_span, ast::BinOpKind::Ne,
128127
prim, utils::expr_int(cx, respan(field.bit_range_span, 0))),
129128
node::FieldType::EnumField {opt_name: _, variants: ref vars} => {
130129
let mut arms: Vec<ast::Arm> = Vec::new();
@@ -138,14 +137,14 @@ fn from_primitive(cx: &ExtCtxt, path: &Vec<String>, _: &node::Reg,
138137
let val: u64 = v.value.node;
139138
let lit = cx.expr_lit(
140139
v.value.span,
141-
ast::LitInt(val, ast::UnsuffixedIntLit(ast::Plus)));
140+
ast::LitKind::Int(val, ast::LitIntType::Unsuffixed));
142141
let arm = ast::Arm {
143142
attrs: vec!(),
144143
pats: vec!(
145144
P(ast::Pat {
146145
id: ast::DUMMY_NODE_ID,
147146
span: lit.span,
148-
node: ast::PatLit(lit),
147+
node: ast::PatKind::Lit(lit),
149148
})
150149
),
151150
guard: None,
@@ -196,7 +195,6 @@ fn build_impl(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg,
196195

197196
let it = quote_item!(cx,
198197
#[allow(dead_code)]
199-
#[inline(always)]
200198
impl $getter_ty {
201199
$new
202200
$getters

ioreg/src/builder/register.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ use syntax::ast;
2020
use syntax::ptr::P;
2121
use syntax::codemap::{respan, mk_sp};
2222
use syntax::ext::base::ExtCtxt;
23-
use syntax::ext::build::AstBuilder;
24-
use syntax::ext::quote::rt::ToTokens;
2523

2624
use super::Builder;
2725
use super::utils;
@@ -72,7 +70,7 @@ fn build_field_type(cx: &ExtCtxt, path: &Vec<String>,
7270
.segments.last().unwrap().identifier;
7371
let enum_def: ast::EnumDef = ast::EnumDef {
7472
variants: FromIterator::from_iter(
75-
variants.iter().map(|v| P(build_enum_variant(cx, v)))),
73+
variants.iter().map(|v| build_enum_variant(cx, v))),
7674
};
7775
let mut attrs: Vec<ast::Attribute> = vec!(
7876
utils::list_attribute(cx, "derive",
@@ -99,8 +97,8 @@ fn build_field_type(cx: &ExtCtxt, path: &Vec<String>,
9997
let ty_item: P<ast::Item> = P(ast::Item {
10098
ident: name,
10199
id: ast::DUMMY_NODE_ID,
102-
node: ast::ItemEnum(enum_def, ast::Generics::default()),
103-
vis: ast::Public,
100+
node: ast::ItemKind::Enum(enum_def, ast::Generics::default()),
101+
vis: ast::Visibility::Public,
104102
attrs: attrs,
105103
span: field.ty.span,
106104
});
@@ -164,7 +162,7 @@ fn build_enum_variant(cx: &ExtCtxt, variant: &node::Variant)
164162
attrs: vec!(doc_attr),
165163
data: ast::VariantData::Unit(ast::DUMMY_NODE_ID),
166164
disr_expr: Some(utils::expr_int(cx, respan(variant.value.span,
167-
variant.value.node as i64))),
165+
variant.value.node))),
168166
}
169167
)
170168
}

ioreg/src/builder/setter.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use syntax::ast;
2020
use syntax::ptr::P;
2121
use syntax::ext::base::ExtCtxt;
2222
use syntax::ext::build::AstBuilder;
23-
use syntax::ext::quote::rt::ToTokens;
2423

2524
use super::Builder;
2625
use super::super::node;
@@ -198,7 +197,6 @@ fn build_impl(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg,
198197
let done = build_done(cx, path);
199198
quote_item!(cx,
200199
#[allow(dead_code)]
201-
#[inline(always)]
202200
impl<'a> $setter_ident<'a> {
203201
$new
204202
$new_is

ioreg/src/builder/union.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::rc::Rc;
1717
use std::iter::FromIterator;
1818
use syntax::ast;
1919
use syntax::ptr::P;
20-
use syntax::codemap::{DUMMY_SP, dummy_spanned, respan, Spanned};
20+
use syntax::codemap::{DUMMY_SP, respan, Spanned};
2121
use syntax::ext::base::ExtCtxt;
2222
use syntax::ext::build::AstBuilder;
2323

@@ -85,7 +85,7 @@ impl<'a> BuildUnionTypes<'a> {
8585
}
8686

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

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

@@ -123,21 +123,17 @@ impl<'a> BuildUnionTypes<'a> {
123123
};
124124
let mut field_path = path.clone();
125125
field_path.push(reg.name.node.clone());
126-
dummy_spanned(
127-
ast::StructField_ {
128-
kind: ast::NamedField(
129-
self.cx.ident_of(reg.name.node.as_str()),
130-
ast::Public),
131-
id: ast::DUMMY_NODE_ID,
132-
ty: reg_struct_type(self.cx, &field_path, reg),
133-
attrs: attrs,
134-
}
135-
)
126+
ast::StructField {
127+
span: DUMMY_SP,
128+
ident: Some(self.cx.ident_of(reg.name.node.as_str())),
129+
vis: ast::Visibility::Public,
130+
id: ast::DUMMY_NODE_ID,
131+
ty: reg_struct_type(self.cx, &field_path, reg),
132+
attrs: attrs,
133+
}
136134
}
137135

138136
/// Build field for padding or a register
139-
// Dummy spans allowed here because u8 doesn't come from anywhere
140-
#[allow(dummy_span)]
141137
fn build_pad_or_reg(&self, path: &Vec<String>, reg_or_pad: RegOrPadding,
142138
index: usize) -> ast::StructField {
143139
match reg_or_pad {
@@ -150,17 +146,15 @@ impl<'a> BuildUnionTypes<'a> {
150146
let ty: P<ast::Ty> =
151147
self.cx.ty(
152148
DUMMY_SP,
153-
ast::TyFixedLengthVec(u8_ty, expr_usize(self.cx, respan(DUMMY_SP, length))));
154-
dummy_spanned(
155-
ast::StructField_ {
156-
kind: ast::NamedField(
157-
self.cx.ident_of(format!("_pad{}", index).as_str()),
158-
ast::Inherited),
159-
id: ast::DUMMY_NODE_ID,
160-
ty: ty,
161-
attrs: Vec::new(),
162-
},
163-
)
149+
ast::TyKind::FixedLengthVec(u8_ty, expr_usize(self.cx, respan(DUMMY_SP, length))));
150+
ast::StructField {
151+
span: DUMMY_SP,
152+
ident: Some(self.cx.ident_of(format!("_pad{}", index).as_str())),
153+
vis: ast::Visibility::Inherited,
154+
id: ast::DUMMY_NODE_ID,
155+
ty: ty,
156+
attrs: Vec::new(),
157+
}
164158
},
165159
}
166160
}
@@ -199,8 +193,8 @@ impl<'a> BuildUnionTypes<'a> {
199193
ident: name,
200194
attrs: attrs,
201195
id: ast::DUMMY_NODE_ID,
202-
node: ast::ItemStruct(struct_def, ast::Generics::default()),
203-
vis: ast::Public,
196+
node: ast::ItemKind::Struct(struct_def, ast::Generics::default()),
197+
vis: ast::Visibility::Public,
204198
span: reg.name.span,
205199
});
206200
let mut full_size: u64 = 0;

ioreg/src/builder/utils.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ use syntax::parse::token;
2525
use super::super::node;
2626

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

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

6160
/// Generate a `#[doc="..."]` attribute of the given type
62-
#[allow(dummy_span)]
6361
pub fn doc_attribute(cx: &ExtCtxt, docstring: token::InternedString)
6462
-> ast::Attribute {
6563
use syntax::codemap::DUMMY_SP;
6664

67-
let s: ast::Lit_ = ast::LitStr(docstring, ast::CookedStr);
65+
let s: ast::LitKind = ast::LitKind::Str(docstring, ast::StrStyle::Cooked);
6866
let attr =
6967
cx.meta_name_value(DUMMY_SP, token::InternedString::new("doc"), s);
7068
cx.attribute(DUMMY_SP, attr)
@@ -135,8 +133,8 @@ pub fn field_type_path(cx: &ExtCtxt, path: &Vec<String>,
135133

136134
pub fn unwrap_impl_item(item: P<ast::Item>) -> P<ast::ImplItem> {
137135
match item.node {
138-
ast::ItemImpl(_, _, _, _, _, ref items) => {
139-
items.clone().pop().expect("ImplItem not found")
136+
ast::ItemKind::Impl(_, _, _, _, _, ref items) => {
137+
P(items.clone().pop().expect("ImplItem not found"))
140138
},
141139
_ => panic!("Tried to unwrap ImplItem from Non-Impl")
142140
}
@@ -152,11 +150,11 @@ pub fn mask(cx: &ExtCtxt, field: &node::Field) -> P<ast::Expr> {
152150
/// index if necessary)
153151
pub fn shift(cx: &ExtCtxt, idx: Option<P<ast::Expr>>,
154152
field: &node::Field) -> P<ast::Expr> {
155-
let low = expr_int(cx, respan(field.bit_range_span, field.low_bit as i64));
153+
let low = expr_int(cx, respan(field.bit_range_span, field.low_bit as u64));
156154
match idx {
157155
Some(idx) => {
158156
let width = expr_int(cx, respan(field.bit_range_span,
159-
field.width as i64));
157+
field.width as u64));
160158
quote_expr!(cx, $low + $idx * $width)
161159
},
162160
None => low,

ioreg/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,7 @@ N => NAME
327327
328328
*/
329329

330-
#![feature(quote, plugin_registrar, rustc_private, convert)]
331-
#![feature(plugin)]
332-
333-
#![plugin(syntaxext_lint)]
330+
#![feature(quote, plugin_registrar, rustc_private)]
334331

335332
extern crate rustc;
336333
extern crate syntax;

ioreg/src/parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use syntax::ext::base::ExtCtxt;
2222
use syntax::parse::{token, ParseSess, lexer};
2323
use syntax::parse;
2424
use syntax::print::pprust;
25+
use syntax::parse::lexer::Reader;
2526

2627
use node;
2728
use node::RegType;
@@ -39,7 +40,7 @@ enum Scope {
3940
pub struct Parser<'a> {
4041
cx: &'a ExtCtxt<'a>,
4142
sess: &'a ParseSess,
42-
reader: Box<lexer::Reader+'a>,
43+
reader: lexer::TtReader<'a>,
4344
token: token::Token,
4445
span: Span,
4546

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

5757
let tok0 = reader.next_token();
5858
let token = tok0.tok;
@@ -379,7 +379,7 @@ impl<'a> Parser<'a> {
379379
token::Colon => {
380380
self.bump();
381381
match self.token.clone() {
382-
ref t@token::Ident(_,_) => {
382+
ref t@token::Ident(_) => {
383383
match pprust::token_to_string(t) {
384384
ref s if s.eq(&"rw") => { self.bump(); node::Access::ReadWrite },
385385
ref s if s.eq(&"ro") => { self.bump(); node::Access::ReadOnly },
@@ -546,7 +546,7 @@ impl<'a> Parser<'a> {
546546
&self.sess.span_diagnostic,
547547
self.span);
548548
match lit {
549-
ast::LitInt(n, _) => Some(n),
549+
ast::LitKind::Int(n, _) => Some(n),
550550
_ => None,
551551
}
552552
},
@@ -631,7 +631,7 @@ impl<'a> Parser<'a> {
631631
fn expect_ident(&mut self) -> Option<String> {
632632
let tok_str = pprust::token_to_string(&self.token);
633633
match self.token {
634-
token::Ident(_, _) => {
634+
token::Ident(_) => {
635635
self.bump();
636636
Some(tok_str)
637637
},

macro_platformtree/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
#![feature(rustc_private, plugin_registrar, quote, convert)]
16+
#![feature(rustc_private, plugin_registrar, quote)]
1717

1818
extern crate platformtree;
1919
extern crate rustc;
@@ -76,7 +76,7 @@ fn macro_zinc_task(cx: &mut ExtCtxt, _: Span, _: &ast::MetaItem,
7676

7777
fn macro_zinc_task_item(cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
7878
match it.node {
79-
ast::ItemFn(ref decl, style, constness, abi, _, ref block) => {
79+
ast::ItemKind::Fn(ref decl, style, constness, abi, _, ref block) => {
8080
let istr = it.ident.name.as_str();
8181
let fn_name = &*istr;
8282
let ty_params = platformtree::builder::meta_args::get_ty_params_for_task(cx, fn_name);
@@ -103,7 +103,7 @@ fn macro_zinc_task_item(cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
103103
}).collect(),
104104
vec!())),
105105
None,
106-
ast::MutImmutable));
106+
ast::Mutability::Immutable));
107107
let new_decl = P(ast::FnDecl {
108108
inputs: vec!(new_arg),
109109
..decl.deref().clone()
@@ -117,7 +117,7 @@ fn macro_zinc_task_item(cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
117117
predicates: vec!(),
118118
}
119119
};
120-
let new_node = ast::ItemFn(new_decl, style, constness, abi, new_generics, block.clone());
120+
let new_node = ast::ItemKind::Fn(new_decl, style, constness, abi, new_generics, block.clone());
121121

122122
P(ast::Item {node: new_node, ..it.deref().clone() })
123123
},

platformtree/src/builder/meta_args.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn set_tasks(cx: &mut ExtCtxt, tasks: Vec<P<ast::MetaItem>>) {
6363
let mut vec_clone = cx.cfg();
6464
let maybe_pos = vec_clone.iter().position(|i| {
6565
match i.node {
66-
ast::MetaList(ref k, _) if *k == TAG => true,
66+
ast::MetaItemKind::List(ref k, _) if *k == TAG => true,
6767
_ => false,
6868
}
6969
});
@@ -80,7 +80,7 @@ fn set_tasks(cx: &mut ExtCtxt, tasks: Vec<P<ast::MetaItem>>) {
8080
fn get_tasks(cx: &ExtCtxt) -> Vec<P<ast::MetaItem>> {
8181
for i in cx.cfg.iter() {
8282
match i.node {
83-
ast::MetaList(ref k, ref v) if *k == TAG => return v.clone(),
83+
ast::MetaItemKind::List(ref k, ref v) if *k == TAG => return v.clone(),
8484
_ => (),
8585
}
8686
};
@@ -92,10 +92,10 @@ fn get_task(tasks: &Vec<P<ast::MetaItem>>, task: &str) -> Vec<String> {
9292
let mut ty_params = vec!();
9393
for mi in tasks.iter() {
9494
match mi.node {
95-
ast::MetaList(ref k, ref v) if *k == task => {
95+
ast::MetaItemKind::List(ref k, ref v) if *k == task => {
9696
for submi in v.iter() {
9797
match submi.node {
98-
ast::MetaWord(ref w) => ty_params.push((&*w).to_string()),
98+
ast::MetaItemKind::Word(ref w) => ty_params.push((&*w).to_string()),
9999
_ => panic!("unexpected node type"),
100100
}
101101
}

0 commit comments

Comments
 (0)