diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 780bd7d8..666f9096 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -403,7 +403,6 @@ bool Converter::ConvertVarDeclSkipInit(clang::VarDecl *decl) { } if (decl->isFileVarDecl()) { - name = ReplaceAll(Mapper::ToString(decl), "::", "_"); if ((decl->isThisDeclarationADefinition() == clang::VarDecl::DeclarationOnly && !decl->hasInit()) || @@ -2378,7 +2377,7 @@ std::string Converter::ConvertDeclRefExpr(clang::DeclRefExpr *expr) { } if (IsGlobalVar(expr)) { - return ReplaceAll(Mapper::ToString(expr->getDecl()), "::", "_"); + return GetNamedDeclAsString(expr->getDecl()); } return GetNamedDeclAsString(decl); diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 051aed2d..04bfb785 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -369,6 +369,16 @@ std::string GetID(const clang::Decl *decl) { static std::unordered_map type_mapping; +static size_t GetDeclId(const clang::NamedDecl *decl, bool internal) { + std::string key = + clang::ASTNameGenerator(decl->getASTContext()).getName(decl) + + GetParamSignature(decl); + if (internal) { + key += GetLocationID(decl); + } + return type_mapping.try_emplace(key, type_mapping.size()).first->second; +} + std::string GetNamedDeclAsString(const clang::NamedDecl *decl) { auto name = decl->getDeclName().isIdentifier() ? decl->getName().str() : decl->getNameAsString(); @@ -384,19 +394,19 @@ std::string GetNamedDeclAsString(const clang::NamedDecl *decl) { return std::format("anon_{}", GetAnonIndex(target)); } + std::optional id; if (auto *fn = clang::dyn_cast(decl)) { if (!clang::isa(fn)) { - auto mangled = - clang::ASTNameGenerator(decl->getASTContext()).getName(decl) + - GetParamSignature(decl); - if (fn->getFormalLinkage() == clang::Linkage::Internal) { - mangled += GetLocationID(decl); - } - auto id = - type_mapping.try_emplace(mangled, type_mapping.size()).first->second; - name += '_'; - name += std::to_string(id); + id = GetDeclId(decl, fn->getFormalLinkage() == clang::Linkage::Internal); } + } else if (auto *var = clang::dyn_cast(decl); + var && (var->isFileVarDecl() || var->isStaticLocal())) { + id = GetDeclId(var->getCanonicalDecl(), + var->getFormalLinkage() != clang::Linkage::External); + } + if (id) { + name += '_'; + name += std::to_string(*id); } // transform decl names that are rust keywords: diff --git a/tests/multi-file/static_name_collision/CMakeLists.txt b/tests/multi-file/static_name_collision/CMakeLists.txt new file mode 100644 index 00000000..09247631 --- /dev/null +++ b/tests/multi-file/static_name_collision/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(static_name_collision LANGUAGES C) +add_executable(app a.c b.c) diff --git a/tests/multi-file/static_name_collision/a.c b/tests/multi-file/static_name_collision/a.c new file mode 100644 index 00000000..940fa85b --- /dev/null +++ b/tests/multi-file/static_name_collision/a.c @@ -0,0 +1,18 @@ +#include + +static int same_name_different_type = 1; +static int same_name_same_type = 5; + +int a_foo() { return same_name_different_type; } +int a_bar() { return same_name_same_type; } + +float b_foo(); +int b_bar(); + +int main(void) { + assert(a_foo() == 1); + assert(b_foo() == 1.0f); + assert(a_bar() == 5); + assert(b_bar() == 6); + return 0; +} diff --git a/tests/multi-file/static_name_collision/b.c b/tests/multi-file/static_name_collision/b.c new file mode 100644 index 00000000..c0ec785b --- /dev/null +++ b/tests/multi-file/static_name_collision/b.c @@ -0,0 +1,5 @@ +static float same_name_different_type = 1.0f; +static int same_name_same_type = 6; + +float b_foo() { return same_name_different_type; } +int b_bar() { return same_name_same_type; } diff --git a/tests/multi-file/static_name_collision/out/refcount/static_name_collision.rs b/tests/multi-file/static_name_collision/out/refcount/static_name_collision.rs new file mode 100644 index 00000000..d87da909 --- /dev/null +++ b/tests/multi-file/static_name_collision/out/refcount/static_name_collision.rs @@ -0,0 +1,42 @@ +extern crate libcc2rs; +use libcc2rs::*; +use std::cell::RefCell; +use std::collections::BTreeMap; +use std::io::prelude::*; +use std::io::{Read, Seek, Write}; +use std::os::fd::AsFd; +use std::rc::{Rc, Weak}; +thread_local!( + pub static same_name_different_type_0: Value = Rc::new(RefCell::new(1)); +); +thread_local!( + pub static same_name_same_type_1: Value = Rc::new(RefCell::new(5)); +); +pub fn a_foo_2() -> i32 { + return (*same_name_different_type_0.with(Value::clone).borrow()); +} +pub fn a_bar_3() -> i32 { + return (*same_name_same_type_1.with(Value::clone).borrow()); +} +pub fn main() { + std::process::exit(main_0()); +} +fn main_0() -> i32 { + assert!((((({ a_foo_2() }) == 1) as i32) != 0)); + assert!((((({ b_foo_4() }) == 1.0E+0) as i32) != 0)); + assert!((((({ a_bar_3() }) == 5) as i32) != 0)); + assert!((((({ b_bar_5() }) == 6) as i32) != 0)); + return 0; +} +thread_local!( + pub static same_name_different_type_6: Value = Rc::new(RefCell::new(1.0E+0)); +); +thread_local!( + pub static same_name_same_type_7: Value = Rc::new(RefCell::new(6)); +); +pub fn b_foo_4() -> f32 { + return (*same_name_different_type_6.with(Value::clone).borrow()); +} +pub fn b_bar_5() -> i32 { + return (*same_name_same_type_7.with(Value::clone).borrow()); +} diff --git a/tests/multi-file/static_name_collision/out/unsafe/static_name_collision.rs b/tests/multi-file/static_name_collision/out/unsafe/static_name_collision.rs new file mode 100644 index 00000000..f66ac5ea --- /dev/null +++ b/tests/multi-file/static_name_collision/out/unsafe/static_name_collision.rs @@ -0,0 +1,36 @@ +extern crate libc; +use libc::*; +extern crate libcc2rs; +use libcc2rs::*; +use std::collections::BTreeMap; +use std::io::{Read, Seek, Write}; +use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; +use std::rc::Rc; +pub static mut same_name_different_type_0: i32 = unsafe { 1 }; +pub static mut same_name_same_type_1: i32 = unsafe { 5 }; +pub unsafe fn a_foo_2() -> i32 { + return same_name_different_type_0; +} +pub unsafe fn a_bar_3() -> i32 { + return same_name_same_type_1; +} +pub fn main() { + unsafe { + std::process::exit(main_0() as i32); + } +} +unsafe fn main_0() -> i32 { + assert!(((((unsafe { a_foo_2() }) == (1)) as i32) != 0)); + assert!(((((unsafe { b_foo_4() }) == (1.0E+0)) as i32) != 0)); + assert!(((((unsafe { a_bar_3() }) == (5)) as i32) != 0)); + assert!(((((unsafe { b_bar_5() }) == (6)) as i32) != 0)); + return 0; +} +pub static mut same_name_different_type_6: f32 = unsafe { 1.0E+0 }; +pub static mut same_name_same_type_7: i32 = unsafe { 6 }; +pub unsafe fn b_foo_4() -> f32 { + return same_name_different_type_6; +} +pub unsafe fn b_bar_5() -> i32 { + return same_name_same_type_7; +} diff --git a/tests/unit/out/refcount/addr_of_global.rs b/tests/unit/out/refcount/addr_of_global.rs index 943025df..01ddb7f7 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -42,29 +42,29 @@ impl Clone for Outer { } impl ByteRepr for Outer {} thread_local!( - pub static alpha: Value = Rc::new(RefCell::new(Inner { + pub static alpha_0: Value = Rc::new(RefCell::new(Inner { value: Rc::new(RefCell::new(1)), })); ); thread_local!( - pub static beta: Value = Rc::new(RefCell::new(Inner { + pub static beta_1: Value = Rc::new(RefCell::new(Inner { value: Rc::new(RefCell::new(2)), })); ); thread_local!( - pub static shared: Value = Rc::new(RefCell::new(Inner { + pub static shared_2: Value = Rc::new(RefCell::new(Inner { value: Rc::new(RefCell::new(42)), })); ); thread_local!( - pub static items: Value]>> = Rc::new(RefCell::new(Box::new([ - (alpha.with(Value::clone).as_pointer()), - (beta.with(Value::clone).as_pointer()), + pub static items_3: Value]>> = Rc::new(RefCell::new(Box::new([ + (alpha_0.with(Value::clone).as_pointer()), + (beta_1.with(Value::clone).as_pointer()), ]))); ); thread_local!( - pub static obj: Value = Rc::new(RefCell::new(Outer { - p: Rc::new(RefCell::new((shared.with(Value::clone).as_pointer()))), + pub static obj_4: Value = Rc::new(RefCell::new(Outer { + p: Rc::new(RefCell::new((shared_2.with(Value::clone).as_pointer()))), })); ); pub fn main() { @@ -72,7 +72,7 @@ pub fn main() { } fn main_0() -> i32 { assert!( - ((*(*(*items.with(Value::clone).borrow())[(0) as usize] + ((*(*(*items_3.with(Value::clone).borrow())[(0) as usize] .upgrade() .deref()) .value @@ -80,7 +80,7 @@ fn main_0() -> i32 { == 1) ); assert!( - ((*(*(*items.with(Value::clone).borrow())[(1) as usize] + ((*(*(*items_3.with(Value::clone).borrow())[(1) as usize] .upgrade() .deref()) .value @@ -88,7 +88,7 @@ fn main_0() -> i32 { == 2) ); assert!( - ((*(*(*(*obj.with(Value::clone).borrow()).p.borrow()) + ((*(*(*(*obj_4.with(Value::clone).borrow()).p.borrow()) .upgrade() .deref()) .value @@ -96,13 +96,13 @@ fn main_0() -> i32 { == 42) ); thread_local!( - static cache: Value]>> = Rc::new(RefCell::new(Box::new([ - (alpha.with(Value::clone).as_pointer()), - (beta.with(Value::clone).as_pointer()), + static cache_5: Value]>> = Rc::new(RefCell::new(Box::new([ + (alpha_0.with(Value::clone).as_pointer()), + (beta_1.with(Value::clone).as_pointer()), ]))); ); assert!( - ((*(*(*cache.with(Value::clone).borrow())[(0) as usize] + ((*(*(*cache_5.with(Value::clone).borrow())[(0) as usize] .upgrade() .deref()) .value @@ -110,7 +110,7 @@ fn main_0() -> i32 { == 1) ); assert!( - ((*(*(*cache.with(Value::clone).borrow())[(1) as usize] + ((*(*(*cache_5.with(Value::clone).borrow())[(1) as usize] .upgrade() .deref()) .value diff --git a/tests/unit/out/refcount/bool_condition_logical.rs b/tests/unit/out/refcount/bool_condition_logical.rs index 31425290..7b263d30 100644 --- a/tests/unit/out/refcount/bool_condition_logical.rs +++ b/tests/unit/out/refcount/bool_condition_logical.rs @@ -25,17 +25,17 @@ impl From for Code { } libcc2rs::impl_enum_inc_dec!(Code); thread_local!( - pub static side_effect: Value = Rc::new(RefCell::new(0)); + pub static side_effect_0: Value = Rc::new(RefCell::new(0)); ); -pub fn observe_0(v: i32) -> i32 { +pub fn observe_1(v: i32) -> i32 { let v: Value = Rc::new(RefCell::new(v)); - (*side_effect.with(Value::clone).borrow_mut()).prefix_inc(); + (*side_effect_0.with(Value::clone).borrow_mut()).prefix_inc(); return (*v.borrow()); } -pub fn returns_one_1() -> i32 { +pub fn returns_one_2() -> i32 { return 1; } -pub fn returns_zero_2() -> i32 { +pub fn returns_zero_3() -> i32 { return 0; } pub fn main() { @@ -66,25 +66,25 @@ fn main_0() -> i32 { { assert!(true); } - (*side_effect.with(Value::clone).borrow_mut()) = 0; + (*side_effect_0.with(Value::clone).borrow_mut()) = 0; if ((*zero.borrow()) != 0) && (({ let _v: i32 = 1; - observe_0(_v) + observe_1(_v) }) != 0) { assert!(false); } - assert!(((*side_effect.with(Value::clone).borrow()) == 0)); + assert!(((*side_effect_0.with(Value::clone).borrow()) == 0)); if ((*n.borrow()) != 0) || (({ let _v: i32 = 1; - observe_0(_v) + observe_1(_v) }) != 0) { assert!(true); } - assert!(((*side_effect.with(Value::clone).borrow()) == 0)); + assert!(((*side_effect_0.with(Value::clone).borrow()) == 0)); let x: Value = Rc::new(RefCell::new(5)); let y: Value = Rc::new(RefCell::new(3)); let flags: Value = Rc::new(RefCell::new(2_u32)); @@ -138,19 +138,19 @@ fn main_0() -> i32 { if ((*x.borrow()) > (*y.borrow())) && (((*n.borrow()) != 0) && (!(*cp.borrow()).is_null())) { assert!(true); } - if ((*x.borrow()) > (*y.borrow())) && (({ returns_one_1() }) != 0) { + if ((*x.borrow()) > (*y.borrow())) && (({ returns_one_2() }) != 0) { assert!(true); } - if ((*x.borrow()) > (*y.borrow())) && (!(({ returns_zero_2() }) != 0)) { + if ((*x.borrow()) > (*y.borrow())) && (!(({ returns_zero_3() }) != 0)) { assert!(true); } - if ((*x.borrow()) < (*y.borrow())) || (({ returns_one_1() }) != 0) { + if ((*x.borrow()) < (*y.borrow())) || (({ returns_one_2() }) != 0) { assert!(true); } - if ((*x.borrow()) < (*y.borrow())) || (!(({ returns_one_1() }) != 0)) { + if ((*x.borrow()) < (*y.borrow())) || (!(({ returns_one_2() }) != 0)) { assert!(false); } - if ((!((*p.borrow()).is_null())) && (({ returns_one_1() }) != 0)) && ((*n.borrow()) != 0) { + if ((!((*p.borrow()).is_null())) && (({ returns_one_2() }) != 0)) && ((*n.borrow()) != 0) { assert!(true); } return 0; diff --git a/tests/unit/out/refcount/bool_condition_logical_c.rs b/tests/unit/out/refcount/bool_condition_logical_c.rs index 31e3d7fd..d7cfa358 100644 --- a/tests/unit/out/refcount/bool_condition_logical_c.rs +++ b/tests/unit/out/refcount/bool_condition_logical_c.rs @@ -25,17 +25,17 @@ impl From for Code { } libcc2rs::impl_enum_inc_dec!(Code); thread_local!( - pub static side_effect: Value = Rc::new(RefCell::new(0)); + pub static side_effect_0: Value = Rc::new(RefCell::new(0)); ); -pub fn observe_0(v: i32) -> i32 { +pub fn observe_1(v: i32) -> i32 { let v: Value = Rc::new(RefCell::new(v)); - (*side_effect.with(Value::clone).borrow_mut()).prefix_inc(); + (*side_effect_0.with(Value::clone).borrow_mut()).prefix_inc(); return (*v.borrow()); } -pub fn returns_one_1() -> i32 { +pub fn returns_one_2() -> i32 { return 1; } -pub fn returns_zero_2() -> i32 { +pub fn returns_zero_3() -> i32 { return 0; } pub fn main() { @@ -70,27 +70,27 @@ fn main_0() -> i32 { { assert!((1 != 0)); } - (*side_effect.with(Value::clone).borrow_mut()) = 0; + (*side_effect_0.with(Value::clone).borrow_mut()) = 0; if (((((*zero.borrow()) != 0) && (({ let _v: i32 = 1; - observe_0(_v) + observe_1(_v) }) != 0)) as i32) != 0) { assert!((0 != 0)); } - assert!(((((*side_effect.with(Value::clone).borrow()) == 0) as i32) != 0)); + assert!(((((*side_effect_0.with(Value::clone).borrow()) == 0) as i32) != 0)); if (((((*n.borrow()) != 0) || (({ let _v: i32 = 1; - observe_0(_v) + observe_1(_v) }) != 0)) as i32) != 0) { assert!((1 != 0)); } - assert!(((((*side_effect.with(Value::clone).borrow()) == 0) as i32) != 0)); + assert!(((((*side_effect_0.with(Value::clone).borrow()) == 0) as i32) != 0)); let x: Value = Rc::new(RefCell::new(5)); let y: Value = Rc::new(RefCell::new(3)); let flags: Value = Rc::new(RefCell::new(2_u32)); @@ -170,29 +170,29 @@ fn main_0() -> i32 { { assert!((1 != 0)); } - if (((((((*x.borrow()) > (*y.borrow())) as i32) != 0) && (({ returns_one_1() }) != 0)) as i32) + if (((((((*x.borrow()) > (*y.borrow())) as i32) != 0) && (({ returns_one_2() }) != 0)) as i32) != 0) { assert!((1 != 0)); } - if (((((((*x.borrow()) > (*y.borrow())) as i32) != 0) && (!(({ returns_zero_2() }) != 0))) + if (((((((*x.borrow()) > (*y.borrow())) as i32) != 0) && (!(({ returns_zero_3() }) != 0))) as i32) != 0) { assert!((1 != 0)); } - if (((((((*x.borrow()) < (*y.borrow())) as i32) != 0) || (({ returns_one_1() }) != 0)) as i32) + if (((((((*x.borrow()) < (*y.borrow())) as i32) != 0) || (({ returns_one_2() }) != 0)) as i32) != 0) { assert!((1 != 0)); } - if (((((((*x.borrow()) < (*y.borrow())) as i32) != 0) || (!(({ returns_one_1() }) != 0))) + if (((((((*x.borrow()) < (*y.borrow())) as i32) != 0) || (!(({ returns_one_2() }) != 0))) as i32) != 0) { assert!((0 != 0)); } - if (((((((((!((*p.borrow()).is_null())) as i32) != 0) && (({ returns_one_1() }) != 0)) as i32) + if (((((((((!((*p.borrow()).is_null())) as i32) != 0) && (({ returns_one_2() }) != 0)) as i32) != 0) && ((((*n.borrow()) != 0) as i32) != 0)) as i32) != 0) diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index dc58f95d..6d4844c2 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -99,18 +99,18 @@ impl Default for Foo { } impl ByteRepr for Foo {} thread_local!( - pub static static_fn: Value i32>> = Rc::new(RefCell::new(FnPtr::null())); + pub static static_fn_0: Value i32>> = Rc::new(RefCell::new(FnPtr::null())); ); thread_local!( - pub static static_outer: Value = Rc::new(RefCell::new(::default())); + pub static static_outer_1: Value = Rc::new(RefCell::new(::default())); ); thread_local!( - pub static static_inner_array: Value> = Rc::new(RefCell::new( + pub static static_inner_array_2: Value> = Rc::new(RefCell::new( (0..2).map(|_| ::default()).collect::>(), )); ); thread_local!( - pub static static_foo: Value = Rc::new(RefCell::new(Foo { + pub static static_foo_3: Value = Rc::new(RefCell::new(Foo { s1: Rc::new(RefCell::new(Ptr::from_string_literal("hello"))), s2: Rc::new(RefCell::new(Ptr::::null())), fn1: Rc::new(RefCell::new(FnPtr::null())), @@ -119,7 +119,7 @@ thread_local!( })); ); thread_local!( - pub static static_foo_array: Value> = Rc::new(RefCell::new(Box::new([ + pub static static_foo_array_4: Value> = Rc::new(RefCell::new(Box::new([ Foo { s1: Rc::new(RefCell::new(Ptr::from_string_literal("first"))), s2: Rc::new(RefCell::new(Ptr::::null())), @@ -136,40 +136,41 @@ thread_local!( }, ]))); ); -pub fn check_local_static_0() { +pub fn check_local_static_5() { thread_local!( - static local_outer: Value = Rc::new(RefCell::new(::default())); + static local_outer_6: Value = Rc::new(RefCell::new(::default())); ); thread_local!( - static local_fn: Value i32>> = Rc::new(RefCell::new(FnPtr::null())); + static local_fn_7: Value i32>> = Rc::new(RefCell::new(FnPtr::null())); ); thread_local!( - static local_p: Value> = Rc::new(RefCell::new(Ptr::::null())); + static local_p_8: Value> = Rc::new(RefCell::new(Ptr::::null())); ); - assert!((*(*local_outer.with(Value::clone).borrow()).p1.borrow()).is_null()); - assert!((*(*local_outer.with(Value::clone).borrow()).fn_.borrow()).is_null()); - assert!((*local_fn.with(Value::clone).borrow()).is_null()); - assert!((*local_p.with(Value::clone).borrow()).is_null()); + assert!((*(*local_outer_6.with(Value::clone).borrow()).p1.borrow()).is_null()); + assert!((*(*local_outer_6.with(Value::clone).borrow()).fn_.borrow()).is_null()); + assert!((*local_fn_7.with(Value::clone).borrow()).is_null()); + assert!((*local_p_8.with(Value::clone).borrow()).is_null()); } pub fn main() { std::process::exit(main_0()); } fn main_0() -> i32 { - assert!((*static_fn.with(Value::clone).borrow()).is_null()); - assert!((*(*static_outer.with(Value::clone).borrow()).p1.borrow()).is_null()); - assert!((*(*static_outer.with(Value::clone).borrow()).p2.borrow()).is_null()); - assert!((*(*static_outer.with(Value::clone).borrow()).cp.borrow()).is_null()); - assert!((*(*static_outer.with(Value::clone).borrow()).pp.borrow()).is_null()); - assert!((*(*static_outer.with(Value::clone).borrow()).fn_.borrow()).is_null()); + assert!((*static_fn_0.with(Value::clone).borrow()).is_null()); + assert!((*(*static_outer_1.with(Value::clone).borrow()).p1.borrow()).is_null()); + assert!((*(*static_outer_1.with(Value::clone).borrow()).p2.borrow()).is_null()); + assert!((*(*static_outer_1.with(Value::clone).borrow()).cp.borrow()).is_null()); + assert!((*(*static_outer_1.with(Value::clone).borrow()).pp.borrow()).is_null()); + assert!((*(*static_outer_1.with(Value::clone).borrow()).fn_.borrow()).is_null()); let i: Value = Rc::new(RefCell::new(0)); 'loop_: while ((*i.borrow()) < 3) { - assert!(((*(*static_outer.with(Value::clone).borrow()).arr.borrow()) - [(*i.borrow()) as usize]) - .is_null()); + assert!( + ((*(*static_outer_1.with(Value::clone).borrow()).arr.borrow())[(*i.borrow()) as usize]) + .is_null() + ); (*i.borrow_mut()).prefix_inc(); } assert!( - (*(*(*static_outer.with(Value::clone).borrow()).inner.borrow()) + (*(*(*static_outer_1.with(Value::clone).borrow()).inner.borrow()) .name .borrow()) .is_null() @@ -177,39 +178,39 @@ fn main_0() -> i32 { let i: Value = Rc::new(RefCell::new(0)); 'loop_: while ((*i.borrow()) < 2) { assert!( - (*(*static_inner_array.with(Value::clone).borrow())[(*i.borrow()) as usize] + (*(*static_inner_array_2.with(Value::clone).borrow())[(*i.borrow()) as usize] .name .borrow()) .is_null() ); (*i.borrow_mut()).prefix_inc(); } - assert!((*(*static_foo.with(Value::clone).borrow()).s2.borrow()).is_null()); - assert!((*(*static_foo.with(Value::clone).borrow()).fn1.borrow()).is_null()); - assert!((*(*static_foo.with(Value::clone).borrow()).fn2.borrow()).is_null()); - assert!(((*(*static_foo.with(Value::clone).borrow()).n.borrow()) == 42)); + assert!((*(*static_foo_3.with(Value::clone).borrow()).s2.borrow()).is_null()); + assert!((*(*static_foo_3.with(Value::clone).borrow()).fn1.borrow()).is_null()); + assert!((*(*static_foo_3.with(Value::clone).borrow()).fn2.borrow()).is_null()); + assert!(((*(*static_foo_3.with(Value::clone).borrow()).n.borrow()) == 42)); let i: Value = Rc::new(RefCell::new(0)); 'loop_: while ((*i.borrow()) < 2) { assert!( - (*(*static_foo_array.with(Value::clone).borrow())[(*i.borrow()) as usize] + (*(*static_foo_array_4.with(Value::clone).borrow())[(*i.borrow()) as usize] .s2 .borrow()) .is_null() ); assert!( - (*(*static_foo_array.with(Value::clone).borrow())[(*i.borrow()) as usize] + (*(*static_foo_array_4.with(Value::clone).borrow())[(*i.borrow()) as usize] .fn1 .borrow()) .is_null() ); assert!( - (*(*static_foo_array.with(Value::clone).borrow())[(*i.borrow()) as usize] + (*(*static_foo_array_4.with(Value::clone).borrow())[(*i.borrow()) as usize] .fn2 .borrow()) .is_null() ); (*i.borrow_mut()).prefix_inc(); } - ({ check_local_static_0() }); + ({ check_local_static_5() }); return 0; } diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index 4426a475..f8334281 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -80,16 +80,16 @@ impl Clone for Entry { } impl ByteRepr for Entry {} thread_local!( - pub static global_color: Value = Rc::new(RefCell::new(Color::GREEN)); + pub static global_color_0: Value = Rc::new(RefCell::new(Color::GREEN)); ); thread_local!( - pub static global_opt: Value