(
module: &Module,
import_args: &[I],
check: impl Fn(&matching::MatchCx<'_>, &EntityType, &I) -> Result<()>,
)
| 1022 | } |
| 1023 | |
| 1024 | fn typecheck<I>( |
| 1025 | module: &Module, |
| 1026 | import_args: &[I], |
| 1027 | check: impl Fn(&matching::MatchCx<'_>, &EntityType, &I) -> Result<()>, |
| 1028 | ) -> Result<()> { |
| 1029 | let env_module = module.compiled_module().module(); |
| 1030 | let expected_len = env_module.imports().count(); |
| 1031 | let actual_len = import_args.len(); |
| 1032 | if expected_len != actual_len { |
| 1033 | bail!("expected {expected_len} imports, found {actual_len}"); |
| 1034 | } |
| 1035 | let cx = matching::MatchCx::new(module.engine()); |
| 1036 | for ((name, field, expected_ty), actual) in env_module.imports().zip(import_args) { |
| 1037 | debug_assert!(expected_ty.is_canonicalized_for_runtime_usage()); |
| 1038 | check(&cx, &expected_ty, actual) |
| 1039 | .with_context(|| format!("incompatible import type for `{name}::{field}`"))?; |
| 1040 | } |
| 1041 | Ok(()) |
| 1042 | } |
no test coverage detected