use crate::core::config::ResolvedCrateConfig;
use crate::core::ir::{ErrorDef, TypeDef};
use ahash::AHashSet;
pub(crate) fn pyclass_absent_type_names(
config: &ResolvedCrateConfig,
types: &[TypeDef],
errors: &[ErrorDef],
) -> AHashSet<String> {
let mut absent: AHashSet<String> = config
.python
.as_ref()
.map(|python| python.exclude_types.iter().cloned().collect())
.unwrap_or_default();
absent.extend(
types
.iter()
.filter(|typ| typ.binding_excluded)
.map(|typ| typ.name.clone()),
);
let capsule_types = config
.python
.as_ref()
.map(|python| python.capsule_types.clone())
.unwrap_or_default();
super::config_opaque::exclude_capsule_opaque_types(&mut absent, config, &capsule_types);
absent.extend(capsule_types.keys().cloned());
for error in errors {
absent.insert(error.name.clone());
absent.extend(
error
.variants
.iter()
.map(|variant| crate::codegen::error_gen::python_exception_name(&variant.name, &error.name)),
);
}
absent
}