Skip to content

Commit 77a4657

Browse files
committed
ctest: add skips and mappings.
1 parent 04afcef commit 77a4657

23 files changed

+969
-69
lines changed

ctest-next/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "ctest-next"
33
version = "0.1.0"
44
edition = "2021"
5-
rust-version = "1.77"
5+
rust-version = "1.87"
66
license = "MIT OR Apache-2.0"
77
repository = "https://github.com/rust-lang/libc"
88
publish = false

ctest-next/src/ast/field.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ pub struct Field {
66
#[expect(unused)]
77
pub(crate) public: bool,
88
pub(crate) ident: BoxStr,
9-
#[expect(unused)]
109
pub(crate) ty: syn::Type,
1110
}
1211

1312
impl Field {
14-
/// Return the identifier of the field as a string if it exists.
13+
/// Return the identifier of the field as a string.
1514
pub fn ident(&self) -> &str {
1615
&self.ident
1716
}

ctest-next/src/ast/parameter.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
use crate::BoxStr;
2+
13
/// Represents a parameter in a function signature defined in Rust.
24
#[derive(Debug, Clone)]
35
pub struct Parameter {
4-
#[expect(unused)]
5-
pub(crate) pattern: syn::Pat,
6+
pub(crate) ident: BoxStr,
67
#[expect(unused)]
78
pub(crate) ty: syn::Type,
89
}
10+
11+
impl Parameter {
12+
/// Return the identifier of the parameter as a string.
13+
pub fn ident(&self) -> &str {
14+
&self.ident
15+
}
16+
}

ctest-next/src/ast/static_variable.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub struct Static {
1111
#[expect(unused)]
1212
pub(crate) abi: Abi,
1313
pub(crate) ident: BoxStr,
14-
#[expect(unused)]
1514
pub(crate) ty: syn::Type,
1615
}
1716

ctest-next/src/ast/type_alias.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub struct Type {
66
#[expect(unused)]
77
pub(crate) public: bool,
88
pub(crate) ident: BoxStr,
9-
#[expect(unused)]
109
pub(crate) ty: syn::Type,
1110
}
1211

ctest-next/src/ffi_items.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ use crate::{Abi, Const, Field, Fn, Parameter, Static, Struct, Type, Union};
99
/// Includes foreign functions/statics, type aliases, structs, unions, and constants.
1010
#[derive(Default, Clone, Debug)]
1111
pub(crate) struct FfiItems {
12-
aliases: Vec<Type>,
13-
structs: Vec<Struct>,
14-
unions: Vec<Union>,
15-
constants: Vec<Const>,
16-
foreign_functions: Vec<Fn>,
17-
foreign_statics: Vec<Static>,
12+
pub(crate) aliases: Vec<Type>,
13+
pub(crate) structs: Vec<Struct>,
14+
pub(crate) unions: Vec<Union>,
15+
pub(crate) constants: Vec<Const>,
16+
pub(crate) foreign_functions: Vec<Fn>,
17+
pub(crate) foreign_statics: Vec<Static>,
1818
}
1919

2020
impl FfiItems {
@@ -24,15 +24,13 @@ impl FfiItems {
2424
}
2525

2626
/// Return whether the type has parsed a struct with the given identifier.
27-
#[expect(unused)]
2827
pub(crate) fn contains_struct(&self, ident: &str) -> bool {
2928
self.structs()
3029
.iter()
3130
.any(|structure| structure.ident() == ident)
3231
}
3332

3433
/// Return whether the type has parsed a union with the given identifier.
35-
#[expect(unused)]
3634
pub(crate) fn contains_union(&self, ident: &str) -> bool {
3735
self.unions().iter().any(|union| union.ident() == ident)
3836
}
@@ -106,7 +104,12 @@ fn visit_foreign_item_fn(table: &mut FfiItems, i: &syn::ForeignItemFn, abi: &Abi
106104
.iter()
107105
.map(|arg| match arg {
108106
syn::FnArg::Typed(arg) => Parameter {
109-
pattern: arg.pat.deref().clone(),
107+
ident: match arg.pat.deref() {
108+
syn::Pat::Ident(i) => i.ident.to_string().into_boxed_str(),
109+
_ => {
110+
unimplemented!("Foreign functions are unlikely to have any other pattern.")
111+
}
112+
},
110113
ty: arg.ty.deref().clone(),
111114
},
112115
syn::FnArg::Receiver(_) => {

0 commit comments

Comments
 (0)