@@ -106,7 +106,6 @@ impl Parse for Pyo3Import {
106106/// ```
107107/// and not `from module import function`
108108#[ allow( non_snake_case) ] // follow python exception naming for error messages
109- #[ rustfmt:: skip] // for import in testcase.imports ... want consistent formatting for each line
110109fn wrap_testcase ( testcase : Pyo3TestCase ) -> TokenStream2 {
111110 let mut o3_moduleidents = Vec :: < Ident > :: new ( ) ;
112111 let mut py_moduleidents = Vec :: < Ident > :: new ( ) ;
@@ -117,26 +116,20 @@ fn wrap_testcase(testcase: Pyo3TestCase) -> TokenStream2 {
117116 let mut py_functionnames = Vec :: < String > :: new ( ) ;
118117 let mut py_AttributeErrormsgs = Vec :: < String > :: new ( ) ;
119118
120-
121119 for import in testcase. pythonimports {
122- if let Some ( functionname) = import. py_functionname {
123- py_AttributeErrormsgs. push ( "Failed to get " . to_string ( ) + & functionname + " function" ) ;
124- py_functionidents. push ( Ident :: new ( & functionname, Span :: call_site ( ) ) ) ;
125- py_moduleswithfnsidents. push ( Ident :: new ( & import. py_modulename , Span :: mixed_site ( ) ) ) ;
126- py_functionnames. push ( functionname) ;
120+ // statements ordered to allow multiple borrows of module and functionname before moving to Vec
121+ let py_modulename = import. py_modulename ;
122+ if let Some ( py_functionname) = import. py_functionname {
123+ py_AttributeErrormsgs
124+ . push ( "Failed to get " . to_string ( ) + & py_functionname + " function" ) ;
125+ py_functionidents. push ( Ident :: new ( & py_functionname, Span :: call_site ( ) ) ) ;
126+ py_moduleswithfnsidents. push ( Ident :: new ( & py_modulename, Span :: mixed_site ( ) ) ) ;
127+ py_functionnames. push ( py_functionname) ;
127128 } ;
128- o3_moduleidents. push (
129- import. o3_moduleident
130- ) ;
131- py_moduleidents. push (
132- Ident :: new ( & import. py_modulename , Span :: mixed_site ( ) )
133- ) ;
134- py_modulenames. push (
135- import. py_modulename
136- ) ;
137- py_ModuleNotFoundErrormsgs. push (
138- "Failed to import " . to_string ( ) + py_modulenames. iter ( ) . last ( ) . unwrap ( )
139- ) ;
129+ py_ModuleNotFoundErrormsgs. push ( "Failed to import " . to_string ( ) + & py_modulename) ;
130+ py_moduleidents. push ( Ident :: new ( & py_modulename, Span :: mixed_site ( ) ) ) ;
131+ py_modulenames. push ( py_modulename) ;
132+ o3_moduleidents. push ( import. o3_moduleident ) ;
140133 }
141134
142135 let testfn_signature = testcase. signature ;
0 commit comments