2019 Commits

Author SHA1 Message Date
David Tolnay
2e040531f3
Merge pull request #651 from dtolnay/slices
Enable slices and arrays containing str/slice
2021-01-02 23:24:26 -08:00
David Tolnay
bf9d6e815b
Enable slices and arrays containing str/slice 2021-01-02 23:11:01 -08:00
David Tolnay
10852ed506
Fix slice restriction to exclude slice of CxxString 2021-01-02 23:07:18 -08:00
David Tolnay
4d7e4aa3a8
Merge pull request #650 from dtolnay/lifetime
Support lifetimes on shared structs
2021-01-02 23:04:57 -08:00
David Tolnay
62da031965
Test a struct definition containing lifetimes and derives 2021-01-02 22:53:15 -08:00
David Tolnay
bc25f11e7b
Emit lifetimes into struct derived impls 2021-01-02 22:52:23 -08:00
David Tolnay
81b69558e4
Emit lifetimes into struct definition 2021-01-02 22:49:17 -08:00
David Tolnay
43d03b6737
Parse lifetimes on shared structs 2021-01-02 22:47:46 -08:00
David Tolnay
341f1a19d3
Merge pull request #649 from dtolnay/warnings
Build with -Werror in CI
2021-01-02 22:04:07 -08:00
David Tolnay
fc07064015
Revert "Trigger intentional warning in cxx.cc" 2021-01-02 21:30:43 -08:00
David Tolnay
0e84959b2a
Enable deny_warnings in CI 2021-01-02 21:30:43 -08:00
David Tolnay
970ed99049
Add an option to fail build on C++ compile warnings 2021-01-02 21:30:42 -08:00
David Tolnay
a9b3a77ba8
Trigger intentional warning in cxx.cc 2021-01-02 21:30:42 -08:00
David Tolnay
e5cd1489e3
Fix remaining "C-linkage specified, but returns UDT" warnings on macOS 2021-01-02 21:28:14 -08:00
David Tolnay
85805cec90
Turn off explicit instantiations in test suite on MSVC
MSVC warns about the ones that are specialized out of line.

    cxxbridge\include\rust/cxx.h(324): warning C4661: 'rust::cxxbridge1::Vec<uint8_t>::Vec(void) noexcept': no suitable definition provided for explicit template instantiation request
    cxxbridge\include\rust/cxx.h(269): note: see declaration of 'rust::cxxbridge1::Vec<uint8_t>::Vec'
    cxxbridge\include\rust/cxx.h(324): warning C4661: 'size_t rust::cxxbridge1::Vec<uint8_t>::size(void) noexcept const': no suitable definition provided for explicit template instantiation request
    cxxbridge\include\rust/cxx.h(278): note: see declaration of 'rust::cxxbridge1::Vec<uint8_t>::size'
    cxxbridge\include\rust/cxx.h(324): warning C4661: 'const T *rust::cxxbridge1::Vec<T>::data(void) noexcept const': no suitable definition provided for explicit template instantiation request
            with
            [
                T=uint8_t
            ]
    cxxbridge\include\rust/cxx.h(280): note: see declaration of 'rust::cxxbridge1::Vec<uint8_t>::data'
    cxxbridge\include\rust/cxx.h(324): warning C4661: 'size_t rust::cxxbridge1::Vec<uint8_t>::capacity(void) noexcept const': no suitable definition provided for explicit template instantiation request
    cxxbridge\include\rust/cxx.h(282): note: see declaration of 'rust::cxxbridge1::Vec<uint8_t>::capacity'
2021-01-02 20:06:28 -08:00
David Tolnay
671d2b90ea
Enable standard exception handling for MSVC in CI 2021-01-02 18:55:34 -08:00
David Tolnay
e229bf7193
Merge pull request #648 from dtolnay/destructor
Explicitly delete opaque Rust type destructors
2021-01-02 18:55:11 -08:00
David Tolnay
8f940cf269
Explicitly delete opaque Rust type destructors
I guess MSVC finds this important enough to emit warnings about.

    cxxbridge\sources\tests\ffi\lib.rs.cc(1220): warning C4624: 'tests::R': destructor was implicitly defined as deleted
