File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
compiler/rustc_driver_impl/src Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ pub mod args;
8686pub mod pretty;
8787#[ macro_use]
8888mod print;
89- mod highlighter;
89+ pub mod highlighter;
9090mod session_diagnostics;
9191
9292// Keep the OS parts of this `cfg` in sync with the `cfg` on the `libc`
Original file line number Diff line number Diff line change 1+ //@ run-pass
2+ //@ check-run-results
3+
4+ #![ feature( rustc_private) ]
5+ use std:: io:: Write ;
6+ extern crate rustc_driver;
7+ extern crate rustc_driver_impl;
8+
9+ use rustc_driver_impl:: highlighter:: highlight;
10+
11+ const TEST_INPUT : & str = "
12+ struct Foo;
13+
14+ fn baz(x: i32) {
15+ // A function
16+ }
17+
18+ fn main() {
19+ let foo = Foo;
20+ foo.bar();
21+ }
22+ " ;
23+
24+ fn main ( ) {
25+ let mut buf = Vec :: new ( ) ;
26+ highlight ( TEST_INPUT , & mut buf) . unwrap ( ) ;
27+ let mut stdout = std:: io:: stdout ( ) ;
28+ stdout. write_all ( & buf) . unwrap ( ) ;
29+ }
Original file line number Diff line number Diff line change 1+ [2m[97m
2+ [0m[35mstruct[0m[2m[97m [0m[33mFoo[0m[2m[97m;[0m[2m[97m
3+
4+ [0m[35mfn[0m[34m [0m[34mbaz[0m[2m[97m([0mx[2m[97m:[0m[2m[97m [0m[36mi32[0m[2m[97m)[0m[2m[97m [0m[2m[97m{[0m[2m[97m
5+ [0m[2m[97m// A function[0m[2m[97m
6+ [0m[2m[97m}[0m[2m[97m
7+
8+ [0m[35mfn[0m[34m [0m[34mmain[0m[2m[97m([0m[2m[97m)[0m[2m[97m [0m[2m[97m{[0m[2m[97m
9+ [0m[35mlet[0m[2m[97m [0mfoo[2m[97m [0m[2m[97m=[0m[2m[97m [0m[33mFoo[0m[2m[97m;[0m[2m[97m
10+ [0mfoo[2m[97m.[0m[34mbar[0m[2m[97m([0m[2m[97m)[0m[2m[97m;[0m[2m[97m
11+ [0m[2m[97m}[0m[2m[97m
12+ [0m
You can’t perform that action at this time.
0 commit comments