Commit Graph

222 Commits

Author SHA1 Message Date
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