File tree Expand file tree Collapse file tree 3 files changed +30
-10
lines changed
test/run-pass/rfc-2126-extern-absolute-paths Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -319,14 +319,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
319
319
types : Vec < P < ast:: Ty > > ,
320
320
bindings : Vec < ast:: TypeBinding > )
321
321
-> ast:: Path {
322
- use syntax:: parse:: token;
323
-
324
322
let last_identifier = idents. pop ( ) . unwrap ( ) ;
325
323
let mut segments: Vec < ast:: PathSegment > = Vec :: new ( ) ;
326
- if global &&
327
- !idents. first ( ) . map_or ( false , |& ident| token:: Ident ( ident) . is_path_segment_keyword ( ) ) {
328
- segments. push ( ast:: PathSegment :: crate_root ( span) ) ;
329
- }
330
324
331
325
segments. extend ( idents. into_iter ( ) . map ( |i| ast:: PathSegment :: from_ident ( i, span) ) ) ;
332
326
let parameters = if !lifetimes. is_empty ( ) || !types. is_empty ( ) || !bindings. is_empty ( ) {
@@ -335,7 +329,9 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
335
329
None
336
330
} ;
337
331
segments. push ( ast:: PathSegment { identifier : last_identifier, span, parameters } ) ;
338
- ast:: Path { span, segments }
332
+ let path = ast:: Path { span, segments } ;
333
+
334
+ if global { path. default_to_global ( ) } else { path }
339
335
}
340
336
341
337
/// Constructs a qualified path.
Original file line number Diff line number Diff line change @@ -733,9 +733,12 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
733
733
field( "should_panic" , fail_expr) ,
734
734
field( "allow_fail" , allow_fail_expr) ] ) ;
735
735
736
-
737
- let mut visible_path = match cx. toplevel_reexport {
738
- Some ( id) => vec ! [ id] ,
736
+ let mut visible_path = vec ! [ ] ;
737
+ if cx. features . extern_absolute_paths {
738
+ visible_path. push ( keywords:: Crate . ident ( ) ) ;
739
+ }
740
+ match cx. toplevel_reexport {
741
+ Some ( id) => visible_path. push ( id) ,
739
742
None => {
740
743
let diag = cx. span_diagnostic ;
741
744
diag. bug ( "expected to find top-level re-export name, but found None" ) ;
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Check that `#[test]` works with extern-absolute-paths enabled.
12
+ //
13
+ // Regression test for #47075.
14
+
15
+ // compile-flags: --test
16
+
17
+ #![ feature( extern_absolute_paths) ]
18
+
19
+ #[ test]
20
+ fn test ( ) {
21
+ }
You can’t perform that action at this time.
0 commit comments