2021-01-02 18:45:02 -08:00
David Tolnay
fe77f3323b
Resolve MSVC "C-linkage specified, but returns UDT" warning
cxxbridge\sources\tests\ffi\lib.rs.cc(1335): warning C4190: 'tests$cxxbridge1$c_return_str' has C-linkage specified, but returns UDT 'rust::cxxbridge1::Str' which is incompatible with C
    cxxbridge\include\rust/cxx.h(93): note: see declaration of 'rust::cxxbridge1::Str'
    cxxbridge\sources\tests\ffi\lib.rs.cc(1340): warning C4190: 'tests$cxxbridge1$c_return_slice_char' has C-linkage specified, but returns UDT 'rust::cxxbridge1::Slice<const char>' which is incompatible with C
    cxxbridge\crate\tests/ffi/tests.h(93): note: see declaration of 'rust::cxxbridge1::Slice<const char>'
    cxxbridge\sources\tests\ffi\lib.rs.cc(1345): warning C4190: 'tests$cxxbridge1$c_return_mutsliceu8' has C-linkage specified, but returns UDT 'rust::cxxbridge1::Slice<uint8_t>' which is incompatible with C
    cxxbridge\crate\tests/ffi/tests.h(94): note: see declaration of 'rust::cxxbridge1::Slice<uint8_t>'
    cxxbridge\sources\tests\ffi\lib.rs.cc(1976): warning C4190: 'tests$cxxbridge1$r_return_str' has C-linkage specified, but returns UDT 'rust::cxxbridge1::Str' which is incompatible with C
    cxxbridge\include\rust/cxx.h(93): note: see declaration of 'rust::cxxbridge1::Str'
    cxxbridge\sources\tests\ffi\lib.rs.cc(1978): warning C4190: 'tests$cxxbridge1$r_return_sliceu8' has C-linkage specified, but returns UDT 'rust::cxxbridge1::Slice<const uint8_t>' which is incompatible with C
    cxxbridge\crate\tests/ffi/tests.h(163): note: see declaration of 'rust::cxxbridge1::Slice<const uint8_t>'
    cxxbridge\sources\tests\ffi\lib.rs.cc(1980): warning C4190: 'tests$cxxbridge1$r_return_mutsliceu8' has C-linkage specified, but returns UDT 'rust::cxxbridge1::Slice<uint8_t>' which is incompatible with C
    cxxbridge\crate\tests/ffi/tests.h(94): note: see declaration of 'rust::cxxbridge1::Slice<uint8_t>'
2021-01-02 18:34:50 -08:00
David Tolnay
8b22953347
Reduce indentation in write_data_structures 2021-01-02 18:30:45 -08:00
David Tolnay
36614d60d4
Move triviality static assertions to implementation files only 2021-01-02 18:30:15 -08:00
David Tolnay
e05de8796e
Move template class workaround to implementation files only 2021-01-02 18:21:06 -08:00
David Tolnay
bf6731a13b
Clean up stray whitespace from PR 642 2021-01-02 17:31:34 -08:00
David Tolnay
4ddae80e7d
Allow through bad_alloc from Error(const Error &) and operator= 2021-01-02 16:48:50 -08:00
David Tolnay
10c48f5904
Resolve msvc warning on strncpy by replacing with memcpy
src/cxx.cc(356): error C2220: the following warning is treated as an error
    src/cxx.cc(356): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2021-01-02 16:40:08 -08:00
David Tolnay
837eefee5e
Simplify to_c_error by using NonNull inline 2021-01-02 16:24:00 -08:00
David Tolnay
6c12520836
Clean some unneeded string manipulation from exception conversion
These used to be needed prior to #644.
2021-01-02 16:24:00 -08:00
David Tolnay
ba750b626d
Silence -Wunused-private-field warning on macOS
In file included from src/cxx.cc:1:
    src/../include/cxx.h:131:33: error: private field 'repr' is not used [-Werror,-Wunused-private-field]
      std::array<std::uintptr_t, 2> repr;
                                    ^
