1
Fork 0

librustc_driver: use unboxed closures

This commit is contained in:
Jorge Aparicio 2014-12-09 16:32:45 -05:00
parent 521a6e62b1
commit 015c0fcee5
3 changed files with 15 additions and 10 deletions

View file

@ -25,6 +25,7 @@
#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)]
#![feature(slicing_syntax, unsafe_destructor)]
#![feature(rustc_diagnostic_macros)]
#![feature(unboxed_closures)]
extern crate arena;
extern crate flate;

View file

@ -99,13 +99,15 @@ pub fn parse_pretty(sess: &Session, name: &str) -> (PpMode, Option<UserIdentifie
impl PpSourceMode {
/// Constructs a `PrinterSupport` object and passes it to `f`.
fn call_with_pp_support<'tcx, A, B>(&self,
sess: Session,
ast_map: Option<ast_map::Map<'tcx>>,
type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
id: String,
payload: B,
f: |&PrinterSupport, B| -> A) -> A {
fn call_with_pp_support<'tcx, A, B, F>(&self,
sess: Session,
ast_map: Option<ast_map::Map<'tcx>>,
type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
id: String,
payload: B,
f: F) -> A where
F: FnOnce(&PrinterSupport, B) -> A,
{
match *self {
PpmNormal | PpmExpanded => {
let annotation = NoAnn { sess: sess, ast_map: ast_map };

View file

@ -93,9 +93,11 @@ fn errors(msgs: &[&str]) -> (Box<Emitter+Send>, uint) {
(box ExpectErrorEmitter { messages: v } as Box<Emitter+Send>, msgs.len())
}
fn test_env(source_string: &str,
(emitter, expected_err_count): (Box<Emitter+Send>, uint),
body: |Env|) {
fn test_env<F>(source_string: &str,
(emitter, expected_err_count): (Box<Emitter+Send>, uint),
body: F) where
F: FnOnce(Env),
{
let mut options =
config::basic_options();
options.debugging_opts |= config::VERBOSE;