@@ -1513,18 +1513,20 @@ impl<'tu> TypeRef<'tu> {
1513
1513
// vector<std::string> if not - both.
1514
1514
let vec_cv_string = self . gen_env . resolve_type ( "std::vector<cv::String>" ) . expect ( "Can't resolve std::vector<cv::String>" ) ;
1515
1515
let vec_std_string = self . gen_env . resolve_type ( "std::vector<std::string>" ) . expect ( "Can't resolve std::vector<std::string>" ) ;
1516
- let vec_type_ref = if vec_cv_string. get_canonical_type ( ) == vec_std_string. get_canonical_type ( ) {
1517
- TypeRef :: new ( vec_std_string, self . gen_env )
1518
- } else {
1519
- vec. type_ref ( )
1520
- } ;
1521
- let const_hint = self . get_const_hint ( & vec_type_ref) ;
1522
- out. push ( D :: from_return_type_wrapper ( ReturnTypeWrapper :: new_ext (
1523
- vec_type_ref,
1524
- const_hint,
1525
- DefinitionLocation :: Module ,
1526
- self . gen_env ,
1527
- ) ) ) ;
1516
+ if let DependentTypeMode :: ForReturn ( def_location) = mode {
1517
+ let vec_type_ref = if vec_cv_string. get_canonical_type ( ) == vec_std_string. get_canonical_type ( ) {
1518
+ TypeRef :: new ( vec_std_string, self . gen_env )
1519
+ } else {
1520
+ vec. type_ref ( )
1521
+ } ;
1522
+ let const_hint = self . get_const_hint ( & vec_type_ref) ;
1523
+ out. push ( D :: from_return_type_wrapper ( ReturnTypeWrapper :: new_ext (
1524
+ vec_type_ref,
1525
+ const_hint,
1526
+ def_location,
1527
+ self . gen_env ,
1528
+ ) ) ) ;
1529
+ }
1528
1530
// implement workaround for race when type with std::string gets generated first
1529
1531
// we only want vector<cv::String> because it's more compatible across OpenCV versions
1530
1532
if str_type == StrType :: StdString {
@@ -1537,28 +1539,31 @@ impl<'tu> TypeRef<'tu> {
1537
1539
out. push ( D :: from_vector ( vec) )
1538
1540
}
1539
1541
} else {
1540
- let vec_type_ref = vec. type_ref ( ) . canonical_clang ( ) ;
1541
- let const_hint = self . get_const_hint ( & vec_type_ref) ;
1542
- out. push ( D :: from_return_type_wrapper ( ReturnTypeWrapper :: new_ext (
1543
- vec_type_ref,
1544
- const_hint,
1545
- DefinitionLocation :: Module ,
1546
- self . gen_env ,
1547
- ) ) ) ;
1542
+ if let DependentTypeMode :: ForReturn ( def_location) = mode {
1543
+ let vec_type_ref = vec. type_ref ( ) . canonical_clang ( ) ;
1544
+ let const_hint = self . get_const_hint ( & vec_type_ref) ;
1545
+ out. push ( D :: from_return_type_wrapper ( ReturnTypeWrapper :: new_ext (
1546
+ vec_type_ref,
1547
+ const_hint,
1548
+ def_location,
1549
+ self . gen_env ,
1550
+ ) ) ) ;
1551
+ }
1548
1552
out. push ( D :: from_vector ( vec) ) ;
1549
1553
}
1550
1554
} ,
1551
1555
Kind :: SmartPtr ( ptr) => {
1552
1556
out = ptr. dependent_types ( ) ;
1553
- out. reserve ( 2 ) ;
1554
- let ptr_type_ref = ptr. type_ref ( ) . canonical_clang ( ) ;
1555
- let const_hint = self . get_const_hint ( & ptr_type_ref) ;
1556
- out. push ( D :: from_return_type_wrapper ( ReturnTypeWrapper :: new_ext (
1557
- ptr_type_ref,
1558
- const_hint,
1559
- DefinitionLocation :: Module ,
1560
- self . gen_env ,
1561
- ) ) ) ;
1557
+ if let DependentTypeMode :: ForReturn ( def_location) = mode {
1558
+ let ptr_type_ref = ptr. type_ref ( ) . canonical_clang ( ) ;
1559
+ let const_hint = self . get_const_hint ( & ptr_type_ref) ;
1560
+ out. push ( D :: from_return_type_wrapper ( ReturnTypeWrapper :: new_ext (
1561
+ ptr_type_ref,
1562
+ const_hint,
1563
+ def_location,
1564
+ self . gen_env ,
1565
+ ) ) ) ;
1566
+ }
1562
1567
out. push ( D :: from_smart_ptr ( ptr) )
1563
1568
} ,
1564
1569
Kind :: Typedef ( typedef) => {
0 commit comments