2021-01-02 16:24:00 -08:00
David Tolnay
dc2d4c3747
Mark error conversion function noexcept
This prevents a std::bad_alloc exception from operator new[] from
potentially propagating into Rust, which would be UB.
2021-01-02 16:14:31 -08:00
David Tolnay
0194dc5947
Merge pull request #647 from dtolnay/slice
Preserve &[T]'s Rust representation in rust::Slice
2021-01-02 15:28:21 -08:00
David Tolnay
0e1cc3da8c
Hide slice implementation details from name lookup 2021-01-02 15:09:03 -08:00
David Tolnay
0e3f776362
Fix slice compilation on MSVC
cxxbridge-demo.lib(blobstore.o) : error LNK2019: unresolved external symbol "void __cdecl sliceInit(void *,void const *,unsigned __int64)" (?sliceInit@@YAXPEAXPEBX_K@Z) referenced in function "public: __cdecl rust::cxxbridge1::Slice<unsigned char const >::Slice<unsigned char const >(unsigned char const *,unsigned __int64)" (??0?$Slice@$$CBE@cxxbridge1@rust@@QEAA@PEBE_K@Z)
    cxxbridge-demo.lib(blobstore.o) : error LNK2001: unresolved external symbol "void __cdecl sliceInit(void *,void const *,unsigned __int64)" (?sliceInit@@YAXPEAXPEBX_K@Z)
    cxxbridge-demo.lib(main.rs.o) : error LNK2001: unresolved external symbol "void __cdecl sliceInit(void *,void const *,unsigned __int64)" (?sliceInit@@YAXPEAXPEBX_K@Z)
    cxxbridge-demo.lib(main.rs.o) : error LNK2001: unresolved external symbol "void __cdecl sliceInit(void *,void const *,unsigned __int64)" (?sliceInit@@YAXPEAXPEBX_K@Z)
      Hint on symbols that are defined and could potentially match:
        "void __cdecl rust::cxxbridge1::sliceInit(void *,void const *,unsigned __int64)" (?sliceInit@cxxbridge1@rust@@YAXPEAXPEBX_K@Z)
    cxxbridge-demo.lib(blobstore.o) : error LNK2019: unresolved external symbol "unsigned __int64 __cdecl sliceLen(void const *)" (?sliceLen@@YA_KPEBX@Z) referenced in function "public: unsigned __int64 __cdecl rust::cxxbridge1::Slice<unsigned char const >::size(void)const " (?size@?$Slice@$$CBE@cxxbridge1@rust@@QEBA_KXZ)
    cxxbridge-demo.lib(main.rs.o) : error LNK2001: unresolved external symbol "unsigned __int64 __cdecl sliceLen(void const *)" (?sliceLen@@YA_KPEBX@Z)
      Hint on symbols that are defined and could potentially match:
        "unsigned __int64 __cdecl rust::cxxbridge1::sliceLen(void const *)" (?sliceLen@cxxbridge1@rust@@YA_KPEBX@Z)
    cxxbridge-demo.lib(blobstore.o) : error LNK2019: unresolved external symbol "void * __cdecl slicePtr(void const *)" (?slicePtr@@YAPEAXPEBX@Z) referenced in function "private: void * __cdecl rust::cxxbridge1::Slice<unsigned char const >::ptr(void)const " (?ptr@?$Slice@$$CBE@cxxbridge1@rust@@AEBAPEAXXZ)
    cxxbridge-demo.lib(main.rs.o) : error LNK2001: unresolved external symbol "void * __cdecl slicePtr(void const *)" (?slicePtr@@YAPEAXPEBX@Z)
      Hint on symbols that are defined and could potentially match:
        "void * __cdecl rust::cxxbridge1::slicePtr(void const *)" (?slicePtr@cxxbridge1@rust@@YAPEAXPEBX@Z)
    D:\a\cxx\cxx\target\debug\deps\demo.exe : fatal error LNK1120: 3 unresolved externals
2021-01-02 15:08:09 -08:00
David Tolnay
9bffb93783
Preserve &[T]'s Rust representation in rust::Slice 2021-01-02 15:01:59 -08:00
David Tolnay
2a58a8afdf
Merge pull request #646 from dtolnay/swap
Restore swapping Str and Slice in member function form only
2021-01-02 14:05:11 -08:00
David Tolnay
0413ee2709
Restore swapping Str and Slice in member function form only 2021-01-02 13:57:48 -08:00
David Tolnay
815ca8cafc
Revert "Omit swap member functions from website"
This reverts commit d835ac6cadf7cf1cee76f2e108248e083e4236ea.
2021-01-02 13:57:30 -08:00
David Tolnay
d1812baec0
Merge pull request #645 from dtolnay/str
Preserve &str's original Rust representation in C++
2021-01-02 13:22:28 -08:00
David Tolnay
1202de50b7
Preserve &str's original Rust representation in C++ 2021-01-02 13:15:08 -08:00
David Tolnay
aec3f24fb1
Merge pull request #644 from dtolnay/result
Decouple C++ exception representation from Rust str
2021-01-02 13:14:58 -08:00
David Tolnay
8ce57ec900
Decouple C++ exception representation from Rust str 2021-01-02 13:04:40 -08:00
David Tolnay
cf7bb9ba76
Elide template parameters in swaps where unneeded 2021-01-02 13:03:28 -08:00
David Tolnay
fec1715ad6
Move swap member functions below less-niche functions
The swap member functions are going to be infrequently used (relative to
things like operator==, Box's operator->) so let's present it lower down
in the API.
2021-01-02 12:51:31 -08:00
David Tolnay
4f2b30e1a6
Merge pull request #643 from dtolnay/swap
Remove Str and Slice swaps
2021-01-02 12:44:09 -08:00
David Tolnay
8f68939ae9
Remove Str and Slice swaps 2021-01-02 12:34:12 -08:00
David Tolnay
2ae80499c1
Clean up trailing whitespaces 2021-01-02 12:28:02 -08:00
David Tolnay
d835ac6cad
Omit swap member functions from website
I feel it's sufficient that std::swap "does the right thing". These do
not need to be explicitly presented as part of the API.
2021-01-02 12:26:20 -08:00
David Tolnay
bc44ebf520
Touch up PR 642 2021-01-02 12:23:37 -08:00
David Tolnay
c9e597e938
Format PR 642 with clang-format 10 2021-01-02 12:15:11 -08:00
David Tolnay
1ca730e0a1
Update Box website page to match header 2021-01-02 12:14:03 -08:00
David Tolnay
756556e23c
Merge pull request 642 from capickett/swap 2021-01-02 12:04:19 -08:00