1954 Commits

Author SHA1 Message Date
David Tolnay
7f59a693e4
Fix a wrong cast in Slice<T>::iterator::operator[]
cxx-test-suite-2b81d5f39edd0bcf/out/cxxbridge/include/rust/cxx.h:559:11: error: invalid static_cast from type ‘char*’ to type ‘const unsigned char*’
      559 |   return *static_cast<T *>(pos);
          |           ^~~~~~~~~~~~~~~~~~~~~

Doing a reinterpret_cast<> instead matches what is done a few lines
above by Slice<T>::operator[].
2021-01-02 00:07:41 -08:00
David Tolnay
2b4f07d8d8
Explicit instantiations for easy typecheck coverage in test suite 2021-01-02 00:06:59 -08:00
David Tolnay
233e60e231
Resolve unnecessary_wraps clippy lint 2021-01-01 22:12:50 -08:00
David Tolnay
dc09c52a3d
Tweak enum generics error handling 2021-01-01 21:52:08 -08:00
David Tolnay
dc415ccf8e
Merge pull request #635 from dtolnay/lifetimes
Parameterize shim trait impl blocks over lifetimes
2021-01-01 20:09:14 -08:00
David Tolnay
dc79f24aad
Parameterize shim trait impl blocks over lifetimes 2021-01-01 19:59:22 -08:00
David Tolnay
c417977d27
Distinguish Impl's impl generics vs generics on the Self type 2021-01-01 19:51:13 -08:00
David Tolnay
eb472ad837
Remove unused Impl hashing impls
These used to be for a HashSet<&Impl> held by Types, which has since
been refactored into a different data structure.
2021-01-01 19:40:19 -08:00
David Tolnay
1d5ffbb4c9
Fix span placement on ForeignName parse error 2021-01-01 19:28:34 -08:00
David Tolnay
43d8e4295d
Merge pull request #634 from dtolnay/resolve
Record lifetimes associated with generic type instantiation
2021-01-01 19:05:20 -08:00
David Tolnay
1e5fe237d8
Record lifetimes associated with generic type instantiation 2021-01-01 18:28:28 -08:00
David Tolnay
038b29a024
Add place for struct and enum lifetime parameters 2021-01-01 18:26:26 -08:00
David Tolnay
010b5c3c25
Merge pull request #633 from dtolnay/foreign
Add ForeignName wrapper around non-Rust names
2021-01-01 18:03:11 -08:00
David Tolnay
ed6ba4a63c
Add ForeignName wrapper around non-Rust names 2021-01-01 17:57:14 -08:00
David Tolnay
9f84fe8bbd
Check rust idents for cxxbridge prefix 2021-01-01 15:59:59 -08:00
David Tolnay
442dffdbbc
Merge pull request #632 from dtolnay/var
Support rename attributes on struct fields
2021-01-01 15:59:51 -08:00
David Tolnay
0a89256c28
Support rename attributes on struct fields 2021-01-01 15:53:56 -08:00
David Tolnay
d357bb15cf
Merge pull request #631 from dtolnay/var
Track independent Rust/C++ names on struct fields and fn args
2021-01-01 15:53:47 -08:00
David Tolnay
84ed6adda5
Track independent Rust/C++ names on struct fields and fn args 2021-01-01 15:46:10 -08:00
David Tolnay
b97a245c93
Avoid hashing arg names in hash of function signature 2021-01-01 15:32:35 -08:00
David Tolnay
5be7c81f40
Merge pull request #630 from dtolnay/impls
Generate all explicit and implicit impls based on one map
2021-01-01 14:43:01 -08:00
David Tolnay
3abed4794a
Generate all explicit and implicit impls based on one map 2021-01-01 14:28:38 -08:00
David Tolnay
b1f0b9be93
Incorporate explicit impl spans into Box and Vec instantiation 2021-01-01 14:26:26 -08:00
David Tolnay
77a5e758e6
Rename RustName -> NamedType 2021-01-01 14:15:26 -08:00
David Tolnay
95bc57fc47
Remove RustName::to_symbol in favor of explicit resolve 2021-01-01 13:36:49 -08:00
David Tolnay
bbcd75c0d1
Pull in syn 1.0.57 for const Punctuated::new support 2021-01-01 13:04:55 -08:00
David Tolnay
873b822c54
Add OrderedMap type 2020-12-31 23:39:06 -08:00
David Tolnay
e352c1e140
Add wrapper to prevent iteration of unordered maps 2020-12-31 17:15:56 -08:00
David Tolnay
292cfffe5a
Downgrade some ordered type checker sets to unordered 2020-12-31 16:37:55 -08:00
David Tolnay
7248f0ee51
Merge pull request #627 from dtolnay/impl
Parse generic params on impl block
2020-12-31 15:47:14 -08:00
David Tolnay
c455e97405
Parse generic params on impl block 2020-12-31 15:38:19 -08:00
David Tolnay
0acb2d6337
Merge pull request #628 from dtolnay/implkey
Key impls by an enum rather than by Type
2020-12-31 15:38:08 -08:00
David Tolnay
4c6052d749
Key impls by an enum rather than by Type 2020-12-31 15:31:28 -08:00
David Tolnay
f4d978941e
Ignore wrong_self_convention clippy lint
warning: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name
       --> src/cxx_vector.rs:130:25
        |
    130 |     pub fn as_mut_slice(self: Pin<&mut Self>) -> &mut [T]
        |                         ^^^^
        |
        = note: `#[warn(clippy::wrong_self_convention)]` on by default
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention
2020-12-31 15:30:55 -08:00
David Tolnay
89fd09b66b
Emit lifetime parameters in ToTokens of Type 2020-12-31 14:51:12 -08:00
David Tolnay
ab1ac88c44
Add CxxVector::as_mut_slice 2020-12-31 11:58:26 -08:00
David Tolnay
5573e529e5
Emit docs on struct fields into generated C++ code 2020-12-31 11:07:52 -08:00
David Tolnay
3fab70e0de
Release 1.0.25 1.0.25 2020-12-31 10:51:19 -08:00
David Tolnay
5b395b33db
Work around conflict between CxxVector::get_mut and Pin::get_mut
Previously:

    error[E0034]: multiple applicable items in scope
      --> src/main.rs:39:20
       |
    39 |     let _ = vector.get_mut(0);
       |                    ^^^^^^^ multiple `get_mut` found
       |
       = note: candidate #1 is defined in an impl for the type `Pin<&'a mut T>`
       = note: candidate #2 is defined in an impl for the type `CxxVector<T>`
