@@ -42,6 +42,7 @@ use syntax::attr;
4242use syntax:: attr:: { AttrMetaMethods } ;
4343use syntax:: codemap;
4444use syntax:: diagnostic;
45+ use syntax:: diagnostic:: Emitter ;
4546use syntax:: ext:: base:: CrateLoader ;
4647use syntax:: parse;
4748use syntax:: parse:: token:: InternedString ;
@@ -136,10 +137,10 @@ pub fn build_configuration(sess: Session) ->
136137}
137138
138139// 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 ] )
140141 -> ast:: CrateConfig {
141142 cfgspecs. move_iter ( ) . map ( |s| {
142- let sess = parse:: new_parse_sess ( Some ( demitter ) ) ;
143+ let sess = parse:: new_parse_sess ( ) ;
143144 parse:: parse_meta_from_source_str ( "cfgspec" . to_str ( ) , s, ~[ ] , sess)
144145 } ) . collect :: < ast:: CrateConfig > ( )
145146}
@@ -539,9 +540,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
539540 phase_6_link_output ( sess, & trans, & outputs) ;
540541}
541542
542- struct IdentifiedAnnotation {
543- contents : ( ) ,
544- }
543+ struct IdentifiedAnnotation ;
545544
546545impl pprust:: PpAnn for IdentifiedAnnotation {
547546 fn pre ( & self , node : pprust:: AnnNode ) -> io:: IoResult < ( ) > {
@@ -619,18 +618,16 @@ pub fn pretty_print_input(sess: Session,
619618
620619 let annotation = match ppm {
621620 PpmIdentified | PpmExpandedIdentified => {
622- @IdentifiedAnnotation {
623- contents: (),
624- } as @pprust::PpAnn
621+ ~IdentifiedAnnotation as ~pprust::PpAnn
625622 }
626623 PpmTyped => {
627624 let ast_map = ast_map.expect(" --pretty=typed missing ast_map");
628625 let analysis = phase_3_run_analysis_passes(sess, &crate, ast_map);
629- @ TypedAnnotation {
626+ ~ TypedAnnotation {
630627 analysis: analysis
631- } as @ pprust::PpAnn
628+ } as ~ pprust::PpAnn:
632629 }
633- _ => @ pprust::NoAnn as @ pprust::PpAnn,
630+ _ => ~ pprust::NoAnn as ~ pprust::PpAnn: ,
634631 };
635632
636633 let src = &sess.codemap.get_filemap(source_name(input)).src;
@@ -682,17 +679,15 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat
682679
683680 (" mips", abi::Mips)];
684681
685- pub fn build_target_config(sopts: @session::Options,
686- demitter: @diagnostic::Emitter)
682+ pub fn build_target_config(sopts: @session::Options)
687683 -> @session::Config {
688684 let os = match get_os(sopts.target_triple) {
689685 Some(os) => os,
690- None => early_error(demitter, " unknown operating system")
686+ None => early_error(" unknown operating system")
691687 };
692688 let arch = match get_arch(sopts.target_triple) {
693689 Some(arch) => arch,
694- None => early_error(demitter,
695- " unknown architecture: " + sopts.target_triple)
690+ None => early_error(" unknown architecture: " + sopts.target_triple)
696691 };
697692 let (int_type, uint_type) = match arch {
698693 abi::X86 => (ast::TyI32, ast::TyU32),
@@ -730,8 +725,7 @@ pub fn host_triple() -> ~str {
730725}
731726
732727pub fn build_session_options(binary: ~str,
733- matches: &getopts::Matches,
734- demitter: @diagnostic::Emitter)
728+ matches: &getopts::Matches)
735729 -> @session::Options {
736730 let crate_types = matches.opt_strs(" crate -type ").flat_map(|s| {
737731 s.split(',').map(|part| {
@@ -741,8 +735,7 @@ pub fn build_session_options(binary: ~str,
741735 " staticlib" => session::CrateTypeStaticlib,
742736 " dylib" => session::CrateTypeDylib,
743737 " bin" => session::CrateTypeExecutable,
744- _ => early_error(demitter,
745- format!(" unknown crate type : `{ } `", part) )
738+ _ => early_error(format!(" unknown crate type : `{ } `", part) )
746739 }
747740 } ) . collect ( )
748741 } ) ;
@@ -767,8 +760,8 @@ pub fn build_session_options(binary: ~str,
767760 let lint_name = lint_name. replace ( "-" , "_" ) ;
768761 match lint_dict. find_equiv( & lint_name) {
769762 None => {
770- early_error( demitter , format ! ( "unknown {} flag: {}" ,
771- level_name, lint_name) ) ;
763+ early_error( format ! ( "unknown {} flag: {}" ,
764+ level_name, lint_name) ) ;
772765 }
773766 Some ( lint) => {
774767 lint_opts. push ( ( lint. lint , * level) ) ;
@@ -787,7 +780,7 @@ pub fn build_session_options(binary: ~str,
787780 if * name == * debug_flag { this_bit = bit; break ; }
788781 }
789782 if this_bit == 0 {
790- early_error ( demitter , format ! ( "unknown debug flag: {}" , * debug_flag) )
783+ early_error ( format ! ( "unknown debug flag: {}" , * debug_flag) )
791784 }
792785 debugging_opts |= this_bit;
793786 }
@@ -807,9 +800,7 @@ pub fn build_session_options(binary: ~str,
807800 "bc" => link:: OutputTypeBitcode ,
808801 "obj" => link:: OutputTypeObject ,
809802 "link" => link:: OutputTypeExe ,
810- _ => early_error ( demitter,
811- format ! ( "unknown emission type: `{}`" ,
812- part) )
803+ _ => early_error ( format ! ( "unknown emission type: `{}`" , part) )
813804 }
814805 } ) . collect ( )
815806 } )
@@ -830,7 +821,7 @@ pub fn build_session_options(binary: ~str,
830821 No
831822 } else if matches. opt_present ( "O" ) {
832823 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" ) ;
834825 }
835826 Default
836827 } else if matches. opt_present ( "opt-level" ) {
@@ -840,7 +831,7 @@ pub fn build_session_options(binary: ~str,
840831 ~"2 " => Default ,
841832 ~"3 " => Aggressive ,
842833 _ => {
843- early_error ( demitter , "optimization level needs to be between 0-3" )
834+ early_error ( "optimization level needs to be between 0-3" )
844835 }
845836 }
846837 } else { No }
@@ -865,7 +856,7 @@ pub fn build_session_options(binary: ~str,
865856 } ) . collect ( )
866857 } ) ;
867858
868- let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) , demitter ) ;
859+ let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
869860 let test = matches. opt_present ( "test" ) ;
870861 let android_cross_path = matches. opt_str ( "android-cross-path" ) ;
871862 let write_dependency_info = ( matches. opt_present ( "dep-info" ) ,
@@ -926,25 +917,23 @@ pub fn build_session_options(binary: ~str,
926917}
927918
928919pub fn build_session ( sopts : @session:: Options ,
929- local_crate_source_file : Option < Path > ,
930- demitter : @diagnostic:: Emitter )
920+ local_crate_source_file : Option < Path > )
931921 -> Session {
932922 let codemap = @codemap:: CodeMap :: new ( ) ;
933923 let diagnostic_handler =
934- diagnostic:: mk_handler ( Some ( demitter ) ) ;
924+ diagnostic:: mk_handler ( ) ;
935925 let span_diagnostic_handler =
936926 diagnostic:: mk_span_handler ( diagnostic_handler, codemap) ;
937927
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)
939929}
940930
941931pub fn build_session_ ( sopts : @session:: Options ,
942932 local_crate_source_file : Option < Path > ,
943933 codemap : @codemap:: CodeMap ,
944- demitter : @diagnostic:: Emitter ,
945934 span_diagnostic_handler : @diagnostic:: SpanHandler )
946935 -> Session {
947- let target_cfg = build_target_config ( sopts, demitter ) ;
936+ let target_cfg = build_target_config ( sopts) ;
948937 let p_s = parse:: new_parse_sess_special_handler ( span_diagnostic_handler, codemap) ;
949938 let cstore = @CStore :: new ( token:: get_ident_interner ( ) ) ;
950939 let filesearch = @filesearch:: FileSearch :: new (
@@ -1167,8 +1156,8 @@ pub fn build_output_filenames(input: &Input,
11671156 }
11681157}
11691158
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 ) ;
11721161 fail ! ( diagnostic:: FatalError ) ;
11731162}
11741163
@@ -1198,8 +1187,8 @@ mod test {
11981187 Ok ( m) => m,
11991188 Err ( f) => fail ! ( "test_switch_implies_cfg_test: {}" , f. to_err_msg( ) )
12001189 } ;
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 ) ;
12031192 let cfg = build_configuration ( sess) ;
12041193 assert ! ( ( attr:: contains_name( cfg, "test" ) ) ) ;
12051194 }
@@ -1216,8 +1205,8 @@ mod test {
12161205 f. to_err_msg( ) ) ;
12171206 }
12181207 } ;
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 ) ;
12211210 let cfg = build_configuration ( sess) ;
12221211 let mut test_items = cfg. iter ( ) . filter ( |m| m. name ( ) . equiv ( & ( "test" ) ) ) ;
12231212 assert ! ( test_items. next( ) . is_some( ) ) ;
0 commit comments