Commit Graph

453 Commits

Author SHA1 Message Date
David Tolnay
8a893c79ed
Extract variant info from ast dump 2021-04-22 20:04:02 -07:00
David Tolnay
2b62812419
Store original Attribute of the variants_from_header for spans 2021-04-22 20:04:01 -07:00
David Tolnay
bbf96674a2
Implicltly extern type for enums sourced from header 2021-04-22 20:04:01 -07:00
David Tolnay
2cf2d0c7b2
Preserve item inner attrs 2021-04-22 20:04:01 -07:00
David Tolnay
dd8320320c
Implement variants_from_header checking 2021-04-21 18:23:21 -07:00
David Tolnay
15bf509509
Parse #![variants_from_header] inner attribute 2021-04-21 18:21:56 -07:00
David Tolnay
c5f472ef62
Factor out helper for identifying maybe trivial types 2021-04-16 15:16:19 -07:00
David Tolnay
757f7ff85f
Support inner attributes inside bridge
Example:

    #[cxx::bridge]
    mod ffi {
        #![deny(missing_docs)]

        unsafe extern "C++" {
            include!("example/include/header.h");

            /// wow
            fn f();
        }
    }

    pub use self::ffi::*;
2021-04-13 20:52:25 -07:00
David Tolnay
65b8338411
Add padding around member functions that have documentation 2021-04-13 20:23:19 -07:00
David Tolnay
8a0abfdfb1
Touch up BareFn type parsing 2021-04-10 13:47:40 -07:00
David Tolnay
281d49ac95
Store span of method receiver colon tokens 2021-04-10 13:44:31 -07:00
David Tolnay
f6cad33f31
Store span of function argument colon tokens 2021-04-10 13:42:07 -07:00
David Tolnay
c46b0fa065
Make errors rustc already catches specific to C++ generator 2021-04-08 18:45:16 -07:00
David Tolnay
ef1b70d0db
Diagnostic for invalid lifetime param 'static 2021-04-08 18:45:08 -07:00
David Tolnay
22cb28882a
Recognize mutable slice in return position of a safe function 2021-03-28 04:23:06 -04:00
David Tolnay
ffd6f84833
Recognize mutable slice argument as permitting mutable return 2021-03-28 04:17:56 -04:00
David Tolnay
06ef96fa5f
Handle unrecognized type names in checking signature for mutable return type 2021-03-28 04:07:57 -04:00
David Tolnay
5f5602c2e5
Print type name in type resolver error 2021-03-28 03:58:06 -04:00
David Tolnay
9dab9d8e38
Track the outer type's spans too for implicit impls 2021-03-27 01:51:08 -04:00
David Tolnay
fedc63bfb7
Simplify type resolution of named impl keys 2021-03-27 01:23:04 -04:00
David Tolnay
dde630235b
Track the angle brackets attached to generic implicit impls 2021-03-27 01:23:04 -04:00
David Tolnay
795e7b478f
Factor out impl/ty generic splitting to module 2021-03-27 01:23:04 -04:00
David Tolnay
6edd2d2a59
Add a void ptr cast for extern type aliases containing Rust-native types 2021-03-26 18:13:41 -04:00
David Tolnay
47b820940c
Remove multiple arg lifetimes check
This was made obsolete by support for explicit lifetime annotations
in cxx 1.0.26.
2021-03-26 18:05:28 -04:00
David Tolnay
b55bd6392b
Allow mutable return reference on signatures with any lifetime in argument 2021-03-26 17:59:14 -04:00
David Tolnay
a17230db8c
Factor out Type traversal to a Visit trait 2021-03-26 17:36:51 -04:00
David Tolnay
4a024613f1
Fix wording of unsupported vector element type error
Vectors have elements, not targets. (Pointers, like unique_ptr and
shared_ptr, have targets -- matching the terminology of Target in the
std::ops::Deref trait.)
2021-03-26 17:14:24 -04:00
David Tolnay
04376c7d94
Permit mut from ref in unsafe-to-call signatures 2021-03-26 17:08:48 -04:00
David Tolnay
2dec4215e3
Include unsafe token in notional span of extern fn signatures 2021-03-26 17:07:54 -04:00
David Tolnay
5f04fda69d
Merge pull request #750 from dtolnay/pointers
Pointer to pointer, pointer to reference, reference to pointer
2021-03-22 19:41:13 -07:00
David Tolnay
d2d225c10c
East const to make nested pointer types work 2021-03-22 19:23:51 -07:00
David Tolnay
bd313d5e92
Add dedicated error message for ptr to ptr and ref to ptr 2021-03-22 19:23:51 -07:00
David Tolnay
2a2264c483
Add dedicated error message for pointer to reference 2021-03-22 19:23:50 -07:00
David Tolnay
d91d2a8d4a
Relax restriction on target types of pointer 2021-03-22 19:23:49 -07:00
David Tolnay
aba7ab1bb0
Detect pointer argument inside of function pointer 2021-03-22 19:18:18 -07:00
David Tolnay
285779635a
Defer unsafety check for fn with ptr argument
That error does not need to be fatal at parse time, because the parser
still understands exactly what was written. We accumulate and emit it
alongside other type errors that might be present in the same function
signature.
2021-03-22 19:12:06 -07:00
David Tolnay
b70310b760
Remove unneeded pointer parse check
A pointer with neither `const` nor `mut` would not have parsed as a
syn::Type::Ptr.
2021-03-22 19:06:08 -07:00
David Tolnay
beba43d024
Touch up PR 689 imports 2021-03-22 19:06:07 -07:00
David Tolnay
94909e0a6e
Remove duplicate unsafety parse from PR 689 2021-03-22 19:06:07 -07:00
David Tolnay
7c3197eba8
Format PR 689 with rustfmt 2021-03-22 19:06:02 -07:00
David Tolnay
9fc8138823
Merge pull request #689 from adetaylor/pointers
Support raw pointers in cxx::bridge.
2021-03-22 19:04:37 -07:00
David Tolnay
2e43b51227
Consistently use 'other: &Self' in homogeneous comparison impls 2021-03-18 13:35:38 -07:00
Adrian Taylor
57832124b4 Merge fix. 2021-02-17 16:11:08 -08:00
David Tolnay
6c39d4b9c8
Document the arrangements of preprocessor variables 2021-02-17 15:56:07 -08:00
David Tolnay
415f23255e
Document the possible arrangements of mangled symbols 2021-02-17 15:49:39 -08:00
adetaylor
f67287db6f
Merge branch 'master' into pointers 2021-02-17 15:32:06 -08:00
David Tolnay
dfafc8b210
Move span of inherited pub to next consecutive token 2021-02-11 22:03:48 -08:00
David Tolnay
35f07dbdf8
Avoid wrapping error message across source lines
This makes the source of the message easier to locate for someone using
grep with the full message.

The Linux kernel coding style follows the same approach:
https://www.kernel.org/doc/html/v5.10/process/coding-style.html#breaking-long-lines-and-strings

> never break user-visible strings such as printk messages because that
> breaks the ability to grep for them.
2021-02-07 13:38:01 -08:00
David Tolnay
d15608434d
Touch up error message from PR 688 2021-02-07 13:36:35 -08:00
Adrian Taylor
38ae228834 Support raw pointers in cxx::bridge.
This allows raw pointers to types to be passed into and out of
cxx::bridge extern "C++" APIs. As normal with raw pointers in Rust,
there are no safety or lifetime guarantees.

Passing a raw pointer into such an API requires that the
function be marked "unsafe".
2021-01-23 11:34:13 -08:00