@@ -316,14 +316,16 @@ fn get_arch(triple: str) -> option<session::arch> {
316
316
} else { none } ;
317
317
}
318
318
319
- fn build_target_config ( sopts : @session:: options ) -> @session:: config {
319
+ fn build_target_config ( sopts : @session:: options ,
320
+ demitter : diagnostic:: emitter ) -> @session:: config {
320
321
let os = alt get_os ( sopts. target_triple ) {
321
322
some ( os) { os }
322
- none. { early_error ( "Unknown operating system!" ) }
323
+ none. { early_error ( demitter , "Unknown operating system!" ) }
323
324
} ;
324
325
let arch = alt get_arch ( sopts. target_triple ) {
325
326
some ( arch) { arch }
326
- none. { early_error ( "Unknown architecture! " + sopts. target_triple ) }
327
+ none. { early_error ( demitter,
328
+ "Unknown architecture! " + sopts. target_triple ) }
327
329
} ;
328
330
let ( int_type, uint_type, float_type) = alt arch {
329
331
session : : arch_x86. { ( ast:: ty_i32, ast:: ty_u32, ast:: ty_f64) }
@@ -353,8 +355,8 @@ fn host_triple() -> str {
353
355
ret ht != "" ? ht : fail "rustc built without CFG_HOST_TRIPLE" ;
354
356
}
355
357
356
- fn build_session_options( match : getopts:: match )
357
- -> @session:: options {
358
+ fn build_session_options( match : getopts:: match ,
359
+ demitter : diagnostic :: emitter ) -> @session:: options {
358
360
let crate_type = if opt_present ( match , "lib" ) {
359
361
session:: lib_crate
360
362
} else if opt_present ( match , "bin" ) {
@@ -398,7 +400,7 @@ fn build_session_options(match: getopts::match)
398
400
let opt_level: uint =
399
401
if opt_present( match , "O" ) {
400
402
if opt_present( match, "opt-level" ) {
401
- early_error( "-O and --opt-level both provided" ) ;
403
+ early_error( demitter , "-O and --opt-level both provided" ) ;
402
404
}
403
405
2 u
404
406
} else if opt_present ( match , "opt-level" ) {
@@ -408,7 +410,7 @@ fn build_session_options(match: getopts::match)
408
410
"2" { 2 u }
409
411
"3" { 3 u }
410
412
_ {
411
- early_error( "optimization level needs " +
413
+ early_error( demitter , "optimization level needs " +
412
414
"to be between 0-3" )
413
415
}
414
416
}
@@ -450,8 +452,9 @@ fn build_session_options(match: getopts::match)
450
452
ret sopts;
451
453
}
452
454
453
- fn build_session ( sopts : @session:: options , input : str ) -> session:: session {
454
- let target_cfg = build_target_config ( sopts) ;
455
+ fn build_session ( sopts : @session:: options , input : str ,
456
+ demitter : diagnostic:: emitter ) -> session:: session {
457
+ let target_cfg = build_target_config ( sopts, demitter) ;
455
458
let cstore = cstore:: mk_cstore ( ) ;
456
459
let filesearch = filesearch:: mk_filesearch (
457
460
sopts. maybe_sysroot ,
@@ -590,8 +593,8 @@ fn build_output_filenames(ifile: str,
590
593
obj_filename : obj_path} ;
591
594
}
592
595
593
- fn early_error ( msg : str ) -> ! {
594
- diagnostic :: emit_diagnostic ( none, msg, diagnostic:: fatal) ;
596
+ fn early_error ( emitter : diagnostic :: emitter , msg : str ) -> ! {
597
+ emitter ( none, msg, diagnostic:: fatal) ;
595
598
fail;
596
599
}
597
600
0 commit comments