Skip to content

Commit bd2a8dc

Browse files
committed
PR feedback
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
1 parent fa6fddc commit bd2a8dc

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/commands/targets.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
};
77
use wac_types::{ExternKind, ItemKind, Package, SubtypeChecker, Types, WorldId};
88

9-
/// Parses a WAC source file into a JSON AST representation.
9+
/// Verifies that a given WebAssembly component targets a world.
1010
#[derive(Args)]
1111
#[clap(disable_version_flag = true)]
1212
pub struct TargetsCommand {
@@ -59,7 +59,7 @@ fn get_wit_world(
5959
Some(world_name) => top_level_world
6060
.exports
6161
.get(world_name)
62-
.with_context(|| format!("wit package did not contain a world name '{world_name}'"))?,
62+
.with_context(|| format!("wit package did not contain a world named '{world_name}'"))?,
6363
None if top_level_world.exports.len() == 1 => {
6464
top_level_world.exports.values().next().unwrap()
6565
}
@@ -92,14 +92,11 @@ fn encode_wit_as_component(path: &Path) -> anyhow::Result<Vec<u8>> {
9292
path = path.display()
9393
);
9494

95-
let (pkg, _) = resolve.push_dir(&path)?;
96-
pkg
97-
} else if path.extension().and_then(std::ffi::OsStr::to_str) == Some("wit") {
98-
let unresolved = wit_parser::UnresolvedPackage::parse_file(&path)?;
99-
let pkg = resolve.push(unresolved)?;
95+
let (pkg, _) = resolve.push_dir(path)?;
10096
pkg
10197
} else {
102-
bail!("expected either a wit directory or wit file")
98+
let unresolved = wit_parser::UnresolvedPackage::parse_file(path)?;
99+
resolve.push(unresolved)?
103100
};
104101
let encoded = wit_component::encode(Some(true), &resolve, pkg).with_context(|| {
105102
format!(
@@ -142,8 +139,8 @@ pub enum Error {
142139
}
143140

144141
/// Validate whether the component conforms to the given world
145-
pub fn validate_target<'a>(
146-
types: &'a Types,
142+
pub fn validate_target(
143+
types: &Types,
147144
wit_world_id: WorldId,
148145
component_world_id: WorldId,
149146
) -> Result<(), Error> {

0 commit comments

Comments
 (0)