55 Commits

Author SHA1 Message Date
Adrian Taylor
0447e96b84 Revert to older error string. 2020-10-29 21:22:24 -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
David Tolnay
743caa283c
Remove duplicated UniquePtr<C> impl in ui test 2020-10-16 13:22:47 -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
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
Adrian Taylor
feb0dc104c Fix expected error messages. 2020-09-30 16:51:31 -07:00
David Tolnay
d7fef0a162
Update ui tests to nightly-2020-09-05 2020-09-04 23:28:56 -07:00
David Tolnay
5e668bce9b
Format ui test files using rustfmt 2020-08-29 11:36:22 -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
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
bbd2620921
Update ui tests to nightly-2020-06-14 2020-06-13 19:17:21 -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
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
David Tolnay
094db3ecea
Document ExternType trait 2020-05-08 02:06:30 -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
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
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
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
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
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
David Tolnay
2dd73eaf03
Add ui test for reserved type names 2020-04-22 17:56:27 -07:00