Skip to content

Commit 2a14276

Browse files
committed
remove unneeded and buggy UnusedFFIImplementations error
1 parent 9e9621e commit 2a14276

5 files changed

Lines changed: 12 additions & 35 deletions

File tree

src/build/error.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ pub enum BuildError {
4848
path: PathBuf,
4949
missing: Vec<String>,
5050
},
51-
#[error("The following values in the foreign module for module {module_name} are unused: {}", unused.join(", "))]
52-
UnusedFFIImplementations {
53-
module_name: String,
54-
path: PathBuf,
55-
unused: Vec<String>,
56-
},
5751
#[error("CommonJS exports in the ES foreign module for module {module_name} are unsupported: {}", exports.join(", "))]
5852
UnsupportedFFICommonJSExports {
5953
module_name: String,
@@ -99,7 +93,6 @@ impl BuildError {
9993
BuildError::InvalidModuleName { .. } => "SyntaxError".into(),
10094
BuildError::MissingFFIModule { .. } => "MissingFFIModule".into(),
10195
BuildError::MissingFFIImplementations { .. } => "MissingFFIImplementations".into(),
102-
BuildError::UnusedFFIImplementations { .. } => "UnusedFFIImplementations".into(),
10396
BuildError::UnsupportedFFICommonJSExports { .. } => "UnsupportedFFICommonJSExports".into(),
10497
BuildError::UnsupportedFFICommonJSImports { .. } => "UnsupportedFFICommonJSImports".into(),
10598
BuildError::DeprecatedFFICommonJSModule { .. } => "DeprecatedFFICommonJSModule".into(),

src/build/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -748,18 +748,6 @@ fn build_from_sources_impl(
748748
missing,
749749
});
750750
}
751-
js_ffi::FfiError::UnusedFFIImplementations { unused } => {
752-
log::debug!(
753-
" FFI error in {}: unused implementations: {:?}",
754-
pm.module_name,
755-
unused
756-
);
757-
build_errors.push(BuildError::UnusedFFIImplementations {
758-
module_name: pm.module_name.clone(),
759-
path: pm.path.clone(),
760-
unused,
761-
});
762-
}
763751
js_ffi::FfiError::UnsupportedFFICommonJSExports { exports } => {
764752
build_errors.push(
765753
BuildError::UnsupportedFFICommonJSExports {

src/js_ffi.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ pub enum FfiError {
3131
DeprecatedFFICommonJSModule,
3232
/// Declared `foreign import` but not exported in FFI
3333
MissingFFIImplementations { missing: Vec<String> },
34-
/// Exported in FFI but no corresponding `foreign import`
35-
UnusedFFIImplementations { unused: Vec<String> },
3634
/// CommonJS exports mixed with ES module syntax
3735
UnsupportedFFICommonJSExports { exports: Vec<String> },
3836
/// CommonJS imports (require) mixed with ES module syntax
@@ -339,9 +337,5 @@ pub fn validate_foreign_module(
339337
errors.push(FfiError::MissingFFIImplementations { missing });
340338
}
341339

342-
if !unused.is_empty() {
343-
errors.push(FfiError::UnusedFFIImplementations { unused });
344-
}
345-
346340
errors
347341
}

src/main.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,32 @@ fn main() {
7474
log::debug!("Failed to save build cache: {e}");
7575
}
7676

77-
let mut error_count = 0;
77+
let mut error_messages: Vec<String> = Vec::new();
7878

7979
for err in &result.build_errors {
80-
eprintln!("[error] {err}");
81-
error_count += 1;
80+
error_messages.push(format!("{err}"));
8281
}
8382

84-
for module in &result.modules {
83+
let total = result.modules.len();
84+
for (i, module) in result.modules.iter().enumerate() {
8585
if module.type_errors.is_empty() {
86-
println!("[ok] {}", module.module_name);
86+
println!("[{}/{}] {}", i + 1, total, module.module_name);
8787
} else {
8888
for err in &module.type_errors {
89-
eprintln!("[error] {}: {err}", module.module_name);
90-
error_count += 1;
89+
error_messages.push(format!("{}: {err}", module.module_name));
9190
}
9291
}
9392
}
9493

95-
if error_count > 0 {
94+
if !error_messages.is_empty() {
95+
let error_count = error_messages.len();
9696
eprintln!(
97-
"\nCompilation failed with {error_count} error{}.",
97+
"\nCompilation failed with {error_count} error{}:\n",
9898
if error_count == 1 { "" } else { "s" }
9999
);
100+
for msg in &error_messages {
101+
eprintln!(" {msg}");
102+
}
100103
std::process::exit(1);
101104
} else {
102105
println!(

tests/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ fn matches_expected_error(
535535
"UnsupportedTypeInKind" => has("UnsupportedTypeInKind"),
536536
"CannotDeriveInvalidConstructorArg" => has("CannotDeriveInvalidConstructorArg"),
537537
"MissingFFIImplementations" => has("MissingFFIImplementations"),
538-
"UnusedFFIImplementations" => has("UnusedFFIImplementations"),
539538
"UnsupportedFFICommonJSExports" => has("UnsupportedFFICommonJSExports"),
540539
"UnsupportedFFICommonJSImports" => has("UnsupportedFFICommonJSImports"),
541540
"DeprecatedFFICommonJSModule" => has("DeprecatedFFICommonJSModule"),

0 commit comments

Comments
 (0)