Skip to content

ctest: Add skips and mappings. #4514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ctest-next/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "ctest-next"
version = "0.1.0"
edition = "2021"
rust-version = "1.77"
rust-version = "1.87"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/libc"
publish = false
Expand Down
3 changes: 1 addition & 2 deletions ctest-next/src/ast/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ pub struct Field {
#[expect(unused)]
pub(crate) public: bool,
pub(crate) ident: BoxStr,
#[expect(unused)]
pub(crate) ty: syn::Type,
}

impl Field {
/// Return the identifier of the field as a string if it exists.
/// Return the identifier of the field as a string.
pub fn ident(&self) -> &str {
&self.ident
}
Expand Down
12 changes: 10 additions & 2 deletions ctest-next/src/ast/parameter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
use crate::BoxStr;

/// Represents a parameter in a function signature defined in Rust.
#[derive(Debug, Clone)]
pub struct Parameter {
#[expect(unused)]
pub(crate) pattern: syn::Pat,
pub(crate) ident: BoxStr,
#[expect(unused)]
pub(crate) ty: syn::Type,
}

impl Parameter {
/// Return the identifier of the parameter as a string.
pub fn ident(&self) -> &str {
&self.ident
}
}
1 change: 0 additions & 1 deletion ctest-next/src/ast/static_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub struct Static {
#[expect(unused)]
pub(crate) abi: Abi,
pub(crate) ident: BoxStr,
#[expect(unused)]
pub(crate) ty: syn::Type,
}

Expand Down
1 change: 0 additions & 1 deletion ctest-next/src/ast/type_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub struct Type {
#[expect(unused)]
pub(crate) public: bool,
pub(crate) ident: BoxStr,
#[expect(unused)]
pub(crate) ty: syn::Type,
}

Expand Down
21 changes: 12 additions & 9 deletions ctest-next/src/ffi_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use crate::{Abi, Const, Field, Fn, Parameter, Static, Struct, Type, Union};
/// Includes foreign functions/statics, type aliases, structs, unions, and constants.
#[derive(Default, Clone, Debug)]
pub(crate) struct FfiItems {
aliases: Vec<Type>,
structs: Vec<Struct>,
unions: Vec<Union>,
constants: Vec<Const>,
foreign_functions: Vec<Fn>,
foreign_statics: Vec<Static>,
pub(crate) aliases: Vec<Type>,
pub(crate) structs: Vec<Struct>,
pub(crate) unions: Vec<Union>,
pub(crate) constants: Vec<Const>,
pub(crate) foreign_functions: Vec<Fn>,
pub(crate) foreign_statics: Vec<Static>,
}

impl FfiItems {
Expand All @@ -24,15 +24,13 @@ impl FfiItems {
}

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

/// Return whether the type has parsed a union with the given identifier.
#[expect(unused)]
pub(crate) fn contains_union(&self, ident: &str) -> bool {
self.unions().iter().any(|union| union.ident() == ident)
}
Expand Down Expand Up @@ -106,7 +104,12 @@ fn visit_foreign_item_fn(table: &mut FfiItems, i: &syn::ForeignItemFn, abi: &Abi
.iter()
.map(|arg| match arg {
syn::FnArg::Typed(arg) => Parameter {
pattern: arg.pat.deref().clone(),
ident: match arg.pat.deref() {
syn::Pat::Ident(i) => i.ident.to_string().into_boxed_str(),
_ => {
unimplemented!("Foreign functions are unlikely to have any other pattern.")
}
},
ty: arg.ty.deref().clone(),
},
syn::FnArg::Receiver(_) => {
Expand Down
Loading
Loading