Skip to content

Commit aad2133

Browse files
refactor: check for module interface rather than AST
1 parent 94e1e51 commit aad2133

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

compiler-cli/src/publish.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,20 +378,21 @@ fn do_build_hex_tarball(paths: &ProjectPaths, config: &mut PackageConfig) -> Res
378378
});
379379
}
380380

381-
// empty_modules is a list of modules that contain no public definitions
382-
// it is used to refuse to publish packages that are not yet finished.
381+
// empty_modules is a list of modules that do not export any values or types.
382+
// We do not allow publishing packages that contain empty modules.
383383
let empty_modules: Vec<_> = built
384384
.root_package
385385
.modules
386386
.iter()
387387
.filter(|module| {
388-
module
389-
.ast
390-
.definitions
391-
.iter()
392-
.filter(|def| def.is_public())
393-
.count()
394-
== 0
388+
built
389+
.module_interfaces
390+
.get(&module.name)
391+
.map(|interface| {
392+
// Check if the module exports any values or types
393+
interface.values.is_empty() && interface.types.is_empty()
394+
})
395+
.unwrap_or(false)
395396
})
396397
.map(|module| module.name.clone())
397398
.collect();

0 commit comments

Comments
 (0)