@@ -627,8 +627,15 @@ fn path_node(ids: Vec<Ident>) -> ast::Path {
627
627
}
628
628
629
629
fn path_name_i ( idents : & [ Ident ] ) -> String {
630
- // FIXME: Bad copies (#2543 -- same for everything else that says "bad")
631
- idents. iter ( ) . map ( |i| i. to_string ( ) ) . collect :: < Vec < String > > ( ) . join ( "::" )
630
+ let mut path_name = "" . to_string ( ) ;
631
+ let mut idents_iter = idents. iter ( ) . peekable ( ) ;
632
+ while let Some ( ident) = idents_iter. next ( ) {
633
+ path_name. push_str ( & ident. name . as_str ( ) ) ;
634
+ if let Some ( _) = idents_iter. peek ( ) {
635
+ path_name. push_str ( "::" )
636
+ }
637
+ }
638
+ path_name
632
639
}
633
640
634
641
fn mk_tests ( cx : & TestCtxt ) -> P < ast:: Item > {
@@ -681,7 +688,6 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
681
688
// gensym information.
682
689
683
690
let span = ignored_span ( cx, test. span ) ;
684
- let path = test. path . clone ( ) ;
685
691
let ecx = & cx. ext_cx ;
686
692
let self_id = ecx. ident_of ( "self" ) ;
687
693
let test_id = ecx. ident_of ( "test" ) ;
@@ -693,10 +699,11 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
693
699
// creates $name: $expr
694
700
let field = |name, expr| ecx. field_imm ( span, ecx. ident_of ( name) , expr) ;
695
701
696
- debug ! ( "encoding {}" , path_name_i( & path[ ..] ) ) ;
697
-
698
702
// path to the #[test] function: "foo::bar::baz"
699
- let path_string = path_name_i ( & path[ ..] ) ;
703
+ let path_string = path_name_i ( & test. path [ ..] ) ;
704
+
705
+ debug ! ( "encoding {}" , path_string) ;
706
+
700
707
let name_expr = ecx. expr_str ( span, Symbol :: intern ( & path_string) ) ;
701
708
702
709
// self::test::StaticTestName($name_expr)
@@ -743,7 +750,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
743
750
diag. bug ( "expected to find top-level re-export name, but found None" ) ;
744
751
}
745
752
} ;
746
- visible_path. extend ( path) ;
753
+ visible_path. extend_from_slice ( & test . path [ .. ] ) ;
747
754
748
755
// Rather than directly give the test function to the test
749
756
// harness, we create a wrapper like one of the following:
0 commit comments