2020-12-31 10:49:18 -08:00
David Tolnay
30bea1c6c6
Move CxxVector mut indexing to Pin<&mut Self>
Fixes #625.
2020-12-31 10:48:36 -08:00
David Tolnay
249df3baef
Merge pull request #624 from dtolnay/identlife
Parse lifetimes on Ident type names
2020-12-30 20:59:12 -08:00
David Tolnay
679b15d677
Parse lifetimes on Ident type names 2020-12-30 20:51:39 -08:00
David Tolnay
5a565827d0
Merge pull request #623 from dtolnay/metadata
Defer Cargo links metadata printing until after code generation
2020-12-30 20:20:18 -08:00
David Tolnay
5b41c09e9a
Defer Cargo links metadata printing until after code generation
This results in slightly less noise when code generation produces an
error during a Cargo build.

Before:

    process didn't exit successfully: `/git/example-cxx/target/debug/build/example-f20ef12178a95a23/build-script-build` (exit code: 1)
    --- stdout
    cargo:CXXBRIDGE_PREFIX=example
    cargo:CXXBRIDGE_DIR0=/git/example-cxx/target/debug/build/example-188c8410ffc8bb7d/out/cxxbridge/include
    cargo:CXXBRIDGE_DIR1=/git/example-cxx/target/debug/build/example-188c8410ffc8bb7d/out/cxxbridge/crate

    --- stderr

    error[cxxbridge]: extern type with lifetimes is not supported yet
      ┌─ src/main.rs:9:21
      │
    9 │         type Object<'a>;
      │                     ^^ extern type with lifetimes is not supported yet

After:

    process didn't exit successfully: `/git/example-cxx/target/debug/build/example-f20ef12178a95a23/build-script-build` (exit code: 1)
    --- stderr

    error[cxxbridge]: extern type with lifetimes is not supported yet
      ┌─ src/main.rs:9:21
      │
    9 │         type Object<'a>;
      │                     ^^ extern type with lifetimes is not supported yet
2020-12-30 20:11:33 -08:00
David Tolnay
926634ac3b
Merge pull request #622 from dtolnay/lifetimes
Represent type names with generic lifetime parameters
2020-12-30 20:10:58 -08:00
David Tolnay
4a79b7f8d8
Track lifetimes on rust name types 2020-12-30 20:03:35 -08:00
David Tolnay
0c669ea3d1
Replace ref cast to RustName with just using Ident 2020-12-30 20:02:35 -08:00
David Tolnay
444f2dce6b
Update ToTokens impls with exhaustive field matching 2020-12-30 20:02:12 -08:00
David Tolnay
9a1de625ea
Merge pull request #621 from dtolnay/spans
Fix span placement for rust lints inside of bridge module
2020-12-30 18:18:18 -08:00
David Tolnay
a00f468cfa
Factor out visibility conversion helper 2020-12-30 18:11:16 -08:00