@@ -77,7 +77,7 @@ pub fn run(input: &str, libs: @RefCell<HashSet<Path>>, mut test_args: ~[~str]) -
77
77
let ( krate, _) = passes:: unindent_comments ( krate) ;
78
78
let ( krate, _) = passes:: collapse_docs ( krate) ;
79
79
80
- let mut collector = Collector :: new ( krate. name . to_owned ( ) , libs, false ) ;
80
+ let mut collector = Collector :: new ( krate. name . to_owned ( ) , libs, false , false ) ;
81
81
collector. fold_crate ( krate) ;
82
82
83
83
test_args. unshift ( ~"rustdoctest") ;
@@ -88,8 +88,8 @@ pub fn run(input: &str, libs: @RefCell<HashSet<Path>>, mut test_args: ~[~str]) -
88
88
}
89
89
90
90
fn runtest ( test : & str , cratename : & str , libs : HashSet < Path > , should_fail : bool ,
91
- no_run : bool ) {
92
- let test = maketest ( test, cratename) ;
91
+ no_run : bool , loose_feature_gating : bool ) {
92
+ let test = maketest ( test, cratename, loose_feature_gating ) ;
93
93
let parsesess = parse:: new_parse_sess ( ) ;
94
94
let input = driver:: StrInput ( test) ;
95
95
@@ -162,11 +162,18 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool,
162
162
}
163
163
}
164
164
165
- fn maketest ( s : & str , cratename : & str ) -> ~str {
165
+ fn maketest ( s : & str , cratename : & str , loose_feature_gating : bool ) -> ~str {
166
166
let mut prog = ~r"
167
167
#[deny(warnings)];
168
168
#[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
169
169
" ;
170
+
171
+ if loose_feature_gating {
172
+ // FIXME #12773: avoid inserting these when the tutorial & manual
173
+ // etc. have been updated to not use them so prolifically.
174
+ prog. push_str ( "#[ feature(macro_rules, globs, struct_variant, managed_boxes) ];\n " ) ;
175
+ }
176
+
170
177
if !s. contains ( "extern crate" ) {
171
178
if s. contains ( "extra" ) {
172
179
prog. push_str ( "extern crate extra;\n " ) ;
@@ -194,18 +201,23 @@ pub struct Collector {
194
201
priv use_headers : bool ,
195
202
priv current_header : Option < ~str > ,
196
203
priv cratename : ~str ,
204
+
205
+ priv loose_feature_gating : bool
197
206
}
198
207
199
208
impl Collector {
200
- pub fn new ( cratename : ~str , libs : @RefCell < HashSet < Path > > , use_headers : bool ) -> Collector {
209
+ pub fn new ( cratename : ~str , libs : @RefCell < HashSet < Path > > ,
210
+ use_headers : bool , loose_feature_gating : bool ) -> Collector {
201
211
Collector {
202
212
tests : ~[ ] ,
203
213
names : ~[ ] ,
204
214
libs : libs,
205
215
cnt : 0 ,
206
216
use_headers : use_headers,
207
217
current_header : None ,
208
- cratename : cratename
218
+ cratename : cratename,
219
+
220
+ loose_feature_gating : loose_feature_gating
209
221
}
210
222
}
211
223
@@ -220,6 +232,7 @@ impl Collector {
220
232
let libs = self . libs . borrow ( ) ;
221
233
let libs = ( * libs. get ( ) ) . clone ( ) ;
222
234
let cratename = self . cratename . to_owned ( ) ;
235
+ let loose_feature_gating = self . loose_feature_gating ;
223
236
debug ! ( "Creating test {}: {}" , name, test) ;
224
237
self . tests . push ( testing:: TestDescAndFn {
225
238
desc : testing:: TestDesc {
@@ -228,7 +241,7 @@ impl Collector {
228
241
should_fail : false , // compiler failures are test failures
229
242
} ,
230
243
testfn : testing:: DynTestFn ( proc ( ) {
231
- runtest ( test, cratename, libs, should_fail, no_run) ;
244
+ runtest ( test, cratename, libs, should_fail, no_run, loose_feature_gating ) ;
232
245
} ) ,
233
246
} ) ;
234
247
}
0 commit comments