@@ -7,24 +7,19 @@ 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 ;
1110
1211use rustc_target:: spec:: { LinkerFlavor , MergeFunctions , PanicStrategy , RelroLevel } ;
1312use rustc_target:: spec:: { Target , TargetTriple } ;
1413
1514use syntax;
16- use syntax:: ast:: { self , IntTy , UintTy , MetaItemKind } ;
15+ use syntax:: ast:: { self , IntTy , UintTy } ;
1716use syntax:: source_map:: { FileName , FilePathMapping } ;
1817use syntax:: edition:: { Edition , EDITION_NAME_LIST , DEFAULT_EDITION } ;
19- use syntax:: parse:: new_parser_from_source_str;
20- use syntax:: parse:: token;
21- use syntax:: sess:: ParseSess ;
2218use syntax:: symbol:: { sym, Symbol } ;
2319use syntax:: feature_gate:: UnstableFeatures ;
24- use syntax:: source_map:: SourceMap ;
2520
2621use errors:: emitter:: HumanReadableErrorType ;
27- use errors:: { ColorConfig , FatalError , Handler , SourceMapperDyn } ;
22+ use errors:: { ColorConfig , FatalError , Handler } ;
2823
2924use getopts;
3025
@@ -1854,59 +1849,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
18541849 opts
18551850}
18561851
1857- struct NullEmitter ;
1858-
1859- impl errors:: emitter:: Emitter for NullEmitter {
1860- fn emit_diagnostic ( & mut self , _: & errors:: Diagnostic ) { }
1861- fn source_map ( & self ) -> Option < & Lrc < SourceMapperDyn > > { None }
1862- }
1863-
1864- // Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`.
1865- pub fn parse_cfgspecs ( cfgspecs : Vec < String > ) -> FxHashSet < ( String , Option < String > ) > {
1866- syntax:: with_default_globals ( move || {
1867- let cfg = cfgspecs. into_iter ( ) . map ( |s| {
1868-
1869- let cm = Lrc :: new ( SourceMap :: new ( FilePathMapping :: empty ( ) ) ) ;
1870- let handler = Handler :: with_emitter ( false , None , Box :: new ( NullEmitter ) ) ;
1871- let sess = ParseSess :: with_span_handler ( handler, cm) ;
1872- let filename = FileName :: cfg_spec_source_code ( & s) ;
1873- let mut parser = new_parser_from_source_str ( & sess, filename, s. to_string ( ) ) ;
1874-
1875- macro_rules! error { ( $reason: expr) => {
1876- early_error( ErrorOutputType :: default ( ) ,
1877- & format!( concat!( "invalid `--cfg` argument: `{}` (" , $reason, ")" ) , s) ) ;
1878- } }
1879-
1880- match & mut parser. parse_meta_item ( ) {
1881- Ok ( meta_item) if parser. token == token:: Eof => {
1882- if meta_item. path . segments . len ( ) != 1 {
1883- error ! ( "argument key must be an identifier" ) ;
1884- }
1885- match & meta_item. kind {
1886- MetaItemKind :: List ( ..) => {
1887- error ! ( r#"expected `key` or `key="value"`"# ) ;
1888- }
1889- MetaItemKind :: NameValue ( lit) if !lit. kind . is_str ( ) => {
1890- error ! ( "argument value must be a string" ) ;
1891- }
1892- MetaItemKind :: NameValue ( ..) | MetaItemKind :: Word => {
1893- let ident = meta_item. ident ( ) . expect ( "multi-segment cfg key" ) ;
1894- return ( ident. name , meta_item. value_str ( ) ) ;
1895- }
1896- }
1897- }
1898- Ok ( ..) => { }
1899- Err ( err) => err. cancel ( ) ,
1900- }
1901-
1902- error ! ( r#"expected `key` or `key="value"`"# ) ;
1903- } ) . collect :: < ast:: CrateConfig > ( ) ;
1904- cfg. into_iter ( ) . map ( |( a, b) | {
1905- ( a. to_string ( ) , b. map ( |b| b. to_string ( ) ) )
1906- } ) . collect ( )
1907- } )
1908- }
1909-
19101852pub fn get_cmd_lint_options ( matches : & getopts:: Matches ,
19111853 error_format : ErrorOutputType )
19121854 -> ( Vec < ( String , lint:: Level ) > , bool , Option < lint:: Level > ) {
@@ -2877,6 +2819,3 @@ mod dep_tracking {
28772819 }
28782820 }
28792821}
2880-
2881- #[ cfg( test) ]
2882- mod tests;
0 commit comments