From 9c4090a86d6dfa0d1b57ad8b388110188d93ec6e Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 16 Oct 2026 19:59:45 +0100 Subject: [PATCH 1/4] Add until metadata for standard version --- CMakeLists.txt | 2 +- cpp2rust/converter/rules/rules_loader.cpp | 3 ++ .../rule_preprocessing/cpp_rule_indexer.cpp | 32 ++++++++++++++----- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 933b9a235..5500eabc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,7 +231,7 @@ set(rules_index_parts_dir ${CMAKE_BINARY_DIR}/rules_index/parts) set(RULES_IR_DIR "${CMAKE_BINARY_DIR}/rules") set(rust_rules_ir_outputs) foreach(_rule_dir IN LISTS rule_subdirs) - file(GLOB _cpp_srcs ${_rule_dir}/src.c ${_rule_dir}/src.cpp ${_rule_dir}/src_cxx*.cpp) + file(GLOB _cpp_srcs ${_rule_dir}/src.c ${_rule_dir}/src.cpp ${_rule_dir}/src_*.cpp) if(NOT _cpp_srcs) continue() endif() diff --git a/cpp2rust/converter/rules/rules_loader.cpp b/cpp2rust/converter/rules/rules_loader.cpp index 73f5c1bfe..7f12147d8 100644 --- a/cpp2rust/converter/rules/rules_loader.cpp +++ b/cpp2rust/converter/rules/rules_loader.cpp @@ -320,6 +320,9 @@ std::string BuildRulesEpilogue(const std::unordered_set &keys, if (auto since = rule->getInteger("since"); since && *since > standard) { continue; } + if (auto until = rule->getInteger("until"); until && *until <= standard) { + continue; + } if (auto required = rule->getArray("requires"); required && !llvm::all_of(*required, [&](const llvm::json::Value &key) { diff --git a/cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp b/cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp index 2478d6f2c..240431c17 100644 --- a/cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp +++ b/cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp @@ -335,15 +335,27 @@ llvm::json::Object ReadJson(const fs::path &path) { return std::move(*parsed->getAsObject()); } -unsigned SinceStandard(const fs::path &src_path) { +struct StandardRange { + unsigned since = 11; + unsigned until = 0; +}; + +StandardRange RuleFileStandards(const fs::path &src_path) { auto stem_string = src_path.stem().string(); llvm::StringRef stem = stem_string; - unsigned standard = 11; - if (stem.consume_front("src_cxx") && stem.getAsInteger(10, standard)) { + StandardRange range; + bool valid = stem.consume_front("src"); + if (valid && stem.consume_front("_cxx")) { + valid = !stem.consumeInteger(10, range.since); + } + if (valid && stem.consume_front("_until_cxx")) { + valid = !stem.consumeInteger(10, range.until); + } + if (!valid || !stem.empty()) { llvm::errs() << "ERROR: unexpected rule file " << src_path.string() << '\n'; std::exit(EXIT_FAILURE); } - return standard; + return range; } void MergeRules(llvm::json::Object &into, llvm::json::Object &&from) { @@ -364,20 +376,24 @@ void IndexDir(const fs::path &rule_dir, const fs::path &out) { for (const auto &entry : fs::directory_iterator(rule_dir)) { auto name = entry.path().filename().string(); if (name == "src.c" || name == "src.cpp" || - (name.starts_with("src_cxx") && name.ends_with(".cpp"))) { + (name.starts_with("src_") && name.ends_with(".cpp"))) { cxx_srcs.push_back(entry.path()); } } std::ranges::sort(cxx_srcs); llvm::json::Object cxx_rules; for (const auto &src_path : cxx_srcs) { - auto standard = SinceStandard(src_path); + auto range = RuleFileStandards(src_path); llvm::json::Object rules; Index(src_path, /*is_c=*/false, dir_name, - {std::format("-std=c++{}", standard)}, rules); + {std::format("-std=c++{}", range.since)}, rules); for (auto &[key, entries] : rules) { for (auto &entry : *entries.getAsArray()) { - (*entry.getAsObject())["since"] = standard; + auto &rule = *entry.getAsObject(); + rule["since"] = range.since; + if (range.until) { + rule["until"] = range.until; + } } } MergeRules(cxx_rules, std::move(rules)); From 9188d358d29230d09734ad427ae88c6ccf82115b Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 16 Oct 2026 20:07:32 +0100 Subject: [PATCH 2/4] Add example rules --- rules/algorithm/src_until_cxx17.cpp | 8 ++++++++ rules/algorithm/tgt_refcount.rs | 13 +++++++++++++ rules/algorithm/tgt_unsafe.rs | 8 ++++++++ rules/memory/src_until_cxx23.cpp | 11 +++++++++++ rules/memory/tgt_refcount.rs | 8 ++++++++ rules/memory/tgt_unsafe.rs | 6 ++++++ rules/string/src_until_cxx20.cpp | 6 ++++++ rules/string/tgt_refcount.rs | 4 ++++ rules/string/tgt_unsafe.rs | 7 +++++++ 9 files changed, 71 insertions(+) create mode 100644 rules/algorithm/src_until_cxx17.cpp create mode 100644 rules/memory/src_until_cxx23.cpp create mode 100644 rules/memory/tgt_refcount.rs create mode 100644 rules/memory/tgt_unsafe.rs create mode 100644 rules/string/src_until_cxx20.cpp diff --git a/rules/algorithm/src_until_cxx17.cpp b/rules/algorithm/src_until_cxx17.cpp new file mode 100644 index 000000000..09eb27554 --- /dev/null +++ b/rules/algorithm/src_until_cxx17.cpp @@ -0,0 +1,8 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +#include + +template void f18(T1 first, T1 last) { + return std::random_shuffle(first, last); +} diff --git a/rules/algorithm/tgt_refcount.rs b/rules/algorithm/tgt_refcount.rs index 52a96393e..fb5d275e3 100644 --- a/rules/algorithm/tgt_refcount.rs +++ b/rules/algorithm/tgt_refcount.rs @@ -117,3 +117,16 @@ fn f16(a0: Ptr, a1: Ptr) -> Ptr { fn f17(a0: Ptr, a1: Ptr) -> Ptr { if a0.read() >= a1.read() { a0 } else { a1 } } + +fn f18(a0: Ptr, a1: Ptr) { + let count = a1.get_offset() - a0.get_offset(); + let random = std::hash::RandomState::new(); + for i in (1..count).rev() { + let j = std::hash::BuildHasher::hash_one(&random, i) as usize % (i + 1); + let x = a0.offset(i); + let y = a0.offset(j); + let tmp = x.read(); + x.write(y.read()); + y.write(tmp); + } +} diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 6257589a5..ffec814fc 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -133,3 +133,11 @@ unsafe fn f17(a0: *const T1, a1: *const T1) -> *const T1 { (a1) as *const _ } } + +unsafe fn f18(a0: *mut T1, a1: *mut T1) { + let len = a1.offset_from(a0) as usize; + let slice = ::std::slice::from_raw_parts_mut(a0, len); + for i in (1..len).rev() { + slice.swap(i, libc::rand() as usize % (i + 1)); + } +} diff --git a/rules/memory/src_until_cxx23.cpp b/rules/memory/src_until_cxx23.cpp new file mode 100644 index 000000000..ad684538e --- /dev/null +++ b/rules/memory/src_until_cxx23.cpp @@ -0,0 +1,11 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +#include +#include + +void f1(char *a0, std::size_t a1) { return std::declare_no_pointers(a0, a1); } + +void f2(char *a0, std::size_t a1) { + return std::undeclare_no_pointers(a0, a1); +} diff --git a/rules/memory/tgt_refcount.rs b/rules/memory/tgt_refcount.rs new file mode 100644 index 000000000..e34c4b97f --- /dev/null +++ b/rules/memory/tgt_refcount.rs @@ -0,0 +1,8 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +use libcc2rs::*; + +fn f1(_a0: Ptr, _a1: usize) {} + +fn f2(_a0: Ptr, _a1: usize) {} diff --git a/rules/memory/tgt_unsafe.rs b/rules/memory/tgt_unsafe.rs new file mode 100644 index 000000000..7a68e55ba --- /dev/null +++ b/rules/memory/tgt_unsafe.rs @@ -0,0 +1,6 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +unsafe fn f1(_a0: *mut libc::c_char, _a1: usize) {} + +unsafe fn f2(_a0: *mut libc::c_char, _a1: usize) {} diff --git a/rules/string/src_until_cxx20.cpp b/rules/string/src_until_cxx20.cpp new file mode 100644 index 000000000..1e763b1fe --- /dev/null +++ b/rules/string/src_until_cxx20.cpp @@ -0,0 +1,6 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +#include + +bool f31(const std::string &a, const char *b) { return a != b; } diff --git a/rules/string/tgt_refcount.rs b/rules/string/tgt_refcount.rs index 96b9cb6ed..4d96960d2 100644 --- a/rules/string/tgt_refcount.rs +++ b/rules/string/tgt_refcount.rs @@ -190,3 +190,7 @@ fn f29(a0: Ptr>, a1: Vec) { fn f30(a0: Ptr>, a1: &mut Vec) { a0.write(std::mem::take(&mut *a1)) } + +fn f31(a0: Vec, a1: Ptr) -> bool { + a1.with_c_str(|__s| a0[..a0.len().saturating_sub(1)] != *__s) +} diff --git a/rules/string/tgt_unsafe.rs b/rules/string/tgt_unsafe.rs index a31efb208..a7b7966de 100644 --- a/rules/string/tgt_unsafe.rs +++ b/rules/string/tgt_unsafe.rs @@ -184,3 +184,10 @@ unsafe fn f29(a0: &mut Vec, a1: Vec) { unsafe fn f30(a0: &mut Vec, a1: &mut Vec) { *a0 = std::mem::take(&mut *a1) } + +unsafe fn f31(a0: Vec, a1: *const libc::c_char) -> bool { + a0 != { + let s = a1; + std::slice::from_raw_parts(s, (0..).take_while(|&i| *s.add(i) != 0).count() + 1).to_vec() + } +} From e383ae592c0a53184cbfc5fbcda3660d281ac928 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 16 Oct 2026 20:13:41 +0100 Subject: [PATCH 3/4] Add tests --- rules/memory/src_until_cxx23.cpp | 4 +--- rules/memory/tgt_refcount.rs | 8 ++++++-- rules/memory/tgt_unsafe.rs | 8 ++++++-- tests/unit/08_unique_array.cpp | 6 ++++++ tests/unit/elidable_iterator_copy_cxx11.cpp | 3 +++ tests/unit/out/refcount/08_unique_array.rs | 7 +++++++ .../out/refcount/elidable_iterator_copy_cxx11.rs | 15 +++++++++++++++ tests/unit/out/refcount/string.rs | 8 ++++++++ tests/unit/out/unsafe/08_unique_array.rs | 9 +++++++++ .../out/unsafe/elidable_iterator_copy_cxx11.rs | 12 ++++++++++++ tests/unit/out/unsafe/string.rs | 14 ++++++++++++++ tests/unit/string.cpp | 3 +++ 12 files changed, 90 insertions(+), 7 deletions(-) diff --git a/rules/memory/src_until_cxx23.cpp b/rules/memory/src_until_cxx23.cpp index ad684538e..6f9da5933 100644 --- a/rules/memory/src_until_cxx23.cpp +++ b/rules/memory/src_until_cxx23.cpp @@ -6,6 +6,4 @@ void f1(char *a0, std::size_t a1) { return std::declare_no_pointers(a0, a1); } -void f2(char *a0, std::size_t a1) { - return std::undeclare_no_pointers(a0, a1); -} +void f2(char *a0, std::size_t a1) { return std::undeclare_no_pointers(a0, a1); } diff --git a/rules/memory/tgt_refcount.rs b/rules/memory/tgt_refcount.rs index e34c4b97f..f885e978f 100644 --- a/rules/memory/tgt_refcount.rs +++ b/rules/memory/tgt_refcount.rs @@ -3,6 +3,10 @@ use libcc2rs::*; -fn f1(_a0: Ptr, _a1: usize) {} +fn f1(a0: Ptr, a1: usize) { + () +} -fn f2(_a0: Ptr, _a1: usize) {} +fn f2(a0: Ptr, a1: usize) { + () +} diff --git a/rules/memory/tgt_unsafe.rs b/rules/memory/tgt_unsafe.rs index 7a68e55ba..9d31fca82 100644 --- a/rules/memory/tgt_unsafe.rs +++ b/rules/memory/tgt_unsafe.rs @@ -1,6 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -unsafe fn f1(_a0: *mut libc::c_char, _a1: usize) {} +unsafe fn f1(a0: *mut libc::c_char, a1: usize) { + () +} -unsafe fn f2(_a0: *mut libc::c_char, _a1: usize) {} +unsafe fn f2(a0: *mut libc::c_char, a1: usize) { + () +} diff --git a/tests/unit/08_unique_array.cpp b/tests/unit/08_unique_array.cpp index a34d3765c..db6094a40 100644 --- a/tests/unit/08_unique_array.cpp +++ b/tests/unit/08_unique_array.cpp @@ -1,3 +1,4 @@ +// ADDITIONAL_COMPILE_FLAGS: -std=c++20 #include #include @@ -9,5 +10,10 @@ int main() { g_ptr[0] = 13; g_ptr[1] = 14; assert(g[0] + g[1] == 27); + auto buf = std::make_unique(16); + std::declare_no_pointers(buf.get(), 16); + buf[0] = 'x'; + std::undeclare_no_pointers(buf.get(), 16); + assert(buf[0] == 'x'); return 0; } diff --git a/tests/unit/elidable_iterator_copy_cxx11.cpp b/tests/unit/elidable_iterator_copy_cxx11.cpp index 6b8fad741..fbb30febd 100644 --- a/tests/unit/elidable_iterator_copy_cxx11.cpp +++ b/tests/unit/elidable_iterator_copy_cxx11.cpp @@ -10,5 +10,8 @@ int main() { std::vector::iterator it = std::find(v.begin(), v.end(), 7); assert(it != v.end()); assert(*it == 7); + std::random_shuffle(v.begin(), v.end()); + std::sort(v.begin(), v.end()); + assert(v[0] == 4 && v[1] == 7); return 0; } diff --git a/tests/unit/out/refcount/08_unique_array.rs b/tests/unit/out/refcount/08_unique_array.rs index ab21d5dd7..5632155f9 100644 --- a/tests/unit/out/refcount/08_unique_array.rs +++ b/tests/unit/out/refcount/08_unique_array.rs @@ -24,6 +24,13 @@ fn main_0() -> i32 { + g.as_ref().unwrap().borrow()[(1_usize) as usize]) == 27) ); + let mut buf: Option>> = Some(Rc::new(RefCell::new( + (0..16_usize).map(|_| ::default()).collect::>(), + ))); + (); + buf.as_ref().unwrap().borrow_mut()[(0_usize) as usize] = ('x' as i8); + (); + assert!(((buf.as_ref().unwrap().borrow()[(0_usize) as usize] as i32) == (('x' as i8) as i32))); return 0; } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs index cda73dcf7..adc8e2314 100644 --- a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs @@ -34,6 +34,21 @@ fn main_0() -> i32 { }; assert!(it != (v.as_pointer() as Ptr).to_end()); assert!(((it.read()) == 7)); + { + let count = (v.as_pointer() as Ptr).to_end().get_offset() + - (v.as_pointer() as Ptr).get_offset(); + let random = std::hash::RandomState::new(); + for i in (1..count).rev() { + let j = std::hash::BuildHasher::hash_one(&random, i) as usize % (i + 1); + let x = (v.as_pointer() as Ptr).offset(i); + let y = (v.as_pointer() as Ptr).offset(j); + let tmp = x.read(); + x.write(y.read()); + y.write(tmp); + } + }; + (v.as_pointer() as Ptr).sort((v.as_pointer() as Ptr).to_end().get_offset()); + assert!(({ (*v.borrow())[0_usize] } == 4) && ({ (*v.borrow())[1_usize] } == 7)); return 0; } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/string.rs b/tests/unit/out/refcount/string.rs index 1f4e13a22..69da8da79 100644 --- a/tests/unit/out/refcount/string.rs +++ b/tests/unit/out/refcount/string.rs @@ -29,6 +29,14 @@ fn main_0() -> i32 { Ptr::::from_string_literal(b"hello") .with_c_str(|__s| (*s1.borrow())[..(*s1.borrow()).len().saturating_sub(1)] == *__s) ); + assert!( + Ptr::::from_string_literal(b"world") + .with_c_str(|__s| (*s1.borrow())[..(*s1.borrow()).len().saturating_sub(1)] != *__s) + ); + assert!( + !(Ptr::::from_string_literal(b"hello") + .with_c_str(|__s| (*s1.borrow())[..(*s1.borrow()).len().saturating_sub(1)] != *__s)) + ); let mut p1: Ptr = (s1.as_pointer() as Ptr); assert!((((elem!(p1, 0).read()) as i32) == (('h' as i8) as i32))); assert!((((elem!(p1, 1).read()) as i32) == (('e' as i8) as i32))); diff --git a/tests/unit/out/unsafe/08_unique_array.rs b/tests/unit/out/unsafe/08_unique_array.rs index 52325f4c3..f098f4f3a 100644 --- a/tests/unit/out/unsafe/08_unique_array.rs +++ b/tests/unit/out/unsafe/08_unique_array.rs @@ -23,6 +23,15 @@ unsafe fn main_0() -> i32 { (*g_ptr.offset((0) as isize)) = 13; (*g_ptr.offset((1) as isize)) = 14; assert!((((g.as_mut().unwrap()[(0_usize)]) + (g.as_mut().unwrap()[(1_usize)])) == (27))); + let mut buf: Option> = Some( + (0..16_usize) + .map(|_| ::default()) + .collect::>(), + ); + (); + buf.as_mut().unwrap()[(0_usize)] = ('x' as libc::c_char); + (); + assert!(((buf.as_mut().unwrap()[(0_usize)] as i32) == (('x' as libc::c_char) as i32))); return 0; } pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs index ddbf28195..e53770a75 100644 --- a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs @@ -31,6 +31,18 @@ unsafe fn main_0() -> i32 { }; assert!(it != v.as_mut_ptr().add(v.len())); assert!(((*it) == (7))); + { + let len = v.as_mut_ptr().add(v.len()).offset_from(v.as_mut_ptr()) as usize; + let slice = ::std::slice::from_raw_parts_mut(v.as_mut_ptr(), len); + for i in (1..len).rev() { + slice.swap(i, libc::rand() as usize % (i + 1)); + } + }; + { + let len = v.as_mut_ptr().add(v.len()).offset_from(v.as_mut_ptr()) as usize; + ::std::slice::from_raw_parts_mut(v.as_mut_ptr(), len).sort() + }; + assert!(((v[(0_usize)]) == (4)) && ((v[(1_usize)]) == (7))); return 0; } pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/string.rs b/tests/unit/out/unsafe/string.rs index 71432816b..eb2fe255e 100644 --- a/tests/unit/out/unsafe/string.rs +++ b/tests/unit/out/unsafe/string.rs @@ -33,6 +33,20 @@ unsafe fn main_0() -> i32 { .to_vec() } ); + assert!( + s1 != { + let s = c"world".as_ptr(); + std::slice::from_raw_parts(s, (0..).take_while(|&i| *s.add(i) != 0).count() + 1) + .to_vec() + } + ); + assert!( + !(s1 != { + let s = c"hello".as_ptr(); + std::slice::from_raw_parts(s, (0..).take_while(|&i| *s.add(i) != 0).count() + 1) + .to_vec() + }) + ); let mut p1: *const libc::c_char = (s1.as_mut_ptr()).cast_const(); assert!((((*p1.offset((0) as isize)) as i32) == (('h' as libc::c_char) as i32))); assert!((((*p1.offset((1) as isize)) as i32) == (('e' as libc::c_char) as i32))); diff --git a/tests/unit/string.cpp b/tests/unit/string.cpp index 560531bce..41ba4d0ee 100644 --- a/tests/unit/string.cpp +++ b/tests/unit/string.cpp @@ -1,3 +1,4 @@ +// ADDITIONAL_COMPILE_FLAGS: -std=c++17 #include #include #include @@ -14,6 +15,8 @@ int main() { assert(s1[3] == 'l'); assert(s1[4] == 'o'); assert(s1 == "hello"); + assert(s1 != "world"); + assert(!(s1 != "hello")); const char *p1 = s1.data(); assert(p1[0] == 'h'); assert(p1[1] == 'e'); From b397865a12b718dd08d3de65abbd878181d3c546 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 16 Oct 2026 20:27:22 +0100 Subject: [PATCH 4/4] Remove memory rules, macos donesn't have them --- rules/memory/src_until_cxx23.cpp | 9 --------- rules/memory/tgt_refcount.rs | 12 ------------ rules/memory/tgt_unsafe.rs | 10 ---------- tests/unit/08_unique_array.cpp | 6 ------ tests/unit/out/refcount/08_unique_array.rs | 7 ------- tests/unit/out/unsafe/08_unique_array.rs | 9 --------- 6 files changed, 53 deletions(-) delete mode 100644 rules/memory/src_until_cxx23.cpp delete mode 100644 rules/memory/tgt_refcount.rs delete mode 100644 rules/memory/tgt_unsafe.rs diff --git a/rules/memory/src_until_cxx23.cpp b/rules/memory/src_until_cxx23.cpp deleted file mode 100644 index 6f9da5933..000000000 --- a/rules/memory/src_until_cxx23.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2022-present INESC-ID. -// Distributed under the MIT license that can be found in the LICENSE file. - -#include -#include - -void f1(char *a0, std::size_t a1) { return std::declare_no_pointers(a0, a1); } - -void f2(char *a0, std::size_t a1) { return std::undeclare_no_pointers(a0, a1); } diff --git a/rules/memory/tgt_refcount.rs b/rules/memory/tgt_refcount.rs deleted file mode 100644 index f885e978f..000000000 --- a/rules/memory/tgt_refcount.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2022-present INESC-ID. -// Distributed under the MIT license that can be found in the LICENSE file. - -use libcc2rs::*; - -fn f1(a0: Ptr, a1: usize) { - () -} - -fn f2(a0: Ptr, a1: usize) { - () -} diff --git a/rules/memory/tgt_unsafe.rs b/rules/memory/tgt_unsafe.rs deleted file mode 100644 index 9d31fca82..000000000 --- a/rules/memory/tgt_unsafe.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2022-present INESC-ID. -// Distributed under the MIT license that can be found in the LICENSE file. - -unsafe fn f1(a0: *mut libc::c_char, a1: usize) { - () -} - -unsafe fn f2(a0: *mut libc::c_char, a1: usize) { - () -} diff --git a/tests/unit/08_unique_array.cpp b/tests/unit/08_unique_array.cpp index db6094a40..a34d3765c 100644 --- a/tests/unit/08_unique_array.cpp +++ b/tests/unit/08_unique_array.cpp @@ -1,4 +1,3 @@ -// ADDITIONAL_COMPILE_FLAGS: -std=c++20 #include #include @@ -10,10 +9,5 @@ int main() { g_ptr[0] = 13; g_ptr[1] = 14; assert(g[0] + g[1] == 27); - auto buf = std::make_unique(16); - std::declare_no_pointers(buf.get(), 16); - buf[0] = 'x'; - std::undeclare_no_pointers(buf.get(), 16); - assert(buf[0] == 'x'); return 0; } diff --git a/tests/unit/out/refcount/08_unique_array.rs b/tests/unit/out/refcount/08_unique_array.rs index 5632155f9..ab21d5dd7 100644 --- a/tests/unit/out/refcount/08_unique_array.rs +++ b/tests/unit/out/refcount/08_unique_array.rs @@ -24,13 +24,6 @@ fn main_0() -> i32 { + g.as_ref().unwrap().borrow()[(1_usize) as usize]) == 27) ); - let mut buf: Option>> = Some(Rc::new(RefCell::new( - (0..16_usize).map(|_| ::default()).collect::>(), - ))); - (); - buf.as_ref().unwrap().borrow_mut()[(0_usize) as usize] = ('x' as i8); - (); - assert!(((buf.as_ref().unwrap().borrow()[(0_usize) as usize] as i32) == (('x' as i8) as i32))); return 0; } pub 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 f098f4f3a..52325f4c3 100644 --- a/tests/unit/out/unsafe/08_unique_array.rs +++ b/tests/unit/out/unsafe/08_unique_array.rs @@ -23,15 +23,6 @@ unsafe fn main_0() -> i32 { (*g_ptr.offset((0) as isize)) = 13; (*g_ptr.offset((1) as isize)) = 14; assert!((((g.as_mut().unwrap()[(0_usize)]) + (g.as_mut().unwrap()[(1_usize)])) == (27))); - let mut buf: Option> = Some( - (0..16_usize) - .map(|_| ::default()) - .collect::>(), - ); - (); - buf.as_mut().unwrap()[(0_usize)] = ('x' as libc::c_char); - (); - assert!(((buf.as_mut().unwrap()[(0_usize)] as i32) == (('x' as libc::c_char) as i32))); return 0; } pub unsafe fn __cpp2rust_init_globals() {}