File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ pub struct Options {
97
97
pub color : ColorConfig ,
98
98
pub externs : HashMap < String , Vec < String > > ,
99
99
pub crate_name : Option < String > ,
100
+ pub alt_std_name : Option < String >
100
101
}
101
102
102
103
/// Some reasonable defaults
@@ -124,6 +125,7 @@ pub fn basic_options() -> Options {
124
125
color : Auto ,
125
126
externs : HashMap :: new ( ) ,
126
127
crate_name : None ,
128
+ alt_std_name : None ,
127
129
}
128
130
}
129
131
@@ -787,6 +789,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
787
789
color : color,
788
790
externs : externs,
789
791
crate_name : crate_name,
792
+ alt_std_name : None
790
793
}
791
794
}
792
795
Original file line number Diff line number Diff line change @@ -60,9 +60,16 @@ struct StandardLibraryInjector<'a> {
60
60
61
61
impl < ' a > fold:: Folder for StandardLibraryInjector < ' a > {
62
62
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
+
63
70
let mut vis = vec ! ( ast:: ViewItem {
64
71
node: ast:: ViewItemExternCrate ( token:: str_to_ident( "std" ) ,
65
- None ,
72
+ Some ( ( actual_crate_name , ast :: CookedStr ) ) ,
66
73
ast:: DUMMY_NODE_ID ) ,
67
74
attrs: vec!(
68
75
attr:: mk_attr_outer( attr:: mk_attr_id( ) , attr:: mk_list_item(
You can’t perform that action at this time.
0 commit comments