466 Commits

Author SHA1 Message Date
David Tolnay
def09ab798
Add link to cxx-async repo in async error message 2021-12-12 20:25:28 -08:00
David Tolnay
338636308b
Pass through serde attributes 2021-12-05 19:37:43 -08:00
David Tolnay
0faefeb777
Merge pull request #941 from rookboom/master
Added Serde Serialize/Deserialize traits
2021-10-26 19:50:07 -07:00
Johan Verwey
b3ac95e814
Added Serde Serialize/Deserialize traits 2021-10-26 19:48:43 -07:00
David Tolnay
989ce7db0f
Resolve to_string_in_format_args clippy lint
error: `to_string` applied to a type that implements `Display` in `format!` args
      --> syntax/symbol.rs:45:44
       |
    45 |         Symbol(format!("{}{}", prefix, self.to_string()))
       |                                            ^^^^^^^^^^^^ help: remove this
       |
       = note: `-D clippy::to-string-in-format-args` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args
2021-10-22 19:28:33 -07:00
David Tolnay
9754a725f5
Pass through doc(hidden) attribute 2021-10-05 16:27:08 -04:00
David Tolnay
d9a561cf48
Delete unused span field from ForeignName
warning: field is never read: `span`
      --> macro/src/syntax/names.rs:12:5
       |
    12 |     span: Span,
       |     ^^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default
2021-09-12 05:08:34 -07:00
David Tolnay
c59a4022cd
Avoid inheriting formatter flags in some Display impls
The previous implementation would produce wrong unintentional output
when formatting with alignment or padding, such as {:<15}.
2021-07-29 13:34:55 -07:00
David Tolnay
20cb73ae6f
Support slice of trivial extern type alias 2021-07-23 14:16:46 -07:00
David Tolnay
9b252141c0
Ignore whether variants_from_header attr is outer or inner 2021-04-22 20:35:35 -07:00
David Tolnay
4584958676
Support enum repr types from std::os::raw 2021-04-22 20:04:03 -07:00
David Tolnay
3b58d1c799
Move empty enum check to before filling in variants 2021-04-22 20:04:02 -07:00
David Tolnay
e2250bca87
Parse discriminant values from clang AST 2021-04-22 20:04:02 -07:00
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