From e8a4db25acde9d2d23a4ebfb464d283d495b5b8d Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Tue, 27 Sep 2016 11:45:50 +1300 Subject: Allow supplying an error destination via the compiler driver Allows replacing stderr with a buffer from the client. Also, some refactoring around run_compiler. --- src/libsyntax/json.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index a40c30b3e33..a1c273baeea 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -38,14 +38,24 @@ pub struct JsonEmitter { } impl JsonEmitter { + pub fn stderr(registry: Option, + code_map: Rc) -> JsonEmitter { + JsonEmitter { + dst: Box::new(io::stderr()), + registry: registry, + cm: code_map, + } + } + pub fn basic() -> JsonEmitter { JsonEmitter::stderr(None, Rc::new(CodeMap::new())) } - pub fn stderr(registry: Option, - code_map: Rc) -> JsonEmitter { + pub fn new(dst: Box, + registry: Option, + code_map: Rc) -> JsonEmitter { JsonEmitter { - dst: Box::new(io::stderr()), + dst: dst, registry: registry, cm: code_map, } -- cgit 1.4.1-3-g733a5