David Tolnay
9075bafa1d
Add array len parse ui tests
2020-11-24 21:17:07 -08:00
David Tolnay
c351dc40cd
Preserve lit token of array length
2020-11-24 21:17:06 -08:00
David Tolnay
f22fb65fcf
Add ui test of improper suffix on array len
2020-11-24 21:17:06 -08:00
David Tolnay
7750b8165a
Merge master into pr/459
2020-11-24 20:25:43 -08:00
Xiangpeng Hao
7876235c3f
add initial array support
2020-11-24 20:23:29 -08:00
David Tolnay
f5ead103f3
Resolve clippy unnecessary_wraps lints
2020-11-24 17:08:05 -08:00
David Tolnay
c5629f021e
Support &mut [u8]
2020-11-24 13:45:27 -08:00
David Tolnay
cd271f2dc8
Add some more slice test functions
2020-11-24 12:38:18 -08:00
David Tolnay
94469c2077
Move aux types lower in test suite
2020-11-24 12:38:15 -08:00
David Tolnay
8988a75049
Format with rustfmt 1.4.27-nightly
2020-11-22 12:05:51 -08:00
David Tolnay
09a3086b45
Add UniquePtr::pin_mut
2020-11-22 12:04:38 -08:00
David Tolnay
227ff0cbf5
Fix test suite panic message forward compatibility lint
...
warning: panic message contains braces
--> tests/test.rs:21:9
|
21 | assert!(CORRECT.with(|correct| correct.get()), stringify!($run));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
106 | check!(ffi::c_take_shared(ffi::Shared { z: 2020 }));
| ---------------------------------------------------- in this macro invocation
|
= note: `#[warn(panic_fmt)]` on by default
= note: this message is not used as a format string, but will be in a future Rust edition
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: add a "{}" format string to use the message literally
|
21 | assert!(CORRECT.with(|correct| correct.get()), "{}", stringify!($run));
| ^^^^^
2020-11-22 12:04:19 -08:00
David Tolnay
58eee39e60
Allow enum with undeclared variants as long as it has explicit repr
2020-11-20 20:37:58 -08:00
David Tolnay
300ef4a0f4
Add conditional DerefMut for UniquePtr
2020-11-19 20:28:29 -08:00
David Tolnay
da55763434
Add UniquePtr deref mut ui test
2020-11-19 20:21:32 -08:00
David Tolnay
ced2adc9c7
Remove check for duplicated discriminants
...
C++ enum and enum class are allowed to contain multiple enumerator
definitions with the same value. Our enum representation in Rust is
compatible with this too, so there is no need to error on such enums.
enum class Enum {
A = 5,
B = 4,
C = 4, // dup
D, // = 5 dup
};
2020-11-19 19:57:58 -08:00
David Tolnay
468063fb69
Add failing test of extern enum used as struct field
...
Currently fails with:
error[cxxbridge]: needs a cxx::ExternType impl in order to be used as a field of `Second`
┌─ lib.rs:222:9
│
222 │ type COwnedEnum;
│ ^^^^^^^^^^^^^^^ needs a cxx::ExternType impl in order to be used as a field of `Second`
which is wrong because the bridge should know it's producing a
compatible ExternType impl for this type.
2020-11-19 14:56:58 -08:00
David Tolnay
fbd0a8de26
Combine 'extra' and 'module' modules in test suite
2020-11-19 14:22:59 -08:00
David Tolnay
b2bf244a90
No longer need rustfmt::skip when using extern type alias
2020-11-19 14:00:38 -08:00
David Tolnay
80ef068ea0
Produce error message for a few more unsupported signatures
2020-11-19 13:57:42 -08:00
David Tolnay
8de461f44a
Improve async fn error message with link to workaround
2020-11-19 13:46:14 -08:00
David Tolnay
7c5c7bef34
Add ui test of async extern fn
2020-11-19 13:41:01 -08:00
David Tolnay
0f0162f37d
Bump namespace to 1
2020-11-17 08:30:10 -08:00
David Tolnay
62cae8e16c
Restrict extern Rust types to unique local types for now
2020-11-17 08:01:08 -08:00
David Tolnay
6fdeeebee0
Remove &mut T access from UniquePtr
2020-11-16 23:33:49 -08:00
David Tolnay
9938b6449d
Allow lifetime in extern fn signature
2020-11-15 19:09:01 -08:00
David Tolnay
9eef609c19
Enforce no explicit Unpin impls
2020-11-15 18:02:32 -08:00
David Tolnay
0fe6ca2c44
Add ui test with explicit Unpin impl
2020-11-15 17:34:30 -08:00
David Tolnay
20fa62bf71
Enforce opaque Rust types are unpin for now
2020-11-15 17:34:05 -08:00
David Tolnay
c90897fb2f
Add ui test with pinned extern Rust type
2020-11-15 17:30:20 -08:00
David Tolnay
dbc86ead14
Add mut opaque ui test
2020-11-15 17:22:21 -08:00
David Tolnay
14a49435f8
More test suite pins
2020-11-15 17:15:48 -08:00
David Tolnay
1346ca319d
Introduce pins in test suite
2020-11-15 16:13:15 -08:00
David Tolnay
95dab1db60
Ensure opaque types are !Unpin
2020-11-15 14:50:58 -08:00
David Tolnay
cf9aed6fd9
Add Unpin to autotraits test
2020-11-15 14:50:49 -08:00
David Tolnay
836341a643
Fix conflict between pr 456 and fallible fn ui test
2020-11-15 14:49:05 -08:00
David Tolnay
5e0d82f59d
Merge pull request #456 from dtolnay/unsafe
...
Enforce unsafe surrounding block on safe-to-call functions
2020-11-15 14:45:05 -08:00
David Tolnay
77cb5c17ef
Add ui test of opaque type autotraits
2020-11-15 14:26:27 -08:00
David Tolnay
57c166d775
Improve error message spanning for fallible fn ptr
2020-11-14 23:40:43 -08:00
David Tolnay
579cfbe82c
Add fallible function pointer ui test
2020-11-14 23:40:18 -08:00
David Tolnay
1126426ab7
Merge pull request #454 from dtolnay/externcxx
...
Enforce use of extern "C++" as the ABI string
2020-11-11 11:33:37 -08:00
David Tolnay
6bd29d526b
Merge pull request #453 from dtolnay/sliceconst
...
Rename rust::Slice<T> to rust::Slice<const T>
2020-11-11 11:33:02 -08:00
David Tolnay
7be5b1f134
Enforce unsafe surrounding block on safe-to-call functions
2020-11-11 11:09:33 -08:00
David Tolnay
ea25ac8df5
Enforce use of extern "C++" as the ABI string
2020-11-11 11:04:08 -08:00
David Tolnay
8685745538
Merge pull request #455 from dtolnay/cxxabi
...
Update cxx::bridge modules to use extern "C++" as the ABI
2020-11-11 11:03:34 -08:00
David Tolnay
c72a9f6ad6
Update cxx::bridge modules to use extern "C++" as the ABI
2020-11-11 10:57:50 -08:00
David Tolnay
ce29823968
Rename rust::Slice<T> to rust::Slice<const T>
2020-11-11 10:15:13 -08:00
David Tolnay
3f76b5d780
Merge pull request #446 from dtolnay/push
...
Add rust::Vec push_back and emplace_back
2020-11-10 20:16:14 -08:00
David Tolnay
fb6b73c777
Add rust::Vec push_back and emplace_back
2020-11-10 20:08:14 -08:00
David Tolnay
4ee0f84397
Merge pull request #443 from dtolnay/comma
...
Fix placement of commas in C++ member functions that call Rust methods
2020-11-10 08:56:37 -08:00
David Tolnay
74608d79bf
Add test of indirect return on member function
...
cxxbridge/sources/tests/ffi/lib.rs.cc: In member function ‘rust::cxxbridge05::String tests::Shared::r_method_on_shared() const’:
cxxbridge/sources/tests/ffi/lib.rs.cc:1583:52: error: no match for ‘operator&’ (operand types are ‘const tests::Shared’ and ‘rust::cxxbridge05::String’)
1583 | tests$cxxbridge05$Shared$r_method_on_shared(*this&return$.value);
| ~~~~~^~~~~~~~~~~~~~
| | |
| | rust::cxxbridge05::String
| const tests::Shared
2020-11-10 08:49:23 -08:00
David Tolnay
5d164678ae
Improve placement of diagnostic on Result without Display impl
2020-11-09 20:47:14 -08:00
David Tolnay
0e7e37f8e2
Suppress 'consider choosing a more descriptive name' clippy lint in tests
...
warning: consider choosing a more descriptive name
--> tests/ffi/lib.rs:247:30
|
247 | fn r_return_identity(_: usize) -> usize;
| ^
|
= note: `#[warn(clippy::just_underscores_and_digits)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
warning: consider choosing a more descriptive name
--> tests/ffi/lib.rs:248:25
|
248 | fn r_return_sum(_: usize, _: usize) -> usize;
| ^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
warning: consider choosing a more descriptive name
--> tests/ffi/lib.rs:248:35
|
248 | fn r_return_sum(_: usize, _: usize) -> usize;
| ^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
2020-11-09 20:41:35 -08:00
David Tolnay
2621946855
Enforce accurate unsafety declaration on extern Rust sigs
2020-11-09 20:30:45 -08:00
David Tolnay
464d3fc0ac
Add test of unsupported elided lifetime in extern Rust sig
2020-11-09 20:30:45 -08:00
David Tolnay
5f8a70472a
Add test of missing unsafe on extern Rust sig
2020-11-09 20:30:45 -08:00
David Tolnay
9e2f590691
Add ui test of returning a non-displayable error
2020-11-09 20:17:12 -08:00
David Tolnay
464aeeb515
Rust-defined methods on shared structs
2020-11-08 19:14:06 -08:00
David Tolnay
102c7eaf68
C++-defined methods on shared structs
2020-11-08 19:08:31 -08:00
David Tolnay
a972eb7d93
Ignore field_reassign_with_default
2020-11-06 10:12:21 -08:00
David Tolnay
c90b666eec
Ignore some clippy lints in test suite
...
Closes #430 .
2020-11-06 10:11:14 -08:00
David Tolnay
35b662dfc3
Point out every field involved in the cycle
2020-11-03 18:51:41 -08:00
David Tolnay
07b7c13bc8
Add ui test of struct cycle
2020-11-03 18:41:48 -08:00
David Tolnay
392fbc6669
Add test of unsorted nested structs
2020-11-03 18:14:17 -08:00
David Tolnay
701c688476
Add repro of shared string by reference error
2020-11-02 18:20:08 -08:00
David Tolnay
7907966838
Switch to namespace = "quoted::path" in docs and tests
...
To preserve parity with item-level #[namespace = "..."] which is
currently restricted by rustc to a quoted string.
2020-11-01 09:12:05 -08:00
David Tolnay
ace45fa942
Re-enable c_take_callback test
2020-10-31 23:38:49 -07:00
David Tolnay
0aa9c773a1
Merge pull request #392 from adetaylor/namespace-forward-declarations
...
Namespace forward declarations
2020-10-31 22:39:47 -07:00
Adrian Taylor
9238b706a8
Test for namespace order sensitivity.
2020-10-31 22:15:24 -07:00
David Tolnay
0356d33acb
Pass Str in PtrLen representation
...
MSVC is hesitant about passing private fields in an extern "C" signature.
Repro:
struct Str1 {
const char *ptr;
size_t len;
};
struct Str2 {
private:
const char *ptr;
size_t len;
};
extern "C" {
Str1 str1();
Str2 str2();
}
Warning from MSVC v19.27:
warning C4190: 'str2' has C-linkage specified, but returns UDT 'Str2' which is incompatible with C
2020-10-31 20:33:39 -07:00
David Tolnay
5df1f06eb8
Eliminate Str::Repr struct
2020-10-31 17:31:44 -07:00
David Tolnay
bf23e3e185
Format PR 370 with clang-format
2020-10-30 21:12:50 -07:00
Adrian Taylor
0447e96b84
Revert to older error string.
2020-10-29 21:22:24 -07:00
Adrian Taylor
f2d9d86c3d
Simplify test suite.
2020-10-29 21:21:30 -07:00
Adrian Taylor
3e5cff4a3d
Switch to #[namespace = A::B] syntax.
...
Thanks to sbrocket for this parsing code.
2020-10-29 19:48:45 -07:00
Adrian Taylor
c871343ac2
Allow namespace override.
...
This change allows a
#[namespace (namespace = A::B)]
attribute for each item in a cxx::bridge.
We now have a fair number of different types of name floating
around:
* C++ identifiers
* C++ fully-qualified names
* Rust identifiers
* Rust fully-qualified names (future, when we support sub-modules)
* Items with both a Rust and C++ name (a 'Pair')
* Types with only a known Rust name, which can be resolved to a
C++ name.
This change attempts to put some sensible names for all these
things in syntax/mod.rs, and so that would be a good place to start
review.
At the moment, the Namespace (included in each CppName)
is ruthlessly cloned all over the place. As a given namespace is
likely to be applicable to many types and functions, it may
save significant memory in future to use Rc<> here. But let's not
optimise too early.
2020-10-26 15:23:34 -07:00
Adrian Taylor
0fac321939
Adding tests for method calls in foreign namespaces
2020-10-26 15:17:02 -07:00
Adrian Taylor
ddc146ef9f
Adding tests for functions in other namespaces.
2020-10-26 15:17:02 -07:00
Adrian Taylor
d47af7a9d3
Tests for opaque C types in namepsaces
2020-10-26 15:17:02 -07:00
Adrian Taylor
585bb0bc56
Tests for namespaced extern trivial types
2020-10-26 15:17:02 -07:00
Adrian Taylor
5e79c64769
Tests for namespaced opaque extern types.
2020-10-26 15:17:02 -07:00
Adrian Taylor
9a158e408f
Adding tests for types in namespaces.
2020-10-26 15:17:02 -07:00
David Tolnay
743caa283c
Remove duplicated UniquePtr<C> impl in ui test
2020-10-16 13:22:47 -07:00
David Tolnay
441956e803
Match layout of C++ tests::E and struct E in Rust
2020-10-16 13:21:51 -07:00
David Tolnay
ca0f9da832
Format PR 361 with rustfmt
2020-10-16 13:18:54 -07:00
Adrian Taylor
9f7ff2e3a6
Switch to build-time squashing of 'new' method.
2020-10-12 20:14:17 -07:00
Adrian Taylor
117d3baac7
Bazel/Buck test build fixups.
...
Sacrifices to satisfy the PR builder guardians.
2020-10-12 16:33:30 -07:00
Adrian Taylor
d75f7e2911
Allow creation of UniquePtrs to trivial aliased types.
2020-10-12 16:16:19 -07:00
David Tolnay
362c9f92b0
Touch up PR 356
2020-10-10 16:30:04 -07:00
Adrian Taylor
1931ccf65e
Attempt at BUCK and BUILD files.
2020-10-10 16:19:20 -07:00
Adrian Taylor
121cca4a06
Add tests for ExternType.
2020-10-10 16:01:26 -07:00
David Tolnay
3bbcdbbbf6
Add test of cxx_/rust_name attributes
2020-10-09 20:22:23 -07:00
David Tolnay
8f16ae75f3
Bump namespace to 05
2020-10-08 19:34:50 -07:00
David Tolnay
d41eef59c9
Change test suite's include_prefix to match workspace path
2020-10-08 16:57:55 -07:00
David Tolnay
1f7a7e5bca
Touch up cxx_gen test
2020-10-04 19:50:35 -07:00
David Tolnay
821402b2a6
Move C++ generated code test to cxx's integration test
2020-10-04 19:50:35 -07:00
David Tolnay
0531f43ce9
Improve error message on a conflicting explicit impl
2020-10-04 00:36:56 -07:00
David Tolnay
64cab48688
Add ui test of explicit impl trait for type
2020-10-04 00:20:22 -07:00
David Tolnay
2b3c2b2fa4
Add ui test of invalid nonempty impl block
2020-10-04 00:20:22 -07:00
David Tolnay
50b7563de4
Add ui test of explicit impl with unsupported Self
2020-10-04 00:20:22 -07:00
David Tolnay
ac8394bd18
Add test of UniquePtrTarget impl conflict
2020-10-04 00:20:21 -07:00
David Tolnay
3208fd7a58
Provide more helpful error when opaque C++ type used by value
2020-10-03 21:10:05 -07:00
David Tolnay
9f69230783
Merge pull request #325 from adetaylor/with-trivial-2
...
Allow type aliases to be marked as Trivial.
2020-10-03 20:53:30 -07:00
Adrian Taylor
feb0dc104c
Fix expected error messages.
2020-09-30 16:51:31 -07:00
David Tolnay
e53ec04397
Bypass compiletest on Windows push and pull_request builds
2020-09-24 23:36:00 -04:00
David Tolnay
80631e93ef
Add test involving empty vector
2020-09-24 16:07:30 -04:00
David Tolnay
5df0a71dcf
Add test for CxxVector::as_slice
2020-09-24 15:58:58 -04:00
David Tolnay
717c7e6aa8
Factor out genrules to rust_cxx_bridge.bzl
2020-09-24 10:08:10 -04:00
David Tolnay
dc57990e22
Use more systematic naming for generated code targets
2020-09-24 10:00:50 -04:00
David Tolnay
0cd342913a
Make buck/bazel generated filepaths match source path with extension
2020-09-24 09:40:27 -04:00
David Tolnay
55151b4575
Match bazel's semantics for genrule cmd
2020-09-24 09:40:27 -04:00
David Tolnay
e02c8b3b98
Load cc_library from @rules_cc
...
Buildifier warns about this now.
Function "cc_library" is not global anymore and needs to be loaded
from "@rules_cc//cc:defs.bzl".buildifier(native-cc)
2020-09-24 08:58:09 -04:00
David Tolnay
e4d30f2257
Set test size of //tests:test Bazel test
...
Without this:
INFO: Analyzed 33 targets (1 packages loaded, 12 targets configured).
INFO: Found 32 targets and 1 test target...
INFO: Elapsed time: 0.905s, Critical Path: 0.66s
INFO: 3 processes: 3 linux-sandbox.
INFO: Build completed successfully, 3 total actions
//tests:test PASSED in 0.1s
WARNING: //tests:test: Test execution time (0.1s excluding execution overhead) outside of range for MODERATE tests. Consider setting timeout="short" or size="small".
2020-09-24 08:57:22 -04:00
David Tolnay
22602b43a8
Fix return Result<Box<T>> from Rust to C++
2020-09-21 18:22:37 -04:00
David Tolnay
d7fef0a162
Update ui tests to nightly-2020-09-05
2020-09-04 23:28:56 -07:00
David Tolnay
25db1555f5
Update import path scheme for tests
2020-09-01 22:41:15 -07:00
David Tolnay
7273963a61
Sort buck genrule args the way buildifier wants
...
https://github.com/bazelbuild/buildtools/tree/master/buildifier
2020-09-01 20:48:11 -07:00
David Tolnay
5e668bce9b
Format ui test files using rustfmt
2020-08-29 11:36:22 -07:00
David Tolnay
de1cb777b2
Specify consistent c++ standard between cxx and cxx-test-suite
2020-08-28 17:36:33 -07:00
David Tolnay
47e239df11
Implement CxxVector<CxxString>
2020-08-28 00:43:10 -07:00
David Tolnay
33f56ad8d5
Implement Vec<String>
2020-08-28 00:25:41 -07:00
David Tolnay
18d93b6d58
Add &mut tests
2020-08-27 01:00:18 -07:00
David Tolnay
a7ba6a629c
Format with rustfmt 1.4.20
2020-08-27 00:15:55 -07:00
David Tolnay
b10c4bc33a
Format with clang-format 10
2020-08-26 22:13:31 -07:00
David Tolnay
8e1e6ac25c
Extend exception message from Vec<T>::at
2020-08-26 22:13:31 -07:00
David Tolnay
61adf428be
Add test for Vec<T>::at exception message
2020-08-26 22:13:31 -07:00
David Tolnay
fb8ddd8eb3
Merge pull request #257 from rinon/rust_vec_accessors
...
Add rust::Vec accessors
2020-08-26 21:49:23 -07:00
David Tolnay
c8361027d9
Remove dependency of ui test on whether rust-src is installed
2020-08-25 22:03:00 -07:00
David Tolnay
691dc171b5
Update ui tests with rust-src component installed
2020-08-25 19:56:12 -07:00
David Tolnay
a08b19f5b1
Add include required for back_inserter
...
See failure in https://github.com/dtolnay/cxx/issues/260 .
2020-08-25 19:21:16 -07:00
Stephen Crane
9e48d5b5c6
Add rust::Vec accessors
...
Adds operator[], at(), front(), and back() to rust::Vec.
2020-08-21 12:17:02 -07:00
David Tolnay
291a8b87a1
Update to trybuild 1.0.32
2020-08-09 16:46:45 -07:00
David Tolnay
6911d6d604
Update ui tests to nightly-2020-07-15
2020-07-21 18:05:48 -07:00
David Tolnay
0067236217
Update ui tests to nightly-2020-07-07
2020-07-21 18:02:36 -07:00
David Tolnay
b3d5e600a7
Update ui tests to nightly-2020-06-27
2020-07-21 17:58:14 -07:00
David Tolnay
0c8c0f26fa
Unbreak ui test on c_take_callback warning
2020-07-21 17:57:46 -07:00
David Tolnay
bbd2620921
Update ui tests to nightly-2020-06-14
2020-06-13 19:17:21 -07:00
David Tolnay
ae7143655d
Test c method calls without needing PartialEq on Exception
2020-05-22 11:12:35 -07:00
myronahn
e3b78ea409
Fix issue with indirect return for C++ member function w/no args
2020-05-22 11:08:13 -07:00
Myron Ahn
d963bf97b7
Fix for when std::os::raw::c_char is u8 (armv7)
2020-05-17 12:32:42 +07:00
David Tolnay
cf96664b29
Test include parsing
2020-05-11 20:07:34 -07:00
David Tolnay
65bc8e6af8
Detect earlier untyped discriminants out of bounds of later suffix
2020-05-11 00:30:24 -07:00
David Tolnay
f6a89f2813
Respect inferred enum repr in C++ code generator
2020-05-10 23:45:51 -07:00
David Tolnay
c605e6fa61
Respect inferred enum repr in Rust code generator
2020-05-10 23:37:12 -07:00
David Tolnay
560661abe5
Test unsatisfiable discriminant range
2020-05-10 23:32:31 -07:00
David Tolnay
b24f52e289
Test inconsistent suffix on enum discriminants
2020-05-10 23:29:12 -07:00
David Tolnay
f85431239d
Test discriminant outside of the repr's bounds
2020-05-10 23:28:04 -07:00
David Tolnay
f2d584101d
Expand maximum recognized discriminant to 64 bits
2020-05-10 23:23:37 -07:00
Philip Craig
7e14e2e6cb
avoid MSVC warning via flag_if_supported
2020-05-09 12:00:49 -07:00
David Tolnay
ae4dedab55
Update build files of test suite
2020-05-08 02:23:10 -07:00
David Tolnay
094db3ecea
Document ExternType trait
2020-05-08 02:06:30 -07:00
David Tolnay
a62cca2268
Add a use of type alias to test suite
2020-05-07 23:20:06 -07:00
David Tolnay
83fe0f06d5
Preserve a better span for type id mismatch errors
2020-05-07 20:14:49 -07:00
David Tolnay
c6ba2d27f4
Condense type ids rendered by rustc
2020-05-07 19:46:02 -07:00
David Tolnay
9f07303af1
Add ui test of type_id mismatch
2020-05-07 19:46:02 -07:00
David Tolnay
e2f9ec4c89
Type alias parsing
2020-05-07 19:46:02 -07:00
David Tolnay
a3f6407efa
Expand discriminant overflow error message
...
Renders as:
error[cxxbridge]: discriminant overflow on value after 4294967295
┌─ src/main.rs:11:9
│
11 │ B,
│ ^ discriminant overflow
│
= note: explicitly set `= 0` if that is desired outcome
This more closely matches rustc's error message, which is:
error[E0370]: enum discriminant overflowed
--> src/lib.rs:4:5
|
4 | B,
| ^ overflowed on value after 255
|
= note: explicitly set `B = 0` if that is desired outcome
2020-05-05 10:28:00 -07:00
David Tolnay
884d91f0bc
Resolve absurd_extreme_comparisons lint
2020-05-05 10:17:23 -07:00
Joel Galenson
8854773c56
Compute enum discriminant during parsing
...
This allows us to reuse the computation in multiple places later.
2020-05-05 08:32:32 -07:00
Joel Galenson
0f654ffeb0
Fix previous commit.
2020-05-04 20:04:21 -07:00
David Tolnay
4c14162d34
Update multi parse errors ui test
2020-05-04 01:30:09 -07:00
David Tolnay
15a6c76352
Add test of invocation with multiple parse errors
2020-05-04 01:29:01 -07:00
Joel Galenson
db1ec31283
Expose the enum value to Rust as a field
2020-05-01 14:00:48 -07:00
David Tolnay
57d81a12fb
Merge pull request #180 from jgalenson/enums
...
Properly handle enum discriminant overflows.
2020-05-01 10:13:24 -07:00
Joel Galenson
04fa0967e2
Properly handle enum discriminant overflows.
...
This both checks for enum values that are illegal due to overflow and
ensures we do not overflow on valid enums.
2020-05-01 10:00:31 -07:00
David Tolnay
c4ddb4d172
Add tests for by-value-not-supported errors
2020-05-01 10:00:17 -07:00
David Tolnay
4037de267a
Use a better constant string idiom in test
2020-04-30 22:51:51 -07:00
David Tolnay
f5aeea2e4c
Touch up a variable name in vector test
2020-04-30 22:51:51 -07:00
David Tolnay
9beba146b7
Avoid relying on ADL for std::back_inserter
2020-04-30 22:51:50 -07:00
David Tolnay
d7984c2b7f
Touch up PR 170
2020-04-30 22:50:10 -07:00
David Tolnay
2b12b32113
Update PR 170 compiletests at nightly rustc
2020-04-30 22:03:25 -07:00
Joel Galenson
c03402aee5
Support C-style enums
...
This adds support for passing C-style enums between Rust and C++.
We use the Rust representation for enums suggested by dtolnay in #132 .
Note that as this does not use real enums, Rust code cannot treat them
as normal enums, e.g., by converting them to integers. But common
uses such as pattern matching remain unchanged.
2020-04-30 14:12:37 -07:00
David Tolnay
f8ed07327b
Split cxx runtime and build components
2020-04-29 18:23:14 -07:00
myronahn
da9be50ad8
Add all std::iterator_traits required types to const_iterator of rust::Vec<T> ( #157 )
...
https://en.cppreference.com/w/cpp/iterator/iterator_traits
`std::iterator_traits` requires the following 5 types:
- `difference_type` - a signed integer type that can be used to identify distance between iterators
- `value_type` - the type of the values that can be obtained by dereferencing the iterator. This type is void for output iterators.
- `pointer` - defines a pointer to the type iterated over (value_type)
- `reference` - defines a reference to the type iterated over (value_type)
- `iterator_category` - the category of the iterator. Must be one of iterator category tags.
The current `const_iterator` for `rust::Vec<T>` only defined `value_type` and `reference` which caused an error when using `std::copy` on gcc 7.5.0 on Ubuntu but seemed to work fine on MacOS.
2020-04-28 15:47:23 -07:00
David Tolnay
776fd8953d
Generalize reference-to-reference check to cover all positions
...
Checking this in check_type_ref allows it to apply anywhere that a
reference is written, such as return position which was not covered by
the previous logic.
2020-04-28 13:38:28 -07:00
Joel Galenson
2bd1312f2f
Disallow passing a reference to a reference.
2020-04-28 10:14:41 -07:00
David Tolnay
378ca50c4c
Format PR 159 with clang-format
2020-04-27 16:47:55 -07:00
Joel Galenson
ba67607fa2
Allow wildcard argument names.
...
This adds support for wildcard variable names by internally giving
them unique names.
2020-04-27 16:00:50 -07:00
David Tolnay
83c69e92f7
Test Rust Vec in Rust signatures
2020-04-25 18:02:19 -07:00
David Tolnay
d2ce8a997b
Fix and test passing Vec by value from Rust to C
2020-04-25 18:02:19 -07:00
David Tolnay
7798969827
Fix and test returning Vec by reference from C to Rust
2020-04-25 18:02:19 -07:00
David Tolnay
8b9d176ea7
Fix and test fallible return of Vec from C to Rust
2020-04-25 18:02:19 -07:00
David Tolnay
b41e74c152
Test returning Vec by value from C to Rust
2020-04-25 18:02:18 -07:00
David Tolnay
de5340ec85
Test returning CxxVector by reference from C to Rust
2020-04-25 18:02:18 -07:00
David Tolnay
2244d1f553
Test passing CxxVector by reference from Rust to C
2020-04-25 18:02:17 -07:00
David Tolnay
1bcc9fe2e5
Test returning opaque types in CxxVector from C to Rust
2020-04-25 18:02:17 -07:00
David Tolnay
9b304204b7
Use more appropriate name for vector arguments in tests
2020-04-25 18:02:17 -07:00
David Tolnay
c87c215f56
Add begin/end iterators to rust::Vec
2020-04-25 18:02:15 -07:00
David Tolnay
e1dcdf7317
Parse vector's type as CxxVector
2020-04-25 18:02:13 -07:00
David Tolnay
c01d0a0f84
Rename CxxVector::size to len to match Rust conventions
2020-04-25 18:02:10 -07:00
David Tolnay
85db5a01b2
Touch up PR 67
2020-04-25 18:02:08 -07:00
David Tolnay
d1413040ae
Remove absolute paths in non-generated code
2020-04-25 18:02:07 -07:00
David Tolnay
4f6dd4e631
Simplify vector tests using UniquePtr deref
2020-04-25 18:02:07 -07:00
David Tolnay
507c2d75cf
Merge pull request #67 from myronahn/master
...
C++ std::vector<T> and Rust std::vec::Vec<T> support
2020-04-25 18:01:54 -07:00
David Tolnay
7c29546739
Revert some unrelated changes from PR 67
2020-04-25 13:13:43 -07:00
David Tolnay
37dd7e1174
Format with clang-format
2020-04-25 12:51:59 -07:00
Myron Ahn
eba35cfce7
C++ std::vector<T> and Rust std::vec::Vec<T> support
...
Add basic std::vector and std::vec::Vec support across FFI boundary.
2020-04-25 12:47:04 -07:00
David Tolnay
1044d44f30
Suppress irrelevant "required by this bound" from error message
2020-04-22 20:01:21 -07:00
David Tolnay
4b07ab92e3
Improve span of unsized opaque type error
2020-04-22 19:50:21 -07:00
David Tolnay
ab73957a4e
Add ui test for unnamed receiver type error message
2020-04-22 18:25:43 -07:00