@@ -1423,7 +1423,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1423
1423
1424
1424
fn build_root_module ( id : ItemId ) -> Item {
1425
1425
let module = Module :: new ( Some ( "root" . into ( ) ) , ModuleKind :: Normal ) ;
1426
- Item :: new ( id, None , None , id, ItemKind :: Module ( module) )
1426
+ Item :: new ( id, None , None , id, ItemKind :: Module ( module) , None )
1427
1427
}
1428
1428
1429
1429
/// Get the root module.
@@ -1733,6 +1733,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1733
1733
None ,
1734
1734
self . current_module . into ( ) ,
1735
1735
ItemKind :: Type ( sub_ty) ,
1736
+ Some ( child. location ( ) ) ,
1736
1737
) ;
1737
1738
1738
1739
// Bypass all the validations in add_item explicitly.
@@ -1797,6 +1798,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1797
1798
None ,
1798
1799
self . current_module . into ( ) ,
1799
1800
ItemKind :: Type ( ty) ,
1801
+ Some ( location. location ( ) ) ,
1800
1802
) ;
1801
1803
1802
1804
// Bypass all the validations in add_item explicitly.
@@ -1930,6 +1932,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1930
1932
) -> TypeId {
1931
1933
let spelling = ty. spelling ( ) ;
1932
1934
let layout = ty. fallible_layout ( self ) . ok ( ) ;
1935
+ let location = ty. declaration ( ) . location ( ) ;
1933
1936
let type_kind = TypeKind :: ResolvedTypeRef ( wrapped_id) ;
1934
1937
let ty = Type :: new ( Some ( spelling) , layout, type_kind, is_const) ;
1935
1938
let item = Item :: new (
@@ -1938,6 +1941,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1938
1941
None ,
1939
1942
parent_id. unwrap_or_else ( || self . current_module . into ( ) ) ,
1940
1943
ItemKind :: Type ( ty) ,
1944
+ Some ( location) ,
1941
1945
) ;
1942
1946
self . add_builtin_item ( item) ;
1943
1947
with_id. as_type_id_unchecked ( )
@@ -1998,6 +2002,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
1998
2002
let spelling = ty. spelling ( ) ;
1999
2003
let is_const = ty. is_const ( ) ;
2000
2004
let layout = ty. fallible_layout ( self ) . ok ( ) ;
2005
+ let location = ty. declaration ( ) . location ( ) ;
2001
2006
let ty = Type :: new ( Some ( spelling) , layout, type_kind, is_const) ;
2002
2007
let id = self . next_item_id ( ) ;
2003
2008
let item = Item :: new (
@@ -2006,6 +2011,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2006
2011
None ,
2007
2012
self . root_module . into ( ) ,
2008
2013
ItemKind :: Type ( ty) ,
2014
+ Some ( location) ,
2009
2015
) ;
2010
2016
self . add_builtin_item ( item) ;
2011
2017
Some ( id. as_type_id_unchecked ( ) )
@@ -2194,6 +2200,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2194
2200
None ,
2195
2201
self . current_module . into ( ) ,
2196
2202
ItemKind :: Module ( module) ,
2203
+ Some ( cursor. location ( ) ) ,
2197
2204
) ;
2198
2205
2199
2206
let module_id = module. id ( ) . as_module_id_unchecked ( ) ;
@@ -2241,11 +2248,6 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2241
2248
assert ! ( self . in_codegen_phase( ) ) ;
2242
2249
assert ! ( self . current_module == self . root_module) ;
2243
2250
2244
- let cb = match self . options . parse_callbacks {
2245
- Some ( ref cb) => cb,
2246
- None => return CanDerive :: No ,
2247
- } ;
2248
-
2249
2251
* self
2250
2252
. blocklisted_types_implement_traits
2251
2253
. borrow_mut ( )
@@ -2255,8 +2257,27 @@ If you encounter an error missing from this list, please file an issue or a PR!"
2255
2257
. or_insert_with ( || {
2256
2258
item. expect_type ( )
2257
2259
. name ( )
2258
- . and_then ( |name| {
2259
- cb. blocklisted_type_implements_trait ( name, derive_trait)
2260
+ . and_then ( |name| match self . options . parse_callbacks {
2261
+ Some ( ref cb) => cb. blocklisted_type_implements_trait (
2262
+ name,
2263
+ derive_trait,
2264
+ ) ,
2265
+ // Sized integer types from <stdint.h> get mapped to Rust primitive
2266
+ // types regardless of whether they are blocklisted, so ensure that
2267
+ // standard traits are considered derivable for them too.
2268
+ None => match name {
2269
+ "int8_t" | "uint8_t" | "int16_t" | "uint16_t" |
2270
+ "int32_t" | "uint32_t" | "int64_t" |
2271
+ "uint64_t" | "uintptr_t" | "intptr_t" |
2272
+ "ptrdiff_t" => Some ( CanDerive :: Yes ) ,
2273
+ "size_t" if self . options . size_t_is_usize => {
2274
+ Some ( CanDerive :: Yes )
2275
+ }
2276
+ "ssize_t" if self . options . size_t_is_usize => {
2277
+ Some ( CanDerive :: Yes )
2278
+ }
2279
+ _ => Some ( CanDerive :: No ) ,
2280
+ } ,
2260
2281
} )
2261
2282
. unwrap_or ( CanDerive :: No )
2262
2283
} )
0 commit comments