Skip to content

Commit

Permalink
Merge pull request 1437 from anforowicz/cxx20-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Feb 9, 2025
2 parents 178f408 + bc83620 commit 4ff8185
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
matrix:
rust: [nightly, beta, stable, 1.82.0, 1.77.0, 1.74.0, 1.73.0]
os: [ubuntu]
flags: ['']
include:
- name: Cargo on macOS
rust: nightly
Expand All @@ -31,6 +32,18 @@ jobs:
rust: nightly-x86_64-pc-windows-msvc
os: windows
flags: /EHsc
- name: C++14
rust: nightly
os: ubuntu
flags: -std=c++14
- name: C++17
rust: nightly
os: ubuntu
flags: -std=c++17
- name: C++20
rust: nightly
os: ubuntu
flags: -std=c++20
env:
CXXFLAGS: ${{matrix.flags}}
RUSTFLAGS: --cfg deny_warnings -Dwarnings
Expand Down
4 changes: 4 additions & 0 deletions include/cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class String final {
String(const char *, std::size_t);
String(const char16_t *);
String(const char16_t *, std::size_t);
#if __cplusplus >= 202002L
String(const char8_t *s) : String(reinterpret_cast<const char*>(s)) {}
String(const char8_t *s, std::size_t len) : String(reinterpret_cast<const char*>(s), len) {}
#endif

// Replace invalid Unicode data with the replacement character (U+FFFD).
static String lossy(const std::string &) noexcept;
Expand Down
3 changes: 2 additions & 1 deletion tests/ffi/tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,8 @@ extern "C" const char *cxx_run_test() noexcept {
ASSERT(cstr == "foo");
ASSERT(other_cstr == "test");

const char *utf8_literal = u8"Test string";
// u8"foo" is `const char*` before, and `const char8_t*` after C++20, so using `auto`.
const auto *utf8_literal = u8"Test string";
const char16_t *utf16_literal = u"Test string";
rust::String utf8_rstring = utf8_literal;
rust::String utf16_rstring = utf16_literal;
Expand Down

0 comments on commit 4ff8185

Please sign in to comment.