@@ -7,24 +7,19 @@ use crate::session::{early_error, early_warn, Session};
7
7
use crate :: session:: search_paths:: SearchPath ;
8
8
9
9
use rustc_data_structures:: fx:: FxHashSet ;
10
- use rustc_data_structures:: sync:: Lrc ;
11
10
12
11
use rustc_target:: spec:: { LinkerFlavor , MergeFunctions , PanicStrategy , RelroLevel } ;
13
12
use rustc_target:: spec:: { Target , TargetTriple } ;
14
13
15
14
use syntax;
16
- use syntax:: ast:: { self , IntTy , UintTy , MetaItemKind } ;
15
+ use syntax:: ast:: { self , IntTy , UintTy } ;
17
16
use syntax:: source_map:: { FileName , FilePathMapping } ;
18
17
use 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 ;
22
18
use syntax:: symbol:: { sym, Symbol } ;
23
19
use syntax:: feature_gate:: UnstableFeatures ;
24
- use syntax:: source_map:: SourceMap ;
25
20
26
21
use errors:: emitter:: HumanReadableErrorType ;
27
- use errors:: { ColorConfig , FatalError , Handler , SourceMapperDyn } ;
22
+ use errors:: { ColorConfig , FatalError , Handler } ;
28
23
29
24
use getopts;
30
25
@@ -1854,59 +1849,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
1854
1849
opts
1855
1850
}
1856
1851
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
-
1910
1852
pub fn get_cmd_lint_options ( matches : & getopts:: Matches ,
1911
1853
error_format : ErrorOutputType )
1912
1854
-> ( Vec < ( String , lint:: Level ) > , bool , Option < lint:: Level > ) {
@@ -2877,6 +2819,3 @@ mod dep_tracking {
2877
2819
}
2878
2820
}
2879
2821
}
2880
-
2881
- #[ cfg( test) ]
2882
- mod tests;
0 commit comments