@@ -736,9 +736,12 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
736736 // is actually a pub(.*) use statement and map it to the real path.
737737 let path_tmp = path. clone ( ) ;
738738 let crate_name = path_tmp. splitn ( 2 , "::" ) . next ( ) . unwrap ( ) ;
739- let mut module_riter = path_tmp. rsplitn ( 2 , "::" ) ;
740- let obj = module_riter. next ( ) . unwrap ( ) ;
741- if let Some ( module_path) = module_riter. next ( ) {
739+ let mut module_part_iter = path_tmp. split ( "::" ) ;
740+ let mut pos = module_part_iter. next ( ) . unwrap ( ) . len ( ) ;
741+ while let Some ( obj) = module_part_iter. next ( ) {
742+ let module_path = & path_tmp[ ..pos] ;
743+ pos += 2 + obj. len ( ) ;
744+
742745 if let Some ( m) = self . library . modules . get ( module_path) {
743746 for item in m. items . iter ( ) {
744747 if let syn:: Item :: Use ( syn:: ItemUse { vis, tree, .. } ) = item {
@@ -756,6 +759,21 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
756759 } ,
757760 syn:: Visibility :: Inherited => { } ,
758761 }
762+ } else if let syn:: Item :: ExternCrate ( syn:: ItemExternCrate { vis, ident, rename, .. } ) = item {
763+ match vis {
764+ syn:: Visibility :: Public ( _) |
765+ syn:: Visibility :: Crate ( _) |
766+ syn:: Visibility :: Restricted ( _) => {
767+ if let Some ( ( _, ident) ) = rename {
768+ if ident != obj { continue ; }
769+ } else {
770+ if ident != obj { continue ; }
771+ }
772+
773+ path = format ! ( "{}" , ident) + & path_tmp[ pos..] ;
774+ } ,
775+ syn:: Visibility :: Inherited => { } ,
776+ }
759777 }
760778 }
761779 }
@@ -845,8 +863,9 @@ impl FullLibraryAST {
845863 syn:: Item :: Mod ( _) => panic ! ( "--pretty=expanded output should never have non-body modules" ) ,
846864 syn:: Item :: ExternCrate ( c) => {
847865 if export_status ( & c. attrs ) == ExportStatus :: Export {
848- self . dependencies . insert ( c. ident ) ;
866+ self . dependencies . insert ( c. ident . clone ( ) ) ;
849867 }
868+ non_mod_items. push ( syn:: Item :: ExternCrate ( c) ) ;
850869 } ,
851870 _ => { non_mod_items. push ( item) ; }
852871 }
@@ -1128,15 +1147,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
11281147 if !is_ref => Some ( "crate::c_types::ThirtyTwoBytes" ) ,
11291148 "bitcoin::secp256k1::Message" if !is_ref => Some ( "crate::c_types::ThirtyTwoBytes" ) ,
11301149 "bitcoin::secp256k1::Message" if is_ref => Some ( "*const [u8; 32]" ) ,
1131- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash"
1132- |"lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1133- |"lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
1150+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash"
1151+ |"lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1152+ |"lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
11341153 |"lightning::ln::channelmanager::PaymentId" |"lightning::ln::channelmanager::InterceptId"
11351154 |"lightning::sign::KeyMaterial" |"lightning::chain::ClaimId"
11361155 if is_ref => Some ( "*const [u8; 32]" ) ,
1137- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash"
1138- |"lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1139- |"lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
1156+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash"
1157+ |"lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1158+ |"lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
11401159 |"lightning::ln::channelmanager::PaymentId" |"lightning::ln::channelmanager::InterceptId"
11411160 |"lightning::sign::KeyMaterial" |"lightning::chain::ClaimId"
11421161 if !is_ref => Some ( "crate::c_types::ThirtyTwoBytes" ) ,
@@ -1251,11 +1270,11 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
12511270 "bitcoin::constants::ChainHash" => Some ( "::bitcoin::constants::ChainHash::from(&" ) ,
12521271 "bitcoin::hashes::sha256::Hash" if is_ref => Some ( "&::bitcoin::hashes::sha256::Hash::from_slice(&unsafe { &*" ) ,
12531272 "bitcoin::hashes::sha256::Hash" => Some ( "::bitcoin::hashes::sha256::Hash::from_slice(&" ) ,
1254- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash" if !is_ref => Some ( "::lightning::ln::types ::PaymentHash(" ) ,
1255- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash" if is_ref => Some ( "&::lightning::ln::types ::PaymentHash(unsafe { *" ) ,
1256- "lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage" if !is_ref => Some ( "::lightning::ln::types ::PaymentPreimage(" ) ,
1257- "lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage" if is_ref => Some ( "&::lightning::ln::types ::PaymentPreimage(unsafe { *" ) ,
1258- "lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret" if !is_ref => Some ( "::lightning::ln::types ::PaymentSecret(" ) ,
1273+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash" if !is_ref => Some ( "::lightning::types::payment ::PaymentHash(" ) ,
1274+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash" if is_ref => Some ( "&::lightning::types::payment ::PaymentHash(unsafe { *" ) ,
1275+ "lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage" if !is_ref => Some ( "::lightning::types::payment ::PaymentPreimage(" ) ,
1276+ "lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage" if is_ref => Some ( "&::lightning::types::payment ::PaymentPreimage(unsafe { *" ) ,
1277+ "lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret" if !is_ref => Some ( "::lightning::types::payment ::PaymentSecret(" ) ,
12591278 "lightning::ln::channelmanager::PaymentId" if !is_ref => Some ( "::lightning::ln::channelmanager::PaymentId(" ) ,
12601279 "lightning::ln::channelmanager::PaymentId" if is_ref=> Some ( "&::lightning::ln::channelmanager::PaymentId( unsafe { *" ) ,
12611280 "lightning::ln::channelmanager::InterceptId" if !is_ref => Some ( "::lightning::ln::channelmanager::InterceptId(" ) ,
@@ -1362,15 +1381,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
13621381 "bitcoin::hash_types::BlockHash" |"bitcoin::BlockHash" if !is_ref => Some ( ".data[..]).unwrap()" ) ,
13631382 "bitcoin::constants::ChainHash" if !is_ref => Some ( ".data)" ) ,
13641383 "bitcoin::hashes::sha256::Hash" => Some ( " }[..]).unwrap()" ) ,
1365- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash"
1366- |"lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1367- |"lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
1384+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash"
1385+ |"lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1386+ |"lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
13681387 |"lightning::ln::channelmanager::PaymentId" |"lightning::ln::channelmanager::InterceptId"
13691388 |"lightning::sign::KeyMaterial" |"lightning::chain::ClaimId"
13701389 if !is_ref => Some ( ".data)" ) ,
1371- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash"
1372- |"lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1373- |"lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
1390+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash"
1391+ |"lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1392+ |"lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
13741393 |"lightning::ln::channelmanager::PaymentId" |"lightning::ln::channelmanager::InterceptId"
13751394 |"lightning::sign::KeyMaterial" |"lightning::chain::ClaimId"
13761395 if is_ref => Some ( " })" ) ,
@@ -1410,6 +1429,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
14101429 "[u8; 32]" if is_ref => Some ( "" ) ,
14111430 "[u8; 20]" if !is_ref => Some ( "crate::c_types::TwentyBytes { data: " ) ,
14121431 "[u8; 16]" if !is_ref => Some ( "crate::c_types::SixteenBytes { data: " ) ,
1432+ "[u8; 16]" if is_ref => Some ( "" ) ,
14131433 "[u8; 12]" if !is_ref => Some ( "crate::c_types::TwelveBytes { data: " ) ,
14141434 "[u8; 4]" if !is_ref => Some ( "crate::c_types::FourBytes { data: " ) ,
14151435 "[u8; 3]" if !is_ref => Some ( "crate::c_types::ThreeBytes { data: " ) ,
@@ -1492,15 +1512,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
14921512 if !is_ref => Some ( "crate::c_types::ThirtyTwoBytes { data: *" ) ,
14931513 "bitcoin::secp256k1::Message" if !is_ref => Some ( "crate::c_types::ThirtyTwoBytes { data: " ) ,
14941514 "bitcoin::secp256k1::Message" if is_ref => Some ( "" ) ,
1495- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash"
1496- |"lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1497- |"lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
1515+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash"
1516+ |"lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1517+ |"lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
14981518 |"lightning::ln::channelmanager::PaymentId" |"lightning::ln::channelmanager::InterceptId"
14991519 |"lightning::sign::KeyMaterial" |"lightning::chain::ClaimId"
15001520 if is_ref => Some ( "&" ) ,
1501- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash"
1502- |"lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1503- |"lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
1521+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash"
1522+ |"lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1523+ |"lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
15041524 |"lightning::ln::channelmanager::PaymentId" |"lightning::ln::channelmanager::InterceptId"
15051525 |"lightning::sign::KeyMaterial" |"lightning::chain::ClaimId"
15061526 if !is_ref => Some ( "crate::c_types::ThirtyTwoBytes { data: " ) ,
@@ -1523,6 +1543,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
15231543 "[u8; 32]" if !is_ref => Some ( " }" ) ,
15241544 "[u8; 32]" if is_ref => Some ( "" ) ,
15251545 "[u8; 20]" if !is_ref => Some ( " }" ) ,
1546+ "[u8; 16]" if is_ref => Some ( "" ) ,
15261547 "[u8; 16]" if !is_ref => Some ( " }" ) ,
15271548 "[u8; 12]" if !is_ref => Some ( " }" ) ,
15281549 "[u8; 4]" if !is_ref => Some ( " }" ) ,
@@ -1601,15 +1622,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
16011622 if !is_ref => Some ( ".as_ref() }" ) ,
16021623 "bitcoin::secp256k1::Message" if !is_ref => Some ( ".as_ref().clone() }" ) ,
16031624 "bitcoin::secp256k1::Message" if is_ref => Some ( ".as_ref()" ) ,
1604- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash"
1605- |"lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1606- |"lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
1625+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash"
1626+ |"lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1627+ |"lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
16071628 |"lightning::ln::channelmanager::PaymentId" |"lightning::ln::channelmanager::InterceptId"
16081629 |"lightning::sign::KeyMaterial" |"lightning::chain::ClaimId"
16091630 if is_ref => Some ( ".0" ) ,
1610- "lightning::ln::types ::PaymentHash" |"lightning_types::payment::PaymentHash"
1611- |"lightning::ln::types ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1612- |"lightning::ln::types ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
1631+ "lightning::types::payment ::PaymentHash" |"lightning_types::payment::PaymentHash"
1632+ |"lightning::types::payment ::PaymentPreimage" |"lightning_types::payment::PaymentPreimage"
1633+ |"lightning::types::payment ::PaymentSecret" |"lightning_types::payment::PaymentSecret"
16131634 |"lightning::ln::channelmanager::PaymentId" |"lightning::ln::channelmanager::InterceptId"
16141635 |"lightning::sign::KeyMaterial" |"lightning::chain::ClaimId"
16151636 if !is_ref => Some ( ".0 }" ) ,
0 commit comments