David Tolnay
886fff8783
Further prune syntax tree visibilities
2023-09-03 13:06:49 -07:00
David Tolnay
927d8ead12
Reduce visibility of all pub items which are not publicly exported
2023-09-03 12:41:41 -07:00
David Tolnay
718eacac67
Resolve unnested_or_patterns pedantic clippy lint
...
warning: unnested or-patterns
--> gen/src/check.rs:19:20
|
19 | if let Some(Component::CurDir) | Some(Component::ParentDir) = first_component {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
= note: `-W clippy::unnested-or-patterns` implied by `-W clippy::pedantic`
help: nest the patterns
|
19 | if let Some(Component::CurDir | Component::ParentDir) = first_component {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> gen/src/write.rs:208:17
|
208 | / Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(I8) | Some(I16) | Some(I32)
209 | | | Some(I64) => out.include.cstdint = true,
| |___________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
208 | Some(U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64) => out.include.cstdint = true,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> gen/src/write.rs:214:17
|
214 | Some(Bool) | Some(Char) | Some(F32) | Some(F64) | None => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
214 | Some(Bool | Char | F32 | F64) | None => {}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> gen/src/write.rs:851:9
|
851 | Some(Type::Str(_)) | Some(Type::SliceRef(_)) if !indirect_return => write!(out, ")"),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
851 | Some(Type::Str(_) | Type::SliceRef(_)) if !indirect_return => write!(out, ")"),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> gen/src/write.rs:1185:9
|
1185 | Some(Type::RustBox(ty)) | Some(Type::UniquePtr(ty)) => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
1185 | Some(Type::RustBox(ty) | Type::UniquePtr(ty)) => {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> gen/src/write.rs:1196:9
|
1196 | Some(Type::Str(_)) | Some(Type::SliceRef(_)) => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
1196 | Some(Type::Str(_) | Type::SliceRef(_)) => {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> syntax/check.rs:126:17
|
126 | / None | Some(Bool) | Some(Char) | Some(U8) | Some(U16) | Some(U32) | Some(U64)
127 | | | Some(Usize) | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize)
128 | | | Some(F32) | Some(F64) | Some(RustString) => return,
| |__________________________________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
126 ~ None |
127 + Some(Bool | Char | U8 | U16 | U32 | U64 | Usize | I8 | I16 | I32 | I64 | Isize
128 ~ | F32 | F64 | RustString) => return,
|
warning: unnested or-patterns
--> syntax/check.rs:165:13
|
165 | / None | Some(Bool) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize)
166 | | | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32)
167 | | | Some(F64) | Some(CxxString) => return,
| |_________________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
165 ~ None |
166 + Some(Bool | U8 | U16 | U32 | U64 | Usize | I8 | I16 | I32 | I64 | Isize | F32
167 ~ | F64 | CxxString) => return,
|
warning: unnested or-patterns
--> syntax/check.rs:168:13
|
168 | Some(Char) | Some(RustString) => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
168 | Some(Char | RustString) => {}
| ~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> syntax/check.rs:186:13
|
186 | / None | Some(Bool) | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize)
187 | | | Some(I8) | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32)
188 | | | Some(F64) | Some(CxxString) => return,
| |_________________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
186 ~ None |
187 + Some(Bool | U8 | U16 | U32 | U64 | Usize | I8 | I16 | I32 | I64 | Isize | F32
188 ~ | F64 | CxxString) => return,
|
warning: unnested or-patterns
--> syntax/check.rs:189:13
|
189 | Some(Char) | Some(RustString) => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
189 | Some(Char | RustString) => {}
| ~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> syntax/check.rs:210:13
|
210 | / None | Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8)
211 | | | Some(I16) | Some(I32) | Some(I64) | Some(Isize) | Some(F32) | Some(F64)
212 | | | Some(CxxString) => return,
| |_____________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
210 ~ None |
211 + Some(U8 | U16 | U32 | U64 | Usize | I8 | I16 | I32 | I64 | Isize | F32 | F64 |
212 ~ CxxString) => return,
|
warning: unnested or-patterns
--> syntax/check.rs:214:13
|
214 | Some(Bool) | Some(RustString) => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
214 | Some(Bool | RustString) => {}
| ~~~~~~~~~~~~~~~~~~~~~~~
warning: unnested or-patterns
--> gen/build/src/lib.rs:458:21
|
458 | Some("h") | Some("hh") | Some("hpp") => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
|
458 | Some("h" | "hh" | "hpp") => {}
| ~~~~~~~~~~~~~~~~~~~~~~~~
2023-07-06 12:29:28 -07:00
David Tolnay
7a5c69f405
Resolve semicolon_if_nothing_returned pedantic clippy lint
...
warning: consider adding a `;` to the last statement for consistent formatting
--> gen/src/write.rs:132:17
|
132 | check_trivial_extern_type(out, ety, reasons)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `check_trivial_extern_type(out, ety, reasons);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
= note: `-W clippy::semicolon-if-nothing-returned` implied by `-W clippy::pedantic`
warning: consider adding a `;` to the last statement for consistent formatting
--> syntax/parse.rs:45:17
|
45 | parse_foreign_mod(cx, foreign_mod, &mut apis, trusted, namespace)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `parse_foreign_mod(cx, foreign_mod, &mut apis, trusted, namespace);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
warning: consider adding a `;` to the last statement for consistent formatting
--> gen/lib/tests/test.rs:27:5
|
27 | assert!(cxx_gen::generate_header_and_cc(rs, &opt).is_err())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `assert!(cxx_gen::generate_header_and_cc(rs, &opt).is_err());`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
= note: `-W clippy::semicolon-if-nothing-returned` implied by `-W clippy::pedantic`
2023-07-06 12:21:41 -07:00
David Tolnay
a57ac8380b
Delete imports that are newly provided by 2021 edition prelude
2023-07-06 11:54:43 -07:00
David Tolnay
e33fac67d2
Use error reporting provided by Meta
2023-03-18 14:25:20 -07:00
David Tolnay
1259995732
Update to syn 2
2023-03-17 18:41:45 -07:00
David Tolnay
50d9d69ef5
Factor out a constructor from LitStr to QualifiedName
2023-03-15 22:23:11 -07:00
David Tolnay
46040d0912
Support cxx_name containing name that is Rust keyword
2023-01-07 12:02:52 -08:00
David Tolnay
40bb0d3779
Resolve needless_borrow clippy lint
...
error: the borrowed expression implements the required traits
--> syntax/check.rs:91:25
|
91 | cx.error(ident, &msg);
| ^^^^ help: change this to: `msg`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `-D clippy::needless-borrow` implied by `-D clippy::all`
2022-12-29 18:34:05 -08:00
David Tolnay
33432a868d
Provide a suggestion to replace quoted raw identifier
2022-11-08 00:50:54 -08:00
David Tolnay
9f47a6218f
Allow raw identifier outside of quotes only
2022-11-08 00:40:51 -08:00
David Tolnay
8a029059c1
Support raw identifiers in namespace attribute
...
As in: #[namespace = ::my::company::r#box::implementation]
2022-11-08 00:35:10 -08:00
David Tolnay
152b89b08b
No-std fixes for Box, String, Pin, c_char
2022-10-21 09:18:48 -07:00
David Tolnay
b122cff91d
Allow Vec<bool> to pass syntax check
2022-09-27 17:38:47 -07:00
David Tolnay
30427e0205
Propagate attrs from extern mod onto all contents
...
#[cxx::bridge]
mod ffi {
#[allow(clippy::too_many_arguments)]
extern "Rust" {
fn repro(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) -> bool;
}
}
Before:
warning: this function has too many arguments (8/7)
--> src/main.rs:5:12
|
5 | fn repro(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) -> bool;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::too_many_arguments)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
After: no lint.
2022-07-04 09:33:54 -07:00
David Tolnay
e41be2f96b
Begin development on async fn support
2022-01-18 17:58:16 -08:00
David Tolnay
97d7d53c44
Wrap async fn error message
2022-01-18 17:29:01 -08:00
David Tolnay
d58307a1f0
Rename variants_from_header optin to "experimental-enum-variants-from-header"
...
In preparation for "experimental-async-fn" as a completely orthogonal
experimental feature.
2022-01-18 17:29:01 -08:00
David Tolnay
c1f2176154
Handle module-level cfg attributes
2022-01-18 00:39:25 -08:00
David Tolnay
7bafde28f4
Run cfg evaluator to strip syntax tree
2022-01-17 19:54:54 -08:00
David Tolnay
502022a476
Parse attributes on impl blocks
2022-01-17 19:05:47 -08:00
David Tolnay
2476aff7b2
Store parsed cfg attributes into syntax tree
2022-01-17 18:47:30 -08:00
David Tolnay
b9781f0d03
Add parser for cfg expressions
2022-01-17 14:10:10 -08:00
David Tolnay
5c58322742
Format with rustfmt 1.4.38
...
Apparently 7fae55596e
makes a difference in how rustfmt wants to format this enum.
2022-01-17 13:49:01 -08:00
David Tolnay
7fae55596e
Resolve dead code warnings uncovered by rustc_privacy/rustc_resolve refactor
...
warning: associated function is never used: `checked_succ`
--> gen/build/src/syntax/discriminant.rs:183:18
|
183 | pub const fn checked_succ(self) -> Option<Self> {
| ^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: associated function is never used: `ty`
--> gen/build/src/syntax/tokens.rs:305:12
|
305 | pub fn ty(&self) -> ReceiverType {
| ^^
warning: associated function is never used: `ty_self`
--> gen/build/src/syntax/tokens.rs:310:12
|
310 | pub fn ty_self(&self) -> ReceiverTypeSelf {
| ^^^^^^^
warning: variant is never constructed: `Foreign`
--> gen/build/src/syntax/mod.rs:122:5
|
122 | Foreign { rust_type: Path },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: associated function is never used: `checked_succ`
--> macro/src/syntax/discriminant.rs:183:18
|
183 | pub const fn checked_succ(self) -> Option<Self> {
| ^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: associated function is never used: `is_empty`
--> macro/src/syntax/doc.rs:22:12
|
22 | pub fn is_empty(&self) -> bool {
| ^^^^^^^^
warning: associated function is never used: `to_string`
--> macro/src/syntax/doc.rs:26:12
|
26 | pub fn to_string(&self) -> String {
| ^^^^^^^^^
warning: associated function is never used: `remove`
--> macro/src/syntax/map.rs:127:16
|
127 | pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
| ^^^^^^
warning: associated function is never used: `to_fully_qualified`
--> macro/src/syntax/names.rs:24:12
|
24 | pub fn to_fully_qualified(&self) -> String {
| ^^^^^^^^^^^^^^^^^^
warning: associated function is never used: `prefix_with`
--> macro/src/syntax/symbol.rs:44:12
|
44 | pub fn prefix_with(&self, prefix: &str) -> Symbol {
| ^^^^^^^^^^^
warning: variant is never constructed: `Foreign`
--> macro/src/syntax/mod.rs:122:5
|
122 | Foreign { rust_type: Path },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2022-01-10 18:50:49 -08:00
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