File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ pub struct Options {
9797 pub color : ColorConfig ,
9898 pub externs : HashMap < String , Vec < String > > ,
9999 pub crate_name : Option < String > ,
100+ pub alt_std_name : Option < String >
100101}
101102
102103/// Some reasonable defaults
@@ -124,6 +125,7 @@ pub fn basic_options() -> Options {
124125 color : Auto ,
125126 externs : HashMap :: new ( ) ,
126127 crate_name : None ,
128+ alt_std_name : None ,
127129 }
128130}
129131
@@ -787,6 +789,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
787789 color : color,
788790 externs : externs,
789791 crate_name : crate_name,
792+ alt_std_name : None
790793 }
791794}
792795
Original file line number Diff line number Diff line change @@ -60,9 +60,16 @@ struct StandardLibraryInjector<'a> {
6060
6161impl < ' a > fold:: Folder for StandardLibraryInjector < ' a > {
6262 fn fold_crate ( & mut self , mut krate : ast:: Crate ) -> ast:: Crate {
63+
64+ // The name to use in `extern crate std = "name";`
65+ let actual_crate_name = match self . sess . opts . alt_std_name {
66+ Some ( ref s) => token:: intern_and_get_ident ( s. as_slice ( ) ) ,
67+ None => token:: intern_and_get_ident ( "std" ) ,
68+ } ;
69+
6370 let mut vis = vec ! ( ast:: ViewItem {
6471 node: ast:: ViewItemExternCrate ( token:: str_to_ident( "std" ) ,
65- None ,
72+ Some ( ( actual_crate_name , ast :: CookedStr ) ) ,
6673 ast:: DUMMY_NODE_ID ) ,
6774 attrs: vec!(
6875 attr:: mk_attr_outer( attr:: mk_attr_id( ) , attr:: mk_list_item(
You can’t perform that action at this time.
0 commit comments