Skip to content

Commit 6903812

Browse files
author
bors-servo
authored
Auto merge of #324 - emilio:coherent-replacement-and-whitelisting, r=fitzgen
ir: Fix namespace_aware_canonical_name with disable_name_namespacing. This dropped off the previous PR.
2 parents bddd464 + 27fb5df commit 6903812

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

libbindgen/src/ir/item.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,10 +1235,14 @@ impl ItemCanonicalPath for Item {
12351235
fn namespace_aware_canonical_path(&self,
12361236
ctx: &BindgenContext)
12371237
-> Vec<String> {
1238+
let path = self.canonical_path(ctx);
12381239
if ctx.options().enable_cxx_namespaces {
1239-
return self.canonical_path(ctx);
1240+
return path;
12401241
}
1241-
return vec![self.canonical_path(ctx)[1..].join("_")];
1242+
if ctx.options().disable_name_namespacing {
1243+
return vec![path.last().unwrap().clone()];
1244+
}
1245+
return vec![path[1..].join("_")];
12421246
}
12431247

12441248
fn canonical_path(&self, ctx: &BindgenContext) -> Vec<String> {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
#[repr(C)]
8+
#[derive(Debug, Copy)]
9+
pub struct Bar {
10+
pub _address: u8,
11+
}
12+
#[test]
13+
fn bindgen_test_layout_Bar() {
14+
assert_eq!(::std::mem::size_of::<Bar>() , 1usize);
15+
assert_eq!(::std::mem::align_of::<Bar>() , 1usize);
16+
}
17+
impl Clone for Bar {
18+
fn clone(&self) -> Self { *self }
19+
}
20+
extern "C" {
21+
#[link_name = "_Z3bazPN3foo3BarE"]
22+
pub fn baz(arg1: *mut Bar);
23+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// bindgen-flags: --disable-name-namespacing
2+
3+
namespace foo {
4+
struct Bar {};
5+
}
6+
7+
void baz(foo::Bar*);

0 commit comments

Comments
 (0)