diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 6c6b54046..0f3134d3f 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -26,6 +26,7 @@ namespace cpp2rust { std::unordered_map Converter::inner_structs_; std::unordered_set Converter::decl_ids_; std::unordered_set Converter::globals_; +std::vector Converter::global_inits_; std::unordered_set Converter::abstract_structs_; Converter::RecordIndex Converter::record_decls_; std::map Converter::methods_on_ptr_; @@ -59,8 +60,7 @@ use std::rc::Rc; )"); } -std::string Converter::EmitMethodsOnPtr() { - std::string out; +void Converter::EmitMethodsOnPtr(std::string &out) { for (const auto &[name, methods] : methods_on_ptr_) { out += methods.trait_header; out += " {\n"; @@ -71,18 +71,30 @@ std::string Converter::EmitMethodsOnPtr() { out += methods.impl_body; out += "}\n"; } - return out; } -std::string Converter::EmitOpaqueRecords() { - std::string out; +std::string Converter::ForceGlobalInit(const clang::VarDecl *decl) { + return std::format("std::cell::LazyCell::force(&*&raw const {});", + GetNamedDeclAsString(decl)); +} + +void Converter::EmitGlobalInits(Model model, std::string &out) { + out += model == Model::kUnsafe ? "pub unsafe fn __cpp2rust_init_globals() {\n" + : "pub fn __cpp2rust_init_globals() {\n"; + for (const auto &line : global_inits_) { + out += line; + out += '\n'; + } + out += "}\n"; +} + +void Converter::EmitOpaqueRecords(std::string &out) { record_decls_.ForEachUndefined([&](const std::string &name) { out += "#[derive(Clone, Copy, Default, ByteRepr)]"; out += "pub struct "; out += name; out += ";\n"; }); - return out; } bool Converter::VisitRecoveryExpr(clang::RecoveryExpr *expr) { @@ -515,6 +527,7 @@ bool Converter::ConvertVarDeclSkipInit(clang::VarDecl *decl) { StrCat(AccessSpecifierAsString(decl->getAccess()), keyword::kStatic, keyword_mut_); ENSURE(decl_ids_.insert(GetID(decl)).second); + global_inits_.push_back(ForceGlobalInit(decl)); } else if (decl->isStaticLocal()) { StrCat(keyword::kStatic, keyword_mut_); } else if (decl->isLocalVarDecl()) { @@ -535,7 +548,10 @@ bool Converter::ConvertVarDeclSkipInit(clang::VarDecl *decl) { if (is_parm_with_default_value) { StrCat("Option<"); } - Convert(qual_type); + { + PushLazyType lazy(*this, IsGlobalVar(decl) && LazyStaticInit()); + Convert(qual_type); + } if (is_parm_with_default_value) { StrCat('>'); } @@ -600,8 +616,9 @@ void Converter::ConvertGlobalVarDecl(clang::VarDecl *decl) { PushConstInitializer static_init(*this, decl->isFileVarDecl() || decl->isStaticLocal()); StrCat(token::kAssign); - StrCat(keyword_unsafe_); { + PushLazyInit lazy(*this, LazyStaticInit()); + StrCat(keyword_unsafe_); PushBrace push(*this); ConvertVarDeclInitializer(decl); } @@ -2925,7 +2942,11 @@ std::string Converter::ConvertDeclRefExpr(clang::DeclRefExpr *expr) { } if (IsGlobalVar(expr)) { - return GetNamedDeclAsString(expr->getDecl()); + if (LazyStaticInit()) { + return std::format("(*std::cell::LazyCell::force_mut(&mut *&raw mut {}))", + GetNamedDeclAsString(decl)); + } + return GetNamedDeclAsString(decl); } return GetNamedDeclAsString(decl); @@ -4279,14 +4300,15 @@ pub fn main() {{ let mut argv: Vec<*mut libc::c_char> = args.iter().map(|arg| arg.as_ptr() as *mut libc::c_char).collect(); argv.push(::std::ptr::null_mut()); unsafe {{ + __cpp2rust_init_globals(); ::std::process::exit(main_0((argv.len() - 1) as i32, argv.as_mut_ptr()) as i32) }} }})", main_function_name)); } else { - StrCat(std::format( - "pub fn main() {{ unsafe {{ std::process::exit({}() as i32); }} }}", - main_function_name)); + StrCat(std::format("pub fn main() {{ unsafe {{ __cpp2rust_init_globals(); " + "std::process::exit({}() as i32); }} }}", + main_function_name)); } } diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 9e1a8d5a4..9387ee749 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -18,6 +18,7 @@ #include #include "converter/converter_lib.h" +#include "converter/factory.h" #include "converter/lex.h" #include "converter/translation_rule.h" #include "logging.h" @@ -51,9 +52,10 @@ class Converter : public clang::RecursiveASTVisitor { virtual void EmitFilePreamble(); - static std::string EmitOpaqueRecords(); + static void EmitOpaqueRecords(std::string &out); + static void EmitGlobalInits(Model model, std::string &out); - static std::string EmitMethodsOnPtr(); + static void EmitMethodsOnPtr(std::string &out); virtual bool VisitBuiltinType(clang::BuiltinType *type); @@ -98,6 +100,8 @@ class Converter : public clang::RecursiveASTVisitor { virtual bool VisitFunctionTemplateDecl(clang::FunctionTemplateDecl *decl); virtual bool VisitVarDecl(clang::VarDecl *decl); + virtual bool LazyStaticInit() const { return true; } + virtual std::string ForceGlobalInit(const clang::VarDecl *decl); void ConvertVarDecl(clang::VarDecl *decl); @@ -454,18 +458,18 @@ class Converter : public clang::RecursiveASTVisitor { #define StrCat(...) _StrCat(__FUNCTION__, __LINE__, __VA_ARGS__) inline bool is_empty(char c) { return false; } - inline bool is_empty(const char* s) { return s == nullptr || *s == '\0'; } - template - inline bool is_empty(const char (&s)[N]) { return s[0] == '\0'; } - template - inline bool is_empty(const T &s) { return s.empty(); } + inline bool is_empty(const char *s) { return s == nullptr || *s == '\0'; } + template inline bool is_empty(const char (&s)[N]) { + return s[0] == '\0'; + } + template inline bool is_empty(const T &s) { return s.empty(); } template inline void _StrCat(const char *func, int line, const Ts &...vals) { log() << '[' << func << ':' << line << "] "; - ((log() << vals << '\n', - *rs_code_ += vals, - (is_empty(vals) ? void() : void(*rs_code_ += ' '))), ...); + ((log() << vals << '\n', *rs_code_ += vals, + (is_empty(vals) ? void() : void(*rs_code_ += ' '))), + ...); } class Buffer { @@ -481,7 +485,7 @@ class Converter : public clang::RecursiveASTVisitor { std::string str() && { return std::move(partial_code); } }; - template class PushDelim { + template class PushDelim { Converter &c; bool enabled; @@ -506,6 +510,8 @@ class Converter : public clang::RecursiveASTVisitor { PushDelim; using PushParen = PushDelim; using PushBracket = PushDelim; + using PushLazyType = PushDelim; + using PushLazyInit = PushDelim; template inline std::string @@ -1038,6 +1044,7 @@ class Converter : public clang::RecursiveASTVisitor { std::vector curr_expr_kind_; static std::unordered_map inner_structs_; static std::unordered_set globals_; + static std::vector global_inits_; clang::Sema *sema_ = nullptr; }; } // namespace cpp2rust diff --git a/cpp2rust/converter/lex.h b/cpp2rust/converter/lex.h index 207e70779..93b3b4a8d 100644 --- a/cpp2rust/converter/lex.h +++ b/cpp2rust/converter/lex.h @@ -30,6 +30,8 @@ inline constexpr char kDiv = '/'; inline constexpr char kLt = '<'; inline constexpr char kGt = '>'; inline constexpr char kNewLine = '\n'; +inline constexpr const char kLazyCellType[] = "std::cell::LazyCell<"; +inline constexpr const char kLazyCellNew[] = "std::cell::LazyCell::new(||"; } // namespace token namespace keyword { diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 6118f1262..cf2a6a7bc 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -2448,6 +2448,10 @@ void ConverterRefCount::ConvertPointerSubscript( } } +std::string ConverterRefCount::ForceGlobalInit(const clang::VarDecl *decl) { + return std::format("let _ = {}.with(|_| ());", GetNamedDeclAsString(decl)); +} + void ConverterRefCount::ConvertFunctionMain( const clang::FunctionDecl *decl, const std::string_view main_function_name) { @@ -2461,12 +2465,14 @@ pub fn main() {{ argv.iter().map(|x| {{ x.borrow_mut().push(0); x.as_pointer() }}).collect(), )); (*argv.borrow_mut()).push(Ptr::null()); + __cpp2rust_init_globals(); ::std::process::exit({}(::std::env::args().len() as i32, argv.as_pointer())); }})", main_function_name)); } else { - StrCat(std::format("pub fn main() {{ std::process::exit({}()); }}", + StrCat(std::format("pub fn main() {{ __cpp2rust_init_globals(); " + "std::process::exit({}()); }}", main_function_name)); } } diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index bacc7e124..41fa971a0 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -79,6 +79,8 @@ class ConverterRefCount final : public Converter { void EmitFunctionPreamble(clang::FunctionDecl *decl) override; bool VisitVarDecl(clang::VarDecl *decl) override; + bool LazyStaticInit() const override { return false; } + std::string ForceGlobalInit(const clang::VarDecl *decl) override; void ConvertGlobalVarDecl(clang::VarDecl *decl) override; diff --git a/cpp2rust/cpp2rust_lib.cpp b/cpp2rust/cpp2rust_lib.cpp index 5c15a4536..d936aff78 100644 --- a/cpp2rust/cpp2rust_lib.cpp +++ b/cpp2rust/cpp2rust_lib.cpp @@ -30,8 +30,9 @@ std::string TranspileSrc(std::string_view cc_code, Model model, rules_dir), cc_code, tool_args, std::filesystem::path(filename).filename().string(), filename.ends_with(".c") ? CLANG_C_COMPILER : CLANG_CXX_COMPILER); - rs_code += Converter::EmitOpaqueRecords(); - rs_code += Converter::EmitMethodsOnPtr(); + Converter::EmitOpaqueRecords(rs_code); + Converter::EmitMethodsOnPtr(rs_code); + Converter::EmitGlobalInits(model, rs_code); return rs_code; } @@ -71,8 +72,9 @@ std::string TranspileDir(std::string_view build_dir, Model model, std::string rs_code; FrontendActionFactory factory(rs_code, model, rules_dir); Tool.run(&factory); - rs_code += Converter::EmitOpaqueRecords(); - rs_code += Converter::EmitMethodsOnPtr(); + Converter::EmitOpaqueRecords(rs_code); + Converter::EmitMethodsOnPtr(rs_code); + Converter::EmitGlobalInits(model, rs_code); return rs_code; } } // namespace cpp2rust diff --git a/tests/multi-file/cross_tu_anon_enum_collision/out/refcount/cross_tu_anon_enum_collision.rs b/tests/multi-file/cross_tu_anon_enum_collision/out/refcount/cross_tu_anon_enum_collision.rs index 7cf386448..72d39e851 100644 --- a/tests/multi-file/cross_tu_anon_enum_collision/out/refcount/cross_tu_anon_enum_collision.rs +++ b/tests/multi-file/cross_tu_anon_enum_collision/out/refcount/cross_tu_anon_enum_collision.rs @@ -14,6 +14,7 @@ pub fn a_value_1() -> i32 { return (*x.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ pub fn b_value_2() -> i32 { (*x.borrow_mut()) |= (anon_3_BETA as i32); return (*x.borrow()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/cross_tu_anon_enum_collision/out/unsafe/cross_tu_anon_enum_collision.rs b/tests/multi-file/cross_tu_anon_enum_collision/out/unsafe/cross_tu_anon_enum_collision.rs index 85d80f283..6620daee1 100644 --- a/tests/multi-file/cross_tu_anon_enum_collision/out/unsafe/cross_tu_anon_enum_collision.rs +++ b/tests/multi-file/cross_tu_anon_enum_collision/out/unsafe/cross_tu_anon_enum_collision.rs @@ -15,6 +15,7 @@ pub unsafe fn a_value_1() -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -30,3 +31,4 @@ pub unsafe fn b_value_2() -> i32 { x |= (anon_3_BETA as i32); return x; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs index e5499920f..ec058a7bf 100644 --- a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs +++ b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs @@ -36,6 +36,7 @@ pub fn a_value_0() -> i32 { return (*(*w.borrow()).id.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -51,3 +52,4 @@ pub fn b_value_1() -> i32 { let w: Value = Rc::new(RefCell::new(widget_enum_WIDGET_C)); return ((*w.borrow()) as i32); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs index 3da000215..fb1bdc361 100644 --- a/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs +++ b/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs @@ -18,6 +18,7 @@ pub unsafe fn a_value_0() -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -34,3 +35,4 @@ pub unsafe fn b_value_1() -> i32 { let mut w: widget_enum = widget_enum_WIDGET_C; return (w as i32); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs index 6c54b789a..ae955afd9 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs @@ -72,6 +72,7 @@ pub fn sum_0(s: Ptr) -> i32 { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -110,3 +111,4 @@ impl SImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs index 726421dc4..df813be9c 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs @@ -55,6 +55,7 @@ pub unsafe fn sum_0(s: *const S) -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -73,3 +74,4 @@ pub unsafe fn shuffle_1(mut x: i32) -> i32 { assert!(b.v.is_empty()); return (unsafe { sum_0(&c) }); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/extern_functions/out/refcount/extern_functions.rs b/tests/multi-file/extern_functions/out/refcount/extern_functions.rs index e9170cd2c..0434c0e6c 100644 --- a/tests/multi-file/extern_functions/out/refcount/extern_functions.rs +++ b/tests/multi-file/extern_functions/out/refcount/extern_functions.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -29,3 +30,4 @@ pub fn helper_0(x: i32) -> i32 { &({ unrelated3_3() }); return ((*x.borrow()) + 1); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/extern_functions/out/unsafe/extern_functions.rs b/tests/multi-file/extern_functions/out/unsafe/extern_functions.rs index 2c594f5ab..27ceb5dae 100644 --- a/tests/multi-file/extern_functions/out/unsafe/extern_functions.rs +++ b/tests/multi-file/extern_functions/out/unsafe/extern_functions.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -30,3 +31,4 @@ pub unsafe fn helper_0(mut x: i32) -> i32 { &(unsafe { unrelated3_3() }); return ((x) + (1)); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/header_function/out/refcount/header_function.rs b/tests/multi-file/header_function/out/refcount/header_function.rs index e9170cd2c..0434c0e6c 100644 --- a/tests/multi-file/header_function/out/refcount/header_function.rs +++ b/tests/multi-file/header_function/out/refcount/header_function.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -29,3 +30,4 @@ pub fn helper_0(x: i32) -> i32 { &({ unrelated3_3() }); return ((*x.borrow()) + 1); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/header_function/out/unsafe/header_function.rs b/tests/multi-file/header_function/out/unsafe/header_function.rs index 2c594f5ab..27ceb5dae 100644 --- a/tests/multi-file/header_function/out/unsafe/header_function.rs +++ b/tests/multi-file/header_function/out/unsafe/header_function.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -30,3 +31,4 @@ pub unsafe fn helper_0(mut x: i32) -> i32 { &(unsafe { unrelated3_3() }); return ((x) + (1)); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs b/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs index 694e35774..39f2fd4f3 100644 --- a/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs +++ b/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs @@ -35,6 +35,7 @@ impl ByteRepr for container { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -53,3 +54,4 @@ pub fn touch_0(c: Ptr) { } #[derive(Clone, Copy, Default, ByteRepr)] pub struct opaque; +pub fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs b/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs index cb79b4503..419c29841 100644 --- a/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs +++ b/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs @@ -14,6 +14,7 @@ pub struct container { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -32,3 +33,4 @@ pub unsafe fn touch_0(mut c: *mut container) { } #[derive(Clone, Copy, Default, ByteRepr)] pub struct opaque; +pub unsafe fn __cpp2rust_init_globals() {} 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 index d87da909a..fecb8dd53 100644 --- 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 @@ -19,6 +19,7 @@ pub fn a_bar_3() -> i32 { return (*same_name_same_type_1.with(Value::clone).borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,9 @@ pub fn b_foo_4() -> f32 { pub fn b_bar_5() -> i32 { return (*same_name_same_type_7.with(Value::clone).borrow()); } +pub fn __cpp2rust_init_globals() { + let _ = same_name_different_type_0.with(|_| ()); + let _ = same_name_same_type_1.with(|_| ()); + let _ = same_name_different_type_6.with(|_| ()); + let _ = same_name_same_type_7.with(|_| ()); +} 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 index f66ac5ea3..c8ab07740 100644 --- 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 @@ -6,16 +6,19 @@ 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 static mut same_name_different_type_0: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { 1 }); +pub static mut same_name_same_type_1: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { 5 }); pub unsafe fn a_foo_2() -> i32 { - return same_name_different_type_0; + return (*std::cell::LazyCell::force_mut(&mut *&raw mut same_name_different_type_0)); } pub unsafe fn a_bar_3() -> i32 { - return same_name_same_type_1; + return (*std::cell::LazyCell::force_mut(&mut *&raw mut same_name_same_type_1)); } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -26,11 +29,19 @@ unsafe fn main_0() -> i32 { 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 static mut same_name_different_type_6: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { 1.0E+0 }); +pub static mut same_name_same_type_7: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { 6 }); pub unsafe fn b_foo_4() -> f32 { - return same_name_different_type_6; + return (*std::cell::LazyCell::force_mut(&mut *&raw mut same_name_different_type_6)); } pub unsafe fn b_bar_5() -> i32 { - return same_name_same_type_7; + return (*std::cell::LazyCell::force_mut(&mut *&raw mut same_name_same_type_7)); +} +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const same_name_different_type_0); + std::cell::LazyCell::force(&*&raw const same_name_same_type_1); + std::cell::LazyCell::force(&*&raw const same_name_different_type_6); + std::cell::LazyCell::force(&*&raw const same_name_same_type_7); } diff --git a/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs index 285f4984a..4bbe92ed3 100644 --- a/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs +++ b/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs @@ -33,6 +33,7 @@ impl ByteRepr for S_int_ { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -58,3 +59,4 @@ impl S_int_Impl for Ptr { return (*(*(*self).upgrade().deref()).x.borrow()); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs index 880214e0b..1addc0275 100644 --- a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs +++ b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs @@ -18,6 +18,7 @@ impl S_int_ { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -35,3 +36,4 @@ impl S_int_ { pub unsafe fn f_0(mut p: *mut S_int_) -> i32 { return (unsafe { S_int_::get(&mut (*p)) }); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ctor_ref_member.rs b/tests/ub/out/refcount/ctor_ref_member.rs index f99be5a9f..485688a0f 100644 --- a/tests/ub/out/refcount/ctor_ref_member.rs +++ b/tests/ub/out/refcount/ctor_ref_member.rs @@ -28,6 +28,7 @@ impl Clone for S { } impl ByteRepr for S {} pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -38,3 +39,4 @@ fn main_0() -> i32 { assert!((((*s.borrow()).r.read()) == 5)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/dangling-prvalue-as-lvalue.rs b/tests/ub/out/refcount/dangling-prvalue-as-lvalue.rs index 34db3f751..98370becb 100644 --- a/tests/ub/out/refcount/dangling-prvalue-as-lvalue.rs +++ b/tests/ub/out/refcount/dangling-prvalue-as-lvalue.rs @@ -10,6 +10,7 @@ pub fn foo_0(a: Ptr) -> Ptr { return (a).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -18,3 +19,4 @@ fn main_0() -> i32 { (*v.borrow_mut()).clear(); return (b.read()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/enum_out_of_range_cast.rs b/tests/ub/out/refcount/enum_out_of_range_cast.rs index 3ca857102..88ea45f51 100644 --- a/tests/ub/out/refcount/enum_out_of_range_cast.rs +++ b/tests/ub/out/refcount/enum_out_of_range_cast.rs @@ -11,6 +11,7 @@ pub const Color_RED: Color = 0; pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -22,3 +23,4 @@ fn main_0() -> i32 { 1 }; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/enum_out_of_range_increment.rs b/tests/ub/out/refcount/enum_out_of_range_increment.rs index 0b88267bb..5f22ad11d 100644 --- a/tests/ub/out/refcount/enum_out_of_range_increment.rs +++ b/tests/ub/out/refcount/enum_out_of_range_increment.rs @@ -11,6 +11,7 @@ pub const color_RED: color = 0; pub const color_GREEN: color = 1; pub const color_BLUE: color = 2; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -22,3 +23,4 @@ fn main_0() -> i32 { 1 }; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/fd_close_invalid.rs b/tests/ub/out/refcount/fd_close_invalid.rs index ed2b4ca2f..003b7be9e 100644 --- a/tests/ub/out/refcount/fd_close_invalid.rs +++ b/tests/ub/out/refcount/fd_close_invalid.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { 1 }; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/fd_double_close.rs b/tests/ub/out/refcount/fd_double_close.rs index 183e96de5..1434c283f 100644 --- a/tests/ub/out/refcount/fd_double_close.rs +++ b/tests/ub/out/refcount/fd_double_close.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -36,3 +37,4 @@ fn main_0() -> i32 { 1 }; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/fd_use_after_close.rs b/tests/ub/out/refcount/fd_use_after_close.rs index 93b7f621e..a1160c367 100644 --- a/tests/ub/out/refcount/fd_use_after_close.rs +++ b/tests/ub/out/refcount/fd_use_after_close.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -55,3 +56,4 @@ fn main_0() -> i32 { 1 }; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/file_use_after_fclose.rs b/tests/ub/out/refcount/file_use_after_fclose.rs index 73c4f73e4..22f2ed1d6 100644 --- a/tests/ub/out/refcount/file_use_after_fclose.rs +++ b/tests/ub/out/refcount/file_use_after_fclose.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -39,3 +40,4 @@ fn main_0() -> i32 { 0 }; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/max.rs b/tests/ub/out/refcount/max.rs index 1f35f4ed1..298f5581e 100644 --- a/tests/ub/out/refcount/max.rs +++ b/tests/ub/out/refcount/max.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { _lhs == (b.read()) }) as i32); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ret_ref_to_local.rs b/tests/ub/out/refcount/ret_ref_to_local.rs index 22b8643f2..82eb93e73 100644 --- a/tests/ub/out/refcount/ret_ref_to_local.rs +++ b/tests/ub/out/refcount/ret_ref_to_local.rs @@ -11,9 +11,11 @@ pub fn foo_0() -> Ptr { return __tmp_0.as_pointer(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { let bar: Value = Rc::new(RefCell::new((({ foo_0() }).read()))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub1.rs b/tests/ub/out/refcount/ub1.rs index 40b608909..6972c93b5 100644 --- a/tests/ub/out/refcount/ub1.rs +++ b/tests/ub/out/refcount/ub1.rs @@ -12,9 +12,11 @@ pub fn dangling_0() -> Ptr { return (*p.borrow()).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { let x: Ptr = ({ dangling_0() }); return (x.read()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub10.rs b/tests/ub/out/refcount/ub10.rs index feabbc90c..9d007a731 100644 --- a/tests/ub/out/refcount/ub10.rs +++ b/tests/ub/out/refcount/ub10.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { (*ptr.borrow()).delete_array(); return (*out.borrow()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub11.rs b/tests/ub/out/refcount/ub11.rs index a2ed43869..0ed3b67b6 100644 --- a/tests/ub/out/refcount/ub11.rs +++ b/tests/ub/out/refcount/ub11.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { (*element.borrow()).delete(); return (*out.borrow()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub12.rs b/tests/ub/out/refcount/ub12.rs index a2e39dca8..9e551c50e 100644 --- a/tests/ub/out/refcount/ub12.rs +++ b/tests/ub/out/refcount/ub12.rs @@ -11,6 +11,7 @@ pub fn escape_0(ptr: Ptr) { (*ptr.borrow()).delete(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { (*alloc.borrow()).delete(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub13.rs b/tests/ub/out/refcount/ub13.rs index da837124b..e403aadea 100644 --- a/tests/ub/out/refcount/ub13.rs +++ b/tests/ub/out/refcount/ub13.rs @@ -11,6 +11,7 @@ pub fn escape_0(p: Ptr) { (*p.borrow()).delete(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -18,3 +19,4 @@ fn main_0() -> i32 { ({ escape_0((*p1.borrow()).clone()) }); return ((*p1.borrow()).read()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub14.rs b/tests/ub/out/refcount/ub14.rs index 719d21eea..cdf0bc343 100644 --- a/tests/ub/out/refcount/ub14.rs +++ b/tests/ub/out/refcount/ub14.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { (*arr1.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub15.rs b/tests/ub/out/refcount/ub15.rs index 39007f65c..03b81ecd3 100644 --- a/tests/ub/out/refcount/ub15.rs +++ b/tests/ub/out/refcount/ub15.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { (*arr.borrow()).delete_array(); return (*out.borrow()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub16.rs b/tests/ub/out/refcount/ub16.rs index fce22fa4a..d70fba02e 100644 --- a/tests/ub/out/refcount/ub16.rs +++ b/tests/ub/out/refcount/ub16.rs @@ -11,6 +11,7 @@ pub fn foo_0(a: Ptr) -> Ptr { return ((*a.borrow()).offset((5) as isize)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -27,3 +28,4 @@ fn main_0() -> i32 { (*p1.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub17.rs b/tests/ub/out/refcount/ub17.rs index 36af30256..f23955ac7 100644 --- a/tests/ub/out/refcount/ub17.rs +++ b/tests/ub/out/refcount/ub17.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -15,3 +16,4 @@ fn main_0() -> i32 { (*p.borrow()).delete(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub18.rs b/tests/ub/out/refcount/ub18.rs index 1a593dc7d..1666020f6 100644 --- a/tests/ub/out/refcount/ub18.rs +++ b/tests/ub/out/refcount/ub18.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -15,3 +16,4 @@ fn main_0() -> i32 { (*p.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub19.rs b/tests/ub/out/refcount/ub19.rs index 9daa3e7ca..46027acf2 100644 --- a/tests/ub/out/refcount/ub19.rs +++ b/tests/ub/out/refcount/ub19.rs @@ -11,6 +11,7 @@ pub fn foo_0(array: Ptr) { (*array.borrow()).delete_array(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -18,3 +19,4 @@ fn main_0() -> i32 { ({ foo_0((*x.borrow()).clone()) }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub2.rs b/tests/ub/out/refcount/ub2.rs index 2959cf226..5a8f8d564 100644 --- a/tests/ub/out/refcount/ub2.rs +++ b/tests/ub/out/refcount/ub2.rs @@ -11,9 +11,11 @@ pub fn null_0() -> Ptr { return (*p.borrow()).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { let x: Value> = Rc::new(RefCell::new(({ null_0() }))); return ((*x.borrow()).read()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub20.rs b/tests/ub/out/refcount/ub20.rs index f8c7c5eea..01a79f603 100644 --- a/tests/ub/out/refcount/ub20.rs +++ b/tests/ub/out/refcount/ub20.rs @@ -11,6 +11,7 @@ pub fn foo_0(single: Ptr) { (*single.borrow()).delete(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -22,3 +23,4 @@ fn main_0() -> i32 { ({ foo_0((*x.borrow()).clone()) }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub21.rs b/tests/ub/out/refcount/ub21.rs index 8925e4171..7feb56e0b 100644 --- a/tests/ub/out/refcount/ub21.rs +++ b/tests/ub/out/refcount/ub21.rs @@ -15,6 +15,7 @@ pub fn strlen_0(s: Ptr) -> usize { return (*count.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -25,3 +26,4 @@ fn main_0() -> i32 { ]))); return (({ strlen_0((s.as_pointer() as Ptr)) }) as i32); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub3.rs b/tests/ub/out/refcount/ub3.rs index 6587e28cb..4e4d8d81c 100644 --- a/tests/ub/out/refcount/ub3.rs +++ b/tests/ub/out/refcount/ub3.rs @@ -12,9 +12,11 @@ pub fn dangling_0() -> Ptr { return (*p.borrow()).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { let x: Value> = Rc::new(RefCell::new(({ dangling_0() }))); return ((*x.borrow()).read()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub4.rs b/tests/ub/out/refcount/ub4.rs index 1b0d7b226..b738b89fc 100644 --- a/tests/ub/out/refcount/ub4.rs +++ b/tests/ub/out/refcount/ub4.rs @@ -17,6 +17,7 @@ pub fn smaller_0(x1: Ptr, x2: Ptr) -> Ptr { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ fn main_0() -> i32 { } return ((*out.borrow()).read()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub5.rs b/tests/ub/out/refcount/ub5.rs index deef6d0cb..26eab3772 100644 --- a/tests/ub/out/refcount/ub5.rs +++ b/tests/ub/out/refcount/ub5.rs @@ -11,6 +11,7 @@ pub fn null_0(p: Ptr>) { (*p.borrow()).write(Ptr::::null()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { let r: Ptr = (*p.borrow()).clone(); return (r.read()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub6.rs b/tests/ub/out/refcount/ub6.rs index e7628b27f..ad4b8c8fd 100644 --- a/tests/ub/out/refcount/ub6.rs +++ b/tests/ub/out/refcount/ub6.rs @@ -60,6 +60,7 @@ pub fn any_2(arr: Ptr]>>>>, n1: Ptr) -> bool { return (*out.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -73,3 +74,4 @@ fn main_0() -> i32 { ({ fill_1(arr.as_pointer(), n.as_pointer()) }); return (({ any_2(arr.as_pointer(), n.as_pointer()) }) as i32); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub7.rs b/tests/ub/out/refcount/ub7.rs index 3a5cd4d26..fb6035d4d 100644 --- a/tests/ub/out/refcount/ub7.rs +++ b/tests/ub/out/refcount/ub7.rs @@ -15,6 +15,7 @@ pub fn strlen_0(s: Ptr) -> usize { return ((((*s.borrow()).clone() - (*begin.borrow()).clone()) as i64) as usize); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ fn main_0() -> i32 { ]))); return (({ strlen_0(((s.as_pointer() as Ptr).offset(0))) }) as i32); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub8.rs b/tests/ub/out/refcount/ub8.rs index e68690c18..939cb67fc 100644 --- a/tests/ub/out/refcount/ub8.rs +++ b/tests/ub/out/refcount/ub8.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -14,3 +15,4 @@ fn main_0() -> i32 { let p: Value> = Rc::new(RefCell::new((x.as_pointer()))); return ((*p.borrow_mut()).prefix_inc().read()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/refcount/ub9.rs b/tests/ub/out/refcount/ub9.rs index a286b527c..711b7321a 100644 --- a/tests/ub/out/refcount/ub9.rs +++ b/tests/ub/out/refcount/ub9.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { (*arr.borrow()).delete_array(); return (*out.borrow()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ctor_ref_member.rs b/tests/ub/out/unsafe/ctor_ref_member.rs index 8e2dc8471..6370e24cf 100644 --- a/tests/ub/out/unsafe/ctor_ref_member.rs +++ b/tests/ub/out/unsafe/ctor_ref_member.rs @@ -19,6 +19,7 @@ impl S { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -30,3 +31,4 @@ unsafe fn main_0() -> i32 { assert!(((*s.r) == (5))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/dangling-prvalue-as-lvalue.rs b/tests/ub/out/unsafe/dangling-prvalue-as-lvalue.rs index 32337b390..c8d8a40f6 100644 --- a/tests/ub/out/unsafe/dangling-prvalue-as-lvalue.rs +++ b/tests/ub/out/unsafe/dangling-prvalue-as-lvalue.rs @@ -11,6 +11,7 @@ pub unsafe fn foo_0(a: *const i32) -> *const i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -20,3 +21,4 @@ unsafe fn main_0() -> i32 { v.clear(); return (*b); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/enum_out_of_range_cast.rs b/tests/ub/out/unsafe/enum_out_of_range_cast.rs index 981690e48..634c80eae 100644 --- a/tests/ub/out/unsafe/enum_out_of_range_cast.rs +++ b/tests/ub/out/unsafe/enum_out_of_range_cast.rs @@ -12,6 +12,7 @@ pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -24,3 +25,4 @@ unsafe fn main_0() -> i32 { 1 }; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/enum_out_of_range_increment.rs b/tests/ub/out/unsafe/enum_out_of_range_increment.rs index 993fec1b0..19493d356 100644 --- a/tests/ub/out/unsafe/enum_out_of_range_increment.rs +++ b/tests/ub/out/unsafe/enum_out_of_range_increment.rs @@ -12,6 +12,7 @@ pub const color_GREEN: color = 1; pub const color_BLUE: color = 2; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -24,3 +25,4 @@ unsafe fn main_0() -> i32 { 1 }; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/fd_close_invalid.rs b/tests/ub/out/unsafe/fd_close_invalid.rs index b5cfb4c8e..9198925d5 100644 --- a/tests/ub/out/unsafe/fd_close_invalid.rs +++ b/tests/ub/out/unsafe/fd_close_invalid.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -18,3 +19,4 @@ unsafe fn main_0() -> i32 { 1 }; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/fd_double_close.rs b/tests/ub/out/unsafe/fd_double_close.rs index d26a2c4eb..d9076b6ef 100644 --- a/tests/ub/out/unsafe/fd_double_close.rs +++ b/tests/ub/out/unsafe/fd_double_close.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -25,3 +26,4 @@ unsafe fn main_0() -> i32 { 1 }; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/fd_use_after_close.rs b/tests/ub/out/unsafe/fd_use_after_close.rs index 45de7482e..e1e9e65ac 100644 --- a/tests/ub/out/unsafe/fd_use_after_close.rs +++ b/tests/ub/out/unsafe/fd_use_after_close.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -31,3 +32,4 @@ unsafe fn main_0() -> i32 { 1 }; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/file_use_after_fclose.rs b/tests/ub/out/unsafe/file_use_after_fclose.rs index c576dd9d8..17a784c0e 100644 --- a/tests/ub/out/unsafe/file_use_after_fclose.rs +++ b/tests/ub/out/unsafe/file_use_after_fclose.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -24,3 +25,4 @@ unsafe fn main_0() -> i32 { 0 }; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/max.rs b/tests/ub/out/unsafe/max.rs index d63c284bc..cd757bcc3 100644 --- a/tests/ub/out/unsafe/max.rs +++ b/tests/ub/out/unsafe/max.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -32,3 +33,4 @@ unsafe fn main_0() -> i32 { }; return (((*a) == (*b)) as i32); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ret_ref_to_local.rs b/tests/ub/out/unsafe/ret_ref_to_local.rs index 6b6f85b3b..264241698 100644 --- a/tests/ub/out/unsafe/ret_ref_to_local.rs +++ b/tests/ub/out/unsafe/ret_ref_to_local.rs @@ -12,6 +12,7 @@ pub unsafe fn foo_0() -> *const i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -19,3 +20,4 @@ unsafe fn main_0() -> i32 { let mut bar: i32 = (*(unsafe { foo_0() })); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub1.rs b/tests/ub/out/unsafe/ub1.rs index 71faa394e..8cbe0ab66 100644 --- a/tests/ub/out/unsafe/ub1.rs +++ b/tests/ub/out/unsafe/ub1.rs @@ -13,6 +13,7 @@ pub unsafe fn dangling_0() -> *mut i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -20,3 +21,4 @@ unsafe fn main_0() -> i32 { let x: *mut i32 = (unsafe { dangling_0() }); return (*x); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub10.rs b/tests/ub/out/unsafe/ub10.rs index a6e029df2..35ba41fc6 100644 --- a/tests/ub/out/unsafe/ub10.rs +++ b/tests/ub/out/unsafe/ub10.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -23,3 +24,4 @@ unsafe fn main_0() -> i32 { ))); return out; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub11.rs b/tests/ub/out/unsafe/ub11.rs index 10310eaa8..a24855447 100644 --- a/tests/ub/out/unsafe/ub11.rs +++ b/tests/ub/out/unsafe/ub11.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -18,3 +19,4 @@ unsafe fn main_0() -> i32 { ::std::mem::drop(Box::from_raw(element)); return out; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub12.rs b/tests/ub/out/unsafe/ub12.rs index 305521853..6abb788d3 100644 --- a/tests/ub/out/unsafe/ub12.rs +++ b/tests/ub/out/unsafe/ub12.rs @@ -11,6 +11,7 @@ pub unsafe fn escape_0(mut ptr: *mut i32) { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -20,3 +21,4 @@ unsafe fn main_0() -> i32 { ::std::mem::drop(Box::from_raw(alloc)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub13.rs b/tests/ub/out/unsafe/ub13.rs index 2d9016a0b..cfd615347 100644 --- a/tests/ub/out/unsafe/ub13.rs +++ b/tests/ub/out/unsafe/ub13.rs @@ -11,6 +11,7 @@ pub unsafe fn escape_0(mut p: *mut i32) { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -19,3 +20,4 @@ unsafe fn main_0() -> i32 { (unsafe { escape_0(p1) }); return (*p1); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub14.rs b/tests/ub/out/unsafe/ub14.rs index a56a50007..a8c494055 100644 --- a/tests/ub/out/unsafe/ub14.rs +++ b/tests/ub/out/unsafe/ub14.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -22,3 +23,4 @@ unsafe fn main_0() -> i32 { ))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub15.rs b/tests/ub/out/unsafe/ub15.rs index b35b14eea..99c605c8e 100644 --- a/tests/ub/out/unsafe/ub15.rs +++ b/tests/ub/out/unsafe/ub15.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -23,3 +24,4 @@ unsafe fn main_0() -> i32 { ))); return out; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub16.rs b/tests/ub/out/unsafe/ub16.rs index f5485e25c..91bff8772 100644 --- a/tests/ub/out/unsafe/ub16.rs +++ b/tests/ub/out/unsafe/ub16.rs @@ -11,6 +11,7 @@ pub unsafe fn foo_0(mut a: *mut i32) -> *mut i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -26,3 +27,4 @@ unsafe fn main_0() -> i32 { ))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub17.rs b/tests/ub/out/unsafe/ub17.rs index 420ae0254..b54012736 100644 --- a/tests/ub/out/unsafe/ub17.rs +++ b/tests/ub/out/unsafe/ub17.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -17,3 +18,4 @@ unsafe fn main_0() -> i32 { ::std::mem::drop(Box::from_raw(p)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub18.rs b/tests/ub/out/unsafe/ub18.rs index 072a63efc..3b4d67645 100644 --- a/tests/ub/out/unsafe/ub18.rs +++ b/tests/ub/out/unsafe/ub18.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -21,3 +22,4 @@ unsafe fn main_0() -> i32 { ))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub19.rs b/tests/ub/out/unsafe/ub19.rs index e922299d3..15cef6943 100644 --- a/tests/ub/out/unsafe/ub19.rs +++ b/tests/ub/out/unsafe/ub19.rs @@ -14,6 +14,7 @@ pub unsafe fn foo_0(mut array: *mut i32) { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -22,3 +23,4 @@ unsafe fn main_0() -> i32 { (unsafe { foo_0(x) }); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub2.rs b/tests/ub/out/unsafe/ub2.rs index c31e89255..5429bb89e 100644 --- a/tests/ub/out/unsafe/ub2.rs +++ b/tests/ub/out/unsafe/ub2.rs @@ -12,6 +12,7 @@ pub unsafe fn null_0() -> *mut i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -19,3 +20,4 @@ unsafe fn main_0() -> i32 { let mut x: *mut i32 = (unsafe { null_0() }); return (*x); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub20.rs b/tests/ub/out/unsafe/ub20.rs index 43b8f7036..635585f6a 100644 --- a/tests/ub/out/unsafe/ub20.rs +++ b/tests/ub/out/unsafe/ub20.rs @@ -11,6 +11,7 @@ pub unsafe fn foo_0(mut single: *mut i32) { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -20,3 +21,4 @@ unsafe fn main_0() -> i32 { (unsafe { foo_0(x) }); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub21.rs b/tests/ub/out/unsafe/ub21.rs index ca595328c..68b446d82 100644 --- a/tests/ub/out/unsafe/ub21.rs +++ b/tests/ub/out/unsafe/ub21.rs @@ -15,6 +15,7 @@ pub unsafe fn strlen_0(mut s: *const libc::c_char) -> usize { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -26,3 +27,4 @@ unsafe fn main_0() -> i32 { ]; return ((unsafe { strlen_0(s.as_ptr()) }) as i32); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub3.rs b/tests/ub/out/unsafe/ub3.rs index 872c14a6f..49c5feed2 100644 --- a/tests/ub/out/unsafe/ub3.rs +++ b/tests/ub/out/unsafe/ub3.rs @@ -13,6 +13,7 @@ pub unsafe fn dangling_0() -> *mut i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -20,3 +21,4 @@ unsafe fn main_0() -> i32 { let mut x: *mut i32 = (unsafe { dangling_0() }); return (*x); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub4.rs b/tests/ub/out/unsafe/ub4.rs index 22d7d6cb7..6ef1a637f 100644 --- a/tests/ub/out/unsafe/ub4.rs +++ b/tests/ub/out/unsafe/ub4.rs @@ -11,6 +11,7 @@ pub unsafe fn smaller_0(x1: *mut i32, x2: *mut i32) -> *mut i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -23,3 +24,4 @@ unsafe fn main_0() -> i32 { } return (*out); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub5.rs b/tests/ub/out/unsafe/ub5.rs index b3c322cfe..a41c2db7f 100644 --- a/tests/ub/out/unsafe/ub5.rs +++ b/tests/ub/out/unsafe/ub5.rs @@ -11,6 +11,7 @@ pub unsafe fn null_0(mut p: *mut *mut i32) { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -21,3 +22,4 @@ unsafe fn main_0() -> i32 { let r: *mut i32 = &mut (*p); return (*r); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub6.rs b/tests/ub/out/unsafe/ub6.rs index 9bb09de2a..b78127c2b 100644 --- a/tests/ub/out/unsafe/ub6.rs +++ b/tests/ub/out/unsafe/ub6.rs @@ -36,6 +36,7 @@ pub unsafe fn any_2(arr: *mut Option>, n1: *mut i32) -> bool { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -49,3 +50,4 @@ unsafe fn main_0() -> i32 { (unsafe { fill_1(&mut arr, &mut n) }); return ((unsafe { any_2(&mut arr, &mut n) }) as i32); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub7.rs b/tests/ub/out/unsafe/ub7.rs index fbe355d94..ee28ce748 100644 --- a/tests/ub/out/unsafe/ub7.rs +++ b/tests/ub/out/unsafe/ub7.rs @@ -16,6 +16,7 @@ pub unsafe fn strlen_0(mut s: *const libc::c_char) -> usize { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -30,3 +31,4 @@ unsafe fn main_0() -> i32 { ]; return ((unsafe { strlen_0((&s[(0) as usize] as *const libc::c_char)) }) as i32); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub8.rs b/tests/ub/out/unsafe/ub8.rs index 8aee78701..7c533cda1 100644 --- a/tests/ub/out/unsafe/ub8.rs +++ b/tests/ub/out/unsafe/ub8.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -16,3 +17,4 @@ unsafe fn main_0() -> i32 { let mut p: *mut i32 = (&mut x as *mut i32); return (*p.prefix_inc()); } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/ub/out/unsafe/ub9.rs b/tests/ub/out/unsafe/ub9.rs index c774466fc..2d697ad35 100644 --- a/tests/ub/out/unsafe/ub9.rs +++ b/tests/ub/out/unsafe/ub9.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -22,3 +23,4 @@ unsafe fn main_0() -> i32 { ))); return out; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/global_init_side_effect.cpp b/tests/unit/global_init_side_effect.cpp new file mode 100644 index 000000000..bf3919868 --- /dev/null +++ b/tests/unit/global_init_side_effect.cpp @@ -0,0 +1,15 @@ +#include + +static int total = 0; + +struct S { + S(int x) { total += x; } +}; + +static S a(1); +static S b(10); + +int main() { + assert(total == 11); + return 0; +} diff --git a/tests/unit/global_non_const_init.cpp b/tests/unit/global_non_const_init.cpp new file mode 100644 index 000000000..85a2a36a7 --- /dev/null +++ b/tests/unit/global_non_const_init.cpp @@ -0,0 +1,79 @@ +#include +#include +#include + +int next() { + static int counter = 0; + return ++counter; +} + +// constexpr function call +constexpr uint8_t marker(uint8_t tag) { return (tag << 3) | 2; } +const uint8_t signature[3] = {marker(1), 0x04, 'B'}; +static uint8_t single = marker(2); + +// non-constexpr function call +static int from_call = next(); +static int depends_on_call = from_call + 1; + +// constructors +struct Ctor { + int v; + Ctor() : v(next()) {} + explicit Ctor(int x) : v(x) {} +}; +static Ctor default_ctor; +static Ctor arg_ctor(7); + +// std::string +std::string str = "abc"; + +// static data members +struct Holder { + static int member; + static inline Ctor inline_member{5}; +}; +int Holder::member = next(); + +// static locals +int local_static() { + static int once = next(); + static Ctor local_ctor(3); + return once + local_ctor.v; +} + +// singleton via function local static +struct Singleton { + int hits; + Singleton() : hits(0) {} + static Singleton &instance() { + static Singleton s; + return s; + } +}; + +int main() { + assert(signature[0] == 10); + assert(signature[1] == 0x04); + assert(single == 18); + + assert(from_call == 1); + assert(depends_on_call == 2); + + assert(default_ctor.v == 2); + assert(arg_ctor.v == 7); + + assert(str == "abc"); + + assert(Holder::member == 3); + assert(Holder::inline_member.v == 5); + + assert(local_static() == 7); + assert(local_static() == 7); + + Singleton::instance().hits++; + Singleton::instance().hits++; + assert(Singleton::instance().hits == 2); + assert(&Singleton::instance() == &Singleton::instance()); + return 0; +} diff --git a/tests/unit/out/refcount/01_local.rs b/tests/unit/out/refcount/01_local.rs index 41a5f59b6..c97816bd8 100644 --- a/tests/unit/out/refcount/01_local.rs +++ b/tests/unit/out/refcount/01_local.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -14,3 +15,4 @@ fn main_0() -> i32 { assert!(((*a.borrow()) == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/02_address_taken.rs b/tests/unit/out/refcount/02_address_taken.rs index 866b26395..937d046e6 100644 --- a/tests/unit/out/refcount/02_address_taken.rs +++ b/tests/unit/out/refcount/02_address_taken.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -23,3 +24,4 @@ fn main_0() -> i32 { assert!(((*b.borrow()) == 4)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/03_local_array.rs b/tests/unit/out/refcount/03_local_array.rs index 0575c9a45..14607044c 100644 --- a/tests/unit/out/refcount/03_local_array.rs +++ b/tests/unit/out/refcount/03_local_array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { assert!((((*arr1.borrow())[(0) as usize] + (*arr1.borrow())[(1) as usize]) == 7)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/04_address_taken_array.rs b/tests/unit/out/refcount/04_address_taken_array.rs index 8f88f5567..0e2d78edf 100644 --- a/tests/unit/out/refcount/04_address_taken_array.rs +++ b/tests/unit/out/refcount/04_address_taken_array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -21,3 +22,4 @@ fn main_0() -> i32 { assert!((((*arr2.borrow())[(0) as usize] + (*arr2.borrow())[(1) as usize]) == 12)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index 48360cc83..189f3cbaa 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -15,3 +16,4 @@ fn main_0() -> i32 { (*d.borrow()).delete(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/06_new_array.rs b/tests/unit/out/refcount/06_new_array.rs index b85fcee26..76802443a 100644 --- a/tests/unit/out/refcount/06_new_array.rs +++ b/tests/unit/out/refcount/06_new_array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { (*e.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/07_unique.rs b/tests/unit/out/refcount/07_unique.rs index 9fab5506e..e270ab598 100644 --- a/tests/unit/out/refcount/07_unique.rs +++ b/tests/unit/out/refcount/07_unique.rs @@ -12,6 +12,7 @@ pub fn fn_0(u: Option>) -> Option> { return (*u.borrow_mut()).take(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { assert!(((*(*f.borrow()).as_ref().unwrap().borrow()) == 10)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/08_unique_array.rs b/tests/unit/out/refcount/08_unique_array.rs index d10b2e58b..e6c3e9cf0 100644 --- a/tests/unit/out/refcount/08_unique_array.rs +++ b/tests/unit/out/refcount/08_unique_array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -25,3 +26,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/09_references.rs b/tests/unit/out/refcount/09_references.rs index ce5e6f829..73fd3e701 100644 --- a/tests/unit/out/refcount/09_references.rs +++ b/tests/unit/out/refcount/09_references.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -24,3 +25,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/10_struct.rs b/tests/unit/out/refcount/10_struct.rs index 2ac2c7a37..99bdb8733 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_struct.rs @@ -67,6 +67,7 @@ impl ByteRepr for Graph { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -109,3 +110,4 @@ impl GraphImpl for Ptr { .write(__rhs); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/11_move.rs b/tests/unit/out/refcount/11_move.rs index 3cd5d9fbf..8bbc6c7ce 100644 --- a/tests/unit/out/refcount/11_move.rs +++ b/tests/unit/out/refcount/11_move.rs @@ -12,6 +12,7 @@ pub fn change_0(n: Ptr>>) { assert!(((*m.borrow()).as_pointer()).is_null()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { assert!(((*(*n.borrow()).as_ref().unwrap().borrow()) == 20)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/12_test.rs b/tests/unit/out/refcount/12_test.rs index ba1b9e409..a756517e3 100644 --- a/tests/unit/out/refcount/12_test.rs +++ b/tests/unit/out/refcount/12_test.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/13_testing.rs b/tests/unit/out/refcount/13_testing.rs index 747840cfe..1a84c0a5b 100644 --- a/tests/unit/out/refcount/13_testing.rs +++ b/tests/unit/out/refcount/13_testing.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { ((*p2.borrow()).read()).write(3); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/14_testing2.rs b/tests/unit/out/refcount/14_testing2.rs index decfe1f1a..e46ef1b33 100644 --- a/tests/unit/out/refcount/14_testing2.rs +++ b/tests/unit/out/refcount/14_testing2.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -15,3 +16,4 @@ fn main_0() -> i32 { assert!((((*ptr.borrow()).read()) == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/__builtin_constant_p.rs b/tests/unit/out/refcount/__builtin_constant_p.rs index 8602ed261..ddb7efd5d 100644 --- a/tests/unit/out/refcount/__builtin_constant_p.rs +++ b/tests/unit/out/refcount/__builtin_constant_p.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -15,3 +16,4 @@ fn main_0() -> i32 { assert!(((1 + 2) == 3)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/addr_of_global.rs b/tests/unit/out/refcount/addr_of_global.rs index 2c3aceb0e..5244c5fea 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -85,6 +85,7 @@ thread_local!( })); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -136,3 +137,10 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = alpha_0.with(|_| ()); + let _ = beta_1.with(|_| ()); + let _ = shared_2.with(|_| ()); + let _ = items_3.with(|_| ()); + let _ = obj_4.with(|_| ()); +} diff --git a/tests/unit/out/refcount/alloc_array.rs b/tests/unit/out/refcount/alloc_array.rs index 6fbf5bf04..002400014 100644 --- a/tests/unit/out/refcount/alloc_array.rs +++ b/tests/unit/out/refcount/alloc_array.rs @@ -34,6 +34,7 @@ pub fn Consume_1(arr: Option>>, N: i32) -> i32 { return (*sum.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -47,3 +48,4 @@ fn main_0() -> i32 { assert!((({ Consume_1((*arr.borrow_mut()).take(), (*N.borrow()),) }) == 10)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/anonymous-struct.rs b/tests/unit/out/refcount/anonymous-struct.rs index 3ef5f74c3..1a7f34b38 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -255,6 +255,7 @@ impl ByteRepr for Outer { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -368,3 +369,4 @@ impl ByteRepr for anon_6 { } } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/anonymous-struct_c.rs b/tests/unit/out/refcount/anonymous-struct_c.rs index 5473ea074..33c5c824b 100644 --- a/tests/unit/out/refcount/anonymous-struct_c.rs +++ b/tests/unit/out/refcount/anonymous-struct_c.rs @@ -239,6 +239,7 @@ impl ByteRepr for Outer { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -335,3 +336,4 @@ impl ByteRepr for anon_6 { } } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/anonymous_enum.rs b/tests/unit/out/refcount/anonymous_enum.rs index f630eea9a..45162c8a9 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/anonymous_enum.rs @@ -75,6 +75,7 @@ impl ByteRepr for WithAnonField { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -95,3 +96,4 @@ fn main_0() -> i32 { pub type anon_3 = u32; pub const anon_3_THIRD_A: anon_3 = 0; pub const anon_3_THIRD_B: anon_3 = 1; +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/anonymous_enum_c.rs b/tests/unit/out/refcount/anonymous_enum_c.rs index dd356a269..f525cfc25 100644 --- a/tests/unit/out/refcount/anonymous_enum_c.rs +++ b/tests/unit/out/refcount/anonymous_enum_c.rs @@ -71,6 +71,7 @@ impl ByteRepr for WithAnonField { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -97,3 +98,4 @@ fn main_0() -> i32 { pub type anon_3 = u32; pub const anon_3_THIRD_A: anon_3 = 0; pub const anon_3_THIRD_B: anon_3 = 1; +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/array.rs b/tests/unit/out/refcount/array.rs index 04848deb2..0c1566825 100644 --- a/tests/unit/out/refcount/array.rs +++ b/tests/unit/out/refcount/array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ fn main_0() -> i32 { assert!(((*fatorial.borrow()) == 120)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/array_2d_default.rs b/tests/unit/out/refcount/array_2d_default.rs index 2e77999a2..ddf0d4e75 100644 --- a/tests/unit/out/refcount/array_2d_default.rs +++ b/tests/unit/out/refcount/array_2d_default.rs @@ -16,6 +16,7 @@ pub fn fill_row_0(row: Ptr, c: u8) { .write((('\0' as i32) as u8)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -64,3 +65,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index b0e467de1..4335228aa 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -59,6 +59,7 @@ thread_local!( })); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -83,3 +84,6 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() { + let _ = s_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index 93f131759..32ab1026e 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -37,6 +37,7 @@ impl ByteRepr for NonCopy { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -59,3 +60,4 @@ fn main_0() -> i32 { assert!(((*(*arr.borrow())[(2) as usize].data.borrow()).len() == 0_usize)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index 1ddf2c9d8..fd73fcccb 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -160,6 +160,7 @@ pub fn total_len_9(names: Ptr]>>) -> i32 { })); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -211,3 +212,4 @@ fn main_0() -> i32 { assert!((({ total_len_9((names.as_pointer() as Ptr]>>),) }) == 5)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/assert.rs b/tests/unit/out/refcount/assert.rs index 60923cb90..6ec5357aa 100644 --- a/tests/unit/out/refcount/assert.rs +++ b/tests/unit/out/refcount/assert.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -14,3 +15,4 @@ fn main_0() -> i32 { assert!((1 == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/assign_as_value.rs b/tests/unit/out/refcount/assign_as_value.rs index bf16523ba..ebc5443df 100644 --- a/tests/unit/out/refcount/assign_as_value.rs +++ b/tests/unit/out/refcount/assign_as_value.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -46,3 +47,4 @@ fn main_0() -> i32 { assert!((((((*out.borrow()) as i32) == ('x' as i32)) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/auto.rs b/tests/unit/out/refcount/auto.rs index f1628708d..01ad94e17 100644 --- a/tests/unit/out/refcount/auto.rs +++ b/tests/unit/out/refcount/auto.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -24,3 +25,4 @@ fn main_0() -> i32 { assert!(((*sum.borrow()) == 3)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bool_condition_enum.rs b/tests/unit/out/refcount/bool_condition_enum.rs index 4d32a20e9..b4fa7e4cd 100644 --- a/tests/unit/out/refcount/bool_condition_enum.rs +++ b/tests/unit/out/refcount/bool_condition_enum.rs @@ -11,6 +11,7 @@ pub const Code_CODE_OK: Code = 0; pub const Code_CODE_ERR: Code = 1; pub const Code_CODE_FATAL: Code = 2; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -34,3 +35,4 @@ fn main_0() -> i32 { assert!(!(*b4.borrow())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bool_condition_enum_c.rs b/tests/unit/out/refcount/bool_condition_enum_c.rs index c36390048..c812ef505 100644 --- a/tests/unit/out/refcount/bool_condition_enum_c.rs +++ b/tests/unit/out/refcount/bool_condition_enum_c.rs @@ -11,6 +11,7 @@ pub const Code_CODE_OK: Code = 0; pub const Code_CODE_ERR: Code = 1; pub const Code_CODE_FATAL: Code = 2; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -34,3 +35,4 @@ fn main_0() -> i32 { assert!(((!(*b4.borrow()) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bool_condition_int.rs b/tests/unit/out/refcount/bool_condition_int.rs index ad21faed0..d7183ff85 100644 --- a/tests/unit/out/refcount/bool_condition_int.rs +++ b/tests/unit/out/refcount/bool_condition_int.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -69,3 +70,4 @@ fn main_0() -> i32 { assert!((*b1.borrow())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bool_condition_int_c.rs b/tests/unit/out/refcount/bool_condition_int_c.rs index 7578ebc09..78ce5b02f 100644 --- a/tests/unit/out/refcount/bool_condition_int_c.rs +++ b/tests/unit/out/refcount/bool_condition_int_c.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -69,3 +70,4 @@ fn main_0() -> i32 { assert!((*b1.borrow())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bool_condition_logical.rs b/tests/unit/out/refcount/bool_condition_logical.rs index 25ebf4e35..e8995c67a 100644 --- a/tests/unit/out/refcount/bool_condition_logical.rs +++ b/tests/unit/out/refcount/bool_condition_logical.rs @@ -25,6 +25,7 @@ pub fn returns_zero_3() -> i32 { return 0; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -131,3 +132,6 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() { + let _ = side_effect_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/bool_condition_logical_c.rs b/tests/unit/out/refcount/bool_condition_logical_c.rs index 210c7b3e9..f08568c31 100644 --- a/tests/unit/out/refcount/bool_condition_logical_c.rs +++ b/tests/unit/out/refcount/bool_condition_logical_c.rs @@ -25,6 +25,7 @@ pub fn returns_zero_3() -> i32 { return 0; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -175,3 +176,6 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() { + let _ = side_effect_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/bool_condition_ptr.rs b/tests/unit/out/refcount/bool_condition_ptr.rs index a6b9afa02..c0357e1fc 100644 --- a/tests/unit/out/refcount/bool_condition_ptr.rs +++ b/tests/unit/out/refcount/bool_condition_ptr.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -46,3 +47,4 @@ fn main_0() -> i32 { assert!(!(*b3.borrow())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bool_condition_ptr_c.rs b/tests/unit/out/refcount/bool_condition_ptr_c.rs index 8966ba6b8..fddc76dd3 100644 --- a/tests/unit/out/refcount/bool_condition_ptr_c.rs +++ b/tests/unit/out/refcount/bool_condition_ptr_c.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -46,3 +47,4 @@ fn main_0() -> i32 { assert!(((!(*b3.borrow()) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bool_printing.rs b/tests/unit/out/refcount/bool_printing.rs index 757575d42..5f67a4c78 100644 --- a/tests/unit/out/refcount/bool_printing.rs +++ b/tests/unit/out/refcount/bool_printing.rs @@ -13,6 +13,7 @@ pub fn bar_1() -> bool { return true; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -34,3 +35,4 @@ fn main_0() -> i32 { write!(libcc2rs::cout(), "{:}\n", (({ bar_1() }) as u8),); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/borrow_mut_opt.rs b/tests/unit/out/refcount/borrow_mut_opt.rs index 4125f1cab..b55965df2 100644 --- a/tests/unit/out/refcount/borrow_mut_opt.rs +++ b/tests/unit/out/refcount/borrow_mut_opt.rs @@ -104,6 +104,7 @@ pub fn convert_with_rhs_1() { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -111,3 +112,4 @@ fn main_0() -> i32 { ({ convert_with_rhs_1() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bounded_struct_ptr.rs b/tests/unit/out/refcount/bounded_struct_ptr.rs index 738c6dcc7..f7a35b3e0 100644 --- a/tests/unit/out/refcount/bounded_struct_ptr.rs +++ b/tests/unit/out/refcount/bounded_struct_ptr.rs @@ -37,6 +37,7 @@ impl ByteRepr for Foo { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -63,3 +64,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/break.rs b/tests/unit/out/refcount/break.rs index 9cdc02d80..beed4f73b 100644 --- a/tests/unit/out/refcount/break.rs +++ b/tests/unit/out/refcount/break.rs @@ -32,9 +32,11 @@ pub fn for_test_0(n: i32) -> i32 { return (*x.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ for_test_0(200,) }) == 400)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/bst.rs b/tests/unit/out/refcount/bst.rs index 97e18ef6d..8a36763d0 100644 --- a/tests/unit/out/refcount/bst.rs +++ b/tests/unit/out/refcount/bst.rs @@ -105,6 +105,7 @@ pub fn insert_1(node: Ptr, new_node: Ptr) -> Ptr { return (*node.borrow()).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -172,3 +173,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/builtin.rs b/tests/unit/out/refcount/builtin.rs index e4d1af150..c7ae24e12 100644 --- a/tests/unit/out/refcount/builtin.rs +++ b/tests/unit/out/refcount/builtin.rs @@ -70,6 +70,7 @@ pub fn test_mul_overflow_long_long_9() { }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -85,3 +86,4 @@ fn main_0() -> i32 { ({ test_mul_overflow_long_long_9() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/builtin_types_compatible.rs b/tests/unit/out/refcount/builtin_types_compatible.rs index 5f59d13d0..066208d30 100644 --- a/tests/unit/out/refcount/builtin_types_compatible.rs +++ b/tests/unit/out/refcount/builtin_types_compatible.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -23,3 +24,4 @@ fn main_0() -> i32 { assert!((((0 == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/byte.rs b/tests/unit/out/refcount/byte.rs index c7b6fbfac..bbe77a951 100644 --- a/tests/unit/out/refcount/byte.rs +++ b/tests/unit/out/refcount/byte.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { assert!(((*b1.borrow()) == 4)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/c_struct.rs b/tests/unit/out/refcount/c_struct.rs index fd1e1b3ee..846635164 100644 --- a/tests/unit/out/refcount/c_struct.rs +++ b/tests/unit/out/refcount/c_struct.rs @@ -155,6 +155,7 @@ impl ByteRepr for Container { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -215,3 +216,4 @@ fn main_0() -> i32 { assert!((((((*(*c2.borrow()).color.borrow()) as u32) == 2_u32) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index af20aa816..b877e1cdf 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -14,3 +15,4 @@ fn main_0() -> i32 { assert!(((*size.borrow()) == 1_usize)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs index 69265f366..47da1ecca 100644 --- a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs @@ -19,6 +19,7 @@ pub fn strlen_1(s: Ptr) -> i32 { return (*c.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -36,3 +37,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/char_printing.rs b/tests/unit/out/refcount/char_printing.rs index 94842479a..a3a2ed9aa 100644 --- a/tests/unit/out/refcount/char_printing.rs +++ b/tests/unit/out/refcount/char_printing.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -55,3 +56,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/char_printing_cerr.rs b/tests/unit/out/refcount/char_printing_cerr.rs index 7453502a8..66a1cab73 100644 --- a/tests/unit/out/refcount/char_printing_cerr.rs +++ b/tests/unit/out/refcount/char_printing_cerr.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -55,3 +56,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index e3e63d83d..fdc497eb7 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -83,6 +83,7 @@ pub fn RandomRoute_0(route: Ptr) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -169,3 +170,4 @@ impl RouteImpl for Ptr { return (*old_cost.borrow()); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/class_template_lazy_member.rs b/tests/unit/out/refcount/class_template_lazy_member.rs index 6b7c2190c..a1e920a69 100644 --- a/tests/unit/out/refcount/class_template_lazy_member.rs +++ b/tests/unit/out/refcount/class_template_lazy_member.rs @@ -85,6 +85,7 @@ impl ByteRepr for Box_Point_ { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -117,3 +118,4 @@ impl Box_int_Impl for Ptr { + (*(*(*self).upgrade().deref()).val.borrow())); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index 269962fb3..a30862fb9 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -85,6 +85,7 @@ impl ByteRepr for MyContainer_float_ { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -211,3 +212,4 @@ impl MyContainer_int_Impl for Ptr { }; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index 7b51f17be..d23c00968 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -70,6 +70,7 @@ impl Default for Foo { } impl ByteRepr for Foo {} pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -508,3 +509,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index 5d643a5ce..9657c2055 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -43,3 +44,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/complex_function.rs b/tests/unit/out/refcount/complex_function.rs index c2c67a7c0..76ba6b783 100644 --- a/tests/unit/out/refcount/complex_function.rs +++ b/tests/unit/out/refcount/complex_function.rs @@ -110,6 +110,7 @@ impl ByteRepr for X4 { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -420,3 +421,4 @@ impl X4Impl for Ptr { return (*(*self).upgrade().deref()).v.as_pointer(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/compound_assign_paren.rs b/tests/unit/out/refcount/compound_assign_paren.rs index ac6acd029..9f0974167 100644 --- a/tests/unit/out/refcount/compound_assign_paren.rs +++ b/tests/unit/out/refcount/compound_assign_paren.rs @@ -33,6 +33,7 @@ impl ByteRepr for Item { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -86,3 +87,4 @@ fn main_0() -> i32 { assert!((((*(*(*ptr.borrow()).upgrade().deref()).flags.borrow()) as i32) == 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/compound_assign_ref.rs b/tests/unit/out/refcount/compound_assign_ref.rs index df941a462..42ac3bffb 100644 --- a/tests/unit/out/refcount/compound_assign_ref.rs +++ b/tests/unit/out/refcount/compound_assign_ref.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { assert!((((v.as_pointer() as Ptr).read()) == 15)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/constexpr_function.rs b/tests/unit/out/refcount/constexpr_function.rs index d3b6c46b1..c57304321 100644 --- a/tests/unit/out/refcount/constexpr_function.rs +++ b/tests/unit/out/refcount/constexpr_function.rs @@ -52,6 +52,7 @@ impl ByteRepr for P { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -77,3 +78,4 @@ impl PImpl for Ptr

{ return (*(*(*self).upgrade().deref()).v.borrow()); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/constructor.rs b/tests/unit/out/refcount/constructor.rs index aa1d6dc92..8f164092a 100644 --- a/tests/unit/out/refcount/constructor.rs +++ b/tests/unit/out/refcount/constructor.rs @@ -48,6 +48,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -77,3 +78,6 @@ impl SImpl for Ptr { (*total_0.with(Value::clone).borrow_mut()) += ({ SImpl::const_method(self) }); } } +pub fn __cpp2rust_init_globals() { + let _ = total_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/continue.rs b/tests/unit/out/refcount/continue.rs index 64af5fe42..530f25312 100644 --- a/tests/unit/out/refcount/continue.rs +++ b/tests/unit/out/refcount/continue.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -59,3 +60,4 @@ fn main_0() -> i32 { assert!(((*out.borrow()) == 81)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 5708fcb57..339998efb 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -189,6 +189,7 @@ impl ByteRepr for Holder { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -309,3 +310,6 @@ impl RefQualifiedImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() { + let _ = assigns_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index afd3641bd..58b0b3ca6 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -163,6 +163,7 @@ pub fn make_2(v: i32) -> Counted { return Counted::Counted_pconstCounted({ c.as_pointer() }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -236,3 +237,6 @@ fn main_0() -> i32 { assert!(((*(*n2.borrow()).mark.borrow()) == 10)); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = copies_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 8bdafca31..aca969c9f 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -433,6 +433,7 @@ pub fn same_0(a: Ptr, b: Ptr) -> bool { }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -825,3 +826,4 @@ impl UserCopyDefaultMoveImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index 0cf4c0312..a1c4ccf98 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -151,6 +151,7 @@ pub fn bump_ref_1(r: Ptr) { (*(*r.upgrade().deref()).v.borrow_mut()).postfix_inc(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -227,3 +228,4 @@ impl PrivateCopyImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/cout_alias.rs b/tests/unit/out/refcount/cout_alias.rs index 74497fc46..6bf3b4bf4 100644 --- a/tests/unit/out/refcount/cout_alias.rs +++ b/tests/unit/out/refcount/cout_alias.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -25,3 +26,4 @@ fn main_0() -> i32 { write!(os2, "hello\n",); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/cstring.rs b/tests/unit/out/refcount/cstring.rs index a76123813..2ac030344 100644 --- a/tests/unit/out/refcount/cstring.rs +++ b/tests/unit/out/refcount/cstring.rs @@ -912,6 +912,7 @@ pub fn test_strcasecmp_15() { ); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -933,3 +934,4 @@ fn main_0() -> i32 { ({ test_strcasecmp_15() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/default.rs b/tests/unit/out/refcount/default.rs index 7e265c68a..0ff7145c1 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -72,6 +72,7 @@ impl ByteRepr for Pointers { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -83,3 +84,4 @@ fn main_0() -> i32 { (*default_pointers.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/default_function_arguments.rs b/tests/unit/out/refcount/default_function_arguments.rs index d7b475afc..6316882c0 100644 --- a/tests/unit/out/refcount/default_function_arguments.rs +++ b/tests/unit/out/refcount/default_function_arguments.rs @@ -61,6 +61,7 @@ impl ByteRepr for Bar { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -88,3 +89,4 @@ fn main_0() -> i32 { assert!(((*(*arr.borrow())[(2) as usize].v.borrow()) == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index 0bf044502..0d2a34b81 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -225,6 +225,7 @@ pub fn check_local_static_5() { assert!((*local_p_8.with(Value::clone).borrow()).is_null()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -287,3 +288,10 @@ fn main_0() -> i32 { ({ check_local_static_5() }); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = static_fn_0.with(|_| ()); + let _ = static_outer_1.with(|_| ()); + let _ = static_inner_array_2.with(|_| ()); + let _ = static_foo_3.with(|_| ()); + let _ = static_foo_array_4.with(|_| ()); +} diff --git a/tests/unit/out/refcount/destructor.rs b/tests/unit/out/refcount/destructor.rs index 71dff4400..a4c7d87f4 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -323,6 +323,7 @@ impl ByteRepr for Ordered { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -516,3 +517,8 @@ impl Templated_int_Impl for Ptr { }; } } +pub fn __cpp2rust_init_globals() { + let _ = global_0.with(|_| ()); + let _ = order_1.with(|_| ()); + let _ = order_count_2.with(|_| ()); +} diff --git a/tests/unit/out/refcount/do_while_continue.rs b/tests/unit/out/refcount/do_while_continue.rs index 13b7d264b..571c35df3 100644 --- a/tests/unit/out/refcount/do_while_continue.rs +++ b/tests/unit/out/refcount/do_while_continue.rs @@ -41,6 +41,7 @@ pub fn nested_1() -> i32 { return (*runs.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -48,3 +49,4 @@ fn main_0() -> i32 { assert!((((({ nested_1() }) == 6) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/doubly_linked_list.rs b/tests/unit/out/refcount/doubly_linked_list.rs index 306ce35f9..bb37a9259 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -120,6 +120,7 @@ pub fn Tail_4(head: Ptr) -> Ptr { return (*curr.borrow()).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -445,3 +446,4 @@ impl NodeImpl for Ptr { (*(*(*self).upgrade().deref()).prev.borrow_mut()) = (*p.borrow()).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/dowhile.rs b/tests/unit/out/refcount/dowhile.rs index 5e9b79b75..a2ceee856 100644 --- a/tests/unit/out/refcount/dowhile.rs +++ b/tests/unit/out/refcount/dowhile.rs @@ -23,9 +23,11 @@ pub fn dowhile_0(x: i32) -> i32 { return (*x.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ dowhile_0(0,) }) == 202)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/empty_array_init.rs b/tests/unit/out/refcount/empty_array_init.rs index 888a14f83..047804591 100644 --- a/tests/unit/out/refcount/empty_array_init.rs +++ b/tests/unit/out/refcount/empty_array_init.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -15,3 +16,4 @@ fn main_0() -> i32 { )); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/empty_main.rs b/tests/unit/out/refcount/empty_main.rs index be7ceea31..0bc61fbb2 100644 --- a/tests/unit/out/refcount/empty_main.rs +++ b/tests/unit/out/refcount/empty_main.rs @@ -20,6 +20,7 @@ pub fn main() { .collect(), )); (*argv.borrow_mut()).push(Ptr::null()); + __cpp2rust_init_globals(); ::std::process::exit(main_0(::std::env::args().len() as i32, argv.as_pointer())); } fn main_0(_a0: i32, _a1: Ptr>) -> i32 { @@ -27,3 +28,4 @@ fn main_0(_a0: i32, _a1: Ptr>) -> i32 { let _a1: Value>> = Rc::new(RefCell::new(_a1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/enum_comparisson_in_globals.rs b/tests/unit/out/refcount/enum_comparisson_in_globals.rs index c5cb7a392..94643197d 100644 --- a/tests/unit/out/refcount/enum_comparisson_in_globals.rs +++ b/tests/unit/out/refcount/enum_comparisson_in_globals.rs @@ -14,9 +14,13 @@ thread_local!( Rc::new(RefCell::new((((E_A as i32) != (E_B as i32)) as i32))); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!(((*global_0.with(Value::clone).borrow()) == 1)); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = global_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/enum_default_in_static.rs b/tests/unit/out/refcount/enum_default_in_static.rs index 6c8ee7a36..a33c8fb89 100644 --- a/tests/unit/out/refcount/enum_default_in_static.rs +++ b/tests/unit/out/refcount/enum_default_in_static.rs @@ -42,6 +42,7 @@ thread_local!( pub static config_0: Value = >::default(); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -53,3 +54,6 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = config_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/enum_increment.rs b/tests/unit/out/refcount/enum_increment.rs index 7df0bc1a6..600646112 100644 --- a/tests/unit/out/refcount/enum_increment.rs +++ b/tests/unit/out/refcount/enum_increment.rs @@ -12,6 +12,7 @@ pub const color_GREEN: color = 1; pub const color_BLUE: color = 2; pub const color_COLOR_LAST: color = 3; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -37,3 +38,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index 7bf3e6320..7037c45dc 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -114,6 +114,7 @@ pub fn make_color_6(n: i32) -> Color { return ((*n.borrow()) as Color); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -234,3 +235,9 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = global_color_0.with(|_| ()); + let _ = global_opt_1.with(|_| ()); + let _ = global_tag_2.with(|_| ()); + let _ = entries_3.with(|_| ()); +} diff --git a/tests/unit/out/refcount/enum_int_interop_c.rs b/tests/unit/out/refcount/enum_int_interop_c.rs index 4daf19359..5887fe630 100644 --- a/tests/unit/out/refcount/enum_int_interop_c.rs +++ b/tests/unit/out/refcount/enum_int_interop_c.rs @@ -112,6 +112,7 @@ pub fn make_color_6(n: i32) -> Color { return ((*n.borrow()) as Color); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -297,3 +298,9 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = global_color_0.with(|_| ()); + let _ = global_opt_1.with(|_| ()); + let _ = global_tag_2.with(|_| ()); + let _ = entries_3.with(|_| ()); +} diff --git a/tests/unit/out/refcount/enum_with_duplicated_values.rs b/tests/unit/out/refcount/enum_with_duplicated_values.rs index 0c1b5c5de..f272a8e6a 100644 --- a/tests/unit/out/refcount/enum_with_duplicated_values.rs +++ b/tests/unit/out/refcount/enum_with_duplicated_values.rs @@ -12,6 +12,7 @@ pub const E_B: E = 4; pub const E_C: E = 2; pub const E_D: E = 4; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -21,3 +22,4 @@ fn main_0() -> i32 { assert!(((E_D as i32) == (1 << 2))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/errno.rs b/tests/unit/out/refcount/errno.rs index 065a2f4d2..226cb2bf7 100644 --- a/tests/unit/out/refcount/errno.rs +++ b/tests/unit/out/refcount/errno.rs @@ -38,6 +38,7 @@ pub fn test_errno_from_fseek_2() { libcc2rs::cpp2rust_errno().write(0); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -46,3 +47,4 @@ fn main_0() -> i32 { ({ test_errno_from_fseek_2() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/expr_as_bool_c.rs b/tests/unit/out/refcount/expr_as_bool_c.rs index 62d58559d..c2010ce82 100644 --- a/tests/unit/out/refcount/expr_as_bool_c.rs +++ b/tests/unit/out/refcount/expr_as_bool_c.rs @@ -22,6 +22,7 @@ pub fn both_null_2(s1: Ptr, s2: Ptr) -> i32 { && ((((*s2.borrow()).is_null()) as i32) != 0)) as i32); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -90,3 +91,4 @@ fn main_0() -> i32 { assert!((((({ both_null_2((*p1.borrow()).clone(), Ptr::::null(),) }) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/expr_as_bool_cpp.rs b/tests/unit/out/refcount/expr_as_bool_cpp.rs index 17a64cba0..62dff945f 100644 --- a/tests/unit/out/refcount/expr_as_bool_cpp.rs +++ b/tests/unit/out/refcount/expr_as_bool_cpp.rs @@ -21,6 +21,7 @@ pub fn both_null_2(s1: Ptr, s2: Ptr) -> i32 { return ((((*s1.borrow()).is_null()) && ((*s2.borrow()).is_null())) as i32); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -84,3 +85,4 @@ fn main_0() -> i32 { assert!((({ both_null_2((*p1.borrow()).clone(), Ptr::::null(),) }) == 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/exprs.rs b/tests/unit/out/refcount/exprs.rs index 8f91ffa11..98a0a6778 100644 --- a/tests/unit/out/refcount/exprs.rs +++ b/tests/unit/out/refcount/exprs.rs @@ -63,6 +63,7 @@ impl ByteRepr for Y { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -142,3 +143,4 @@ impl YImpl for Ptr { return ((*(*self).upgrade().deref()).x.as_pointer()); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fatorial.rs b/tests/unit/out/refcount/fatorial.rs index b0846ca86..0200a7dbf 100644 --- a/tests/unit/out/refcount/fatorial.rs +++ b/tests/unit/out/refcount/fatorial.rs @@ -47,6 +47,7 @@ pub fn fatorial_by_ptr_2(n: Ptr) { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -57,3 +58,4 @@ fn main_0() -> i32 { assert!((({ fatorial_0((*n.borrow()),) }) == 720)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fcall.rs b/tests/unit/out/refcount/fcall.rs index 2ee7a8b2a..e4d4844cd 100644 --- a/tests/unit/out/refcount/fcall.rs +++ b/tests/unit/out/refcount/fcall.rs @@ -43,9 +43,11 @@ pub fn f1_2(x: f64, y: f64) -> f64 { return ({ f2_0((*z1.borrow()), (*x.borrow())) }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ f1_2(1.0E+0, 2.0E+0,) }) == (-6_i32 as f64))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fcntl.rs b/tests/unit/out/refcount/fcntl.rs index b88f7f246..a1a937359 100644 --- a/tests/unit/out/refcount/fcntl.rs +++ b/tests/unit/out/refcount/fcntl.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -249,3 +250,4 @@ fn main_0() -> i32 { assert!((((FdRegistry::close((*fds.borrow())[(1) as usize]) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fd_io.rs b/tests/unit/out/refcount/fd_io.rs index 2cc681801..2ad7329ea 100644 --- a/tests/unit/out/refcount/fd_io.rs +++ b/tests/unit/out/refcount/fd_io.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -140,3 +141,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fd_set_macros.rs b/tests/unit/out/refcount/fd_set_macros.rs index ac09139a7..0f8847e58 100644 --- a/tests/unit/out/refcount/fd_set_macros.rs +++ b/tests/unit/out/refcount/fd_set_macros.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -39,3 +40,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fflush_null.rs b/tests/unit/out/refcount/fflush_null.rs index b9314f492..e866b7b1b 100644 --- a/tests/unit/out/refcount/fflush_null.rs +++ b/tests/unit/out/refcount/fflush_null.rs @@ -7,9 +7,11 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { let file_ptr: Value> = Rc::new(RefCell::new(Ptr::null())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fft.rs b/tests/unit/out/refcount/fft.rs index 40b783543..09ee323ff 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -225,6 +225,7 @@ pub fn fft_3(a: Ptr>>>, N: i32) -> Option i32 { @@ -284,3 +285,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index 4ad312318..4e72b3e10 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -78,3 +79,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr.rs b/tests/unit/out/refcount/fn_ptr.rs index ec6c2d09f..b8dfde3a9 100644 --- a/tests/unit/out/refcount/fn_ptr.rs +++ b/tests/unit/out/refcount/fn_ptr.rs @@ -16,6 +16,7 @@ pub fn foo_1(fn_: FnPtr i32>, pi: Ptr) -> i32 { return ({ (*(*fn_.borrow()))(((*pi.borrow()).clone() as Ptr).to_any()) }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -39,3 +40,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_arity.rs b/tests/unit/out/refcount/fn_ptr_arity.rs index 4e3dfd71b..184843192 100644 --- a/tests/unit/out/refcount/fn_ptr_arity.rs +++ b/tests/unit/out/refcount/fn_ptr_arity.rs @@ -39,6 +39,7 @@ pub fn foo_0( return 22; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -53,3 +54,4 @@ fn main_0() -> i32 { assert!((({ (*(*f.borrow()))(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,) }) == 22)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_array.rs b/tests/unit/out/refcount/fn_ptr_array.rs index df1347fc9..cffe7c6f2 100644 --- a/tests/unit/out/refcount/fn_ptr_array.rs +++ b/tests/unit/out/refcount/fn_ptr_array.rs @@ -22,6 +22,7 @@ pub fn mul_2(a: i32, b: i32) -> i32 { return ((*a.borrow()) * (*b.borrow())); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -38,3 +39,4 @@ fn main_0() -> i32 { assert!(((*ops.borrow())[(0) as usize] != FnPtr:: i32>::new(sub_1))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_as_condition.rs b/tests/unit/out/refcount/fn_ptr_as_condition.rs index c8d7b5ce8..9f6857a3d 100644 --- a/tests/unit/out/refcount/fn_ptr_as_condition.rs +++ b/tests/unit/out/refcount/fn_ptr_as_condition.rs @@ -21,6 +21,7 @@ pub fn maybe_call_1(cb: FnPtr)>, x: Ptr) { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -41,3 +42,4 @@ fn main_0() -> i32 { assert!(((*c.borrow()) == 6)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index 4d309ef6c..28e71fbb7 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -100,6 +100,7 @@ pub fn test_call_through_cast_5() { assert!(((*result.borrow()) == 142)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -109,3 +110,4 @@ fn main_0() -> i32 { ({ test_call_through_cast_5() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_conditional.rs b/tests/unit/out/refcount/fn_ptr_conditional.rs index e25fd186c..6dbda4b07 100644 --- a/tests/unit/out/refcount/fn_ptr_conditional.rs +++ b/tests/unit/out/refcount/fn_ptr_conditional.rs @@ -42,6 +42,7 @@ pub fn apply_4(fn_: FnPtr i32>, x: i32) -> i32 { return ({ (*(*actual.borrow()))((*x.borrow())) }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -52,3 +53,4 @@ fn main_0() -> i32 { assert!((({ apply_4(FnPtr:: i32>::null(), 5,) }) == 5)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_default_arg.rs b/tests/unit/out/refcount/fn_ptr_default_arg.rs index 0348fc828..7e5a0bb3d 100644 --- a/tests/unit/out/refcount/fn_ptr_default_arg.rs +++ b/tests/unit/out/refcount/fn_ptr_default_arg.rs @@ -20,6 +20,7 @@ pub fn apply_1(x: i32, fn_: Option i32>>) -> i32 { return (*x.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -35,3 +36,4 @@ fn main_0() -> i32 { assert!((({ apply_1(5, Some((*negate.borrow()).clone()),) }) == -5_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_global.rs b/tests/unit/out/refcount/fn_ptr_global.rs index 47af3b84f..626d485af 100644 --- a/tests/unit/out/refcount/fn_ptr_global.rs +++ b/tests/unit/out/refcount/fn_ptr_global.rs @@ -30,6 +30,7 @@ pub fn call_op_4(x: i32) -> i32 { return (*x.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -52,3 +53,6 @@ fn main_0() -> i32 { assert!((({ call_op_4(5,) }) == 5)); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = g_op_2.with(|_| ()); +} diff --git a/tests/unit/out/refcount/fn_ptr_reassign.rs b/tests/unit/out/refcount/fn_ptr_reassign.rs index ce04bf24e..5be70941b 100644 --- a/tests/unit/out/refcount/fn_ptr_reassign.rs +++ b/tests/unit/out/refcount/fn_ptr_reassign.rs @@ -22,6 +22,7 @@ pub fn mul_2(a: i32, b: i32) -> i32 { return ((*a.borrow()) * (*b.borrow())); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -39,3 +40,4 @@ fn main_0() -> i32 { assert!((({ (*(*fn_.borrow()))(1, 1,) }) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_return.rs b/tests/unit/out/refcount/fn_ptr_return.rs index 5fc0dfaf0..5d14ed5c9 100644 --- a/tests/unit/out/refcount/fn_ptr_return.rs +++ b/tests/unit/out/refcount/fn_ptr_return.rs @@ -22,6 +22,7 @@ pub fn pick_2(choose_inc: i32) -> FnPtr i32> { return FnPtr:: i32>::new(dec_1); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -44,3 +45,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_stable_sort.rs b/tests/unit/out/refcount/fn_ptr_stable_sort.rs index 6ca928bee..b84c69b1d 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -43,6 +43,7 @@ pub fn Compare_0(a: Ptr, b: Ptr) -> bool { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -92,3 +93,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_stdlib_compare.rs b/tests/unit/out/refcount/fn_ptr_stdlib_compare.rs index dc405232d..cccb7ef72 100644 --- a/tests/unit/out/refcount/fn_ptr_stdlib_compare.rs +++ b/tests/unit/out/refcount/fn_ptr_stdlib_compare.rs @@ -21,6 +21,7 @@ pub fn my_alternative_fwrite_1(p: Ptr, n: usize, m: usize, f: AnyPtr) -> usi return 33_usize; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -271,3 +272,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_struct.rs b/tests/unit/out/refcount/fn_ptr_struct.rs index 29dc5c656..591311fb2 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -55,6 +55,7 @@ pub fn negate_1(x: i32) -> i32 { return -(*x.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -77,3 +78,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_void_return.rs b/tests/unit/out/refcount/fn_ptr_void_return.rs index d68c8967e..4779ebc24 100644 --- a/tests/unit/out/refcount/fn_ptr_void_return.rs +++ b/tests/unit/out/refcount/fn_ptr_void_return.rs @@ -21,6 +21,7 @@ pub fn run_2(fn_: FnPtr)>, x: Ptr) { ({ (*(*fn_.borrow()))((*x.borrow()).clone()) }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -37,3 +38,4 @@ fn main_0() -> i32 { assert!(((*b.borrow()) == -10_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_vtable.rs b/tests/unit/out/refcount/fn_ptr_vtable.rs index dab4ed34c..312ae756b 100644 --- a/tests/unit/out/refcount/fn_ptr_vtable.rs +++ b/tests/unit/out/refcount/fn_ptr_vtable.rs @@ -70,6 +70,7 @@ pub fn int_destroy_3(p: AnyPtr) { (*p.borrow()).reinterpret_cast::().write(0); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -89,3 +90,6 @@ fn main_0() -> i32 { assert!((*(*vt.borrow()).get.borrow()).is_null()); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = storage_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/fopen.rs b/tests/unit/out/refcount/fopen.rs index d8c30f4fd..972ff7c9e 100644 --- a/tests/unit/out/refcount/fopen.rs +++ b/tests/unit/out/refcount/fopen.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -23,3 +24,4 @@ fn main_0() -> i32 { )); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/foreach.rs b/tests/unit/out/refcount/foreach.rs index 0a4972280..15b57b218 100644 --- a/tests/unit/out/refcount/foreach.rs +++ b/tests/unit/out/refcount/foreach.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -27,3 +28,4 @@ fn main_0() -> i32 { assert!(((*sum.borrow()) == 45)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index 7649198e2..af5037f71 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -37,6 +37,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -48,3 +49,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/foreach_double.rs b/tests/unit/out/refcount/foreach_double.rs index 668606662..eddf39acb 100644 --- a/tests/unit/out/refcount/foreach_double.rs +++ b/tests/unit/out/refcount/foreach_double.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -78,3 +79,4 @@ fn main_0() -> i32 { assert!(((*square.borrow()) == 144)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/foreach_map.rs b/tests/unit/out/refcount/foreach_map.rs index 042cce5cc..76d65c42d 100644 --- a/tests/unit/out/refcount/foreach_map.rs +++ b/tests/unit/out/refcount/foreach_map.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -35,3 +36,4 @@ fn main_0() -> i32 { assert!(((*sum.borrow()) == 7475_f64)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/foreach_mut.rs b/tests/unit/out/refcount/foreach_mut.rs index 6418ab6bd..b9589d94a 100644 --- a/tests/unit/out/refcount/foreach_mut.rs +++ b/tests/unit/out/refcount/foreach_mut.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -64,3 +65,4 @@ fn main_0() -> i32 { assert!(((*sum.borrow()) == 168)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index 5fc9b0adb..138afba71 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -154,6 +154,7 @@ pub fn declared_then_defined_6(d: Ptr) -> i32 { return ((*(*d.upgrade().deref()).x.borrow()) + 1); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -195,3 +196,4 @@ fn main_0() -> i32 { assert!((({ declared_then_defined_6(d.as_pointer(),) }) == 8)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fstat.rs b/tests/unit/out/refcount/fstat.rs index 86bf4c31d..d932b694f 100644 --- a/tests/unit/out/refcount/fstat.rs +++ b/tests/unit/out/refcount/fstat.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -76,3 +77,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/function_call.rs b/tests/unit/out/refcount/function_call.rs index b66416338..2f7f61bbb 100644 --- a/tests/unit/out/refcount/function_call.rs +++ b/tests/unit/out/refcount/function_call.rs @@ -13,6 +13,7 @@ pub fn function_0(y: i32, z: i32) -> i32 { return (((*x.borrow()) + (*y.borrow())) + (*z.borrow())); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { assert!(((*y.borrow()) == 16)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/function_overloading.rs b/tests/unit/out/refcount/function_overloading.rs index 55cdb27ad..e720b72b7 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -63,6 +63,7 @@ pub fn func_6(x: Ptr) -> i32 { return 1; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -119,3 +120,4 @@ impl FooImpl for Ptr { let y: Value = Rc::new(RefCell::new(y)); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/global-initialization-using-global.rs b/tests/unit/out/refcount/global-initialization-using-global.rs index e207d7961..0bcc707c6 100644 --- a/tests/unit/out/refcount/global-initialization-using-global.rs +++ b/tests/unit/out/refcount/global-initialization-using-global.rs @@ -14,6 +14,7 @@ thread_local!( Rc::new(RefCell::new(((*first_0.with(Value::clone).borrow()) + 1))); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -23,3 +24,7 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = first_0.with(|_| ()); + let _ = second_1.with(|_| ()); +} diff --git a/tests/unit/out/refcount/global_init_side_effect.rs b/tests/unit/out/refcount/global_init_side_effect.rs new file mode 100644 index 000000000..c5ed81441 --- /dev/null +++ b/tests/unit/out/refcount/global_init_side_effect.rs @@ -0,0 +1,57 @@ +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 total_0: Value = Rc::new(RefCell::new(0)); +); +#[derive(Default)] +pub struct S {} +impl S { + pub fn S(x: i32) -> Self { + let x: Value = Rc::new(RefCell::new(x)); + let __this: Value = Rc::new(RefCell::new(Self {})); + let this: Ptr = __this.as_pointer(); + (*total_0.with(Value::clone).borrow_mut()) += (*x.borrow()); + Rc::try_unwrap(__this).ok().unwrap().into_inner() + } +} +impl Clone for S { + fn clone(&self) -> Self { + let __this: Value = Rc::new(RefCell::new(Self {})); + let this: Ptr = __this.as_pointer(); + Rc::try_unwrap(__this).ok().unwrap().into_inner() + } +} +impl ByteRepr for S { + fn byte_size() -> usize { + 1 + } + fn to_bytes(&self, buf: &mut [u8]) {} + fn from_bytes(buf: &[u8]) -> Self { + Self {} + } +} +thread_local!( + pub static a_1: Value = Rc::new(RefCell::new(S::S({ 1 }))); +); +thread_local!( + pub static b_2: Value = Rc::new(RefCell::new(S::S({ 10 }))); +); +pub fn main() { + __cpp2rust_init_globals(); + std::process::exit(main_0()); +} +fn main_0() -> i32 { + assert!(((*total_0.with(Value::clone).borrow()) == 11)); + return 0; +} +pub fn __cpp2rust_init_globals() { + let _ = total_0.with(|_| ()); + let _ = a_1.with(|_| ()); + let _ = b_2.with(|_| ()); +} diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs new file mode 100644 index 000000000..7ea73c533 --- /dev/null +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -0,0 +1,229 @@ +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}; +pub fn next_0() -> i32 { + thread_local!( + static counter_1: Value = Rc::new(RefCell::new(0)); + ); + return (*counter_1.with(Value::clone).borrow_mut()).prefix_inc(); +} +pub fn marker_2(tag: u8) -> u8 { + let tag: Value = Rc::new(RefCell::new(tag)); + return (((((*tag.borrow()) as i32) << 3) | 2) as u8); +} +thread_local!( + pub static signature_3: Value> = Rc::new(RefCell::new(Box::new([ + ({ marker_2(1_u8) }), + 4_u8, + ('B' as u8), + ]))); +); +thread_local!( + pub static single_4: Value = Rc::new(RefCell::new(({ marker_2(2_u8) }))); +); +thread_local!( + pub static from_call_5: Value = Rc::new(RefCell::new(({ next_0() }))); +); +thread_local!( + pub static depends_on_call_6: Value = Rc::new(RefCell::new( + ((*from_call_5.with(Value::clone).borrow()) + 1), + )); +); +#[derive()] +pub struct Ctor { + pub v: Value, +} +impl Ctor { + pub fn Ctor1() -> Self { + let __this: Value = Rc::new(RefCell::new(Self { + v: Rc::new(RefCell::new(({ next_0() }))), + })); + let this: Ptr = __this.as_pointer(); + Rc::try_unwrap(__this).ok().unwrap().into_inner() + } + pub fn Ctor2(x: i32) -> Self { + let x: Value = Rc::new(RefCell::new(x)); + let __this: Value = Rc::new(RefCell::new(Self { + v: Rc::new(RefCell::new((*x.borrow()))), + })); + let this: Ptr = __this.as_pointer(); + Rc::try_unwrap(__this).ok().unwrap().into_inner() + } +} +impl Clone for Ctor { + fn clone(&self) -> Self { + let __this: Value = Rc::new(RefCell::new(Self { + v: Rc::new(RefCell::new((*self.v.borrow()))), + })); + let this: Ptr = __this.as_pointer(); + Rc::try_unwrap(__this).ok().unwrap().into_inner() + } +} +impl Default for Ctor { + fn default() -> Self { + { Ctor::Ctor1() } + } +} +impl ByteRepr for Ctor { + fn byte_size() -> usize { + 4 + } + fn to_bytes(&self, buf: &mut [u8]) { + (*self.v.borrow()).to_bytes(&mut buf[0..4]); + } + fn from_bytes(buf: &[u8]) -> Self { + Self { + v: Rc::new(RefCell::new(::from_bytes(&buf[0..4]))), + } + } +} +thread_local!( + pub static default_ctor_7: Value = Rc::new(RefCell::new(Ctor::Ctor1())); +); +thread_local!( + pub static arg_ctor_8: Value = Rc::new(RefCell::new(Ctor::Ctor2({ 7 }))); +); +thread_local!( + pub static str_9: Value> = Rc::new(RefCell::new( + Ptr::from_string_literal(b"abc") + .to_c_string_iterator() + .chain(std::iter::once(0)) + .collect::>(), + )); +); +thread_local!( + pub static inline_member_11: Value = Rc::new(RefCell::new(Ctor::Ctor2({ 5 }))); +); +#[derive(Default)] +pub struct Holder {} +impl Clone for Holder { + fn clone(&self) -> Self { + let __this: Value = Rc::new(RefCell::new(Self {})); + let this: Ptr = __this.as_pointer(); + Rc::try_unwrap(__this).ok().unwrap().into_inner() + } +} +impl ByteRepr for Holder { + fn byte_size() -> usize { + 1 + } + fn to_bytes(&self, buf: &mut [u8]) {} + fn from_bytes(buf: &[u8]) -> Self { + Self {} + } +} +thread_local!( + pub static member_10: Value = Rc::new(RefCell::new(({ next_0() }))); +); +pub fn local_static_12() -> i32 { + thread_local!( + static once_13: Value = Rc::new(RefCell::new(({ next_0() }))); + ); + thread_local!( + static local_ctor_14: Value = Rc::new(RefCell::new(Ctor::Ctor2({ 3 }))); + ); + return ((*once_13.with(Value::clone).borrow()) + + (*(*local_ctor_14.with(Value::clone).borrow()).v.borrow())); +} +#[derive()] +pub struct Singleton { + pub hits: Value, +} +impl Singleton { + pub fn Singleton() -> Self { + let __this: Value = Rc::new(RefCell::new(Self { + hits: Rc::new(RefCell::new(0)), + })); + let this: Ptr = __this.as_pointer(); + Rc::try_unwrap(__this).ok().unwrap().into_inner() + } + pub fn instance() -> Ptr { + thread_local!( + static s_15: Value = Rc::new(RefCell::new(Singleton::Singleton())); + ); + return s_15.with(Value::clone).as_pointer(); + } +} +impl Clone for Singleton { + fn clone(&self) -> Self { + let __this: Value = Rc::new(RefCell::new(Self { + hits: Rc::new(RefCell::new((*self.hits.borrow()))), + })); + let this: Ptr = __this.as_pointer(); + Rc::try_unwrap(__this).ok().unwrap().into_inner() + } +} +impl Default for Singleton { + fn default() -> Self { + { Singleton::Singleton() } + } +} +impl ByteRepr for Singleton { + fn byte_size() -> usize { + 4 + } + fn to_bytes(&self, buf: &mut [u8]) { + (*self.hits.borrow()).to_bytes(&mut buf[0..4]); + } + fn from_bytes(buf: &[u8]) -> Self { + Self { + hits: Rc::new(RefCell::new(::from_bytes(&buf[0..4]))), + } + } +} +pub fn main() { + __cpp2rust_init_globals(); + std::process::exit(main_0()); +} +fn main_0() -> i32 { + assert!((((*signature_3.with(Value::clone).borrow())[(0) as usize] as i32) == 10)); + assert!((((*signature_3.with(Value::clone).borrow())[(1) as usize] as i32) == 4)); + assert!((((*single_4.with(Value::clone).borrow()) as i32) == 18)); + assert!(((*from_call_5.with(Value::clone).borrow()) == 1)); + assert!(((*depends_on_call_6.with(Value::clone).borrow()) == 2)); + assert!(((*(*default_ctor_7.with(Value::clone).borrow()).v.borrow()) == 2)); + assert!(((*(*arg_ctor_8.with(Value::clone).borrow()).v.borrow()) == 7)); + assert!( + (*str_9.with(Value::clone).borrow()) + .iter() + .copied() + .take((*str_9.with(Value::clone).borrow()).len().saturating_sub(1)) + .eq(Ptr::from_string_literal(b"abc").to_c_string_iterator()) + ); + assert!(((*member_10.with(Value::clone).borrow()) == 3)); + assert!(((*(*inline_member_11.with(Value::clone).borrow()).v.borrow()) == 5)); + assert!((({ local_static_12() }) == 7)); + assert!((({ local_static_12() }) == 7)); + (*(*({ Singleton::instance() }).upgrade().deref()) + .hits + .borrow_mut()) + .postfix_inc(); + (*(*({ Singleton::instance() }).upgrade().deref()) + .hits + .borrow_mut()) + .postfix_inc(); + assert!( + ((*(*({ Singleton::instance() }).upgrade().deref()) + .hits + .borrow()) + == 2) + ); + assert!((({ Singleton::instance() }) == ({ Singleton::instance() }))); + return 0; +} +pub fn __cpp2rust_init_globals() { + let _ = signature_3.with(|_| ()); + let _ = single_4.with(|_| ()); + let _ = from_call_5.with(|_| ()); + let _ = depends_on_call_6.with(|_| ()); + let _ = default_ctor_7.with(|_| ()); + let _ = arg_ctor_8.with(|_| ()); + let _ = str_9.with(|_| ()); + let _ = inline_member_11.with(|_| ()); + let _ = member_10.with(|_| ()); +} diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index a3ee9fdab..1dec7a08e 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.rs @@ -62,6 +62,7 @@ thread_local!( ]))); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -81,3 +82,8 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() { + let _ = single_entry_0.with(|_| ()); + let _ = entries_1.with(|_| ()); + let _ = arr_of_pointers_2.with(|_| ()); +} diff --git a/tests/unit/out/refcount/global_without_initializer.rs b/tests/unit/out/refcount/global_without_initializer.rs index 0abcd1dfa..4f615e31e 100644 --- a/tests/unit/out/refcount/global_without_initializer.rs +++ b/tests/unit/out/refcount/global_without_initializer.rs @@ -42,6 +42,7 @@ thread_local!( pub static size_2: Value = Rc::new(RefCell::new(0_usize)); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -50,3 +51,8 @@ fn main_0() -> i32 { assert!(((*size_2.with(Value::clone).borrow()) == 0_usize)); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = s_0.with(|_| ()); + let _ = file_1.with(|_| ()); + let _ = size_2.with(|_| ()); +} diff --git a/tests/unit/out/refcount/goto_aggregate_default.rs b/tests/unit/out/refcount/goto_aggregate_default.rs index 506316fd2..32d6e671a 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -68,6 +68,7 @@ pub fn agg_0(n: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -75,3 +76,4 @@ fn main_0() -> i32 { assert!((((({ agg_0(1,) }) == 1) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/goto_backward.rs b/tests/unit/out/refcount/goto_backward.rs index fa72c1fb0..005d54ad6 100644 --- a/tests/unit/out/refcount/goto_backward.rs +++ b/tests/unit/out/refcount/goto_backward.rs @@ -27,9 +27,11 @@ pub fn retry_0(n: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((((({ retry_0(4,) }) == 12) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/goto_cleanup.rs b/tests/unit/out/refcount/goto_cleanup.rs index baa003ecd..03f91b501 100644 --- a/tests/unit/out/refcount/goto_cleanup.rs +++ b/tests/unit/out/refcount/goto_cleanup.rs @@ -155,6 +155,7 @@ pub fn via_arrays_4(fail: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -174,3 +175,4 @@ fn main_0() -> i32 { assert!((((({ via_arrays_4(1,) }) == -1_i32) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/goto_loop_control.rs b/tests/unit/out/refcount/goto_loop_control.rs index 61e0486ee..a77037adc 100644 --- a/tests/unit/out/refcount/goto_loop_control.rs +++ b/tests/unit/out/refcount/goto_loop_control.rs @@ -30,9 +30,11 @@ pub fn loopctl_0() -> i32 { return (*sum.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((((({ loopctl_0() }) == 3) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/goto_multi_label.rs b/tests/unit/out/refcount/goto_multi_label.rs index 6826fea2f..49dadcda1 100644 --- a/tests/unit/out/refcount/goto_multi_label.rs +++ b/tests/unit/out/refcount/goto_multi_label.rs @@ -31,6 +31,7 @@ pub fn classify_0(n: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -39,3 +40,4 @@ fn main_0() -> i32 { assert!((((({ classify_0(-2_i32,) }) == -1_i32) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/goto_nested_label.rs b/tests/unit/out/refcount/goto_nested_label.rs index de16925c1..53418344d 100644 --- a/tests/unit/out/refcount/goto_nested_label.rs +++ b/tests/unit/out/refcount/goto_nested_label.rs @@ -33,9 +33,11 @@ pub fn scan_0(n: i32) -> i32 { return (*total.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((((({ scan_0(2,) }) == 2010) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/goto_switch_fallthrough.rs b/tests/unit/out/refcount/goto_switch_fallthrough.rs index 579cb5151..1b4cb78dc 100644 --- a/tests/unit/out/refcount/goto_switch_fallthrough.rs +++ b/tests/unit/out/refcount/goto_switch_fallthrough.rs @@ -34,6 +34,7 @@ pub fn sm_0(n: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -42,3 +43,4 @@ fn main_0() -> i32 { assert!((((({ sm_0(9,) }) == 1100) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/goto_switch_self_case.rs b/tests/unit/out/refcount/goto_switch_self_case.rs index 86c3a7de6..1a272a911 100644 --- a/tests/unit/out/refcount/goto_switch_self_case.rs +++ b/tests/unit/out/refcount/goto_switch_self_case.rs @@ -26,6 +26,7 @@ pub fn sm_0(n: i32) -> i32 { return (*steps.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -34,3 +35,4 @@ fn main_0() -> i32 { assert!((((({ sm_0(7,) }) == -1_i32) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index eef8af575..bd74793c6 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -296,6 +296,7 @@ pub fn HuffmanCodes_5( return (*out.borrow_mut()).take(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -548,3 +549,4 @@ impl MinHeapNodeImpl for Ptr { && ((*(*(*self).upgrade().deref()).right.borrow()).is_null()); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/ifaddrs.rs b/tests/unit/out/refcount/ifaddrs.rs index bc4312479..0c46e9320 100644 --- a/tests/unit/out/refcount/ifaddrs.rs +++ b/tests/unit/out/refcount/ifaddrs.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -161,3 +162,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/ignored_rule.rs b/tests/unit/out/refcount/ignored_rule.rs index b2affb4a0..b5e5a9f0d 100644 --- a/tests/unit/out/refcount/ignored_rule.rs +++ b/tests/unit/out/refcount/ignored_rule.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { ]))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/immutable-deref-on-func-call.rs b/tests/unit/out/refcount/immutable-deref-on-func-call.rs index e36f541c7..7104984b5 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -33,6 +33,7 @@ impl ByteRepr for Item { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -72,3 +73,4 @@ impl ItemImpl for Ptr { (*(*(*other.borrow()).upgrade().deref()).value.borrow_mut()) = 10; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/immutable_unsigned_arithmetic.rs b/tests/unit/out/refcount/immutable_unsigned_arithmetic.rs index fcceaf175..fe53b0044 100644 --- a/tests/unit/out/refcount/immutable_unsigned_arithmetic.rs +++ b/tests/unit/out/refcount/immutable_unsigned_arithmetic.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -18,3 +19,4 @@ fn main_0() -> i32 { }; return (((*p.borrow()).read()) as i32); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index d8e45de83..d1b9c47e6 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -37,6 +37,7 @@ pub fn write_through_0(p: Ptr) { (*p.borrow()).write(42); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -91,3 +92,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/implicit_ptr_cast.rs b/tests/unit/out/refcount/implicit_ptr_cast.rs index 135bffd5f..c33c67533 100644 --- a/tests/unit/out/refcount/implicit_ptr_cast.rs +++ b/tests/unit/out/refcount/implicit_ptr_cast.rs @@ -11,6 +11,7 @@ pub fn write_ulong_0(p: Ptr) { (*p.borrow()).write(42_u64); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { assert!(((((*x.borrow()) == 42_usize) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/inet_pton_ntop.rs b/tests/unit/out/refcount/inet_pton_ntop.rs index cdb55376b..3e7ceb4e3 100644 --- a/tests/unit/out/refcount/inet_pton_ntop.rs +++ b/tests/unit/out/refcount/inet_pton_ntop.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -382,3 +383,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index 211f3de2b..5093edcd8 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -36,6 +36,7 @@ pub fn func_0() -> i32 { return 42; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -56,3 +57,4 @@ fn main_0() -> i32 { (*aa.borrow_mut()) = ({ func_0() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/init_list.rs b/tests/unit/out/refcount/init_list.rs index 4913029aa..3de38b43f 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -10,6 +10,7 @@ pub fn f_0(list: Vec) { let list: Value> = Rc::new(RefCell::new(list)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { ({ f_0(vec![1, 2, 3, 4]) }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/initializer_list.rs b/tests/unit/out/refcount/initializer_list.rs index f7684c192..7fe256082 100644 --- a/tests/unit/out/refcount/initializer_list.rs +++ b/tests/unit/out/refcount/initializer_list.rs @@ -14,9 +14,11 @@ pub fn f_0(bytes: Vec) -> usize { return (*n.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ f_0(vec![1, 2, 3,],) }) == 3_usize)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/int_to_bool_explicit.rs b/tests/unit/out/refcount/int_to_bool_explicit.rs index 4024521f5..08898fd44 100644 --- a/tests/unit/out/refcount/int_to_bool_explicit.rs +++ b/tests/unit/out/refcount/int_to_bool_explicit.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -17,3 +18,4 @@ fn main_0() -> i32 { assert!(!(*b2.borrow())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/int_to_bool_explicit_c.rs b/tests/unit/out/refcount/int_to_bool_explicit_c.rs index 0bd69774c..b8aa47cef 100644 --- a/tests/unit/out/refcount/int_to_bool_explicit_c.rs +++ b/tests/unit/out/refcount/int_to_bool_explicit_c.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -17,3 +18,4 @@ fn main_0() -> i32 { assert!(((!(*b2.borrow()) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/ipproto_macros.rs b/tests/unit/out/refcount/ipproto_macros.rs index c97265a33..e58255f7a 100644 --- a/tests/unit/out/refcount/ipproto_macros.rs +++ b/tests/unit/out/refcount/ipproto_macros.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -17,3 +18,4 @@ fn main_0() -> i32 { assert!((((((*tcp.borrow()) + (*udp.borrow())) + (*ip.borrow())) + (*ip6.borrow())) == 64)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/isatty.rs b/tests/unit/out/refcount/isatty.rs index 8f33ed92c..6b75dba6d 100644 --- a/tests/unit/out/refcount/isatty.rs +++ b/tests/unit/out/refcount/isatty.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -56,3 +57,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/iterator_freshness.rs b/tests/unit/out/refcount/iterator_freshness.rs index c626df1e7..278f38085 100644 --- a/tests/unit/out/refcount/iterator_freshness.rs +++ b/tests/unit/out/refcount/iterator_freshness.rs @@ -10,6 +10,7 @@ pub fn foo_0(a0: Ptr) { let a0: Value> = Rc::new(RefCell::new(a0)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -22,3 +23,4 @@ fn main_0() -> i32 { ({ foo_0((*it.borrow()).clone()) }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/iterators.rs b/tests/unit/out/refcount/iterators.rs index 6ea8c0ce3..9eb280bfe 100644 --- a/tests/unit/out/refcount/iterators.rs +++ b/tests/unit/out/refcount/iterators.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -35,3 +36,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/keywords.rs b/tests/unit/out/refcount/keywords.rs index 1a5e82b57..ce755f9a2 100644 --- a/tests/unit/out/refcount/keywords.rs +++ b/tests/unit/out/refcount/keywords.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -14,3 +15,4 @@ fn main_0() -> i32 { assert!(((*in_.borrow()) == 123)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index 036e0fea7..0b7692a73 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -356,6 +356,7 @@ pub fn MSTKruskal_2(graph: Ptr) -> f64 { return (*total_weight.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -539,3 +540,4 @@ impl GraphImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lambda_capture_pass.rs b/tests/unit/out/refcount/lambda_capture_pass.rs index 378003b70..ad5347557 100644 --- a/tests/unit/out/refcount/lambda_capture_pass.rs +++ b/tests/unit/out/refcount/lambda_capture_pass.rs @@ -17,6 +17,7 @@ pub fn apply_1(fn_: impl Fn(i32) -> i32, x: i32) -> i32 { return ({ (*fn_.borrow_mut())((*x.borrow())) }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { assert!((({ apply_1((*scale.borrow()).clone(), 4,) }) == 12)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lambda_nested.rs b/tests/unit/out/refcount/lambda_nested.rs index a1e03c779..29670d7b9 100644 --- a/tests/unit/out/refcount/lambda_nested.rs +++ b/tests/unit/out/refcount/lambda_nested.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ fn main_0() -> i32 { assert!((({ (*outer.borrow_mut())(20,) }) == 121)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/libc_char_ptr_field.rs b/tests/unit/out/refcount/libc_char_ptr_field.rs index ac3719fb5..10679e8e9 100644 --- a/tests/unit/out/refcount/libc_char_ptr_field.rs +++ b/tests/unit/out/refcount/libc_char_ptr_field.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -56,3 +57,4 @@ fn main_0() -> i32 { )); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index 2c59eebde..dd6ab382d 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -80,6 +80,7 @@ impl ByteRepr for FieldIsLibcType { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -115,3 +116,4 @@ fn main_0() -> i32 { assert!((((*(*(*filt.borrow()).addr.borrow()).sa_family.borrow()) as i32) == 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/linked_list.rs b/tests/unit/out/refcount/linked_list.rs index f68374b8b..146005808 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.rs @@ -81,6 +81,7 @@ pub fn Delete_2(head: Ptr, val: i32) -> Ptr { return (*head.borrow()).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -192,3 +193,4 @@ impl NodeImpl for Ptr { (*(*(*self).upgrade().deref()).next.borrow_mut()) = (*next.borrow()).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/local_anon_struct_collision.rs b/tests/unit/out/refcount/local_anon_struct_collision.rs index f9deb5f24..51deb2fcb 100644 --- a/tests/unit/out/refcount/local_anon_struct_collision.rs +++ b/tests/unit/out/refcount/local_anon_struct_collision.rs @@ -75,6 +75,7 @@ impl ByteRepr for anon_3 { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -82,3 +83,4 @@ fn main_0() -> i32 { assert!((((({ second_2() }) == 30) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/local_record_template.rs b/tests/unit/out/refcount/local_record_template.rs index b7170eaf9..2df7b8a86 100644 --- a/tests/unit/out/refcount/local_record_template.rs +++ b/tests/unit/out/refcount/local_record_template.rs @@ -130,6 +130,7 @@ impl ByteRepr for Local_1 { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -169,3 +170,4 @@ impl ByteRepr for Local_3 { } } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/loop_with_postfix_inc.rs b/tests/unit/out/refcount/loop_with_postfix_inc.rs index 2965f6f51..79fbf076b 100644 --- a/tests/unit/out/refcount/loop_with_postfix_inc.rs +++ b/tests/unit/out/refcount/loop_with_postfix_inc.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -17,3 +18,4 @@ fn main_0() -> i32 { assert!(((*x.borrow()) == 101)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lseek_ftruncate.rs b/tests/unit/out/refcount/lseek_ftruncate.rs index 2547c1c10..3a59e1546 100644 --- a/tests/unit/out/refcount/lseek_ftruncate.rs +++ b/tests/unit/out/refcount/lseek_ftruncate.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -174,3 +175,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lvalue_ref_goto.rs b/tests/unit/out/refcount/lvalue_ref_goto.rs index 88ef0ac86..ab483dd4f 100644 --- a/tests/unit/out/refcount/lvalue_ref_goto.rs +++ b/tests/unit/out/refcount/lvalue_ref_goto.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -24,3 +25,4 @@ fn main_0() -> i32 { }); panic!("ub: non-void function does not return a value") } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/macros.rs b/tests/unit/out/refcount/macros.rs index 6a3505512..927b5ec12 100644 --- a/tests/unit/out/refcount/macros.rs +++ b/tests/unit/out/refcount/macros.rs @@ -18,6 +18,7 @@ pub fn log_0(file: Ptr, line: i32, func: Ptr) { ); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -36,3 +37,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/main.rs b/tests/unit/out/refcount/main.rs index 0115435f0..fa3cdee66 100644 --- a/tests/unit/out/refcount/main.rs +++ b/tests/unit/out/refcount/main.rs @@ -20,6 +20,7 @@ pub fn main() { .collect(), )); (*argv.borrow_mut()).push(Ptr::null()); + __cpp2rust_init_globals(); ::std::process::exit(main_0(::std::env::args().len() as i32, argv.as_pointer())); } fn main_0(argc: i32, argv: Ptr>) -> i32 { @@ -36,3 +37,4 @@ fn main_0(argc: i32, argv: Ptr>) -> i32 { assert!((((*argc.borrow()) + ((((*s.borrow()).len() - 1) > 0_usize) as i32)) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/malloc_realloc_free.rs b/tests/unit/out/refcount/malloc_realloc_free.rs index d07cebe55..632c4701e 100644 --- a/tests/unit/out/refcount/malloc_realloc_free.rs +++ b/tests/unit/out/refcount/malloc_realloc_free.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -149,3 +150,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/map-reallocation.rs b/tests/unit/out/refcount/map-reallocation.rs index b2649021e..bb4f3bee2 100644 --- a/tests/unit/out/refcount/map-reallocation.rs +++ b/tests/unit/out/refcount/map-reallocation.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -104,3 +105,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index 5bf2841c8..d9424f573 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -16,6 +16,7 @@ pub fn bar_1(x: Ptr) { x.write(__rhs); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -406,3 +407,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/matmul.rs b/tests/unit/out/refcount/matmul.rs index 0d7d95502..f9dd26a5c 100644 --- a/tests/unit/out/refcount/matmul.rs +++ b/tests/unit/out/refcount/matmul.rs @@ -90,6 +90,7 @@ pub fn matmul_1( return (*m3.borrow_mut()).take(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -121,3 +122,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index e6f700913..e71c226e8 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -65,3 +66,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/memcpy_overlap.rs b/tests/unit/out/refcount/memcpy_overlap.rs index e10a5708f..59fb28782 100644 --- a/tests/unit/out/refcount/memcpy_overlap.rs +++ b/tests/unit/out/refcount/memcpy_overlap.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -29,3 +30,4 @@ fn main_0() -> i32 { assert!((((*buf.borrow())[(5) as usize] as i32) == 4)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/memcpy_struct_bytes.rs b/tests/unit/out/refcount/memcpy_struct_bytes.rs index 43030c7b2..e6e329860 100644 --- a/tests/unit/out/refcount/memcpy_struct_bytes.rs +++ b/tests/unit/out/refcount/memcpy_struct_bytes.rs @@ -35,6 +35,7 @@ impl ByteRepr for point { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -64,3 +65,4 @@ fn main_0() -> i32 { assert!(((((*(*dst.borrow()).y.borrow()) == 7) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/memcpy_struct_struct.rs b/tests/unit/out/refcount/memcpy_struct_struct.rs index f5785cf21..e4d725b2c 100644 --- a/tests/unit/out/refcount/memcpy_struct_struct.rs +++ b/tests/unit/out/refcount/memcpy_struct_struct.rs @@ -37,6 +37,7 @@ impl ByteRepr for Entry { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -102,3 +103,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/memset.rs b/tests/unit/out/refcount/memset.rs index f402c7748..96d909a3c 100644 --- a/tests/unit/out/refcount/memset.rs +++ b/tests/unit/out/refcount/memset.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -34,3 +35,4 @@ fn main_0() -> i32 { assert!(((*sum.borrow()) == 50529027)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/min_max_ptr2ptr.rs b/tests/unit/out/refcount/min_max_ptr2ptr.rs index 6cf409db9..441e2fc30 100644 --- a/tests/unit/out/refcount/min_max_ptr2ptr.rs +++ b/tests/unit/out/refcount/min_max_ptr2ptr.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -35,3 +36,4 @@ fn main_0() -> i32 { assert!((((*r1.borrow()) + (*r2.borrow())) == 30)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index 9a69f38a7..a37b59de7 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -78,6 +78,7 @@ pub fn make_0(v: i32) -> MoveOnly { return MoveOnly::MoveOnly_pmutMoveOnly({ m.as_pointer() }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -188,3 +189,4 @@ impl MoveOnlyImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index 564326b33..3f3d2269f 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -96,6 +96,7 @@ pub fn make_1(v: i32) -> MoveOnly { return MoveOnly::MoveOnly_pmutMoveOnly({ m.as_pointer() }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -153,3 +154,4 @@ fn main_0() -> i32 { assert!(((*(*m2.borrow()).mark.borrow()) == 10)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/move_this.rs b/tests/unit/out/refcount/move_this.rs index 273a6e53a..aac859481 100644 --- a/tests/unit/out/refcount/move_this.rs +++ b/tests/unit/out/refcount/move_this.rs @@ -59,6 +59,7 @@ pub fn consume_0(c: Chain) -> i32 { return (*(*c.borrow()).v.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -117,3 +118,4 @@ impl ChainImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/nested_block_scope.rs b/tests/unit/out/refcount/nested_block_scope.rs index 44fb5e25b..dd51d7348 100644 --- a/tests/unit/out/refcount/nested_block_scope.rs +++ b/tests/unit/out/refcount/nested_block_scope.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -44,3 +45,4 @@ fn main_0() -> i32 { assert!(((*x.borrow()) == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/nested_structs.rs b/tests/unit/out/refcount/nested_structs.rs index 58bade839..31ba4c3eb 100644 --- a/tests/unit/out/refcount/nested_structs.rs +++ b/tests/unit/out/refcount/nested_structs.rs @@ -163,6 +163,7 @@ impl ByteRepr for Level0 { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -187,3 +188,4 @@ fn main_0() -> i32 { })); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/netdb.rs b/tests/unit/out/refcount/netdb.rs index c69604b9f..bd2abecd3 100644 --- a/tests/unit/out/refcount/netdb.rs +++ b/tests/unit/out/refcount/netdb.rs @@ -478,6 +478,7 @@ pub fn test_null_hints_2() { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -486,3 +487,4 @@ fn main_0() -> i32 { ({ test_null_hints_2() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/new.rs b/tests/unit/out/refcount/new.rs index c8c701d48..002991001 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { assert!(((*out.borrow()) == 5)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/new_alloc_array.rs b/tests/unit/out/refcount/new_alloc_array.rs index c4e12b232..72cc5b564 100644 --- a/tests/unit/out/refcount/new_alloc_array.rs +++ b/tests/unit/out/refcount/new_alloc_array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { assert!(((*out.borrow()) == 99)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/new_array.rs b/tests/unit/out/refcount/new_array.rs index b794ac55a..f6f06091c 100644 --- a/tests/unit/out/refcount/new_array.rs +++ b/tests/unit/out/refcount/new_array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -18,3 +19,4 @@ fn main_0() -> i32 { (*array.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/new_array_var_size.rs b/tests/unit/out/refcount/new_array_var_size.rs index 149fe32ca..1b3ecc6b7 100644 --- a/tests/unit/out/refcount/new_array_var_size.rs +++ b/tests/unit/out/refcount/new_array_var_size.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { (*A2.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/new_bst.rs b/tests/unit/out/refcount/new_bst.rs index fdd53877b..f54de07bb 100644 --- a/tests/unit/out/refcount/new_bst.rs +++ b/tests/unit/out/refcount/new_bst.rs @@ -119,6 +119,7 @@ pub fn del_2(node: Ptr) { (*node.borrow()).delete(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -162,3 +163,4 @@ fn main_0() -> i32 { assert!((*out.borrow())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/new_struct.rs b/tests/unit/out/refcount/new_struct.rs index 4bdcf4370..85b039dbd 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -37,6 +37,7 @@ impl ByteRepr for Pair { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -52,3 +53,4 @@ fn main_0() -> i32 { assert!(((*out.borrow()) == 3)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/no_direct_callee.rs b/tests/unit/out/refcount/no_direct_callee.rs index 9a5941ea4..ed9a17b92 100644 --- a/tests/unit/out/refcount/no_direct_callee.rs +++ b/tests/unit/out/refcount/no_direct_callee.rs @@ -17,9 +17,11 @@ pub fn test_1(fn_: FnPtr bool>) -> i32 { return 0; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ test_1(FnPtr:: bool>::new(test1_0),) }) == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/null_compare.rs b/tests/unit/out/refcount/null_compare.rs index 4eec7cad7..b76f41b9f 100644 --- a/tests/unit/out/refcount/null_compare.rs +++ b/tests/unit/out/refcount/null_compare.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { assert!(((((*p.borrow()).is_null()) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/null_in_statics.rs b/tests/unit/out/refcount/null_in_statics.rs index 84e7f9439..3e8f2df98 100644 --- a/tests/unit/out/refcount/null_in_statics.rs +++ b/tests/unit/out/refcount/null_in_statics.rs @@ -39,6 +39,7 @@ thread_local!( pub static p_zero_7: Value> = Rc::new(RefCell::new(Ptr::::null())); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -62,3 +63,13 @@ fn main_0() -> i32 { assert!((*p_zero_7.with(Value::clone).borrow()).is_null()); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = p_mut_0.with(|_| ()); + let _ = p_const_1.with(|_| ()); + let _ = cp_2.with(|_| ()); + let _ = arr_of_ptr_3.with(|_| ()); + let _ = pp_4.with(|_| ()); + let _ = const_arr_of_ptr_5.with(|_| ()); + let _ = cp_explicit_null_6.with(|_| ()); + let _ = p_zero_7.with(|_| ()); +} diff --git a/tests/unit/out/refcount/offsetof.rs b/tests/unit/out/refcount/offsetof.rs index da61178fd..5a9dacdd3 100644 --- a/tests/unit/out/refcount/offsetof.rs +++ b/tests/unit/out/refcount/offsetof.rs @@ -83,6 +83,7 @@ impl ByteRepr for Frame { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -114,3 +115,4 @@ fn main_0() -> i32 { assert!(((*total.borrow()) == (2_usize).wrapping_add((*len.borrow())))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/opaque_forward_decl.rs b/tests/unit/out/refcount/opaque_forward_decl.rs index 983539989..eccaf1602 100644 --- a/tests/unit/out/refcount/opaque_forward_decl.rs +++ b/tests/unit/out/refcount/opaque_forward_decl.rs @@ -35,6 +35,7 @@ impl ByteRepr for container { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -47,3 +48,4 @@ fn main_0() -> i32 { } #[derive(Clone, Copy, Default, ByteRepr)] pub struct opaque; +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/opaque_record_copy.rs b/tests/unit/out/refcount/opaque_record_copy.rs index 143a36dbb..db9f94120 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -37,6 +37,7 @@ impl ByteRepr for Wrapper_Probe_ { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -51,3 +52,4 @@ fn main_0() -> i32 { } #[derive(Clone, Copy, Default, ByteRepr)] pub struct Probe; +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/opaque_then_defined.rs b/tests/unit/out/refcount/opaque_then_defined.rs index 1c8c7a14a..8e4c56590 100644 --- a/tests/unit/out/refcount/opaque_then_defined.rs +++ b/tests/unit/out/refcount/opaque_then_defined.rs @@ -63,6 +63,7 @@ impl ByteRepr for node { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -84,3 +85,4 @@ fn main_0() -> i32 { assert!(((((*(*l.borrow()).size.borrow()) == 1) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_arithmetic_free.rs b/tests/unit/out/refcount/operator_arithmetic_free.rs index ebbf39a7a..f36e73e57 100644 --- a/tests/unit/out/refcount/operator_arithmetic_free.rs +++ b/tests/unit/out/refcount/operator_arithmetic_free.rs @@ -121,6 +121,7 @@ pub fn operator_add_12(a: i32, b: Ptr) -> S { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -247,3 +248,4 @@ fn main_0() -> i32 { assert!(((*({ operator_add_12(1, a.as_pointer(),) }).v.borrow()) == 8)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_arithmetic_member.rs b/tests/unit/out/refcount/operator_arithmetic_member.rs index b1065522d..8a49bb27f 100644 --- a/tests/unit/out/refcount/operator_arithmetic_member.rs +++ b/tests/unit/out/refcount/operator_arithmetic_member.rs @@ -33,6 +33,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -199,3 +200,4 @@ impl SImpl for Ptr { return (*old.borrow()).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_bitwise_free.rs b/tests/unit/out/refcount/operator_bitwise_free.rs index 5a5be3f88..9a9e05310 100644 --- a/tests/unit/out/refcount/operator_bitwise_free.rs +++ b/tests/unit/out/refcount/operator_bitwise_free.rs @@ -80,6 +80,7 @@ pub fn operator_shr_5(a: Ptr, n: i32) -> S { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -145,3 +146,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_bitwise_member.rs b/tests/unit/out/refcount/operator_bitwise_member.rs index 8a6966d8e..416ac195b 100644 --- a/tests/unit/out/refcount/operator_bitwise_member.rs +++ b/tests/unit/out/refcount/operator_bitwise_member.rs @@ -33,6 +33,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -120,3 +121,4 @@ impl SImpl for Ptr { }; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index 8d8c3fa81..eb09a71b9 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -408,6 +408,7 @@ impl ByteRepr for Secondary { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -724,3 +725,4 @@ impl SecondaryImpl for Ptr { }) != std::cmp::Ordering::Less; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 6b2384908..73e92aa4c 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -118,6 +118,7 @@ pub fn operator_lt_7(a: i32, b: Ptr) -> bool { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -181,3 +182,4 @@ fn main_0() -> i32 { assert!(({ operator_lt_7(0, a.as_pointer(),) })); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index b1bf82e86..ce29724c9 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -68,6 +68,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -141,3 +142,4 @@ impl SImpl for Ptr { return ((*(*(*self).upgrade().deref()).v.borrow()) < (*o.borrow())); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 1163f6a46..bd1115762 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -82,6 +82,7 @@ pub fn operator_lt_6(a: Ptr, b: i32) -> bool { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -152,3 +153,4 @@ impl SImpl for Ptr { }; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index 71d910679..2532b1f7f 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -106,6 +106,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -132,3 +133,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_compound_assignment_free.rs b/tests/unit/out/refcount/operator_compound_assignment_free.rs index 74cb86ac4..4b2fb36bb 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_free.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_free.rs @@ -98,6 +98,7 @@ pub fn operator_shr_assign_9(a: Ptr, n: i32) -> Ptr { return (a).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -169,3 +170,4 @@ fn main_0() -> i32 { assert!(((*(*a.borrow()).v.borrow()) == 14_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_compound_assignment_member.rs b/tests/unit/out/refcount/operator_compound_assignment_member.rs index 6c9e61f3d..56cd792b8 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_member.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_member.rs @@ -33,6 +33,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -168,3 +169,4 @@ impl SImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_less_than.rs b/tests/unit/out/refcount/operator_less_than.rs index b2c303367..c35245a5c 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -107,6 +107,7 @@ impl ByteRepr for Pair { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -138,3 +139,4 @@ impl PairImpl for Ptr { })); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_logical_free.rs b/tests/unit/out/refcount/operator_logical_free.rs index 9a4748234..d0d64ccfc 100644 --- a/tests/unit/out/refcount/operator_logical_free.rs +++ b/tests/unit/out/refcount/operator_logical_free.rs @@ -44,6 +44,7 @@ pub fn operator_or_2(a: Ptr, b: Ptr) -> bool { || ((*(*b.upgrade().deref()).v.borrow()) != 0); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -93,3 +94,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_logical_member.rs b/tests/unit/out/refcount/operator_logical_member.rs index 314d6fc6c..a5c9df596 100644 --- a/tests/unit/out/refcount/operator_logical_member.rs +++ b/tests/unit/out/refcount/operator_logical_member.rs @@ -33,6 +33,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -78,3 +79,4 @@ impl SImpl for Ptr { || ((*(*o.upgrade().deref()).v.borrow()) != 0); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_member_pointer_free.rs b/tests/unit/out/refcount/operator_member_pointer_free.rs index 2fd79df30..736898c2f 100644 --- a/tests/unit/out/refcount/operator_member_pointer_free.rs +++ b/tests/unit/out/refcount/operator_member_pointer_free.rs @@ -81,6 +81,7 @@ pub fn operator_addr_1(s: Ptr) -> Ptr { return (((*s.upgrade().deref()).data.as_pointer() as Ptr).offset(0)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -121,3 +122,4 @@ fn main_0() -> i32 { assert!(((*(*s.borrow()).data.borrow())[(0) as usize] == 5)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_member_pointer_member.rs b/tests/unit/out/refcount/operator_member_pointer_member.rs index a0e2fa343..2512f5096 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -102,6 +102,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -179,3 +180,6 @@ impl SImpl for Ptr { return (((*(*self).upgrade().deref()).data.as_pointer() as Ptr).offset(0)); } } +pub fn __cpp2rust_init_globals() { + let _ = table_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/operator_other_free.rs b/tests/unit/out/refcount/operator_other_free.rs index 9cc3895e8..0d26549ee 100644 --- a/tests/unit/out/refcount/operator_other_free.rs +++ b/tests/unit/out/refcount/operator_other_free.rs @@ -41,6 +41,7 @@ pub fn operator_comma_0(a: Ptr, b: Ptr) -> S { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -76,3 +77,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index 0395abaf1..fbd3e5c22 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -58,6 +58,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -128,3 +129,4 @@ impl SImpl for Ptr { return ((*(*(*self).upgrade().deref()).v.borrow()) != 0); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index 4e2de1c54..42dd25eea 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -76,6 +76,7 @@ pub fn operator_eq_5(a: i64, b: Ptr) -> i32 { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -176,3 +177,4 @@ impl SImpl for Ptr { return (((*(*(*self).upgrade().deref()).v.borrow()) * (*o.borrow())) + 1); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_qualifiers.rs b/tests/unit/out/refcount/operator_qualifiers.rs index b0727eb64..569f3e0ec 100644 --- a/tests/unit/out/refcount/operator_qualifiers.rs +++ b/tests/unit/out/refcount/operator_qualifiers.rs @@ -33,6 +33,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -126,3 +127,4 @@ impl SImpl for Ptr { return (((*(*(*self).upgrade().deref()).v.borrow()) + (*i.borrow())) + 100); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_synonyms.rs b/tests/unit/out/refcount/operator_synonyms.rs index 099ded8f4..53247d4d9 100644 --- a/tests/unit/out/refcount/operator_synonyms.rs +++ b/tests/unit/out/refcount/operator_synonyms.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -30,3 +31,4 @@ fn main_0() -> i32 { assert!(((*a.borrow()) == 0_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 76b3f0962..0c0801d7b 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -59,6 +59,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -113,3 +114,4 @@ impl SImpl for Ptr { }; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index e4c54beb9..30c6b92c8 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -259,6 +259,7 @@ impl ByteRepr for Wrapped_int_ { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -518,3 +519,4 @@ impl LtImpl for Ptr { }; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/overload_mangling.rs b/tests/unit/out/refcount/overload_mangling.rs index c2e306b45..01647469c 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -59,6 +59,7 @@ impl ByteRepr for Box { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -125,3 +126,4 @@ impl SImpl for Ptr { return (((*(*(*self).upgrade().deref()).base.borrow()) + (*x.borrow())) + (2 as i32)); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pair.rs b/tests/unit/out/refcount/pair.rs index f64a154d2..bcefb3073 100644 --- a/tests/unit/out/refcount/pair.rs +++ b/tests/unit/out/refcount/pair.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -30,3 +31,4 @@ fn main_0() -> i32 { assert!(((*(*p3.borrow()).1.borrow()) == 6)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pipe_io.rs b/tests/unit/out/refcount/pipe_io.rs index b46063fb4..253057240 100644 --- a/tests/unit/out/refcount/pipe_io.rs +++ b/tests/unit/out/refcount/pipe_io.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -107,3 +108,4 @@ fn main_0() -> i32 { assert!((((FdRegistry::close((*fds.borrow())[(0) as usize]) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pod.rs b/tests/unit/out/refcount/pod.rs index e1dcea718..8eff4edcb 100644 --- a/tests/unit/out/refcount/pod.rs +++ b/tests/unit/out/refcount/pod.rs @@ -46,6 +46,7 @@ pub fn PODIncrement_0(pod: Ptr) { (*(*pod.upgrade().deref()).x3.borrow_mut()) += 3; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -67,3 +68,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_add_assign.rs b/tests/unit/out/refcount/pointer_add_assign.rs index 5e9646dfe..1b7008954 100644 --- a/tests/unit/out/refcount/pointer_add_assign.rs +++ b/tests/unit/out/refcount/pointer_add_assign.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -53,3 +54,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_arithmetic.rs b/tests/unit/out/refcount/pointer_arithmetic.rs index 5b244fdec..8e6e1f15d 100644 --- a/tests/unit/out/refcount/pointer_arithmetic.rs +++ b/tests/unit/out/refcount/pointer_arithmetic.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -44,3 +45,4 @@ fn main_0() -> i32 { assert!(((*x.borrow()) == 4)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_array.rs b/tests/unit/out/refcount/pointer_array.rs index e38326618..5b57ef3a1 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -56,6 +56,7 @@ pub fn IncrementAll_0(s: Ptr) { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -71,3 +72,4 @@ fn main_0() -> i32 { assert!(((*x.borrow()) == 3)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_call_offset.rs b/tests/unit/out/refcount/pointer_call_offset.rs index 7f2dbdffc..52dc99a78 100644 --- a/tests/unit/out/refcount/pointer_call_offset.rs +++ b/tests/unit/out/refcount/pointer_call_offset.rs @@ -11,6 +11,7 @@ pub fn foo_0(p: Ptr) -> Ptr { return ((*p.borrow()).offset((5) as isize)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -34,3 +35,4 @@ fn main_0() -> i32 { assert!(((*out.borrow()) == 9)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_diff.rs b/tests/unit/out/refcount/pointer_diff.rs index fa2ddccc9..bc4eaa2bf 100644 --- a/tests/unit/out/refcount/pointer_diff.rs +++ b/tests/unit/out/refcount/pointer_diff.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { assert!((((*p1.borrow()).clone() - (*p0.borrow()).clone()) as i64 == 4_i64)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_eq.rs b/tests/unit/out/refcount/pointer_eq.rs index 7c9666a4d..4259cb3f5 100644 --- a/tests/unit/out/refcount/pointer_eq.rs +++ b/tests/unit/out/refcount/pointer_eq.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -62,3 +63,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_neq.rs b/tests/unit/out/refcount/pointer_neq.rs index e2c854e33..a80f8d18f 100644 --- a/tests/unit/out/refcount/pointer_neq.rs +++ b/tests/unit/out/refcount/pointer_neq.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -21,3 +22,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_offset.rs b/tests/unit/out/refcount/pointer_offset.rs index 103d6e777..443452df2 100644 --- a/tests/unit/out/refcount/pointer_offset.rs +++ b/tests/unit/out/refcount/pointer_offset.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -53,3 +54,4 @@ fn main_0() -> i32 { assert!(((*out.borrow()) == 51)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_printf.rs b/tests/unit/out/refcount/pointer_printf.rs index 0c0be9cff..14388ca9a 100644 --- a/tests/unit/out/refcount/pointer_printf.rs +++ b/tests/unit/out/refcount/pointer_printf.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -15,3 +16,4 @@ fn main_0() -> i32 { print!("{:?} {}", (*p.borrow()), ((*p.borrow()).read())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_to_boolean.rs b/tests/unit/out/refcount/pointer_to_boolean.rs index 341bf00a6..8bd7733ff 100644 --- a/tests/unit/out/refcount/pointer_to_boolean.rs +++ b/tests/unit/out/refcount/pointer_to_boolean.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -14,3 +15,4 @@ fn main_0() -> i32 { assert!(!(!(*x.borrow()).is_null())); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointer_usize_arith.rs b/tests/unit/out/refcount/pointer_usize_arith.rs index 01ff7dc7e..b87e520dc 100644 --- a/tests/unit/out/refcount/pointer_usize_arith.rs +++ b/tests/unit/out/refcount/pointer_usize_arith.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -114,3 +115,4 @@ fn main_0() -> i32 { assert!((((*back.borrow()).read()) == 17)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pointers.rs b/tests/unit/out/refcount/pointers.rs index 2fb7aa29b..3c1e46bc7 100644 --- a/tests/unit/out/refcount/pointers.rs +++ b/tests/unit/out/refcount/pointers.rs @@ -48,6 +48,7 @@ pub fn Update_0(t: Ptr) -> Ptr { return (*t.borrow()).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -95,3 +96,4 @@ impl TestImpl for Ptr { (*(*(*self).upgrade().deref()).x.borrow_mut()) = ((*x.borrow()) + (*y.borrow())); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/poll.rs b/tests/unit/out/refcount/poll.rs index acf0a506e..6878ee8f3 100644 --- a/tests/unit/out/refcount/poll.rs +++ b/tests/unit/out/refcount/poll.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -129,3 +130,4 @@ fn main_0() -> i32 { assert!((((FdRegistry::close((*fds.borrow())[(1) as usize]) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/polymorphism.rs b/tests/unit/out/refcount/polymorphism.rs index 6e2b6cf9d..ecceb0753 100644 --- a/tests/unit/out/refcount/polymorphism.rs +++ b/tests/unit/out/refcount/polymorphism.rs @@ -56,6 +56,7 @@ impl ByteRepr for Cat { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -82,3 +83,4 @@ impl CatImpl for Ptr { return true; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/printfs.rs b/tests/unit/out/refcount/printfs.rs index 704eb21dc..2276ea056 100644 --- a/tests/unit/out/refcount/printfs.rs +++ b/tests/unit/out/refcount/printfs.rs @@ -20,6 +20,7 @@ pub fn fn2_1(v: Ptr>) -> Ptr> { return (v).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -57,3 +58,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/prvalue-as-lvalue.rs b/tests/unit/out/refcount/prvalue-as-lvalue.rs index 260d7b718..ea3fd3645 100644 --- a/tests/unit/out/refcount/prvalue-as-lvalue.rs +++ b/tests/unit/out/refcount/prvalue-as-lvalue.rs @@ -10,6 +10,7 @@ pub fn foo_0(a: Ptr) -> Ptr { return (a).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { assert!(((b.read()) == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/ptr2ptr.rs b/tests/unit/out/refcount/ptr2ptr.rs index ceb5378b4..3b7da4388 100644 --- a/tests/unit/out/refcount/ptr2ptr.rs +++ b/tests/unit/out/refcount/ptr2ptr.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -23,3 +24,4 @@ fn main_0() -> i32 { (*out.borrow_mut()) *= (*x.borrow()); return (*out.borrow()); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/ptr_cast_init.rs b/tests/unit/out/refcount/ptr_cast_init.rs index 7e0042e44..3bad3d299 100644 --- a/tests/unit/out/refcount/ptr_cast_init.rs +++ b/tests/unit/out/refcount/ptr_cast_init.rs @@ -59,6 +59,7 @@ impl ByteRepr for view { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -101,3 +102,4 @@ fn main_0() -> i32 { assert!(((((*sel.borrow()).is_null()) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/ptr_to_incomplete_struct.rs b/tests/unit/out/refcount/ptr_to_incomplete_struct.rs index 342a9937a..2db5a1134 100644 --- a/tests/unit/out/refcount/ptr_to_incomplete_struct.rs +++ b/tests/unit/out/refcount/ptr_to_incomplete_struct.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -22,3 +23,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 983b3dc46..276c7505c 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -191,6 +191,7 @@ pub fn self_ref_push_6(comps: Ptr>) { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -329,3 +330,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pwd.rs b/tests/unit/out/refcount/pwd.rs index 38af3b897..406bdfdd8 100644 --- a/tests/unit/out/refcount/pwd.rs +++ b/tests/unit/out/refcount/pwd.rs @@ -220,6 +220,7 @@ pub fn test_getpwuid_r_erange_3() { assert!(((((*result.borrow()).is_null()) as i32) != 0)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -229,3 +230,4 @@ fn main_0() -> i32 { ({ test_getpwuid_r_erange_3() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/qsort_bsearch.rs b/tests/unit/out/refcount/qsort_bsearch.rs index d53ecb1d8..e0f9a3bb5 100644 --- a/tests/unit/out/refcount/qsort_bsearch.rs +++ b/tests/unit/out/refcount/qsort_bsearch.rs @@ -18,6 +18,7 @@ pub fn cmp_int_0(a: AnyPtr, b: AnyPtr) -> i32 { return ((((*x.borrow()) > (*y.borrow())) as i32) - (((*x.borrow()) < (*y.borrow())) as i32)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -125,3 +126,4 @@ fn main_0() -> i32 { assert!(((((*miss.borrow()).is_null()) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index ceb939731..e81f828cd 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -82,6 +82,7 @@ pub fn foo_1(x1: i32, x2: Ptr, x3: Ptr, p2: Ptr, p3: Ptr) let p3: Value> = Rc::new(RefCell::new(p3)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -326,3 +327,4 @@ impl PairImpl for Ptr { return ((*(*self).upgrade().deref()).x.as_pointer()); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/rebind.rs b/tests/unit/out/refcount/rebind.rs index 35edf0344..229b5d74d 100644 --- a/tests/unit/out/refcount/rebind.rs +++ b/tests/unit/out/refcount/rebind.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { assert!(((*x.borrow()) == 10)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/redundant_copy_in_conversion.rs b/tests/unit/out/refcount/redundant_copy_in_conversion.rs index ea7213a93..36078ce7f 100644 --- a/tests/unit/out/refcount/redundant_copy_in_conversion.rs +++ b/tests/unit/out/refcount/redundant_copy_in_conversion.rs @@ -16,6 +16,7 @@ pub fn sink_0(it: RefcountMapIter) -> i32 { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -49,3 +50,4 @@ fn main_0() -> i32 { assert!(((*r.borrow()) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/ref_calls.rs b/tests/unit/out/refcount/ref_calls.rs index 34ce94dc4..d2404fe8b 100644 --- a/tests/unit/out/refcount/ref_calls.rs +++ b/tests/unit/out/refcount/ref_calls.rs @@ -13,6 +13,7 @@ pub fn foo_1(x: Ptr) -> Ptr { return (x).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -31,3 +32,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reference_wrapper.rs b/tests/unit/out/refcount/reference_wrapper.rs index b6850a53b..0def29322 100644 --- a/tests/unit/out/refcount/reference_wrapper.rs +++ b/tests/unit/out/refcount/reference_wrapper.rs @@ -47,6 +47,7 @@ pub fn read_1(ref_: Ptr) -> i32 { return (r.read()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -93,3 +94,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/references.rs b/tests/unit/out/refcount/references.rs index ad31326eb..61764d3ae 100644 --- a/tests/unit/out/refcount/references.rs +++ b/tests/unit/out/refcount/references.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { assert!(((*x.borrow()) == 5)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/references2.rs b/tests/unit/out/refcount/references2.rs index d7b1e5272..277ff7aa0 100644 --- a/tests/unit/out/refcount/references2.rs +++ b/tests/unit/out/refcount/references2.rs @@ -11,6 +11,7 @@ pub fn change_0(p: Ptr>>) { ((p).clone() as Ptr>>).write((*q.borrow_mut()).take()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { assert!(((*(*a.borrow()).as_ref().unwrap().borrow()) == 7)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/refs_as_args.rs b/tests/unit/out/refcount/refs_as_args.rs index cf1416c08..1e2b439a8 100644 --- a/tests/unit/out/refcount/refs_as_args.rs +++ b/tests/unit/out/refcount/refs_as_args.rs @@ -43,6 +43,7 @@ pub fn more_refs_0(x1: i32, x2: i32, r1: Ptr, r2: Ptr) { r1.write(__rhs); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -52,3 +53,4 @@ fn main_0() -> i32 { assert!((((*x1.borrow()) + (*x2.borrow())) == 21)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast.rs b/tests/unit/out/refcount/reinterpret_cast.rs index 6f3019872..7a07f2534 100644 --- a/tests/unit/out/refcount/reinterpret_cast.rs +++ b/tests/unit/out/refcount/reinterpret_cast.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -25,3 +26,4 @@ fn main_0() -> i32 { assert!(((((*arr16.borrow()).offset((1) as isize).read()) as i32) == 1027)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_aliased.rs b/tests/unit/out/refcount/reinterpret_cast_aliased.rs index 30bc28362..03b14219e 100644 --- a/tests/unit/out/refcount/reinterpret_cast_aliased.rs +++ b/tests/unit/out/refcount/reinterpret_cast_aliased.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -23,3 +24,4 @@ fn main_0() -> i32 { assert!(((*val.borrow()) == 18441921396093008810_u64)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_array_write.rs b/tests/unit/out/refcount/reinterpret_cast_array_write.rs index dd0dbec7a..fc093a205 100644 --- a/tests/unit/out/refcount/reinterpret_cast_array_write.rs +++ b/tests/unit/out/refcount/reinterpret_cast_array_write.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -32,3 +33,4 @@ fn main_0() -> i32 { assert!((((*arr.borrow())[(3) as usize] as i32) == 4)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_chain.rs b/tests/unit/out/refcount/reinterpret_cast_chain.rs index 4f8b446da..f444c9f06 100644 --- a/tests/unit/out/refcount/reinterpret_cast_chain.rs +++ b/tests/unit/out/refcount/reinterpret_cast_chain.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -32,3 +33,4 @@ fn main_0() -> i32 { assert!(((((*words.borrow()).offset((3) as isize).read()) as i32) == 65518)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_double.rs b/tests/unit/out/refcount/reinterpret_cast_double.rs index d50ca3764..86ba3fb57 100644 --- a/tests/unit/out/refcount/reinterpret_cast_double.rs +++ b/tests/unit/out/refcount/reinterpret_cast_double.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -17,3 +18,4 @@ fn main_0() -> i32 { assert!(((*d.borrow()) > 3.14E+0) && ((*d.borrow()) < 3.15E+0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_empty_vec.rs b/tests/unit/out/refcount/reinterpret_cast_empty_vec.rs index 50fa67ad2..7805b2765 100644 --- a/tests/unit/out/refcount/reinterpret_cast_empty_vec.rs +++ b/tests/unit/out/refcount/reinterpret_cast_empty_vec.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { )); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_float.rs b/tests/unit/out/refcount/reinterpret_cast_float.rs index 9aa0c7396..d60ad03c5 100644 --- a/tests/unit/out/refcount/reinterpret_cast_float.rs +++ b/tests/unit/out/refcount/reinterpret_cast_float.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -17,3 +18,4 @@ fn main_0() -> i32 { assert!(((*f.borrow()) == 2.0E+0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_i16_u16.rs b/tests/unit/out/refcount/reinterpret_cast_i16_u16.rs index 24ba1ba24..9ed541425 100644 --- a/tests/unit/out/refcount/reinterpret_cast_i16_u16.rs +++ b/tests/unit/out/refcount/reinterpret_cast_i16_u16.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -25,3 +26,4 @@ fn main_0() -> i32 { assert!((((*vals.borrow())[(0) as usize] as i32) == 42)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_identity.rs b/tests/unit/out/refcount/reinterpret_cast_identity.rs index 1d5698d86..56ca47ef8 100644 --- a/tests/unit/out/refcount/reinterpret_cast_identity.rs +++ b/tests/unit/out/refcount/reinterpret_cast_identity.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -30,3 +31,4 @@ fn main_0() -> i32 { assert!((((*back2.borrow()).read()) == 42_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_iterate.rs b/tests/unit/out/refcount/reinterpret_cast_iterate.rs index 8e14bd3f2..cd518ef9c 100644 --- a/tests/unit/out/refcount/reinterpret_cast_iterate.rs +++ b/tests/unit/out/refcount/reinterpret_cast_iterate.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -27,3 +28,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_large_array.rs b/tests/unit/out/refcount/reinterpret_cast_large_array.rs index 29167abcd..acdb561a2 100644 --- a/tests/unit/out/refcount/reinterpret_cast_large_array.rs +++ b/tests/unit/out/refcount/reinterpret_cast_large_array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { (*arr.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_new.rs b/tests/unit/out/refcount/reinterpret_cast_new.rs index c02d0a611..58499340e 100644 --- a/tests/unit/out/refcount/reinterpret_cast_new.rs +++ b/tests/unit/out/refcount/reinterpret_cast_new.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -21,3 +22,4 @@ fn main_0() -> i32 { (*p.borrow()).delete(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_new_array.rs b/tests/unit/out/refcount/reinterpret_cast_new_array.rs index 825f30884..28e70dc5e 100644 --- a/tests/unit/out/refcount/reinterpret_cast_new_array.rs +++ b/tests/unit/out/refcount/reinterpret_cast_new_array.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ fn main_0() -> i32 { (*arr.borrow()).delete_array(); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_oob_read.rs b/tests/unit/out/refcount/reinterpret_cast_oob_read.rs index 9d8056914..816e5058c 100644 --- a/tests/unit/out/refcount/reinterpret_cast_oob_read.rs +++ b/tests/unit/out/refcount/reinterpret_cast_oob_read.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -18,3 +19,4 @@ fn main_0() -> i32 { &(*x.borrow_mut()); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_oob_write.rs b/tests/unit/out/refcount/reinterpret_cast_oob_write.rs index d58992858..3b79e69d4 100644 --- a/tests/unit/out/refcount/reinterpret_cast_oob_write.rs +++ b/tests/unit/out/refcount/reinterpret_cast_oob_write.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -15,3 +16,4 @@ fn main_0() -> i32 { (*bytes.borrow()).offset((4) as isize).write(255_u8); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_partial_overlap.rs b/tests/unit/out/refcount/reinterpret_cast_partial_overlap.rs index 793bf41e7..5eeb059dd 100644 --- a/tests/unit/out/refcount/reinterpret_cast_partial_overlap.rs +++ b/tests/unit/out/refcount/reinterpret_cast_partial_overlap.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -22,3 +23,4 @@ fn main_0() -> i32 { assert!(((*arr.borrow())[(1) as usize] == 134678186_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_roundtrip.rs b/tests/unit/out/refcount/reinterpret_cast_roundtrip.rs index fcaf3c196..8ba41e6a6 100644 --- a/tests/unit/out/refcount/reinterpret_cast_roundtrip.rs +++ b/tests/unit/out/refcount/reinterpret_cast_roundtrip.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -25,3 +26,4 @@ fn main_0() -> i32 { assert!((((*as_int.borrow()).read()) == 67305985)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_same_type.rs b/tests/unit/out/refcount/reinterpret_cast_same_type.rs index 71ef7e1fa..9d699ac86 100644 --- a/tests/unit/out/refcount/reinterpret_cast_same_type.rs +++ b/tests/unit/out/refcount/reinterpret_cast_same_type.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -22,3 +23,4 @@ fn main_0() -> i32 { assert!((((*arr.borrow())[(2) as usize] as i32) == 99)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_signed.rs b/tests/unit/out/refcount/reinterpret_cast_signed.rs index b8ebc6d07..d6e52c5c4 100644 --- a/tests/unit/out/refcount/reinterpret_cast_signed.rs +++ b/tests/unit/out/refcount/reinterpret_cast_signed.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -24,3 +25,4 @@ fn main_0() -> i32 { assert!(((((*quarters.borrow()).offset((3) as isize).read()) as i32) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_string.rs b/tests/unit/out/refcount/reinterpret_cast_string.rs index 3dfd8521d..4e0a6fe98 100644 --- a/tests/unit/out/refcount/reinterpret_cast_string.rs +++ b/tests/unit/out/refcount/reinterpret_cast_string.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { assert!(((((*bytes.borrow()).offset((4) as isize).read()) as i32) == 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct.rs index 66b368154..f0263990e 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -37,6 +37,7 @@ impl ByteRepr for Point { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -50,3 +51,4 @@ fn main_0() -> i32 { assert!(((((*bytes.borrow()).offset((7) as isize).read()) as i32) == 8)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs index c85ca78d9..0673e8555 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs @@ -67,6 +67,7 @@ impl ByteRepr for Pair { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -82,3 +83,4 @@ fn main_0() -> i32 { assert!(((*(*pt.borrow()).x.borrow()) == 42_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_u32_from_u8.rs b/tests/unit/out/refcount/reinterpret_cast_u32_from_u8.rs index 4101a4e0a..c0b757606 100644 --- a/tests/unit/out/refcount/reinterpret_cast_u32_from_u8.rs +++ b/tests/unit/out/refcount/reinterpret_cast_u32_from_u8.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { assert!((((*dwords.borrow()).offset((1) as isize).read()) == 2427178479_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_undersize.rs b/tests/unit/out/refcount/reinterpret_cast_undersize.rs index 39e443ba6..a0f505089 100644 --- a/tests/unit/out/refcount/reinterpret_cast_undersize.rs +++ b/tests/unit/out/refcount/reinterpret_cast_undersize.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -16,3 +17,4 @@ fn main_0() -> i32 { &(*val.borrow_mut()); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_vec_write.rs b/tests/unit/out/refcount/reinterpret_cast_vec_write.rs index df915ca9b..7165f04bc 100644 --- a/tests/unit/out/refcount/reinterpret_cast_vec_write.rs +++ b/tests/unit/out/refcount/reinterpret_cast_vec_write.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { assert!((((vec_.as_pointer() as Ptr).offset(1_usize).read()) == 134678271_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reinterpret_cast_zero_init.rs b/tests/unit/out/refcount/reinterpret_cast_zero_init.rs index c4811a12e..5d27a8cfb 100644 --- a/tests/unit/out/refcount/reinterpret_cast_zero_init.rs +++ b/tests/unit/out/refcount/reinterpret_cast_zero_init.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { assert!(((*val.borrow()) == 3735928559_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/reserved_keywords.rs b/tests/unit/out/refcount/reserved_keywords.rs index 9d7720b94..e8feeecec 100644 --- a/tests/unit/out/refcount/reserved_keywords.rs +++ b/tests/unit/out/refcount/reserved_keywords.rs @@ -263,6 +263,7 @@ pub fn foo_0( return 0; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -351,3 +352,4 @@ fn main_0() -> i32 { ) }); } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/ret_rvalue_ref.rs b/tests/unit/out/refcount/ret_rvalue_ref.rs index 1c587c3cd..fd0d71d8a 100644 --- a/tests/unit/out/refcount/ret_rvalue_ref.rs +++ b/tests/unit/out/refcount/ret_rvalue_ref.rs @@ -10,6 +10,7 @@ pub fn foo_0(v: Ptr) -> i32 { return (v.read()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/rule_of_five.rs b/tests/unit/out/refcount/rule_of_five.rs index 64efc9467..6140a9ec6 100644 --- a/tests/unit/out/refcount/rule_of_five.rs +++ b/tests/unit/out/refcount/rule_of_five.rs @@ -123,6 +123,7 @@ pub fn make_3(size: i32) -> Buffer { return Buffer::Buffer_pmutBuffer({ b.as_pointer() }); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -224,3 +225,8 @@ impl BufferImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() { + let _ = alive_0.with(|_| ()); + let _ = copies_1.with(|_| ()); + let _ = moves_2.with(|_| ()); +} diff --git a/tests/unit/out/refcount/rule_of_three.rs b/tests/unit/out/refcount/rule_of_three.rs index 982f72865..e703ec8d3 100644 --- a/tests/unit/out/refcount/rule_of_three.rs +++ b/tests/unit/out/refcount/rule_of_three.rs @@ -106,6 +106,7 @@ pub fn sum_2(b: Ptr) -> i32 { return (*s.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -186,3 +187,7 @@ impl BufferImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() { + let _ = alive_0.with(|_| ()); + let _ = copies_1.with(|_| ()); +} diff --git a/tests/unit/out/refcount/rvalue_ref_general.rs b/tests/unit/out/refcount/rvalue_ref_general.rs index 4673c8a1b..7a4a42f02 100644 --- a/tests/unit/out/refcount/rvalue_ref_general.rs +++ b/tests/unit/out/refcount/rvalue_ref_general.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -56,3 +57,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/rvalue_ref_global.rs b/tests/unit/out/refcount/rvalue_ref_global.rs index ed7a77f86..f2739da47 100644 --- a/tests/unit/out/refcount/rvalue_ref_global.rs +++ b/tests/unit/out/refcount/rvalue_ref_global.rs @@ -11,9 +11,13 @@ thread_local!( pub static g_0: Ptr = __tmp_0.with(Value::as_pointer); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!(((g_0.with(Ptr::clone).read()) == 5)); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = g_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/rvalue_ref_goto.rs b/tests/unit/out/refcount/rvalue_ref_goto.rs index 88ef0ac86..ab483dd4f 100644 --- a/tests/unit/out/refcount/rvalue_ref_goto.rs +++ b/tests/unit/out/refcount/rvalue_ref_goto.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -24,3 +25,4 @@ fn main_0() -> i32 { }); panic!("ub: non-void function does not return a value") } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/rvalue_struct.rs b/tests/unit/out/refcount/rvalue_struct.rs index 9ce77544c..e00a7c6cb 100644 --- a/tests/unit/out/refcount/rvalue_struct.rs +++ b/tests/unit/out/refcount/rvalue_struct.rs @@ -49,6 +49,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -58,3 +59,4 @@ fn main_0() -> i32 { assert!(((*(*s2.upgrade().deref()).b.borrow()) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs index 2ef9141a7..7d9d73f41 100644 --- a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs @@ -16,6 +16,7 @@ pub fn destroy_2(p: Ptr) { let p: Value> = Rc::new(RefCell::new(p)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -31,3 +32,4 @@ fn main_0() -> i32 { assert!(((*x.borrow()) == 5)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/select.rs b/tests/unit/out/refcount/select.rs index 732d95175..0bd55094d 100644 --- a/tests/unit/out/refcount/select.rs +++ b/tests/unit/out/refcount/select.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -322,3 +323,4 @@ fn main_0() -> i32 { assert!((((FdRegistry::close((*fds.borrow())[(1) as usize]) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/simple_function.rs b/tests/unit/out/refcount/simple_function.rs index 0a565f824..f5a9267aa 100644 --- a/tests/unit/out/refcount/simple_function.rs +++ b/tests/unit/out/refcount/simple_function.rs @@ -10,6 +10,7 @@ pub fn foo_0() -> i32 { return 0; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -18,3 +19,4 @@ fn main_0() -> i32 { assert!((((*x.borrow()) + (*y.borrow())) == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/simple_index.rs b/tests/unit/out/refcount/simple_index.rs index c8a2e5071..fa06fcad0 100644 --- a/tests/unit/out/refcount/simple_index.rs +++ b/tests/unit/out/refcount/simple_index.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/size_t_ssize_t.rs b/tests/unit/out/refcount/size_t_ssize_t.rs index b9e140f73..cabc398b0 100644 --- a/tests/unit/out/refcount/size_t_ssize_t.rs +++ b/tests/unit/out/refcount/size_t_ssize_t.rs @@ -21,6 +21,7 @@ pub fn sub_signed_2(a: isize, b: isize) -> isize { return ((*a.borrow()) - (*b.borrow())); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -223,3 +224,4 @@ fn main_0() -> i32 { assert!(((((*n.borrow()).wrapping_rem(7_usize)) as i32) == 1)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/snprintf.rs b/tests/unit/out/refcount/snprintf.rs index 70b92fcec..e2aecd64f 100644 --- a/tests/unit/out/refcount/snprintf.rs +++ b/tests/unit/out/refcount/snprintf.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -429,3 +430,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/socket_listen.rs b/tests/unit/out/refcount/socket_listen.rs index 1af600fa8..7b76aa6b2 100644 --- a/tests/unit/out/refcount/socket_listen.rs +++ b/tests/unit/out/refcount/socket_listen.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -59,3 +60,4 @@ fn main_0() -> i32 { assert!((((FdRegistry::close((*s.borrow())) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/socket_open_close.rs b/tests/unit/out/refcount/socket_open_close.rs index 7cb8a701d..ee647233e 100644 --- a/tests/unit/out/refcount/socket_open_close.rs +++ b/tests/unit/out/refcount/socket_open_close.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -41,3 +42,4 @@ fn main_0() -> i32 { assert!((((FdRegistry::close((*s.borrow())) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/socket_transparent_union.rs b/tests/unit/out/refcount/socket_transparent_union.rs index 8ff1ea8c4..4a798bc73 100644 --- a/tests/unit/out/refcount/socket_transparent_union.rs +++ b/tests/unit/out/refcount/socket_transparent_union.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -53,3 +54,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/socket_type_constants.rs b/tests/unit/out/refcount/socket_type_constants.rs index 605f0ca03..f0783e7b5 100644 --- a/tests/unit/out/refcount/socket_type_constants.rs +++ b/tests/unit/out/refcount/socket_type_constants.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -14,3 +15,4 @@ fn main_0() -> i32 { assert!((((libc::SOCK_DGRAM == 2) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/sockopt.rs b/tests/unit/out/refcount/sockopt.rs index 1afb88faa..4ae831ea7 100644 --- a/tests/unit/out/refcount/sockopt.rs +++ b/tests/unit/out/refcount/sockopt.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -92,3 +93,4 @@ fn main_0() -> i32 { assert!((((FdRegistry::close((*s.borrow())) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/sort.rs b/tests/unit/out/refcount/sort.rs index 71368aec7..eb5bce489 100644 --- a/tests/unit/out/refcount/sort.rs +++ b/tests/unit/out/refcount/sort.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -36,3 +37,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/split_binop_aliased_borrows.rs b/tests/unit/out/refcount/split_binop_aliased_borrows.rs index 517116b90..8879da974 100644 --- a/tests/unit/out/refcount/split_binop_aliased_borrows.rs +++ b/tests/unit/out/refcount/split_binop_aliased_borrows.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -18,3 +19,4 @@ fn main_0() -> i32 { assert!((((v.as_pointer() as Ptr).offset(0_usize).read()) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/stable_sort.rs b/tests/unit/out/refcount/stable_sort.rs index 784fbf002..5ed2d31df 100644 --- a/tests/unit/out/refcount/stable_sort.rs +++ b/tests/unit/out/refcount/stable_sort.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -29,3 +30,4 @@ fn main_0() -> i32 { }; return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/static_function_vars_same_name.rs b/tests/unit/out/refcount/static_function_vars_same_name.rs index 6f10d84a2..752eab24a 100644 --- a/tests/unit/out/refcount/static_function_vars_same_name.rs +++ b/tests/unit/out/refcount/static_function_vars_same_name.rs @@ -19,6 +19,7 @@ pub fn b_2() -> i32 { return (*i_3.with(Value::clone).borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { assert!((({ b_2() }) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index e023daeee..395d3227b 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -27,9 +27,11 @@ pub fn foo_0() -> i32 { + (*static_i_1.with(Value::clone).borrow())); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((((({ foo_0() }) + ({ foo_0() })) + ({ foo_0() })) == 15)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/static_shadow.rs b/tests/unit/out/refcount/static_shadow.rs index 9a4ee6ef6..518529ff6 100644 --- a/tests/unit/out/refcount/static_shadow.rs +++ b/tests/unit/out/refcount/static_shadow.rs @@ -21,6 +21,7 @@ pub fn read_global_3() -> i32 { return (*value_0.with(Value::clone).borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -29,3 +30,6 @@ fn main_0() -> i32 { assert!((((({ read_global_3() }) == 5) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = value_0.with(|_| ()); +} diff --git a/tests/unit/out/refcount/static_var_in_class.rs b/tests/unit/out/refcount/static_var_in_class.rs index 5b163fa79..7f07589f9 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -49,6 +49,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -65,3 +66,7 @@ impl CImpl for Ptr { return (*inner_const_0.with(Value::clone).borrow()); } } +pub fn __cpp2rust_init_globals() { + let _ = inner_const_0.with(|_| ()); + let _ = inner_const_1.with(|_| ()); +} diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index 63e9fea69..1a8322c73 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ fn main_0() -> i32 { }; return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/stdcopy_ostream.rs b/tests/unit/out/refcount/stdcopy_ostream.rs index 408f521fa..e34142521 100644 --- a/tests/unit/out/refcount/stdcopy_ostream.rs +++ b/tests/unit/out/refcount/stdcopy_ostream.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { }; return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/stdio.rs b/tests/unit/out/refcount/stdio.rs index 33c19da58..a30dc3dcf 100644 --- a/tests/unit/out/refcount/stdio.rs +++ b/tests/unit/out/refcount/stdio.rs @@ -140,6 +140,7 @@ pub fn test_fileno_3() { ); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -149,3 +150,4 @@ fn main_0() -> i32 { ({ test_fileno_3() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/stdio_nofd.rs b/tests/unit/out/refcount/stdio_nofd.rs index 57753ab75..b5dd9a2b8 100644 --- a/tests/unit/out/refcount/stdio_nofd.rs +++ b/tests/unit/out/refcount/stdio_nofd.rs @@ -710,6 +710,7 @@ pub fn test_setvbuf_6() { ); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -722,3 +723,4 @@ fn main_0() -> i32 { ({ test_setvbuf_6() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/stdmin_fpoint.rs b/tests/unit/out/refcount/stdmin_fpoint.rs index cb59ac83a..247654a03 100644 --- a/tests/unit/out/refcount/stdmin_fpoint.rs +++ b/tests/unit/out/refcount/stdmin_fpoint.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { }; return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/stmt_expr.rs b/tests/unit/out/refcount/stmt_expr.rs index c7a3bda53..58716aa06 100644 --- a/tests/unit/out/refcount/stmt_expr.rs +++ b/tests/unit/out/refcount/stmt_expr.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -48,3 +49,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/strdup.rs b/tests/unit/out/refcount/strdup.rs index e20d268b5..0b9565304 100644 --- a/tests/unit/out/refcount/strdup.rs +++ b/tests/unit/out/refcount/strdup.rs @@ -31,6 +31,7 @@ impl ByteRepr for record { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -158,3 +159,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string.rs b/tests/unit/out/refcount/string.rs index 02d72b7e6..a3055f1f1 100644 --- a/tests/unit/out/refcount/string.rs +++ b/tests/unit/out/refcount/string.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -490,3 +491,4 @@ fn main_0() -> i32 { assert!(((*t4.borrow()).wrapping_add(((*s5.borrow()).len() - 1)) == 139_usize)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string2.rs b/tests/unit/out/refcount/string2.rs index d89e5ea08..d44276d44 100644 --- a/tests/unit/out/refcount/string2.rs +++ b/tests/unit/out/refcount/string2.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -32,3 +33,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_escape.rs b/tests/unit/out/refcount/string_escape.rs index 130fdce85..98f660a91 100644 --- a/tests/unit/out/refcount/string_escape.rs +++ b/tests/unit/out/refcount/string_escape.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -71,3 +72,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_h.rs b/tests/unit/out/refcount/string_h.rs index ca2653f8d..849a0da6d 100644 --- a/tests/unit/out/refcount/string_h.rs +++ b/tests/unit/out/refcount/string_h.rs @@ -965,6 +965,7 @@ pub fn test_strcasecmp_14() { ); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -985,3 +986,4 @@ fn main_0() -> i32 { ({ test_strcasecmp_14() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_literal_interior_null.rs b/tests/unit/out/refcount/string_literal_interior_null.rs index 4df8ad389..ee01e33c5 100644 --- a/tests/unit/out/refcount/string_literal_interior_null.rs +++ b/tests/unit/out/refcount/string_literal_interior_null.rs @@ -22,6 +22,7 @@ thread_local!( Rc::new(RefCell::new(Ptr::from_string_literal(b"\x01\0"))); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -42,3 +43,6 @@ fn main_0() -> i32 { assert!(((*d.borrow()) == (('b' as u8) as i32))); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = g_packet_1.with(|_| ()); +} diff --git a/tests/unit/out/refcount/string_literal_ptr_init.rs b/tests/unit/out/refcount/string_literal_ptr_init.rs index c79e6a2b5..728a3a018 100644 --- a/tests/unit/out/refcount/string_literal_ptr_init.rs +++ b/tests/unit/out/refcount/string_literal_ptr_init.rs @@ -65,6 +65,7 @@ thread_local!( ]))); ); pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -171,3 +172,6 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() { + let _ = table_1.with(|_| ()); +} diff --git a/tests/unit/out/refcount/string_literals.rs b/tests/unit/out/refcount/string_literals.rs index d57498a6d..60a91e3e9 100644 --- a/tests/unit/out/refcount/string_literals.rs +++ b/tests/unit/out/refcount/string_literals.rs @@ -13,6 +13,7 @@ pub fn foo_const_1(str: Ptr) { let str: Value> = Rc::new(RefCell::new(str)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -42,3 +43,4 @@ fn main_0() -> i32 { ({ foo_const_1((inited_through_init_list.as_pointer() as Ptr)) }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_literals_c.rs b/tests/unit/out/refcount/string_literals_c.rs index bdac6f4e7..799970b24 100644 --- a/tests/unit/out/refcount/string_literals_c.rs +++ b/tests/unit/out/refcount/string_literals_c.rs @@ -13,6 +13,7 @@ pub fn foo_const_1(str: Ptr) { let str: Value> = Rc::new(RefCell::new(str)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -55,3 +56,4 @@ fn main_0() -> i32 { ({ foo_const_1((inited_through_init_list.as_pointer() as Ptr)) }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_literals_concat.rs b/tests/unit/out/refcount/string_literals_concat.rs index 07056ef6e..4c19974d0 100644 --- a/tests/unit/out/refcount/string_literals_concat.rs +++ b/tests/unit/out/refcount/string_literals_concat.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_literals_concat_c.rs b/tests/unit/out/refcount/string_literals_concat_c.rs index 5fa3aa273..9eb38e846 100644 --- a/tests/unit/out/refcount/string_literals_concat_c.rs +++ b/tests/unit/out/refcount/string_literals_concat_c.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -44,3 +45,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_literals_return.rs b/tests/unit/out/refcount/string_literals_return.rs index 8b535c143..feabaa41a 100644 --- a/tests/unit/out/refcount/string_literals_return.rs +++ b/tests/unit/out/refcount/string_literals_return.rs @@ -20,6 +20,7 @@ pub fn get_branch_2(x: i32) -> Ptr { return Ptr::from_string_literal(b"non-positive"); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -39,3 +40,4 @@ fn main_0() -> i32 { assert!(((((*d.borrow()).offset((12) as isize).read()) as i32) == (('\0' as u8) as i32))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_literals_return_c.rs b/tests/unit/out/refcount/string_literals_return_c.rs index b3f1ad6de..22a10fff6 100644 --- a/tests/unit/out/refcount/string_literals_return_c.rs +++ b/tests/unit/out/refcount/string_literals_return_c.rs @@ -20,6 +20,7 @@ pub fn get_branch_2(x: i32) -> Ptr { return Ptr::from_string_literal(b"non-positive"); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -49,3 +50,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_literals_sized.rs b/tests/unit/out/refcount/string_literals_sized.rs index 1c1d67dfc..ed8d36372 100644 --- a/tests/unit/out/refcount/string_literals_sized.rs +++ b/tests/unit/out/refcount/string_literals_sized.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -35,3 +36,4 @@ fn main_0() -> i32 { assert!(((::std::mem::size_of::<[u8; 16]>() as usize).wrapping_sub(1_usize) == 15_usize)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string_literals_sized_c.rs b/tests/unit/out/refcount/string_literals_sized_c.rs index 296e8ef84..18623cceb 100644 --- a/tests/unit/out/refcount/string_literals_sized_c.rs +++ b/tests/unit/out/refcount/string_literals_sized_c.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -41,3 +42,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/strlen.rs b/tests/unit/out/refcount/strlen.rs index 0d9667082..eafd74f17 100644 --- a/tests/unit/out/refcount/strlen.rs +++ b/tests/unit/out/refcount/strlen.rs @@ -15,6 +15,7 @@ pub fn strlen_0(ptr: Ptr) -> u32 { return (*count.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -29,3 +30,4 @@ fn main_0() -> i32 { assert!((({ strlen_0(((string.as_pointer() as Ptr).offset(0)),) }) == 5_u32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/strlen_diff.rs b/tests/unit/out/refcount/strlen_diff.rs index db9104af9..106bdb078 100644 --- a/tests/unit/out/refcount/strlen_diff.rs +++ b/tests/unit/out/refcount/strlen_diff.rs @@ -15,6 +15,7 @@ pub fn strlen_0(s: Ptr) -> usize { return ((((*s.borrow()).clone() - (*begin.borrow()).clone()) as i64) as usize); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -30,3 +31,4 @@ fn main_0() -> i32 { assert!((({ strlen_0(((s.as_pointer() as Ptr).offset(0)),) }) == 6_usize)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/strlen_rec.rs b/tests/unit/out/refcount/strlen_rec.rs index f95b9643d..d6e1763ce 100644 --- a/tests/unit/out/refcount/strlen_rec.rs +++ b/tests/unit/out/refcount/strlen_rec.rs @@ -16,6 +16,7 @@ pub fn strlen_0(s: Ptr, n: i32) -> i32 { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ fn main_0() -> i32 { assert!((({ strlen_0(((s.as_pointer() as Ptr).offset(0)), 0,) }) == 3)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/struct_ctor.rs b/tests/unit/out/refcount/struct_ctor.rs index a9d9c5c3a..586e10403 100644 --- a/tests/unit/out/refcount/struct_ctor.rs +++ b/tests/unit/out/refcount/struct_ctor.rs @@ -54,6 +54,7 @@ pub fn foo_0(x: Ptr) -> Ptr { return (x).clone(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -79,3 +80,4 @@ impl StructWithCtorImpl for Ptr { return (*(*self).upgrade().deref()).x2_.as_pointer(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/struct_default_ctor.rs b/tests/unit/out/refcount/struct_default_ctor.rs index d87a731e4..6ab4f46b2 100644 --- a/tests/unit/out/refcount/struct_default_ctor.rs +++ b/tests/unit/out/refcount/struct_default_ctor.rs @@ -52,6 +52,7 @@ impl ByteRepr for S { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -60,3 +61,4 @@ fn main_0() -> i32 { assert!((((*(*s.borrow()).b.borrow()) as i32) == (true as i32))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/struct_ptr.rs b/tests/unit/out/refcount/struct_ptr.rs index 0336f8f78..799554b36 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -33,6 +33,7 @@ impl ByteRepr for XX { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -54,3 +55,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/swap.rs b/tests/unit/out/refcount/swap.rs index 0e5384e3d..7e762c1eb 100644 --- a/tests/unit/out/refcount/swap.rs +++ b/tests/unit/out/refcount/swap.rs @@ -27,6 +27,7 @@ pub fn swap_by_ref_2(a: Ptr, b: Ptr) { b.write(__rhs); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -42,3 +43,4 @@ fn main_0() -> i32 { assert!(((*c.borrow()) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/swap_extended.rs b/tests/unit/out/refcount/swap_extended.rs index 8b6469fe1..ec589462b 100644 --- a/tests/unit/out/refcount/swap_extended.rs +++ b/tests/unit/out/refcount/swap_extended.rs @@ -27,6 +27,7 @@ pub fn swap_by_ref_2(a: Ptr, b: Ptr) { b.write(__rhs); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -82,3 +83,4 @@ fn main_0() -> i32 { assert!(((*c.borrow()) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_basic.rs b/tests/unit/out/refcount/switch_basic.rs index 25b60600a..ffd205e93 100644 --- a/tests/unit/out/refcount/switch_basic.rs +++ b/tests/unit/out/refcount/switch_basic.rs @@ -34,6 +34,7 @@ pub fn basic_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -42,3 +43,4 @@ fn main_0() -> i32 { assert!((({ basic_0(99,) }) == 40)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_borrow_in_condition_and_in_body.rs b/tests/unit/out/refcount/switch_borrow_in_condition_and_in_body.rs index e13f444e3..3de6b123a 100644 --- a/tests/unit/out/refcount/switch_borrow_in_condition_and_in_body.rs +++ b/tests/unit/out/refcount/switch_borrow_in_condition_and_in_body.rs @@ -17,6 +17,7 @@ pub fn borrow_in_condition_and_in_body_0(x: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -24,3 +25,4 @@ fn main_0() -> i32 { assert!((({ borrow_in_condition_and_in_body_0(1,) }) == 2)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_case_then_default.rs b/tests/unit/out/refcount/switch_case_then_default.rs index ae6b216a9..a1cdf1699 100644 --- a/tests/unit/out/refcount/switch_case_then_default.rs +++ b/tests/unit/out/refcount/switch_case_then_default.rs @@ -25,6 +25,7 @@ pub fn case_then_default_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { assert!((({ case_then_default_0(99,) }) == 10)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_cases_and_default_stacked.rs b/tests/unit/out/refcount/switch_cases_and_default_stacked.rs index 2f11539a4..6ad7b207c 100644 --- a/tests/unit/out/refcount/switch_cases_and_default_stacked.rs +++ b/tests/unit/out/refcount/switch_cases_and_default_stacked.rs @@ -25,6 +25,7 @@ pub fn cases_and_default_stacked_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -34,3 +35,4 @@ fn main_0() -> i32 { assert!((({ cases_and_default_stacked_0(99,) }) == 42)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_char.rs b/tests/unit/out/refcount/switch_char.rs index 07c03e3b4..a6f6dd257 100644 --- a/tests/unit/out/refcount/switch_char.rs +++ b/tests/unit/out/refcount/switch_char.rs @@ -35,6 +35,7 @@ pub const Color_kRed: Color = 0; pub const Color_kGreen: Color = 1; pub const Color_kBlue: Color = 2; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -45,3 +46,4 @@ fn main_0() -> i32 { assert!((({ switch_char_0(('z' as u8),) }) == 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_complex_cond.rs b/tests/unit/out/refcount/switch_complex_cond.rs index c5143e463..61797a702 100644 --- a/tests/unit/out/refcount/switch_complex_cond.rs +++ b/tests/unit/out/refcount/switch_complex_cond.rs @@ -32,6 +32,7 @@ pub fn switch_complex_cond_0(p: Ptr, bias: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -42,3 +43,4 @@ fn main_0() -> i32 { assert!((({ switch_complex_cond_0((p_val.as_pointer()), 99,) }) == 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_compound_case_body.rs b/tests/unit/out/refcount/switch_compound_case_body.rs index c4a17f1ce..356fe8004 100644 --- a/tests/unit/out/refcount/switch_compound_case_body.rs +++ b/tests/unit/out/refcount/switch_compound_case_body.rs @@ -32,6 +32,7 @@ pub fn compound_case_body_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { assert!((({ compound_case_body_0(9,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_continue_inside_switch.rs b/tests/unit/out/refcount/switch_continue_inside_switch.rs index 068f9658f..d70769cec 100644 --- a/tests/unit/out/refcount/switch_continue_inside_switch.rs +++ b/tests/unit/out/refcount/switch_continue_inside_switch.rs @@ -30,9 +30,11 @@ pub fn continue_inside_switch_0(n: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ continue_inside_switch_0(6,) }) == (((1 + 3) + 5) + (3 * 1000)))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_default_first.rs b/tests/unit/out/refcount/switch_default_first.rs index 57f0ab01e..d2b19c543 100644 --- a/tests/unit/out/refcount/switch_default_first.rs +++ b/tests/unit/out/refcount/switch_default_first.rs @@ -29,6 +29,7 @@ pub fn default_first_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -36,3 +37,4 @@ fn main_0() -> i32 { assert!((({ default_first_0(99,) }) == 7)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_default_middle.rs b/tests/unit/out/refcount/switch_default_middle.rs index 48aee8b7d..f99f280f4 100644 --- a/tests/unit/out/refcount/switch_default_middle.rs +++ b/tests/unit/out/refcount/switch_default_middle.rs @@ -29,6 +29,7 @@ pub fn default_middle_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -37,3 +38,4 @@ fn main_0() -> i32 { assert!((({ default_middle_0(99,) }) == 99)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_default_then_case.rs b/tests/unit/out/refcount/switch_default_then_case.rs index 1eb6cb21c..2e01f0b8e 100644 --- a/tests/unit/out/refcount/switch_default_then_case.rs +++ b/tests/unit/out/refcount/switch_default_then_case.rs @@ -29,6 +29,7 @@ pub fn default_then_case_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -38,3 +39,4 @@ fn main_0() -> i32 { assert!((({ default_then_case_0(99,) }) == 77)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_empty_case_with_break.rs b/tests/unit/out/refcount/switch_empty_case_with_break.rs index a3783ef0a..2a8002af7 100644 --- a/tests/unit/out/refcount/switch_empty_case_with_break.rs +++ b/tests/unit/out/refcount/switch_empty_case_with_break.rs @@ -28,6 +28,7 @@ pub fn empty_case_with_break_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -36,3 +37,4 @@ fn main_0() -> i32 { assert!((({ empty_case_with_break_0(9,) }) == 9)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_empty_switch.rs b/tests/unit/out/refcount/switch_empty_switch.rs index 109d2542f..30c3794f8 100644 --- a/tests/unit/out/refcount/switch_empty_switch.rs +++ b/tests/unit/out/refcount/switch_empty_switch.rs @@ -17,9 +17,11 @@ pub fn empty_switch_0(x: i32) -> i32 { return (*x.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ empty_switch_0(5,) }) == 5)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_enum.rs b/tests/unit/out/refcount/switch_enum.rs index b89cf1cb0..dc317d9bf 100644 --- a/tests/unit/out/refcount/switch_enum.rs +++ b/tests/unit/out/refcount/switch_enum.rs @@ -30,6 +30,7 @@ pub fn switch_enum_0(c: Color) -> i32 { return -1_i32; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -38,3 +39,4 @@ fn main_0() -> i32 { assert!((({ switch_enum_0(Color_kBlue,) }) == 30)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_fallthrough_chain.rs b/tests/unit/out/refcount/switch_fallthrough_chain.rs index fee2cd2d2..cad7c3de0 100644 --- a/tests/unit/out/refcount/switch_fallthrough_chain.rs +++ b/tests/unit/out/refcount/switch_fallthrough_chain.rs @@ -31,6 +31,7 @@ pub fn fallthrough_chain_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -41,3 +42,4 @@ fn main_0() -> i32 { assert!((({ fallthrough_chain_0(99,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_fallthrough_default.rs b/tests/unit/out/refcount/switch_fallthrough_default.rs index 9e819b00d..b438f714a 100644 --- a/tests/unit/out/refcount/switch_fallthrough_default.rs +++ b/tests/unit/out/refcount/switch_fallthrough_default.rs @@ -25,6 +25,7 @@ pub fn fallthrough_default_0(x: i32, flag: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { assert!((({ fallthrough_default_0(99, 0,) }) == 42)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_fallthrough_into_block.rs b/tests/unit/out/refcount/switch_fallthrough_into_block.rs index 86095eb06..5359cb442 100644 --- a/tests/unit/out/refcount/switch_fallthrough_into_block.rs +++ b/tests/unit/out/refcount/switch_fallthrough_into_block.rs @@ -28,6 +28,7 @@ pub fn fallthrough_into_block_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -36,3 +37,4 @@ fn main_0() -> i32 { assert!((({ fallthrough_into_block_0(99,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_fallthrough_one.rs b/tests/unit/out/refcount/switch_fallthrough_one.rs index b4fe92e92..cd7f9620b 100644 --- a/tests/unit/out/refcount/switch_fallthrough_one.rs +++ b/tests/unit/out/refcount/switch_fallthrough_one.rs @@ -25,6 +25,7 @@ pub fn fallthrough_one_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { assert!((({ fallthrough_one_0(99,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_for_in_switch_break.rs b/tests/unit/out/refcount/switch_for_in_switch_break.rs index e255e5893..5c7f2533a 100644 --- a/tests/unit/out/refcount/switch_for_in_switch_break.rs +++ b/tests/unit/out/refcount/switch_for_in_switch_break.rs @@ -33,6 +33,7 @@ pub fn for_in_switch_break_0(n: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { assert!((({ for_in_switch_break_0(99,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_for_in_switch_continue.rs b/tests/unit/out/refcount/switch_for_in_switch_continue.rs index b436be236..e347f746f 100644 --- a/tests/unit/out/refcount/switch_for_in_switch_continue.rs +++ b/tests/unit/out/refcount/switch_for_in_switch_continue.rs @@ -33,6 +33,7 @@ pub fn for_in_switch_continue_0(n: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { assert!((({ for_in_switch_continue_0(99,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_for_switch_for_break.rs b/tests/unit/out/refcount/switch_for_switch_for_break.rs index 87ad0ab02..45262cede 100644 --- a/tests/unit/out/refcount/switch_for_switch_for_break.rs +++ b/tests/unit/out/refcount/switch_for_switch_for_break.rs @@ -37,9 +37,11 @@ pub fn for_switch_for_break_0(n: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ for_switch_for_break_0(3,) }) == 122)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_in_dowhile.rs b/tests/unit/out/refcount/switch_in_dowhile.rs index fb0c62d2f..80e9576ab 100644 --- a/tests/unit/out/refcount/switch_in_dowhile.rs +++ b/tests/unit/out/refcount/switch_in_dowhile.rs @@ -35,6 +35,7 @@ pub fn switch_in_dowhile_0(n: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -42,3 +43,4 @@ fn main_0() -> i32 { assert!((({ switch_in_dowhile_0(3,) }) == ((1 + 10) + 100))); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_in_loop.rs b/tests/unit/out/refcount/switch_in_loop.rs index 1847fa6c7..cdb395cf2 100644 --- a/tests/unit/out/refcount/switch_in_loop.rs +++ b/tests/unit/out/refcount/switch_in_loop.rs @@ -34,9 +34,11 @@ pub fn switch_in_loop_0(n: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ switch_in_loop_0(6,) }) == 72)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_mixed_literal_cases.rs b/tests/unit/out/refcount/switch_mixed_literal_cases.rs index 9d8346dfd..dc5f4a783 100644 --- a/tests/unit/out/refcount/switch_mixed_literal_cases.rs +++ b/tests/unit/out/refcount/switch_mixed_literal_cases.rs @@ -31,6 +31,7 @@ pub fn mixed_literal_cases_0(x: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -41,3 +42,4 @@ fn main_0() -> i32 { assert!((({ mixed_literal_cases_0(7,) }) == 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_mixed_return_break.rs b/tests/unit/out/refcount/switch_mixed_return_break.rs index d05621857..8ae94bb9f 100644 --- a/tests/unit/out/refcount/switch_mixed_return_break.rs +++ b/tests/unit/out/refcount/switch_mixed_return_break.rs @@ -31,6 +31,7 @@ pub fn mixed_return_break_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { assert!((({ mixed_return_break_0(99,) }) == 99)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_nested.rs b/tests/unit/out/refcount/switch_nested.rs index 959be2d91..4ed7d984b 100644 --- a/tests/unit/out/refcount/switch_nested.rs +++ b/tests/unit/out/refcount/switch_nested.rs @@ -47,6 +47,7 @@ pub fn nested_0(a: i32, b: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -56,3 +57,4 @@ fn main_0() -> i32 { assert!((({ nested_0(3, 3,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_no_default.rs b/tests/unit/out/refcount/switch_no_default.rs index a4551fb43..be1d29642 100644 --- a/tests/unit/out/refcount/switch_no_default.rs +++ b/tests/unit/out/refcount/switch_no_default.rs @@ -26,6 +26,7 @@ pub fn no_default_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { assert!((({ no_default_0(42,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_on_assignment.rs b/tests/unit/out/refcount/switch_on_assignment.rs index 96ebd4b2b..3d138e10d 100644 --- a/tests/unit/out/refcount/switch_on_assignment.rs +++ b/tests/unit/out/refcount/switch_on_assignment.rs @@ -33,6 +33,7 @@ pub fn switch_on_assignment_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -41,3 +42,4 @@ fn main_0() -> i32 { assert!((({ switch_on_assignment_0(9,) }) == 10)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_on_call.rs b/tests/unit/out/refcount/switch_on_call.rs index 5fb88e4ce..d43a8794c 100644 --- a/tests/unit/out/refcount/switch_on_call.rs +++ b/tests/unit/out/refcount/switch_on_call.rs @@ -32,6 +32,7 @@ pub fn switch_on_call_1(x: i32) -> i32 { panic!("ub: non-void function does not return a value") } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -41,3 +42,4 @@ fn main_0() -> i32 { assert!((({ switch_on_call_1(99,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_only_default.rs b/tests/unit/out/refcount/switch_only_default.rs index e2a36c861..46772a7f7 100644 --- a/tests/unit/out/refcount/switch_only_default.rs +++ b/tests/unit/out/refcount/switch_only_default.rs @@ -21,9 +21,11 @@ pub fn only_default_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { assert!((({ only_default_0(1,) }) == 42)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_stacked.rs b/tests/unit/out/refcount/switch_stacked.rs index b3f87d6a2..aae336a35 100644 --- a/tests/unit/out/refcount/switch_stacked.rs +++ b/tests/unit/out/refcount/switch_stacked.rs @@ -29,6 +29,7 @@ pub fn stacked_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -38,3 +39,4 @@ fn main_0() -> i32 { assert!((({ stacked_0(9,) }) == 300)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_stacked_block.rs b/tests/unit/out/refcount/switch_stacked_block.rs index 18acfad40..c50d97bcf 100644 --- a/tests/unit/out/refcount/switch_stacked_block.rs +++ b/tests/unit/out/refcount/switch_stacked_block.rs @@ -26,6 +26,7 @@ pub fn stacked_block_0(x: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { assert!((({ stacked_block_0(9,) }) == 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_stacked_with_inner_fallthrough.rs b/tests/unit/out/refcount/switch_stacked_with_inner_fallthrough.rs index e0aa3f15f..00646f7dc 100644 --- a/tests/unit/out/refcount/switch_stacked_with_inner_fallthrough.rs +++ b/tests/unit/out/refcount/switch_stacked_with_inner_fallthrough.rs @@ -25,6 +25,7 @@ pub fn stacked_with_inner_fallthrough_0(x: i32, flag: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { assert!((({ stacked_with_inner_fallthrough_0(99, 0,) }) == 999)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/switch_while_in_switch_break.rs b/tests/unit/out/refcount/switch_while_in_switch_break.rs index 5f2184b29..6374983cd 100644 --- a/tests/unit/out/refcount/switch_while_in_switch_break.rs +++ b/tests/unit/out/refcount/switch_while_in_switch_break.rs @@ -33,6 +33,7 @@ pub fn while_in_switch_break_0(n: i32) -> i32 { return (*r.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { assert!((({ while_in_switch_break_0(99,) }) == -1_i32)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/sys_stat.rs b/tests/unit/out/refcount/sys_stat.rs index 6ca8fe0c0..059caa119 100644 --- a/tests/unit/out/refcount/sys_stat.rs +++ b/tests/unit/out/refcount/sys_stat.rs @@ -119,6 +119,7 @@ pub fn test_fstat_1() { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -126,3 +127,4 @@ fn main_0() -> i32 { ({ test_fstat_1() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/sys_time.rs b/tests/unit/out/refcount/sys_time.rs index 46a0c95a5..fedcc56bc 100644 --- a/tests/unit/out/refcount/sys_time.rs +++ b/tests/unit/out/refcount/sys_time.rs @@ -298,6 +298,7 @@ pub fn test_strftime_5() { ); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -307,3 +308,4 @@ fn main_0() -> i32 { ({ test_strftime_5() }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/tag_vs_identifier_collision.rs b/tests/unit/out/refcount/tag_vs_identifier_collision.rs index 2905b4b63..74eea3b77 100644 --- a/tests/unit/out/refcount/tag_vs_identifier_collision.rs +++ b/tests/unit/out/refcount/tag_vs_identifier_collision.rs @@ -223,6 +223,7 @@ pub fn is_active_0(w: Ptr) -> i32 { == ((widget_enum_MODE_ACTIVE as i32) as u32)) as i32); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -260,3 +261,4 @@ fn main_0() -> i32 { assert!(((((*(*w.borrow()).id.borrow()) == 7) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/template_pack.rs b/tests/unit/out/refcount/template_pack.rs index ce7a2f34b..c12f4c0f8 100644 --- a/tests/unit/out/refcount/template_pack.rs +++ b/tests/unit/out/refcount/template_pack.rs @@ -58,6 +58,7 @@ pub fn sizeof_pack_9(args_0: i32, args_1: i32, args_2: i32, args_3: i32) -> i32 return (4 as i32); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -72,3 +73,4 @@ fn main_0() -> i32 { assert!((({ sizeof_pack_9(1, 2, 3, 4,) }) == 4)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/templates.rs b/tests/unit/out/refcount/templates.rs index 8183d5edc..8c662110d 100644 --- a/tests/unit/out/refcount/templates.rs +++ b/tests/unit/out/refcount/templates.rs @@ -45,6 +45,7 @@ pub fn func_5(x1: f64, x2: i32, x3: f64) -> i32 { return ((((*x1.borrow()) + ((*x2.borrow()) as f64)) + (*x3.borrow())) as i32); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -60,3 +61,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/termios.rs b/tests/unit/out/refcount/termios.rs index edf6a8a57..e3bb7ee4a 100644 --- a/tests/unit/out/refcount/termios.rs +++ b/tests/unit/out/refcount/termios.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -82,3 +83,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/this.rs b/tests/unit/out/refcount/this.rs index a697f4c59..972b68994 100644 --- a/tests/unit/out/refcount/this.rs +++ b/tests/unit/out/refcount/this.rs @@ -117,6 +117,7 @@ impl ByteRepr for D { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -283,3 +284,4 @@ impl SImpl for Ptr { return true; } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index 00fcdf5bb..8f5f1ce8d 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -63,6 +63,7 @@ impl ByteRepr for Outer { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -95,3 +96,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/types.rs b/tests/unit/out/refcount/types.rs index ac07e3f27..bc5a9226e 100644 --- a/tests/unit/out/refcount/types.rs +++ b/tests/unit/out/refcount/types.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -48,3 +49,4 @@ fn main_0() -> i32 { assert!((::default()).is_null()); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unary.rs b/tests/unit/out/refcount/unary.rs index b259a9af0..60558f7ac 100644 --- a/tests/unit/out/refcount/unary.rs +++ b/tests/unit/out/refcount/unary.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { assert!(((((*out.borrow_mut()).postfix_inc() + (*x2.borrow())) + (*x3.borrow())) == 19)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unary_expr_or_type_trait.rs b/tests/unit/out/refcount/unary_expr_or_type_trait.rs index 1183a0e38..cf01eccd2 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -45,6 +45,7 @@ pub fn pack_size_1(args_0: i32, args_1: f64) -> u64 { return ((2 as usize).wrapping_add((2 as usize)) as u64); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -69,3 +70,4 @@ fn main_0() -> i32 { assert!((({ pack_size_1(1, 2.0E+0,) }) == 4_u64)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unconst.rs b/tests/unit/out/refcount/unconst.rs index 8d34694b0..efbf9a80c 100644 --- a/tests/unit/out/refcount/unconst.rs +++ b/tests/unit/out/refcount/unconst.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -22,3 +23,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_addrof_external.rs b/tests/unit/out/refcount/union_addrof_external.rs index 6da731326..5c2e89724 100644 --- a/tests/unit/out/refcount/union_addrof_external.rs +++ b/tests/unit/out/refcount/union_addrof_external.rs @@ -161,6 +161,7 @@ pub fn fill_1(out: AnyPtr, cap: usize) { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -223,3 +224,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_basic.rs b/tests/unit/out/refcount/union_basic.rs index a9bd9e739..6a068b4ec 100644 --- a/tests/unit/out/refcount/union_basic.rs +++ b/tests/unit/out/refcount/union_basic.rs @@ -45,6 +45,7 @@ impl ByteRepr for basic { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -55,3 +56,4 @@ fn main_0() -> i32 { assert!((((*u.borrow()).f().read()) == 3.140000105E+0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_cross_arm_cast.rs b/tests/unit/out/refcount/union_cross_arm_cast.rs index 6732aafd1..7bcd22ef2 100644 --- a/tests/unit/out/refcount/union_cross_arm_cast.rs +++ b/tests/unit/out/refcount/union_cross_arm_cast.rs @@ -167,6 +167,7 @@ impl ByteRepr for Container { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -224,3 +225,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_field_alignment.rs b/tests/unit/out/refcount/union_field_alignment.rs index 54e96ad90..78f6a0af3 100644 --- a/tests/unit/out/refcount/union_field_alignment.rs +++ b/tests/unit/out/refcount/union_field_alignment.rs @@ -73,6 +73,7 @@ impl ByteRepr for node { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -90,3 +91,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_flex_array_member.rs b/tests/unit/out/refcount/union_flex_array_member.rs index 6bf1107e4..cd217169b 100644 --- a/tests/unit/out/refcount/union_flex_array_member.rs +++ b/tests/unit/out/refcount/union_flex_array_member.rs @@ -77,6 +77,7 @@ impl ByteRepr for node { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -143,3 +144,4 @@ fn main_0() -> i32 { libcc2rs::free_refcount(((*n.borrow()).clone() as Ptr).to_any()); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_memset_memcpy.rs b/tests/unit/out/refcount/union_memset_memcpy.rs index d1c758772..89941a561 100644 --- a/tests/unit/out/refcount/union_memset_memcpy.rs +++ b/tests/unit/out/refcount/union_memset_memcpy.rs @@ -158,6 +158,7 @@ impl ByteRepr for Container { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -273,3 +274,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_nested.rs b/tests/unit/out/refcount/union_nested.rs index 124238a8e..53fe44f36 100644 --- a/tests/unit/out/refcount/union_nested.rs +++ b/tests/unit/out/refcount/union_nested.rs @@ -185,6 +185,7 @@ impl ByteRepr for Outer { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -233,3 +234,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_pointer_pun_address.rs b/tests/unit/out/refcount/union_pointer_pun_address.rs index 464f78bd0..24da361b1 100644 --- a/tests/unit/out/refcount/union_pointer_pun_address.rs +++ b/tests/unit/out/refcount/union_pointer_pun_address.rs @@ -59,6 +59,7 @@ impl ByteRepr for node_b { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -115,3 +116,4 @@ impl ByteRepr for anon_0 { } } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs index 3d470727d..da1bf347e 100644 --- a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -55,3 +56,4 @@ impl ByteRepr for anon_0 { } } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_struct_dual_use.rs b/tests/unit/out/refcount/union_struct_dual_use.rs index 27a23ef17..34d05eff0 100644 --- a/tests/unit/out/refcount/union_struct_dual_use.rs +++ b/tests/unit/out/refcount/union_struct_dual_use.rs @@ -104,6 +104,7 @@ impl ByteRepr for Outer { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -148,3 +149,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_tagged_many_arms.rs b/tests/unit/out/refcount/union_tagged_many_arms.rs index e3acc24bc..0a2f0986b 100644 --- a/tests/unit/out/refcount/union_tagged_many_arms.rs +++ b/tests/unit/out/refcount/union_tagged_many_arms.rs @@ -88,6 +88,7 @@ impl ByteRepr for Slot { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -138,3 +139,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_tagged_simple.rs b/tests/unit/out/refcount/union_tagged_simple.rs index aff8f0f9d..48303998b 100644 --- a/tests/unit/out/refcount/union_tagged_simple.rs +++ b/tests/unit/out/refcount/union_tagged_simple.rs @@ -80,6 +80,7 @@ impl ByteRepr for Event { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -109,3 +110,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_tagged_struct_arms.rs b/tests/unit/out/refcount/union_tagged_struct_arms.rs index 4c31211b7..fdb584e3e 100644 --- a/tests/unit/out/refcount/union_tagged_struct_arms.rs +++ b/tests/unit/out/refcount/union_tagged_struct_arms.rs @@ -192,6 +192,7 @@ impl ByteRepr for Branch { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -330,3 +331,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs index 53c01fc08..b0fc1b0d3 100644 --- a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs @@ -117,6 +117,7 @@ pub fn write_count_1(s: Ptr, count: i64) { }; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -144,3 +145,4 @@ fn main_0() -> i32 { assert!((((((*buf16.borrow()) as i32) == 4660) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index b491bf442..fd5adef18 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -292,6 +292,7 @@ pub fn RndStuff_2() { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -332,3 +333,4 @@ impl SafePointerImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_const_deref.rs b/tests/unit/out/refcount/unique_ptr_const_deref.rs index 7aa75e9e7..4f0fa4500 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -50,6 +50,7 @@ pub fn write_val_1(h: Ptr, v: i32) { .borrow_mut()) = (*v.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -70,3 +71,4 @@ impl HolderImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_deref_ops.rs b/tests/unit/out/refcount/unique_ptr_deref_ops.rs index ca18efc53..446fb5f72 100644 --- a/tests/unit/out/refcount/unique_ptr_deref_ops.rs +++ b/tests/unit/out/refcount/unique_ptr_deref_ops.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -21,3 +22,4 @@ fn main_0() -> i32 { assert!(((*sum.borrow()) == 25)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_nested.rs b/tests/unit/out/refcount/unique_ptr_nested.rs index 729267fa2..5fbf491d4 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -65,6 +65,7 @@ impl ByteRepr for Outer { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -112,3 +113,4 @@ impl OuterImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_small.rs b/tests/unit/out/refcount/unique_ptr_small.rs index d22c425cc..8e94698e7 100644 --- a/tests/unit/out/refcount/unique_ptr_small.rs +++ b/tests/unit/out/refcount/unique_ptr_small.rs @@ -11,6 +11,7 @@ pub fn change_0(n: Ptr>>) { ((n).clone() as Ptr>>).write((*m.borrow_mut()).take()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -19,3 +20,4 @@ fn main_0() -> i32 { assert!(((*(*n.borrow()).as_ref().unwrap().borrow()) == 20)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_struct.rs b/tests/unit/out/refcount/unique_ptr_struct.rs index 46bdd37ac..b6d679858 100644 --- a/tests/unit/out/refcount/unique_ptr_struct.rs +++ b/tests/unit/out/refcount/unique_ptr_struct.rs @@ -41,6 +41,7 @@ pub fn sum_0(p: Point) -> i32 { return ((*(*p.borrow()).x.borrow()) + (*(*p.borrow()).y.borrow())); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -59,3 +60,4 @@ fn main_0() -> i32 { assert!(((*s.borrow()) == 30)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unsigned.rs b/tests/unit/out/refcount/unsigned.rs index b067c3972..83b42022f 100644 --- a/tests/unit/out/refcount/unsigned.rs +++ b/tests/unit/out/refcount/unsigned.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -20,3 +21,4 @@ fn main_0() -> i32 { assert!(((*a.borrow()) == 255)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/user_defined_same_as_libc.rs b/tests/unit/out/refcount/user_defined_same_as_libc.rs index fe6a55c51..5ff492969 100644 --- a/tests/unit/out/refcount/user_defined_same_as_libc.rs +++ b/tests/unit/out/refcount/user_defined_same_as_libc.rs @@ -14,6 +14,7 @@ pub fn fopen_0(path: Ptr, mode: Ptr) -> Ptr { return Ptr::null(); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -28,3 +29,4 @@ fn main_0() -> i32 { assert!(((((*fp.borrow()).is_null()) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_chain.rs b/tests/unit/out/refcount/va_arg_chain.rs index bd4afad0b..6ab011ede 100644 --- a/tests/unit/out/refcount/va_arg_chain.rs +++ b/tests/unit/out/refcount/va_arg_chain.rs @@ -31,6 +31,7 @@ pub fn top_level_2(n: i32, __args: &[VaArg]) -> i32 { return (*result.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -47,3 +48,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_concat.rs b/tests/unit/out/refcount/va_arg_concat.rs index e736569cc..0d43414b3 100644 --- a/tests/unit/out/refcount/va_arg_concat.rs +++ b/tests/unit/out/refcount/va_arg_concat.rs @@ -23,6 +23,7 @@ pub fn sum_ints_0(first: i32, __args: &[VaArg]) -> i32 { return (*total.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -42,3 +43,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_conditional.rs b/tests/unit/out/refcount/va_arg_conditional.rs index 0c71e8fdf..c2a0c4943 100644 --- a/tests/unit/out/refcount/va_arg_conditional.rs +++ b/tests/unit/out/refcount/va_arg_conditional.rs @@ -18,6 +18,7 @@ pub fn conditional_log_0(verbose: i32, fmt: Ptr, __args: &[VaArg]) -> i32 { return -1_i32; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -33,3 +34,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_copy.rs b/tests/unit/out/refcount/va_arg_copy.rs index e58de7db8..3ade7e6ec 100644 --- a/tests/unit/out/refcount/va_arg_copy.rs +++ b/tests/unit/out/refcount/va_arg_copy.rs @@ -28,6 +28,7 @@ pub fn sum_with_copy_0(count: i32, __args: &[VaArg]) -> i32 { return ((*sum1.borrow()) + (*sum2.borrow())); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -37,3 +38,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_fn_ptr.rs b/tests/unit/out/refcount/va_arg_fn_ptr.rs index 2025a4653..311b23386 100644 --- a/tests/unit/out/refcount/va_arg_fn_ptr.rs +++ b/tests/unit/out/refcount/va_arg_fn_ptr.rs @@ -52,6 +52,7 @@ pub fn not_supported_5(ctx: AnyPtr, fn_: FnPtr i32>, extra: AnyPtr) - return -3_i32; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -81,3 +82,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_forward.rs b/tests/unit/out/refcount/va_arg_forward.rs index 1fc4b38ec..7bf21bb08 100644 --- a/tests/unit/out/refcount/va_arg_forward.rs +++ b/tests/unit/out/refcount/va_arg_forward.rs @@ -27,6 +27,7 @@ pub fn outer_1(count: i32, __args: &[VaArg]) -> i32 { return (*result.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -35,3 +36,4 @@ fn main_0() -> i32 { assert!((((({ outer_1(0, &[]) }) == 0) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_mixed_int_ptr.rs b/tests/unit/out/refcount/va_arg_mixed_int_ptr.rs index 7d48118b8..938b2e3ab 100644 --- a/tests/unit/out/refcount/va_arg_mixed_int_ptr.rs +++ b/tests/unit/out/refcount/va_arg_mixed_int_ptr.rs @@ -26,6 +26,7 @@ pub fn mixed_args_0(count: i32, __args: &[VaArg]) -> i32 { return (*total.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -54,3 +55,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_mixed_types.rs b/tests/unit/out/refcount/va_arg_mixed_types.rs index d9426ab9a..36e594190 100644 --- a/tests/unit/out/refcount/va_arg_mixed_types.rs +++ b/tests/unit/out/refcount/va_arg_mixed_types.rs @@ -27,6 +27,7 @@ pub fn sum_mixed_0(count: i32, __args: &[VaArg]) -> i32 { return (*total.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -58,3 +59,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs index 3fc7ae503..188fa6543 100644 --- a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs @@ -79,6 +79,7 @@ pub fn dispatch_0(option: i32, __args: &[VaArg]) -> i32 { return (*result.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -124,3 +125,4 @@ fn main_0() -> i32 { assert!(((((*outp.borrow()).is_null()) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_null_int_ptr.rs b/tests/unit/out/refcount/va_arg_null_int_ptr.rs index 272eadb49..a83a325c4 100644 --- a/tests/unit/out/refcount/va_arg_null_int_ptr.rs +++ b/tests/unit/out/refcount/va_arg_null_int_ptr.rs @@ -24,6 +24,7 @@ pub fn first_nonnull_0(count: i32, __args: &[VaArg]) -> i32 { return (*result.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -49,3 +50,4 @@ fn main_0() -> i32 { assert!((((({ first_nonnull_0(1, &[(AnyPtr::default()).into(),]) }) == -1_i32) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_printf.rs b/tests/unit/out/refcount/va_arg_printf.rs index 2f2f88961..3d106702a 100644 --- a/tests/unit/out/refcount/va_arg_printf.rs +++ b/tests/unit/out/refcount/va_arg_printf.rs @@ -35,6 +35,7 @@ pub fn lenf_2(fmt: Ptr, __args: &[VaArg]) -> i32 { return (*result.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -87,3 +88,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_promotion.rs b/tests/unit/out/refcount/va_arg_promotion.rs index 08a30ddc5..79f642074 100644 --- a/tests/unit/out/refcount/va_arg_promotion.rs +++ b/tests/unit/out/refcount/va_arg_promotion.rs @@ -19,6 +19,7 @@ pub fn test_promotions_0(count: i32, __args: &[VaArg]) -> i32 { return (((*a.borrow()) + (*b.borrow())) + ((*c.borrow()) as i32)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -40,3 +41,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_snprintf.rs b/tests/unit/out/refcount/va_arg_snprintf.rs index 3b74afc0e..2d02e04da 100644 --- a/tests/unit/out/refcount/va_arg_snprintf.rs +++ b/tests/unit/out/refcount/va_arg_snprintf.rs @@ -18,6 +18,7 @@ pub fn extract_first_0(buf: Ptr, size: i32, fmt: Ptr, __args: &[VaArg]) return (*n.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -50,3 +51,4 @@ fn main_0() -> i32 { assert!((((((*buf.borrow())[(0) as usize] as i32) == ('A' as i32)) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_struct_ctx.rs b/tests/unit/out/refcount/va_arg_struct_ctx.rs index 56fd66a5c..8c269fb10 100644 --- a/tests/unit/out/refcount/va_arg_struct_ctx.rs +++ b/tests/unit/out/refcount/va_arg_struct_ctx.rs @@ -45,6 +45,7 @@ pub fn set_error_0(ctx: Ptr, fmt: Ptr, __args: &[VaArg]) { } } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -70,3 +71,4 @@ fn main_0() -> i32 { assert!(((((*(*ctx.borrow()).last_error.borrow()) == 42) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_two_passes.rs b/tests/unit/out/refcount/va_arg_two_passes.rs index 0483bb391..b70bca9a2 100644 --- a/tests/unit/out/refcount/va_arg_two_passes.rs +++ b/tests/unit/out/refcount/va_arg_two_passes.rs @@ -33,6 +33,7 @@ pub fn sum_then_product_0(first: i32, __args: &[VaArg]) -> i32 { return ((*sum.borrow()) + (*product.borrow())); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -41,3 +42,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/va_arg_void_ptr.rs b/tests/unit/out/refcount/va_arg_void_ptr.rs index 6765e2733..1c9fd571e 100644 --- a/tests/unit/out/refcount/va_arg_void_ptr.rs +++ b/tests/unit/out/refcount/va_arg_void_ptr.rs @@ -65,6 +65,7 @@ pub fn registry_update_0(r: Ptr, field: field, __args: &[VaArg]) -> i3 return (*result.borrow()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -105,3 +106,4 @@ fn main_0() -> i32 { assert!(((((*(*r.borrow()).level.borrow()) == 5_i64) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 1227c6012..45cbfd9d1 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -10,6 +10,7 @@ pub fn copy_0(copy_vector: Vec) { let copy_vector: Value> = Rc::new(RefCell::new(copy_vector)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -239,3 +240,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector2.rs b/tests/unit/out/refcount/vector2.rs index 7db493050..633f2a2a2 100644 --- a/tests/unit/out/refcount/vector2.rs +++ b/tests/unit/out/refcount/vector2.rs @@ -53,6 +53,7 @@ pub fn fn_0(v: Ptr>, v3: Vec) { v.with_mut(|__v: &mut Vec| __v.push(20)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -66,3 +67,4 @@ fn main_0() -> i32 { ({ fn_0(v.as_pointer(), (*v2.borrow()).clone()) }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector3.rs b/tests/unit/out/refcount/vector3.rs index 66c71b4ba..fc4582462 100644 --- a/tests/unit/out/refcount/vector3.rs +++ b/tests/unit/out/refcount/vector3.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -76,3 +77,4 @@ fn main_0() -> i32 { } return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector_addr_of_back.rs b/tests/unit/out/refcount/vector_addr_of_back.rs index ee1809644..346738646 100644 --- a/tests/unit/out/refcount/vector_addr_of_back.rs +++ b/tests/unit/out/refcount/vector_addr_of_back.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -26,3 +27,4 @@ fn main_0() -> i32 { assert!(((*(*sink.borrow()).upgrade().deref()).len() == 0_usize)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 04d9348a8..ca53e9dbd 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -86,3 +87,4 @@ fn main_0() -> i32 { ); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index f217e8bae..9787e6eab 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -88,6 +88,7 @@ pub fn fn_1(v: Ptr>, v3: Vec) { v.with_mut(|__v: &mut Vec| __v.push(20)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -377,3 +378,4 @@ impl TestAllocator_int_Impl for Ptr { (*p.borrow()).delete_array(); } } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index 6778ff76a..2b31ab3ad 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -108,6 +108,7 @@ pub fn unused_noncopyable_param_5(x: Ptr) { &(*x.upgrade().deref()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -189,3 +190,6 @@ impl NonCopyableImpl for Ptr { return (*self).clone(); } } +pub fn __cpp2rust_init_globals() { + let _ = side_effect_counter_3.with(|_| ()); +} diff --git a/tests/unit/out/refcount/void_ptr_implicit_conversion.rs b/tests/unit/out/refcount/void_ptr_implicit_conversion.rs index 67f65ddc5..3becb4783 100644 --- a/tests/unit/out/refcount/void_ptr_implicit_conversion.rs +++ b/tests/unit/out/refcount/void_ptr_implicit_conversion.rs @@ -16,6 +16,7 @@ pub fn bump_0(arg: AnyPtr) -> i32 { return ((*value.borrow()).read()); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -29,3 +30,4 @@ fn main_0() -> i32 { assert!(((((*value.borrow()) == 7) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/void_return.rs b/tests/unit/out/refcount/void_return.rs index f1173bb2e..d4458a3ee 100644 --- a/tests/unit/out/refcount/void_return.rs +++ b/tests/unit/out/refcount/void_return.rs @@ -13,6 +13,7 @@ pub fn f1_0(first: Ptr, last: Ptr) { return; } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -24,3 +25,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/void_round_trip.rs b/tests/unit/out/refcount/void_round_trip.rs index b9cfec3cb..9a17e1295 100644 --- a/tests/unit/out/refcount/void_round_trip.rs +++ b/tests/unit/out/refcount/void_round_trip.rs @@ -7,6 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -14,3 +15,4 @@ fn main_0() -> i32 { assert!((((((a.as_pointer()).to_any().reinterpret_cast::().read()) == 42) as i32) != 0)); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/z_bit_cast.rs b/tests/unit/out/refcount/z_bit_cast.rs index c627013ad..59bafee45 100644 --- a/tests/unit/out/refcount/z_bit_cast.rs +++ b/tests/unit/out/refcount/z_bit_cast.rs @@ -13,6 +13,7 @@ pub fn bit_cast_1(p: AnyPtr) { let p: Value = Rc::new(RefCell::new(p)); } pub fn main() { + __cpp2rust_init_globals(); std::process::exit(main_0()); } fn main_0() -> i32 { @@ -37,3 +38,4 @@ fn main_0() -> i32 { }); return 0; } +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/01_local.rs b/tests/unit/out/unsafe/01_local.rs index dc0c7db36..19595a03c 100644 --- a/tests/unit/out/unsafe/01_local.rs +++ b/tests/unit/out/unsafe/01_local.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -16,3 +17,4 @@ unsafe fn main_0() -> i32 { assert!(((a) == (1))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/02_address_taken.rs b/tests/unit/out/unsafe/02_address_taken.rs index f5b37e4b1..fdad7b9d7 100644 --- a/tests/unit/out/unsafe/02_address_taken.rs +++ b/tests/unit/out/unsafe/02_address_taken.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -23,3 +24,4 @@ unsafe fn main_0() -> i32 { assert!(((b) == (4))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/03_local_array.rs b/tests/unit/out/unsafe/03_local_array.rs index bb1596d41..aef836f23 100644 --- a/tests/unit/out/unsafe/03_local_array.rs +++ b/tests/unit/out/unsafe/03_local_array.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -18,3 +19,4 @@ unsafe fn main_0() -> i32 { assert!((((arr1[(0) as usize]) + (arr1[(1) as usize])) == (7))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/04_address_taken_array.rs b/tests/unit/out/unsafe/04_address_taken_array.rs index 04105f2d0..33a2f71b8 100644 --- a/tests/unit/out/unsafe/04_address_taken_array.rs +++ b/tests/unit/out/unsafe/04_address_taken_array.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -23,3 +24,4 @@ unsafe fn main_0() -> i32 { assert!((((arr2[(0) as usize]) + (arr2[(1) as usize])) == (12))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/05_new.rs b/tests/unit/out/unsafe/05_new.rs index 42805c7e0..3507f06b8 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -17,3 +18,4 @@ unsafe fn main_0() -> i32 { ::std::mem::drop(Box::from_raw(d)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/06_new_array.rs b/tests/unit/out/unsafe/06_new_array.rs index 57c72259f..2423b0d2c 100644 --- a/tests/unit/out/unsafe/06_new_array.rs +++ b/tests/unit/out/unsafe/06_new_array.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -23,3 +24,4 @@ unsafe fn main_0() -> i32 { ))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/07_unique.rs b/tests/unit/out/unsafe/07_unique.rs index 1cfbca6cb..e27a68d59 100644 --- a/tests/unit/out/unsafe/07_unique.rs +++ b/tests/unit/out/unsafe/07_unique.rs @@ -12,6 +12,7 @@ pub unsafe fn fn_0(mut u: Option>) -> Option> { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -29,3 +30,4 @@ unsafe fn main_0() -> i32 { assert!(((*f.as_deref_mut().unwrap()) == (10))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/08_unique_array.rs b/tests/unit/out/unsafe/08_unique_array.rs index ce31524a1..52325f4c3 100644 --- a/tests/unit/out/unsafe/08_unique_array.rs +++ b/tests/unit/out/unsafe/08_unique_array.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -24,3 +25,4 @@ unsafe fn main_0() -> i32 { assert!((((g.as_mut().unwrap()[(0_usize)]) + (g.as_mut().unwrap()[(1_usize)])) == (27))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/09_references.rs b/tests/unit/out/unsafe/09_references.rs index 7abb38956..197da2316 100644 --- a/tests/unit/out/unsafe/09_references.rs +++ b/tests/unit/out/unsafe/09_references.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -21,3 +22,4 @@ unsafe fn main_0() -> i32 { assert!((((*h_ref1) + (*h_ref2)) == (34))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/10_struct.rs b/tests/unit/out/unsafe/10_struct.rs index 82cce1464..48671d687 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -32,6 +32,7 @@ impl Graph { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -42,3 +43,4 @@ unsafe fn main_0() -> i32 { }; return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/11_move.rs b/tests/unit/out/unsafe/11_move.rs index 22fa8c853..e9774a476 100644 --- a/tests/unit/out/unsafe/11_move.rs +++ b/tests/unit/out/unsafe/11_move.rs @@ -17,6 +17,7 @@ pub unsafe fn change_0(n: *mut Option>) { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -26,3 +27,4 @@ unsafe fn main_0() -> i32 { assert!(((*n.as_deref_mut().unwrap()) == (20))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/12_test.rs b/tests/unit/out/unsafe/12_test.rs index 34a452804..4980993e8 100644 --- a/tests/unit/out/unsafe/12_test.rs +++ b/tests/unit/out/unsafe/12_test.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -20,3 +21,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/13_testing.rs b/tests/unit/out/unsafe/13_testing.rs index ed7d44c3c..f7ae4a89c 100644 --- a/tests/unit/out/unsafe/13_testing.rs +++ b/tests/unit/out/unsafe/13_testing.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -21,3 +22,4 @@ unsafe fn main_0() -> i32 { (*(*p2)) = 3; return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/14_testing2.rs b/tests/unit/out/unsafe/14_testing2.rs index 306009241..4ac973120 100644 --- a/tests/unit/out/unsafe/14_testing2.rs +++ b/tests/unit/out/unsafe/14_testing2.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -17,3 +18,4 @@ unsafe fn main_0() -> i32 { assert!(((*ptr) == (1))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/__builtin_constant_p.rs b/tests/unit/out/unsafe/__builtin_constant_p.rs index db75aaad5..f1546b993 100644 --- a/tests/unit/out/unsafe/__builtin_constant_p.rs +++ b/tests/unit/out/unsafe/__builtin_constant_p.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -17,3 +18,4 @@ unsafe fn main_0() -> i32 { assert!((((1) + (2)) == (3))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/addr_of_global.rs b/tests/unit/out/unsafe/addr_of_global.rs index 496ef09dd..25040e405 100644 --- a/tests/unit/out/unsafe/addr_of_global.rs +++ b/tests/unit/out/unsafe/addr_of_global.rs @@ -16,36 +16,57 @@ pub struct Inner { pub struct Outer { pub p: *mut Inner, } -pub static mut alpha_0: Inner = unsafe { Inner { value: 1 } }; -pub static mut beta_1: Inner = unsafe { Inner { value: 2 } }; -pub static mut shared_2: Inner = unsafe { Inner { value: 42 } }; -pub static mut items_3: [*mut Inner; 2] = unsafe { - [ - (&raw mut alpha_0 as *mut Inner), - (&raw mut beta_1 as *mut Inner), - ] -}; -pub static mut obj_4: Outer = unsafe { +pub static mut alpha_0: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { Inner { value: 1 } }); +pub static mut beta_1: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { Inner { value: 2 } }); +pub static mut shared_2: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { Inner { value: 42 } }); +pub static mut items_3: std::cell::LazyCell<[*mut Inner; 2]> = + std::cell::LazyCell::new(|| unsafe { + [ + (&raw mut (*std::cell::LazyCell::force_mut(&mut *&raw mut alpha_0)) as *mut Inner), + (&raw mut (*std::cell::LazyCell::force_mut(&mut *&raw mut beta_1)) as *mut Inner), + ] + }); +pub static mut obj_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { Outer { - p: (&raw mut shared_2 as *mut Inner), + p: (&raw mut (*std::cell::LazyCell::force_mut(&mut *&raw mut shared_2)) as *mut Inner), } -}; +}); pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } unsafe fn main_0() -> i32 { - assert!((((*items_3[(0) as usize]).value) == (1))); - assert!((((*items_3[(1) as usize]).value) == (2))); - assert!((((*obj_4.p).value) == (42))); - static mut cache_5: [*mut Inner; 2] = unsafe { - [ - (&raw mut alpha_0 as *mut Inner), - (&raw mut beta_1 as *mut Inner), - ] - };; - assert!((((*cache_5[(0) as usize]).value) == (1))); - assert!((((*cache_5[(1) as usize]).value) == (2))); + assert!( + (((*(*std::cell::LazyCell::force_mut(&mut *&raw mut items_3))[(0) as usize]).value) == (1)) + ); + assert!( + (((*(*std::cell::LazyCell::force_mut(&mut *&raw mut items_3))[(1) as usize]).value) == (2)) + ); + assert!((((*(*std::cell::LazyCell::force_mut(&mut *&raw mut obj_4)).p).value) == (42))); + static mut cache_5: std::cell::LazyCell<[*mut Inner; 2]> = + std::cell::LazyCell::new(|| unsafe { + [ + (&raw mut (*std::cell::LazyCell::force_mut(&mut *&raw mut alpha_0)) as *mut Inner), + (&raw mut (*std::cell::LazyCell::force_mut(&mut *&raw mut beta_1)) as *mut Inner), + ] + });; + assert!( + (((*(*std::cell::LazyCell::force_mut(&mut *&raw mut cache_5))[(0) as usize]).value) == (1)) + ); + assert!( + (((*(*std::cell::LazyCell::force_mut(&mut *&raw mut cache_5))[(1) as usize]).value) == (2)) + ); return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const alpha_0); + std::cell::LazyCell::force(&*&raw const beta_1); + std::cell::LazyCell::force(&*&raw const shared_2); + std::cell::LazyCell::force(&*&raw const items_3); + std::cell::LazyCell::force(&*&raw const obj_4); +} diff --git a/tests/unit/out/unsafe/alloc_array.rs b/tests/unit/out/unsafe/alloc_array.rs index be1d513d2..ef7c2dbde 100644 --- a/tests/unit/out/unsafe/alloc_array.rs +++ b/tests/unit/out/unsafe/alloc_array.rs @@ -29,6 +29,7 @@ pub unsafe fn Consume_1(mut arr: Option>, mut N: i32) -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -43,3 +44,4 @@ unsafe fn main_0() -> i32 { assert!(((unsafe { Consume_1(arr.take(), N,) }) == (10))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/anonymous-struct.rs b/tests/unit/out/unsafe/anonymous-struct.rs index 705075f8d..428007e32 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -58,6 +58,7 @@ pub struct Outer { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -118,3 +119,4 @@ pub struct anon_6 { pub x: i32, pub z: i32, } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/anonymous-struct_c.rs b/tests/unit/out/unsafe/anonymous-struct_c.rs index 5de7e6b69..eb207f052 100644 --- a/tests/unit/out/unsafe/anonymous-struct_c.rs +++ b/tests/unit/out/unsafe/anonymous-struct_c.rs @@ -58,6 +58,7 @@ pub struct Outer { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -114,3 +115,4 @@ pub struct anon_6 { pub x: i32, pub z: i32, } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/anonymous_enum.rs b/tests/unit/out/unsafe/anonymous_enum.rs index e5e75562d..3dd44bfca 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -31,6 +31,7 @@ pub struct WithAnonField { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -52,3 +53,4 @@ unsafe fn main_0() -> i32 { pub type anon_3 = u32; pub const anon_3_THIRD_A: anon_3 = 0; pub const anon_3_THIRD_B: anon_3 = 1; +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/anonymous_enum_c.rs b/tests/unit/out/unsafe/anonymous_enum_c.rs index 3913926e5..ab38346d0 100644 --- a/tests/unit/out/unsafe/anonymous_enum_c.rs +++ b/tests/unit/out/unsafe/anonymous_enum_c.rs @@ -31,6 +31,7 @@ pub struct WithAnonField { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -52,3 +53,4 @@ unsafe fn main_0() -> i32 { pub type anon_3 = u32; pub const anon_3_THIRD_A: anon_3 = 0; pub const anon_3_THIRD_B: anon_3 = 1; +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/array.rs b/tests/unit/out/unsafe/array.rs index 75df0fc08..02062d163 100644 --- a/tests/unit/out/unsafe/array.rs +++ b/tests/unit/out/unsafe/array.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -29,3 +30,4 @@ unsafe fn main_0() -> i32 { assert!(((fatorial) == (120))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/array_2d_default.rs b/tests/unit/out/unsafe/array_2d_default.rs index f242a86e5..07e70fb4d 100644 --- a/tests/unit/out/unsafe/array_2d_default.rs +++ b/tests/unit/out/unsafe/array_2d_default.rs @@ -12,6 +12,7 @@ pub unsafe fn fill_row_0(mut row: *mut libc::c_char, mut c: libc::c_char) { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -34,3 +35,4 @@ unsafe fn main_0() -> i32 { assert!(((((grid[(2) as usize][(5) as usize] as i32) == ('z' as i32)) as i32) != 0)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index 7601a660b..361315761 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -22,29 +22,41 @@ impl Default for S { } } } -pub static mut s_0: S = unsafe { +pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { S { head: 5, tail: [0; 3], buf: [0; 4], } -}; +}); pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } unsafe fn main_0() -> i32 { - assert!(((((s_0.head) == (5)) as i32) != 0)); + assert!((((((*std::cell::LazyCell::force_mut(&mut *&raw mut s_0)).head) == (5)) as i32) != 0)); let mut i: i32 = 0; 'loop_: while ((((i) < (3)) as i32) != 0) { - assert!(((((s_0.tail[(i) as usize]) == (0)) as i32) != 0)); + assert!( + (((((*std::cell::LazyCell::force_mut(&mut *&raw mut s_0)).tail[(i) as usize]) == (0)) + as i32) + != 0) + ); i.postfix_inc(); } let mut i: i32 = 0; 'loop_: while ((((i) < (4)) as i32) != 0) { - assert!(((((s_0.buf[(i) as usize] as i32) == (0)) as i32) != 0)); + assert!( + (((((*std::cell::LazyCell::force_mut(&mut *&raw mut s_0)).buf[(i) as usize] as i32) + == (0)) as i32) + != 0) + ); i.postfix_inc(); } return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const s_0); +} diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index 7fedfe8ce..25d0ac72a 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -14,6 +14,7 @@ pub struct NonCopy { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -28,3 +29,4 @@ unsafe fn main_0() -> i32 { assert!(((arr[(2) as usize].data.len()) == (0_usize))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index 1a39c8411..779f532db 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -64,6 +64,7 @@ pub unsafe fn total_len_9(names: *mut [*const libc::c_char; 2]) -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -97,3 +98,4 @@ unsafe fn main_0() -> i32 { assert!(((unsafe { total_len_9(&mut names,) }) == (5))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/assert.rs b/tests/unit/out/unsafe/assert.rs index 4f9006870..0144311de 100644 --- a/tests/unit/out/unsafe/assert.rs +++ b/tests/unit/out/unsafe/assert.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -16,3 +17,4 @@ unsafe fn main_0() -> i32 { assert!(((1) == (1))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/assign_as_value.rs b/tests/unit/out/unsafe/assign_as_value.rs index 16e13699e..ce60f44c4 100644 --- a/tests/unit/out/unsafe/assign_as_value.rs +++ b/tests/unit/out/unsafe/assign_as_value.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -40,3 +41,4 @@ unsafe fn main_0() -> i32 { assert!(((((out as i32) == ('x' as i32)) as i32) != 0)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/auto.rs b/tests/unit/out/unsafe/auto.rs index 603ea1deb..1f02ba4d1 100644 --- a/tests/unit/out/unsafe/auto.rs +++ b/tests/unit/out/unsafe/auto.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -26,3 +27,4 @@ unsafe fn main_0() -> i32 { assert!(((sum) == (3))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bool_condition_enum.rs b/tests/unit/out/unsafe/bool_condition_enum.rs index 4a8e4bb7d..904f9d1d5 100644 --- a/tests/unit/out/unsafe/bool_condition_enum.rs +++ b/tests/unit/out/unsafe/bool_condition_enum.rs @@ -12,6 +12,7 @@ pub const Code_CODE_ERR: Code = 1; pub const Code_CODE_FATAL: Code = 2; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -36,3 +37,4 @@ unsafe fn main_0() -> i32 { assert!(!(b4)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bool_condition_enum_c.rs b/tests/unit/out/unsafe/bool_condition_enum_c.rs index 116e65128..bbaf58b45 100644 --- a/tests/unit/out/unsafe/bool_condition_enum_c.rs +++ b/tests/unit/out/unsafe/bool_condition_enum_c.rs @@ -12,6 +12,7 @@ pub const Code_CODE_ERR: Code = 1; pub const Code_CODE_FATAL: Code = 2; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -36,3 +37,4 @@ unsafe fn main_0() -> i32 { assert!(((!(b4) as i32) != 0)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bool_condition_int.rs b/tests/unit/out/unsafe/bool_condition_int.rs index 4e65984d2..fc70398a5 100644 --- a/tests/unit/out/unsafe/bool_condition_int.rs +++ b/tests/unit/out/unsafe/bool_condition_int.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -67,3 +68,4 @@ unsafe fn main_0() -> i32 { assert!(b1); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bool_condition_int_c.rs b/tests/unit/out/unsafe/bool_condition_int_c.rs index e0b28b557..476a4b704 100644 --- a/tests/unit/out/unsafe/bool_condition_int_c.rs +++ b/tests/unit/out/unsafe/bool_condition_int_c.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -67,3 +68,4 @@ unsafe fn main_0() -> i32 { assert!(b1); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bool_condition_logical.rs b/tests/unit/out/unsafe/bool_condition_logical.rs index 36ab7f233..a42c00483 100644 --- a/tests/unit/out/unsafe/bool_condition_logical.rs +++ b/tests/unit/out/unsafe/bool_condition_logical.rs @@ -10,9 +10,9 @@ pub type Code = u32; pub const Code_CODE_OK: Code = 0; pub const Code_CODE_ERR: Code = 1; pub const Code_CODE_FATAL: Code = 2; -pub static mut side_effect_0: i32 = unsafe { 0 }; +pub static mut side_effect_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub unsafe fn observe_1(mut v: i32) -> i32 { - side_effect_0.prefix_inc(); + (*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_0)).prefix_inc(); return v; } pub unsafe fn returns_one_2() -> i32 { @@ -23,6 +23,7 @@ pub unsafe fn returns_zero_3() -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -49,15 +50,15 @@ unsafe fn main_0() -> i32 { if (((n != 0) && (u != 0)) && (!(p).is_null())) && ((code as i32) == (Code_CODE_OK as i32)) { assert!(true); } - side_effect_0 = 0; + (*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_0)) = 0; if (zero != 0) && ((unsafe { observe_1(1) }) != 0) { assert!(false); } - assert!(((side_effect_0) == (0))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_0)) == (0))); if (n != 0) || ((unsafe { observe_1(1) }) != 0) { assert!(true); } - assert!(((side_effect_0) == (0))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_0)) == (0))); let mut x: i32 = 5; let mut y: i32 = 3; let mut flags: u32 = 2_u32; @@ -128,3 +129,6 @@ unsafe fn main_0() -> i32 { } return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const side_effect_0); +} diff --git a/tests/unit/out/unsafe/bool_condition_logical_c.rs b/tests/unit/out/unsafe/bool_condition_logical_c.rs index f79c7dd9c..00521fd6c 100644 --- a/tests/unit/out/unsafe/bool_condition_logical_c.rs +++ b/tests/unit/out/unsafe/bool_condition_logical_c.rs @@ -10,9 +10,9 @@ pub type Code = u32; pub const Code_CODE_OK: Code = 0; pub const Code_CODE_ERR: Code = 1; pub const Code_CODE_FATAL: Code = 2; -pub static mut side_effect_0: i32 = unsafe { 0 }; +pub static mut side_effect_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub unsafe fn observe_1(mut v: i32) -> i32 { - side_effect_0.prefix_inc(); + (*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_0)).prefix_inc(); return v; } pub unsafe fn returns_one_2() -> i32 { @@ -23,6 +23,7 @@ pub unsafe fn returns_zero_3() -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -52,15 +53,19 @@ unsafe fn main_0() -> i32 { { assert!((1 != 0)); } - side_effect_0 = 0; + (*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_0)) = 0; if ((((zero != 0) && ((unsafe { observe_1(1) }) != 0)) as i32) != 0) { assert!((0 != 0)); } - assert!(((((side_effect_0) == (0)) as i32) != 0)); + assert!( + ((((*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_0)) == (0)) as i32) != 0) + ); if ((((n != 0) || ((unsafe { observe_1(1) }) != 0)) as i32) != 0) { assert!((1 != 0)); } - assert!(((((side_effect_0) == (0)) as i32) != 0)); + assert!( + ((((*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_0)) == (0)) as i32) != 0) + ); let mut x: i32 = 5; let mut y: i32 = 3; let mut flags: u32 = 2_u32; @@ -137,3 +142,6 @@ unsafe fn main_0() -> i32 { } return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const side_effect_0); +} diff --git a/tests/unit/out/unsafe/bool_condition_ptr.rs b/tests/unit/out/unsafe/bool_condition_ptr.rs index f32b311cf..5f40a9885 100644 --- a/tests/unit/out/unsafe/bool_condition_ptr.rs +++ b/tests/unit/out/unsafe/bool_condition_ptr.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -48,3 +49,4 @@ unsafe fn main_0() -> i32 { assert!(!(b3)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bool_condition_ptr_c.rs b/tests/unit/out/unsafe/bool_condition_ptr_c.rs index ab7bf6352..4841cc529 100644 --- a/tests/unit/out/unsafe/bool_condition_ptr_c.rs +++ b/tests/unit/out/unsafe/bool_condition_ptr_c.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -48,3 +49,4 @@ unsafe fn main_0() -> i32 { assert!(((!(b3) as i32) != 0)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bool_printing.rs b/tests/unit/out/unsafe/bool_printing.rs index 0716902dd..d54e47e97 100644 --- a/tests/unit/out/unsafe/bool_printing.rs +++ b/tests/unit/out/unsafe/bool_printing.rs @@ -14,6 +14,7 @@ pub unsafe fn bar_1() -> bool { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -88,3 +89,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/borrow_mut_opt.rs b/tests/unit/out/unsafe/borrow_mut_opt.rs index 7ebeca1ea..579f247c0 100644 --- a/tests/unit/out/unsafe/borrow_mut_opt.rs +++ b/tests/unit/out/unsafe/borrow_mut_opt.rs @@ -61,6 +61,7 @@ pub unsafe fn convert_with_rhs_1() { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -69,3 +70,4 @@ unsafe fn main_0() -> i32 { (unsafe { convert_with_rhs_1() }); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bounded_struct_ptr.rs b/tests/unit/out/unsafe/bounded_struct_ptr.rs index 6402905e5..b281e2617 100644 --- a/tests/unit/out/unsafe/bounded_struct_ptr.rs +++ b/tests/unit/out/unsafe/bounded_struct_ptr.rs @@ -14,6 +14,7 @@ pub struct Foo { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -25,3 +26,4 @@ unsafe fn main_0() -> i32 { assert!((((a) + ((*p2).x2)) == (5))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/break.rs b/tests/unit/out/unsafe/break.rs index ad4f2bf09..381818ebf 100644 --- a/tests/unit/out/unsafe/break.rs +++ b/tests/unit/out/unsafe/break.rs @@ -31,6 +31,7 @@ pub unsafe fn for_test_0(n: i32) -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -38,3 +39,4 @@ unsafe fn main_0() -> i32 { assert!(((unsafe { for_test_0(200,) }) == (400))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/bst.rs b/tests/unit/out/unsafe/bst.rs index 1d5ffd9f1..d40652cc4 100644 --- a/tests/unit/out/unsafe/bst.rs +++ b/tests/unit/out/unsafe/bst.rs @@ -36,6 +36,7 @@ pub unsafe fn insert_1(mut node: *mut node_t, mut new_node: *mut node_t) -> *mut } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -80,3 +81,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/builtin.rs b/tests/unit/out/unsafe/builtin.rs index b7856c2b1..dd0a64971 100644 --- a/tests/unit/out/unsafe/builtin.rs +++ b/tests/unit/out/unsafe/builtin.rs @@ -71,6 +71,7 @@ pub unsafe fn test_mul_overflow_long_long_9() { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -87,3 +88,4 @@ unsafe fn main_0() -> i32 { (unsafe { test_mul_overflow_long_long_9() }); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/builtin_types_compatible.rs b/tests/unit/out/unsafe/builtin_types_compatible.rs index de474b947..16952ec55 100644 --- a/tests/unit/out/unsafe/builtin_types_compatible.rs +++ b/tests/unit/out/unsafe/builtin_types_compatible.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -25,3 +26,4 @@ unsafe fn main_0() -> i32 { assert!(((((0) == (0)) as i32) != 0)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/byte.rs b/tests/unit/out/unsafe/byte.rs index a48cf14c9..e6d687ddb 100644 --- a/tests/unit/out/unsafe/byte.rs +++ b/tests/unit/out/unsafe/byte.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -35,3 +36,4 @@ unsafe fn main_0() -> i32 { assert!(((b1) == (4))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/c_struct.rs b/tests/unit/out/unsafe/c_struct.rs index ab4902089..0de37421e 100644 --- a/tests/unit/out/unsafe/c_struct.rs +++ b/tests/unit/out/unsafe/c_struct.rs @@ -43,6 +43,7 @@ pub struct Container { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -84,3 +85,4 @@ unsafe fn main_0() -> i32 { assert!(((((c2.color as u32) == (2_u32)) as i32) != 0)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index 5c8128cfc..fc9c815fc 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -16,3 +17,4 @@ unsafe fn main_0() -> i32 { assert!(((size) == (1_usize))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs index 8bbc75843..17c07b7b5 100644 --- a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs @@ -18,6 +18,7 @@ pub unsafe fn strlen_1(mut s: *mut libc::c_char) -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -34,3 +35,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/char_printing.rs b/tests/unit/out/unsafe/char_printing.rs index 72076f398..8480d7a02 100644 --- a/tests/unit/out/unsafe/char_printing.rs +++ b/tests/unit/out/unsafe/char_printing.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -115,3 +116,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/char_printing_cerr.rs b/tests/unit/out/unsafe/char_printing_cerr.rs index acd53963c..d4862a382 100644 --- a/tests/unit/out/unsafe/char_printing_cerr.rs +++ b/tests/unit/out/unsafe/char_printing_cerr.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -115,3 +116,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 2ac686ffa..89b75608e 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -70,6 +70,7 @@ pub unsafe fn RandomRoute_0(route: *mut Route) -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -102,3 +103,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/class_template_lazy_member.rs b/tests/unit/out/unsafe/class_template_lazy_member.rs index 02dde48bd..05ad2e74d 100644 --- a/tests/unit/out/unsafe/class_template_lazy_member.rs +++ b/tests/unit/out/unsafe/class_template_lazy_member.rs @@ -33,6 +33,7 @@ impl Box_Point_ { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -45,3 +46,4 @@ unsafe fn main_0() -> i32 { assert!((((unsafe { Box_Point_::get(&mut p,) }).x) == (4))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index bab75e91e..78ee0f8dc 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -86,6 +86,7 @@ impl MyContainer_float_ { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -129,3 +130,4 @@ unsafe fn main_0() -> i32 { assert!((unsafe { MyContainer_float_::empty(&fmc,) })); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index 4d2f0030f..b764f6f73 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -33,6 +33,7 @@ impl Default for Foo { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -247,3 +248,4 @@ unsafe fn main_0() -> i32 { } return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index 7defe1c34..692c7544f 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -45,3 +46,4 @@ unsafe fn main_0() -> i32 { } return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/complex_function.rs b/tests/unit/out/unsafe/complex_function.rs index 20fd319de..de266d91f 100644 --- a/tests/unit/out/unsafe/complex_function.rs +++ b/tests/unit/out/unsafe/complex_function.rs @@ -52,6 +52,7 @@ impl X4 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -247,3 +248,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/compound_assign_paren.rs b/tests/unit/out/unsafe/compound_assign_paren.rs index ed312d68a..2988a76f9 100644 --- a/tests/unit/out/unsafe/compound_assign_paren.rs +++ b/tests/unit/out/unsafe/compound_assign_paren.rs @@ -13,6 +13,7 @@ pub struct Item { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -38,3 +39,4 @@ unsafe fn main_0() -> i32 { assert!((((*ptr).flags as i32) == (0))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/compound_assign_ref.rs b/tests/unit/out/unsafe/compound_assign_ref.rs index 426080b35..6e0615058 100644 --- a/tests/unit/out/unsafe/compound_assign_ref.rs +++ b/tests/unit/out/unsafe/compound_assign_ref.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -18,3 +19,4 @@ unsafe fn main_0() -> i32 { assert!(((*((v).first_mut().unwrap())) == (15))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/constexpr_function.rs b/tests/unit/out/unsafe/constexpr_function.rs index 834672573..ca86502b9 100644 --- a/tests/unit/out/unsafe/constexpr_function.rs +++ b/tests/unit/out/unsafe/constexpr_function.rs @@ -33,6 +33,7 @@ impl P { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -49,3 +50,4 @@ unsafe fn main_0() -> i32 { assert!(((k) == (4))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/constructor.rs b/tests/unit/out/unsafe/constructor.rs index 558fd5eb6..77b3345ad 100644 --- a/tests/unit/out/unsafe/constructor.rs +++ b/tests/unit/out/unsafe/constructor.rs @@ -6,7 +6,7 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; -pub static mut total_0: i32 = unsafe { 0 }; +pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive(Clone, Default)] pub struct S { @@ -22,16 +22,19 @@ impl S { pub unsafe fn S(mut init: i32) -> Self { let mut this = Self { v: init }; (unsafe { S::mut_method(&mut this) }); - total_0 += (unsafe { S::const_method(&mut this) }); + (*std::cell::LazyCell::force_mut(&mut *&raw mut total_0)) += + (unsafe { S::const_method(&mut this) }); this } pub unsafe fn destructor(&mut self) { (unsafe { S::mut_method(self) }); - total_0 += (unsafe { S::const_method(self) }); + (*std::cell::LazyCell::force_mut(&mut *&raw mut total_0)) += + (unsafe { S::const_method(self) }); } } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -40,8 +43,11 @@ unsafe fn main_0() -> i32 { let mut s: S = S::S({ 3 }); let _dtor_s = ScopedDestructorUnsafe::new(&raw mut s, S::destructor); assert!(((s.v) == (4))); - assert!(((total_0) == (8))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_0)) == (8))); } - assert!(((total_0) == (18))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_0)) == (18))); return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const total_0); +} diff --git a/tests/unit/out/unsafe/continue.rs b/tests/unit/out/unsafe/continue.rs index 6db61b732..f188b5437 100644 --- a/tests/unit/out/unsafe/continue.rs +++ b/tests/unit/out/unsafe/continue.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -61,3 +62,4 @@ unsafe fn main_0() -> i32 { assert!(((out) == (81))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index d1b7469f2..5d5a6cc9e 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -6,7 +6,7 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; -pub static mut assigns_0: i32 = unsafe { 0 }; +pub static mut assigns_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive(Default)] pub struct Partial { @@ -30,7 +30,7 @@ impl Partial { return &mut (*(self as *mut Partial)); } self.v = (*o).v; - assigns_0.prefix_inc(); + (*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)).prefix_inc(); return &mut (*(self as *mut Partial)); } } @@ -105,6 +105,7 @@ impl Default for Holder { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -114,7 +115,7 @@ unsafe fn main_0() -> i32 { let mut c: Partial = Partial::Partial({ 3 }, { 300 }); (unsafe { Partial::operator_assign(&mut a, &b) }); assert!(((a.v) == (2)) && ((a.keep) == (100))); - assert!(((assigns_0) == (1))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (1))); (unsafe { Partial::operator_assign( &mut c, @@ -122,18 +123,18 @@ unsafe fn main_0() -> i32 { ) }); assert!(((c.v) == (2)) && ((c.keep) == (300))); - assert!(((assigns_0) == (3))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (3))); (unsafe { let _o: *const Partial = &a; Partial::operator_assign(&mut a, _o) }); - assert!(((assigns_0) == (3))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (3))); (unsafe { let mut _o: Partial = Partial::Partial({ 9 }, { 900 }); Partial::operator_assign(&mut a, &mut _o) }); assert!(((a.v) == (9)) && ((a.keep) == (100))); - assert!(((assigns_0) == (4))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (4))); let ra: *mut Partial = &mut a; (unsafe { let _o: *const Partial = &c; @@ -146,7 +147,7 @@ unsafe fn main_0() -> i32 { Partial::operator_assign(&mut (*pa), _o) }); assert!(((a.v) == (2))); - assert!(((assigns_0) == (6))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (6))); let mut h: Holder = Holder { p: Partial::Partial({ 4 }, { 40 }), arr: [ @@ -158,7 +159,7 @@ unsafe fn main_0() -> i32 { (unsafe { Partial::operator_assign(&mut h.arr[(1) as usize], &c) }); assert!(((h.p.v) == (2)) && ((h.p.keep) == (40))); assert!(((h.arr[(1) as usize].v) == (2)) && ((h.arr[(1) as usize].keep) == (60))); - assert!(((assigns_0) == (8))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (8))); let mut n: NonConstAssign = NonConstAssign::NonConstAssign(); let mut n1: NonConstAssign = NonConstAssign::NonConstAssign(); let mut n2: NonConstAssign = NonConstAssign::NonConstAssign(); @@ -173,3 +174,6 @@ unsafe fn main_0() -> i32 { assert!(((r1.mark) == (1))); return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const assigns_0); +} diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index e098c68f2..05a41353b 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -6,7 +6,7 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; -pub static mut copies_0: i32 = unsafe { 0 }; +pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive(Default)] pub struct Counted { @@ -19,7 +19,7 @@ impl Counted { } pub unsafe fn Counted_pconstCounted(o: *const Counted) -> Self { let mut this = Self { v: (*o).v }; - copies_0.prefix_inc(); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); this } } @@ -84,6 +84,7 @@ pub unsafe fn make_2(mut v: i32) -> Counted { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -92,20 +93,20 @@ unsafe fn main_0() -> i32 { let mut b: Counted = Counted::Counted_pconstCounted({ &a }); let mut c: Counted = Counted::Counted_pconstCounted({ &a }); let mut d: Counted = Counted::Counted_pconstCounted({ &a }); - assert!(((copies_0) == (3))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (3))); assert!((((b.v) == (1)) && ((c.v) == (1))) && ((d.v) == (1))); assert!(((unsafe { by_value_1(Counted::Counted_pconstCounted({ &a },),) }) == (1))); - assert!(((copies_0) == (4))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (4))); let mut e: Counted = (unsafe { make_2(5) }); assert!(((e.v) == (5))); - assert!(((copies_0) == (5))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (5))); let mut f: Counted = Counted::Counted({ 6 }); assert!(((f.v) == (6))); - assert!(((copies_0) == (5))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (5))); let g: Counted = Counted::Counted({ 7 }); let mut h: Counted = Counted::Counted_pconstCounted({ &g }); assert!(((h.v) == (7))); - assert!(((copies_0) == (6))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (6))); let mut hold: Holder = Holder { c: Counted::Counted({ 8 }), arr: [Counted::Counted({ 9 }), Counted::Counted({ 10 })], @@ -115,14 +116,14 @@ unsafe fn main_0() -> i32 { (((hold2.c.v) == (8)) && ((hold2.arr[(0) as usize].v) == (9))) && ((hold2.arr[(1) as usize].v) == (10)) ); - assert!(((copies_0) == (9))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (9))); let mut vec_: Vec = Vec::new(); { let a0_clone = a.clone(); vec_.push(a0_clone) }; assert!(((vec_[(0_usize)].v) == (1))); - assert!(((copies_0) == (10))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (10))); let mut n: NonConst = NonConst::NonConst(); let mut n1: NonConst = NonConst::NonConst_pmutNonConst({ &mut n }); let cn: NonConst = NonConst::NonConst(); @@ -131,3 +132,6 @@ unsafe fn main_0() -> i32 { assert!(((n2.mark) == (10))); return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const copies_0); +} diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index 8e7386881..b62d9d9b6 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -271,6 +271,7 @@ pub unsafe fn same_0(a: *const Explicit, b: *const Explicit) -> bool { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -445,3 +446,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index ac5257ac4..2e7fb4ea3 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -103,6 +103,7 @@ pub unsafe fn bump_ref_1(r: *mut Immovable) { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -133,3 +134,4 @@ unsafe fn main_0() -> i32 { assert!((((d.inner.v) == (6)) && ((d.tag) == (7))) && ((c.inner.v) == (0))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/cout_alias.rs b/tests/unit/out/unsafe/cout_alias.rs index 3b4f50114..01af49f17 100644 --- a/tests/unit/out/unsafe/cout_alias.rs +++ b/tests/unit/out/unsafe/cout_alias.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -39,3 +40,4 @@ unsafe fn main_0() -> i32 { write!((*os2), "hello\n",); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/cstring.rs b/tests/unit/out/unsafe/cstring.rs index 79cd91665..ea810293d 100644 --- a/tests/unit/out/unsafe/cstring.rs +++ b/tests/unit/out/unsafe/cstring.rs @@ -353,6 +353,7 @@ pub unsafe fn test_strcasecmp_15() { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -375,3 +376,4 @@ unsafe fn main_0() -> i32 { (unsafe { test_strcasecmp_15() }); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/default.rs b/tests/unit/out/unsafe/default.rs index dfee8f817..c8b2e3361 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -28,6 +28,7 @@ impl Default for Pointers { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -46,3 +47,4 @@ unsafe fn main_0() -> i32 { ))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/default_function_arguments.rs b/tests/unit/out/unsafe/default_function_arguments.rs index d52c03be5..3ee1ff59f 100644 --- a/tests/unit/out/unsafe/default_function_arguments.rs +++ b/tests/unit/out/unsafe/default_function_arguments.rs @@ -33,6 +33,7 @@ impl Default for Bar { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -57,3 +58,4 @@ unsafe fn main_0() -> i32 { assert!(((arr[(2) as usize].v) == (1))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index 3ef0e18b5..fdf3ae354 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -58,8 +58,9 @@ impl Default for Foo { } } } -pub static mut static_fn_0: Option i32> = unsafe { None }; -pub static mut static_outer_1: Outer = unsafe { +pub static mut static_fn_0: std::cell::LazyCell i32>> = + std::cell::LazyCell::new(|| unsafe { None }); +pub static mut static_outer_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { Outer { p1: std::ptr::null_mut(), p2: std::ptr::null(), @@ -73,14 +74,15 @@ pub static mut static_outer_1: Outer = unsafe { x: 0_i32, fn_: None, } -}; -pub static mut static_inner_array_2: [Inner; 2] = unsafe { - [Inner { - v: 0_i32, - name: std::ptr::null(), - }; 2] -}; -pub static mut static_foo_3: Foo = unsafe { +}); +pub static mut static_inner_array_2: std::cell::LazyCell<[Inner; 2]> = + std::cell::LazyCell::new(|| unsafe { + [Inner { + v: 0_i32, + name: std::ptr::null(), + }; 2] + }); +pub static mut static_foo_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { Foo { s1: c"hello".as_ptr(), s2: std::ptr::null(), @@ -88,27 +90,28 @@ pub static mut static_foo_3: Foo = unsafe { fn2: None, n: 42, } -}; -pub static mut static_foo_array_4: [Foo; 2] = unsafe { - [ - Foo { - s1: c"first".as_ptr(), - s2: std::ptr::null(), - fn1: None, - fn2: None, - n: 1, - }, - Foo { - s1: c"second".as_ptr(), - s2: std::ptr::null(), - fn1: None, - fn2: None, - n: 2, - }, - ] -}; +}); +pub static mut static_foo_array_4: std::cell::LazyCell<[Foo; 2]> = + std::cell::LazyCell::new(|| unsafe { + [ + Foo { + s1: c"first".as_ptr(), + s2: std::ptr::null(), + fn1: None, + fn2: None, + n: 1, + }, + Foo { + s1: c"second".as_ptr(), + s2: std::ptr::null(), + fn1: None, + fn2: None, + n: 2, + }, + ] + }); pub unsafe fn check_local_static_5() { - static mut local_outer_6: Outer = unsafe { + static mut local_outer_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { Outer { p1: std::ptr::null_mut(), p2: std::ptr::null(), @@ -122,48 +125,81 @@ pub unsafe fn check_local_static_5() { x: 0_i32, fn_: None, } - };; - static mut local_fn_7: Option i32> = unsafe { None };; - static mut local_p_8: *mut i32 = unsafe { std::ptr::null_mut() };; - assert!((local_outer_6.p1).is_null()); - assert!((local_outer_6.fn_).is_none()); - assert!((local_fn_7).is_none()); - assert!((local_p_8).is_null()); + });; + static mut local_fn_7: std::cell::LazyCell i32>> = + std::cell::LazyCell::new(|| unsafe { None });; + static mut local_p_8: std::cell::LazyCell<*mut i32> = + std::cell::LazyCell::new(|| unsafe { std::ptr::null_mut() });; + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut local_outer_6)).p1).is_null()); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut local_outer_6)).fn_).is_none()); + assert!((*std::cell::LazyCell::force_mut(&mut *&raw mut local_fn_7)).is_none()); + assert!((*std::cell::LazyCell::force_mut(&mut *&raw mut local_p_8)).is_null()); } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } unsafe fn main_0() -> i32 { - assert!((static_fn_0).is_none()); - assert!((static_outer_1.p1).is_null()); - assert!((static_outer_1.p2).is_null()); - assert!((static_outer_1.cp).is_null()); - assert!((static_outer_1.pp).is_null()); - assert!((static_outer_1.fn_).is_none()); + assert!((*std::cell::LazyCell::force_mut(&mut *&raw mut static_fn_0)).is_none()); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)).p1).is_null()); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)).p2).is_null()); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)).cp).is_null()); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)).pp).is_null()); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)).fn_).is_none()); let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - assert!((static_outer_1.arr[(i) as usize]).is_null()); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)).arr[(i) as usize]) + .is_null() + ); i.prefix_inc(); } - assert!((static_outer_1.inner.name).is_null()); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)) + .inner + .name) + .is_null() + ); let mut i: i32 = 0; 'loop_: while ((i) < (2)) { - assert!((static_inner_array_2[(i) as usize].name).is_null()); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_inner_array_2))[(i) as usize] + .name) + .is_null() + ); i.prefix_inc(); } - assert!((static_foo_3.s2).is_null()); - assert!((static_foo_3.fn1).is_none()); - assert!((static_foo_3.fn2).is_none()); - assert!(((static_foo_3.n) == (42))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_3)).s2).is_null()); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_3)).fn1).is_none()); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_3)).fn2).is_none()); + assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_3)).n) == (42))); let mut i: i32 = 0; 'loop_: while ((i) < (2)) { - assert!((static_foo_array_4[(i) as usize].s2).is_null()); - assert!((static_foo_array_4[(i) as usize].fn1).is_none()); - assert!((static_foo_array_4[(i) as usize].fn2).is_none()); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4))[(i) as usize].s2) + .is_null() + ); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4))[(i) as usize] + .fn1) + .is_none() + ); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4))[(i) as usize] + .fn2) + .is_none() + ); i.prefix_inc(); } (unsafe { check_local_static_5() }); return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const static_fn_0); + std::cell::LazyCell::force(&*&raw const static_outer_1); + std::cell::LazyCell::force(&*&raw const static_inner_array_2); + std::cell::LazyCell::force(&*&raw const static_foo_3); + std::cell::LazyCell::force(&*&raw const static_foo_array_4); +} diff --git a/tests/unit/out/unsafe/destructor.rs b/tests/unit/out/unsafe/destructor.rs index 4f8e74d18..a860b4a78 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -6,13 +6,13 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; -pub static mut global_0: i32 = unsafe { 0 }; +pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive(Clone, Default)] pub struct S {} impl S { pub unsafe fn destructor(&mut self) { - global_0.postfix_inc(); + (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)).postfix_inc(); } } #[repr(C)] @@ -81,9 +81,9 @@ pub struct Templated_char_ { } impl Templated_char_ { pub unsafe fn destructor(&mut self) { - global_0 = ((global_0 as usize) - .wrapping_add((::std::mem::size_of::() as usize))) - as i32; + (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) = + (((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) as usize) + .wrapping_add((::std::mem::size_of::() as usize))) as i32; } } #[repr(C)] @@ -93,8 +93,9 @@ pub struct Templated_int_ { } impl Templated_int_ { pub unsafe fn destructor(&mut self) { - global_0 = - ((global_0 as usize).wrapping_add((::std::mem::size_of::() as usize))) as i32; + (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) = + (((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) as usize) + .wrapping_add((::std::mem::size_of::() as usize))) as i32; } } #[repr(C)] @@ -104,11 +105,12 @@ pub struct Copied { } impl Copied { pub unsafe fn destructor(&mut self) { - global_0.postfix_inc(); + (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)).postfix_inc(); } } -pub static mut order_1: [i32; 3] = unsafe { [0_i32; 3] }; -pub static mut order_count_2: i32 = unsafe { 0 }; +pub static mut order_1: std::cell::LazyCell<[i32; 3]> = + std::cell::LazyCell::new(|| unsafe { [0_i32; 3] }); +pub static mut order_count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive(Clone, Default)] pub struct Tagged { @@ -116,7 +118,9 @@ pub struct Tagged { } impl Tagged { pub unsafe fn destructor(&mut self) { - order_1[(order_count_2.postfix_inc()) as usize] = self.tag; + (*std::cell::LazyCell::force_mut(&mut *&raw mut order_1)) + [((*std::cell::LazyCell::force_mut(&mut *&raw mut order_count_2)).postfix_inc()) + as usize] = self.tag; } } #[repr(C)] @@ -137,6 +141,7 @@ impl Ordered { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -145,36 +150,36 @@ unsafe fn main_0() -> i32 { let mut s: S = S {}; let _dtor_s = ScopedDestructorUnsafe::new(&raw mut s, S::destructor); } - assert!(((global_0) == (1))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (1))); { let mut s: S = S {}; let _dtor_s = ScopedDestructorUnsafe::new(&raw mut s, S::destructor); } - assert!(((global_0) == (2))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (2))); { let mut d: Defaulted = Defaulted { s: S {} }; let _dtor_d = ScopedDestructorUnsafe::new(&raw mut d, Defaulted::destructor); } - assert!(((global_0) == (3))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (3))); { let mut o: Outer = Outer { m: Middle { s: S {} }, }; let _dtor_o = ScopedDestructorUnsafe::new(&raw mut o, Outer::destructor); } - assert!(((global_0) == (4))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (4))); { let mut am: ArrayMember = ArrayMember { items: [S {}, S {}, S {}], }; let _dtor_am = ScopedDestructorUnsafe::new(&raw mut am, ArrayMember::destructor); } - assert!(((global_0) == (7))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (7))); { let mut e: EmptyBody = EmptyBody { s: S {} }; let _dtor_e = ScopedDestructorUnsafe::new(&raw mut e, EmptyBody::destructor); } - assert!(((global_0) == (8))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (8))); { let mut tc: Templated_char_ = Templated_char_ { v: (0 as libc::c_char), @@ -183,7 +188,7 @@ unsafe fn main_0() -> i32 { let mut ti: Templated_int_ = Templated_int_ { v: 0_i32 }; let _dtor_ti = ScopedDestructorUnsafe::new(&raw mut ti, Templated_int_::destructor); } - assert!(((global_0) == (13))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (13))); { let mut a: Copied = Copied { v: 5 }; let _dtor_a = ScopedDestructorUnsafe::new(&raw mut a, Copied::destructor); @@ -191,7 +196,7 @@ unsafe fn main_0() -> i32 { let _dtor_b = ScopedDestructorUnsafe::new(&raw mut b, Copied::destructor); assert!(((b.v) == (5))); } - assert!(((global_0) == (15))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (15))); { let mut o: Ordered = Ordered { first: Tagged { tag: 1 }, @@ -202,9 +207,14 @@ unsafe fn main_0() -> i32 { }; let _dtor_o = ScopedDestructorUnsafe::new(&raw mut o, Ordered::destructor); } - assert!(((order_count_2) == (3))); - assert!(((order_1[(0) as usize]) == (3))); - assert!(((order_1[(1) as usize]) == (2))); - assert!(((order_1[(2) as usize]) == (1))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut order_count_2)) == (3))); + assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut order_1))[(0) as usize]) == (3))); + assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut order_1))[(1) as usize]) == (2))); + assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut order_1))[(2) as usize]) == (1))); return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const global_0); + std::cell::LazyCell::force(&*&raw const order_1); + std::cell::LazyCell::force(&*&raw const order_count_2); +} diff --git a/tests/unit/out/unsafe/do_while_continue.rs b/tests/unit/out/unsafe/do_while_continue.rs index 787aa4909..6a1db1f66 100644 --- a/tests/unit/out/unsafe/do_while_continue.rs +++ b/tests/unit/out/unsafe/do_while_continue.rs @@ -42,6 +42,7 @@ pub unsafe fn nested_1() -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -50,3 +51,4 @@ unsafe fn main_0() -> i32 { assert!(((((unsafe { nested_1() }) == (6)) as i32) != 0)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index 0d414e79b..078ba921a 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -81,6 +81,7 @@ pub unsafe fn Tail_4(mut head: *mut Node) -> *mut Node { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -206,3 +207,4 @@ unsafe fn main_0() -> i32 { ); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/dowhile.rs b/tests/unit/out/unsafe/dowhile.rs index 973731a35..831fbe748 100644 --- a/tests/unit/out/unsafe/dowhile.rs +++ b/tests/unit/out/unsafe/dowhile.rs @@ -23,6 +23,7 @@ pub unsafe fn dowhile_0(mut x: i32) -> i32 { } pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -30,3 +31,4 @@ unsafe fn main_0() -> i32 { assert!(((unsafe { dowhile_0(0,) }) == (202))); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/empty_array_init.rs b/tests/unit/out/unsafe/empty_array_init.rs index 46d7970a5..96aec284c 100644 --- a/tests/unit/out/unsafe/empty_array_init.rs +++ b/tests/unit/out/unsafe/empty_array_init.rs @@ -8,6 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -15,3 +16,4 @@ unsafe fn main_0() -> i32 { let mut vec_: Vec = std::array::from_fn::<_, 3, _>(|_| Default::default()).to_vec(); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/empty_main.rs b/tests/unit/out/unsafe/empty_main.rs index 08a4a0a4b..c916b5a09 100644 --- a/tests/unit/out/unsafe/empty_main.rs +++ b/tests/unit/out/unsafe/empty_main.rs @@ -17,8 +17,12 @@ pub fn main() { .map(|arg| arg.as_ptr() as *mut libc::c_char) .collect(); argv.push(::std::ptr::null_mut()); - unsafe { ::std::process::exit(main_0((argv.len() - 1) as i32, argv.as_mut_ptr()) as i32) } + unsafe { + __cpp2rust_init_globals(); + ::std::process::exit(main_0((argv.len() - 1) as i32, argv.as_mut_ptr()) as i32) + } } unsafe fn main_0(mut _a0: i32, mut _a1: *mut *mut libc::c_char) -> i32 { return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/enum_comparisson_in_globals.rs b/tests/unit/out/unsafe/enum_comparisson_in_globals.rs index aca69a0e2..171ee229e 100644 --- a/tests/unit/out/unsafe/enum_comparisson_in_globals.rs +++ b/tests/unit/out/unsafe/enum_comparisson_in_globals.rs @@ -9,13 +9,18 @@ use std::rc::Rc; pub type E = u32; pub const E_A: E = 0; pub const E_B: E = 1; -pub static mut global_0: i32 = unsafe { (((E_A as i32) != (E_B as i32)) as i32) }; +pub static mut global_0: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { (((E_A as i32) != (E_B as i32)) as i32) }); pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } unsafe fn main_0() -> i32 { - assert!(((global_0) == (1))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (1))); return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const global_0); +} diff --git a/tests/unit/out/unsafe/enum_default_in_static.rs b/tests/unit/out/unsafe/enum_default_in_static.rs index a4818b42a..737123acf 100644 --- a/tests/unit/out/unsafe/enum_default_in_static.rs +++ b/tests/unit/out/unsafe/enum_default_in_static.rs @@ -16,19 +16,29 @@ pub struct Config { pub count: i32, pub mode: Mode, } -pub static mut config_0: Config = unsafe { +pub static mut config_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { Config { count: 0_i32, mode: Mode_MODE_NONE, } -}; +}); pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } unsafe fn main_0() -> i32 { - assert!(((((config_0.count) == (0)) as i32) != 0)); - assert!(((((config_0.mode as u32) == ((Mode_MODE_NONE as i32) as u32)) as i32) != 0)); + assert!( + (((((*std::cell::LazyCell::force_mut(&mut *&raw mut config_0)).count) == (0)) as i32) != 0) + ); + assert!( + (((((*std::cell::LazyCell::force_mut(&mut *&raw mut config_0)).mode as u32) + == ((Mode_MODE_NONE as i32) as u32)) as i32) + != 0) + ); return 0; } +pub unsafe fn __cpp2rust_init_globals() { + std::cell::LazyCell::force(&*&raw const config_0); +} diff --git a/tests/unit/out/unsafe/enum_increment.rs b/tests/unit/out/unsafe/enum_increment.rs index 780923f73..93c4ea436 100644 --- a/tests/unit/out/unsafe/enum_increment.rs +++ b/tests/unit/out/unsafe/enum_increment.rs @@ -13,6 +13,7 @@ pub const color_BLUE: color = 2; pub const color_COLOR_LAST: color = 3; pub fn main() { unsafe { + __cpp2rust_init_globals(); std::process::exit(main_0() as i32); } } @@ -31,3 +32,4 @@ unsafe fn main_0() -> i32 { assert!(((((c.prefix_dec() as u32) == ((color_RED as i32) as u32)) as i32) != 0)); return 0; } +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/enum_int_interop.rs b/tests/unit/out/unsafe/enum_int_interop.rs index 8c64334d8..349262bb2 100644 --- a/tests/unit/out/unsafe/enum_int_interop.rs +++ b/tests/unit/out/unsafe/enum_int_interop.rs @@ -26,10 +26,13 @@ pub struct Entry { pub color: Color, pub opt: Option, } -pub static mut global_color_0: Color = unsafe { Color_GREEN }; -pub static mut global_opt_1: Option = unsafe { Option_OPT_B }; -pub static mut global_tag_2: Tag = unsafe { Tag_TAG_TWO }; -pub static mut entries_3: [Entry; 3] = unsafe { +pub static mut global_color_0: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { Color_GREEN }); +pub static mut global_opt_1: std::cell::LazyCell