Remove the #[merge] hack from the parser
This commit is contained in:
parent
ec8fb884e9
commit
03ae629259
@ -3550,8 +3550,7 @@ pub impl Parser {
|
||||
fn parse_item_mod(&self, outer_attrs: ~[ast::attribute]) -> item_info {
|
||||
let id_span = *self.span;
|
||||
let id = self.parse_ident();
|
||||
let merge = ::attr::first_attr_value_str_by_name(outer_attrs, "merge");
|
||||
let info_ = if *self.token == token::SEMI {
|
||||
if *self.token == token::SEMI {
|
||||
self.bump();
|
||||
// This mod is in an external file. Let's go get it!
|
||||
let (m, attrs) = self.eval_src_mod(id, outer_attrs, id_span);
|
||||
@ -3564,38 +3563,6 @@ pub impl Parser {
|
||||
self.expect(&token::RBRACE);
|
||||
self.pop_mod_path();
|
||||
(id, item_mod(m), Some(inner))
|
||||
};
|
||||
|
||||
// XXX: Transitionary hack to do the template work inside core
|
||||
// (int-template, iter-trait). If there's a 'merge' attribute
|
||||
// on the mod, then we'll go and suck in another file and merge
|
||||
// its contents
|
||||
match merge {
|
||||
Some(path) => {
|
||||
let prefix = Path(
|
||||
self.sess.cm.span_to_filename(*self.span));
|
||||
let prefix = prefix.dir_path();
|
||||
let path = Path(copy *path);
|
||||
let (new_mod_item, new_attrs) = self.eval_src_mod_from_path(
|
||||
prefix, path, ~[], id_span);
|
||||
|
||||
let (main_id, main_mod_item, main_attrs) = info_;
|
||||
let main_attrs = main_attrs.get();
|
||||
|
||||
let (main_mod, new_mod) =
|
||||
match (main_mod_item, new_mod_item) {
|
||||
(item_mod(m), item_mod(n)) => (m, n),
|
||||
_ => self.bug("parsed mod item should be mod")
|
||||
};
|
||||
let merged_mod = ast::_mod {
|
||||
view_items: main_mod.view_items + new_mod.view_items,
|
||||
items: main_mod.items + new_mod.items
|
||||
};
|
||||
|
||||
let merged_attrs = main_attrs + new_attrs;
|
||||
(main_id, item_mod(merged_mod), Some(merged_attrs))
|
||||
}
|
||||
None => info_
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test not a test. used by mod-merge-hack.rs
|
||||
|
||||
mod inst {
|
||||
pub type T = i32;
|
||||
pub static bits: uint = 32;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test not a test. used by mod-merge-hack.rs
|
||||
|
||||
use T = self::inst::T;
|
||||
|
||||
pub static bits: uint = inst::bits;
|
||||
pub fn min(x: T, y: T) -> T { if x < y { x } else { y } }
|
@ -1,19 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-pretty
|
||||
#[path = "mod-merge-hack-template.rs"]
|
||||
#[merge = "mod-merge-hack-inst.rs"]
|
||||
mod myint32;
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(myint32::bits, 32);
|
||||
assert_eq!(myint32::min(10, 20), 10);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user