Skip to content

Commit 901faef

Browse files
committed
Abstract away differences between Vec and OwnedSlice in HIR
1 parent 8d247aa commit 901faef

File tree

5 files changed

+86
-68
lines changed

5 files changed

+86
-68
lines changed

src/librustc_front/hir.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use std::collections::BTreeMap;
4040
use syntax::codemap::{self, Span, Spanned, DUMMY_SP, ExpnId};
4141
use syntax::abi::Abi;
4242
use syntax::ast::{Name, Ident, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect};
43-
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, CrateConfig};
43+
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem};
4444
use syntax::attr::ThinAttributes;
4545
use syntax::owned_slice::OwnedSlice;
4646
use syntax::parse::token::InternedString;
@@ -52,6 +52,18 @@ use util;
5252
use std::fmt;
5353
use serialize::{Encodable, Encoder, Decoder};
5454

55+
pub type Vec<T> = ::std::vec::Vec<T>;
56+
57+
macro_rules! hir_vec {
58+
($elem:expr; $n:expr) => (
59+
hir::Vec::from(vec![$elem; $n])
60+
);
61+
($($x:expr),*) => (
62+
hir::Vec::from(vec![$($x),*])
63+
);
64+
($($x:expr,)*) => (vec![$($x),*])
65+
}
66+
5567
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
5668
pub struct Lifetime {
5769
pub id: NodeId,
@@ -323,6 +335,8 @@ pub struct WhereEqPredicate {
323335
pub ty: P<Ty>,
324336
}
325337

338+
pub type CrateConfig = Vec<P<MetaItem>>;
339+
326340
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
327341
pub struct Crate {
328342
pub module: Mod,

src/librustc_front/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ extern crate rustc_bitflags;
4747

4848
extern crate serialize as rustc_serialize; // used by deriving
4949

50+
#[macro_use]
5051
pub mod hir;
5152
pub mod lowering;
5253
pub mod fold;

0 commit comments

Comments
 (0)