@@ -7,6 +7,7 @@ use crate::session::{early_error, early_warn, Session};
77use crate :: session:: search_paths:: SearchPath ;
88
99use rustc_data_structures:: fx:: FxHashSet ;
10+ use rustc_data_structures:: sync:: Lrc ;
1011
1112use rustc_target:: spec:: { LinkerFlavor , MergeFunctions , PanicStrategy , RelroLevel } ;
1213use rustc_target:: spec:: { Target , TargetTriple } ;
@@ -19,6 +20,7 @@ use syntax::parse::{ParseSess, new_parser_from_source_str};
1920use syntax:: parse:: token;
2021use syntax:: symbol:: { sym, Symbol } ;
2122use syntax:: feature_gate:: UnstableFeatures ;
23+ use syntax:: source_map:: SourceMap ;
2224
2325use errors:: emitter:: HumanReadableErrorType ;
2426use errors:: { ColorConfig , FatalError , Handler } ;
@@ -1850,11 +1852,20 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
18501852 opts
18511853}
18521854
1855+ struct NullEmitter ;
1856+
1857+ impl errors:: emitter:: Emitter for NullEmitter {
1858+ fn emit_diagnostic ( & mut self , _: & errors:: DiagnosticBuilder < ' _ > ) { }
1859+ }
1860+
18531861// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`.
18541862pub fn parse_cfgspecs ( cfgspecs : Vec < String > ) -> FxHashSet < ( String , Option < String > ) > {
18551863 syntax:: with_default_globals ( move || {
18561864 let cfg = cfgspecs. into_iter ( ) . map ( |s| {
1857- let sess = ParseSess :: new ( FilePathMapping :: empty ( ) ) ;
1865+
1866+ let cm = Lrc :: new ( SourceMap :: new ( FilePathMapping :: empty ( ) ) ) ;
1867+ let handler = Handler :: with_emitter ( false , None , Box :: new ( NullEmitter ) ) ;
1868+ let sess = ParseSess :: with_span_handler ( handler, cm) ;
18581869 let filename = FileName :: cfg_spec_source_code ( & s) ;
18591870 let mut parser = new_parser_from_source_str ( & sess, filename, s. to_string ( ) ) ;
18601871
0 commit comments