Skip to content

Commit e794cd4

Browse files
author
bors-servo
authored
Auto merge of #792 - emilio:inline-ns, r=fitzgen
ir: Properly skip inline namespaces when building names. Fixes #789
2 parents 3bb248b + e938167 commit e794cd4

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

src/ir/item.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,19 @@ impl Item {
768768
.ancestors(ctx)
769769
.filter(|id| *id != ctx.root_module())
770770
.take_while(|id| {
771-
// Stop iterating ancestors once we reach a namespace.
771+
// Stop iterating ancestors once we reach a non-inline namespace
772+
// when opt.within_namespaces is set.
772773
!opt.within_namespaces || !ctx.resolve_item(*id).is_module()
773774
})
775+
.filter(|id| {
776+
if !ctx.options().conservative_inline_namespaces {
777+
if let ItemKind::Module(ref module) = *ctx.resolve_item(*id).kind() {
778+
return !module.is_inline();
779+
}
780+
}
781+
782+
true
783+
})
774784
.map(|id| {
775785
let item = ctx.resolve_item(id);
776786
let target = ctx.resolve_item(item.name_target(ctx));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
5+
6+
7+
#[repr(C)]
8+
#[derive(Debug)]
9+
pub struct std_basic_string<CharT> {
10+
pub hider: std_basic_string_Alloc_hider,
11+
pub length: ::std::os::raw::c_ulong,
12+
pub __bindgen_anon_1: std_basic_string__bindgen_ty_1<CharT>,
13+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<CharT>>,
14+
}
15+
#[repr(C)]
16+
#[derive(Debug, Copy, Clone)]
17+
pub struct std_basic_string_Alloc_hider {
18+
pub storage: *mut ::std::os::raw::c_void,
19+
}
20+
impl Default for std_basic_string_Alloc_hider {
21+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
22+
}
23+
#[repr(C)]
24+
#[derive(Debug)]
25+
pub struct std_basic_string__bindgen_ty_1<CharT> {
26+
pub inline_storage: [CharT; 4usize],
27+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<CharT>>,
28+
}
29+
impl <CharT> Default for std_basic_string__bindgen_ty_1<CharT> {
30+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
31+
}
32+
impl <CharT> Default for std_basic_string<CharT> {
33+
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// bindgen-flags: -- -std=c++11
2+
3+
namespace std {
4+
inline namespace __cxx11 {
5+
6+
template<typename CharT>
7+
class basic_string {
8+
struct Alloc_hider {
9+
void* storage;
10+
} hider;
11+
unsigned long length;
12+
struct {
13+
CharT inline_storage[4];
14+
};
15+
};
16+
17+
}
18+
}

0 commit comments

Comments
 (0)