@@ -42,6 +42,7 @@ use syntax::attr;
42
42
use syntax:: attr:: { AttrMetaMethods } ;
43
43
use syntax:: codemap;
44
44
use syntax:: diagnostic;
45
+ use syntax:: diagnostic:: Emitter ;
45
46
use syntax:: ext:: base:: CrateLoader ;
46
47
use syntax:: parse;
47
48
use syntax:: parse:: token:: InternedString ;
@@ -136,10 +137,10 @@ pub fn build_configuration(sess: Session) ->
136
137
}
137
138
138
139
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
139
- fn parse_cfgspecs ( cfgspecs : ~[ ~str ] , demitter : @diagnostic :: Emitter )
140
+ fn parse_cfgspecs ( cfgspecs : ~[ ~str ] )
140
141
-> ast:: CrateConfig {
141
142
cfgspecs. move_iter ( ) . map ( |s| {
142
- let sess = parse:: new_parse_sess ( Some ( demitter ) ) ;
143
+ let sess = parse:: new_parse_sess ( ) ;
143
144
parse:: parse_meta_from_source_str ( "cfgspec" . to_str ( ) , s, ~[ ] , sess)
144
145
} ) . collect :: < ast:: CrateConfig > ( )
145
146
}
@@ -539,9 +540,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
539
540
phase_6_link_output ( sess, & trans, & outputs) ;
540
541
}
541
542
542
- struct IdentifiedAnnotation {
543
- contents : ( ) ,
544
- }
543
+ struct IdentifiedAnnotation ;
545
544
546
545
impl pprust:: PpAnn for IdentifiedAnnotation {
547
546
fn pre ( & self , node : pprust:: AnnNode ) -> io:: IoResult < ( ) > {
@@ -619,18 +618,16 @@ pub fn pretty_print_input(sess: Session,
619
618
620
619
let annotation = match ppm {
621
620
PpmIdentified | PpmExpandedIdentified => {
622
- @IdentifiedAnnotation {
623
- contents: (),
624
- } as @pprust::PpAnn
621
+ ~IdentifiedAnnotation as ~pprust::PpAnn
625
622
}
626
623
PpmTyped => {
627
624
let ast_map = ast_map.expect(" --pretty=typed missing ast_map");
628
625
let analysis = phase_3_run_analysis_passes(sess, &crate, ast_map);
629
- @ TypedAnnotation {
626
+ ~ TypedAnnotation {
630
627
analysis: analysis
631
- } as @ pprust::PpAnn
628
+ } as ~ pprust::PpAnn:
632
629
}
633
- _ => @ pprust::NoAnn as @ pprust::PpAnn,
630
+ _ => ~ pprust::NoAnn as ~ pprust::PpAnn: ,
634
631
};
635
632
636
633
let src = &sess.codemap.get_filemap(source_name(input)).src;
@@ -682,17 +679,15 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat
682
679
683
680
(" mips", abi::Mips)];
684
681
685
- pub fn build_target_config(sopts: @session::Options,
686
- demitter: @diagnostic::Emitter)
682
+ pub fn build_target_config(sopts: @session::Options)
687
683
-> @session::Config {
688
684
let os = match get_os(sopts.target_triple) {
689
685
Some(os) => os,
690
- None => early_error(demitter, " unknown operating system")
686
+ None => early_error(" unknown operating system")
691
687
};
692
688
let arch = match get_arch(sopts.target_triple) {
693
689
Some(arch) => arch,
694
- None => early_error(demitter,
695
- " unknown architecture: " + sopts.target_triple)
690
+ None => early_error(" unknown architecture: " + sopts.target_triple)
696
691
};
697
692
let (int_type, uint_type) = match arch {
698
693
abi::X86 => (ast::TyI32, ast::TyU32),
@@ -730,8 +725,7 @@ pub fn host_triple() -> ~str {
730
725
}
731
726
732
727
pub fn build_session_options(binary: ~str,
733
- matches: &getopts::Matches,
734
- demitter: @diagnostic::Emitter)
728
+ matches: &getopts::Matches)
735
729
-> @session::Options {
736
730
let crate_types = matches.opt_strs(" crate -type ").flat_map(|s| {
737
731
s.split(',').map(|part| {
@@ -741,8 +735,7 @@ pub fn build_session_options(binary: ~str,
741
735
" staticlib" => session::CrateTypeStaticlib,
742
736
" dylib" => session::CrateTypeDylib,
743
737
" bin" => session::CrateTypeExecutable,
744
- _ => early_error(demitter,
745
- format!(" unknown crate type : `{ } `", part) )
738
+ _ => early_error(format!(" unknown crate type : `{ } `", part) )
746
739
}
747
740
} ) . collect ( )
748
741
} ) ;
@@ -767,8 +760,8 @@ pub fn build_session_options(binary: ~str,
767
760
let lint_name = lint_name. replace ( "-" , "_" ) ;
768
761
match lint_dict. find_equiv( & lint_name) {
769
762
None => {
770
- early_error( demitter , format ! ( "unknown {} flag: {}" ,
771
- level_name, lint_name) ) ;
763
+ early_error( format ! ( "unknown {} flag: {}" ,
764
+ level_name, lint_name) ) ;
772
765
}
773
766
Some ( lint) => {
774
767
lint_opts. push ( ( lint. lint , * level) ) ;
@@ -787,7 +780,7 @@ pub fn build_session_options(binary: ~str,
787
780
if * name == * debug_flag { this_bit = bit; break ; }
788
781
}
789
782
if this_bit == 0 {
790
- early_error ( demitter , format ! ( "unknown debug flag: {}" , * debug_flag) )
783
+ early_error ( format ! ( "unknown debug flag: {}" , * debug_flag) )
791
784
}
792
785
debugging_opts |= this_bit;
793
786
}
@@ -807,9 +800,7 @@ pub fn build_session_options(binary: ~str,
807
800
"bc" => link:: OutputTypeBitcode ,
808
801
"obj" => link:: OutputTypeObject ,
809
802
"link" => link:: OutputTypeExe ,
810
- _ => early_error ( demitter,
811
- format ! ( "unknown emission type: `{}`" ,
812
- part) )
803
+ _ => early_error ( format ! ( "unknown emission type: `{}`" , part) )
813
804
}
814
805
} ) . collect ( )
815
806
} )
@@ -830,7 +821,7 @@ pub fn build_session_options(binary: ~str,
830
821
No
831
822
} else if matches. opt_present ( "O" ) {
832
823
if matches. opt_present ( "opt-level" ) {
833
- early_error ( demitter , "-O and --opt-level both provided" ) ;
824
+ early_error ( "-O and --opt-level both provided" ) ;
834
825
}
835
826
Default
836
827
} else if matches. opt_present ( "opt-level" ) {
@@ -840,7 +831,7 @@ pub fn build_session_options(binary: ~str,
840
831
~"2 " => Default ,
841
832
~"3 " => Aggressive ,
842
833
_ => {
843
- early_error ( demitter , "optimization level needs to be between 0-3" )
834
+ early_error ( "optimization level needs to be between 0-3" )
844
835
}
845
836
}
846
837
} else { No }
@@ -865,7 +856,7 @@ pub fn build_session_options(binary: ~str,
865
856
} ) . collect ( )
866
857
} ) ;
867
858
868
- let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) , demitter ) ;
859
+ let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
869
860
let test = matches. opt_present ( "test" ) ;
870
861
let android_cross_path = matches. opt_str ( "android-cross-path" ) ;
871
862
let write_dependency_info = ( matches. opt_present ( "dep-info" ) ,
@@ -926,25 +917,23 @@ pub fn build_session_options(binary: ~str,
926
917
}
927
918
928
919
pub fn build_session ( sopts : @session:: Options ,
929
- local_crate_source_file : Option < Path > ,
930
- demitter : @diagnostic:: Emitter )
920
+ local_crate_source_file : Option < Path > )
931
921
-> Session {
932
922
let codemap = @codemap:: CodeMap :: new ( ) ;
933
923
let diagnostic_handler =
934
- diagnostic:: mk_handler ( Some ( demitter ) ) ;
924
+ diagnostic:: mk_handler ( ) ;
935
925
let span_diagnostic_handler =
936
926
diagnostic:: mk_span_handler ( diagnostic_handler, codemap) ;
937
927
938
- build_session_ ( sopts, local_crate_source_file, codemap, demitter , span_diagnostic_handler)
928
+ build_session_ ( sopts, local_crate_source_file, codemap, span_diagnostic_handler)
939
929
}
940
930
941
931
pub fn build_session_ ( sopts : @session:: Options ,
942
932
local_crate_source_file : Option < Path > ,
943
933
codemap : @codemap:: CodeMap ,
944
- demitter : @diagnostic:: Emitter ,
945
934
span_diagnostic_handler : @diagnostic:: SpanHandler )
946
935
-> Session {
947
- let target_cfg = build_target_config ( sopts, demitter ) ;
936
+ let target_cfg = build_target_config ( sopts) ;
948
937
let p_s = parse:: new_parse_sess_special_handler ( span_diagnostic_handler, codemap) ;
949
938
let cstore = @CStore :: new ( token:: get_ident_interner ( ) ) ;
950
939
let filesearch = @filesearch:: FileSearch :: new (
@@ -1167,8 +1156,8 @@ pub fn build_output_filenames(input: &Input,
1167
1156
}
1168
1157
}
1169
1158
1170
- pub fn early_error ( emitter : & diagnostic :: Emitter , msg : & str ) -> ! {
1171
- emitter . emit ( None , msg, diagnostic:: Fatal ) ;
1159
+ pub fn early_error ( msg : & str ) -> ! {
1160
+ diagnostic :: DefaultEmitter . emit ( None , msg, diagnostic:: Fatal ) ;
1172
1161
fail ! ( diagnostic:: FatalError ) ;
1173
1162
}
1174
1163
@@ -1198,8 +1187,8 @@ mod test {
1198
1187
Ok ( m) => m,
1199
1188
Err ( f) => fail ! ( "test_switch_implies_cfg_test: {}" , f. to_err_msg( ) )
1200
1189
} ;
1201
- let sessopts = build_session_options ( ~"rustc", matches, @diagnostic :: DefaultEmitter ) ;
1202
- let sess = build_session ( sessopts, None , @diagnostic :: DefaultEmitter ) ;
1190
+ let sessopts = build_session_options ( ~"rustc", matches) ;
1191
+ let sess = build_session ( sessopts, None ) ;
1203
1192
let cfg = build_configuration ( sess) ;
1204
1193
assert ! ( ( attr:: contains_name( cfg, "test" ) ) ) ;
1205
1194
}
@@ -1216,8 +1205,8 @@ mod test {
1216
1205
f. to_err_msg( ) ) ;
1217
1206
}
1218
1207
} ;
1219
- let sessopts = build_session_options ( ~"rustc", matches, @diagnostic :: DefaultEmitter ) ;
1220
- let sess = build_session ( sessopts, None , @diagnostic :: DefaultEmitter ) ;
1208
+ let sessopts = build_session_options ( ~"rustc", matches) ;
1209
+ let sess = build_session ( sessopts, None ) ;
1221
1210
let cfg = build_configuration ( sess) ;
1222
1211
let mut test_items = cfg. iter ( ) . filter ( |m| m. name ( ) . equiv ( & ( "test" ) ) ) ;
1223
1212
assert ! ( test_items. next( ) . is_some( ) ) ;
0 commit comments