Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslavsky committed May 27, 2024
1 parent 899a46e commit b4e83ed
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/wit-component/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl From<StringEncoding> for wasm_encoder::CanonicalOption {
/// Handles world name resolution for cases when multiple packages may have been resolved. If this
/// is the case, and we're dealing with input that contains a user-supplied world name (like via a
/// CLI command, for instance), we want to ensure that the world name follows the following rules:
///
///
/// * If there is a single resolved package with a single world, the world name name MAY be
/// omitted.
/// * If there is a single resolved package with multiple worlds, the world name MUST be supplied,
Expand Down
2 changes: 1 addition & 1 deletion crates/wit-component/tests/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn run_test(path: &Path, is_dir: bool) -> Result<()> {
};

for package in packages {
assert_print(&resolve, vec!(package), path, is_dir)?;
assert_print(&resolve, vec![package], path, is_dir)?;

let features = WasmFeatures::default() | WasmFeatures::COMPONENT_MODEL;

Expand Down
2 changes: 1 addition & 1 deletion crates/wit-component/tests/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn merging() -> Result<()> {
.join("merge")
.join(&pkg.name.name)
.with_extension("wit");
let output = WitPrinter::default().print(&into, vec!(id))?;
let output = WitPrinter::default().print(&into, vec![id])?;
assert_output(&expected, &output)?;
}
}
Expand Down
4 changes: 1 addition & 3 deletions crates/wit-component/tests/wit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ fn parse_wit_file() -> Result<()> {
drop(env_logger::try_init());

let mut resolver = Resolve::default();
let package_id = resolver
.push_path("tests/wit/parse-dir/wit/deps/bar/bar.wit")?
[0].0;
let package_id = resolver.push_path("tests/wit/parse-dir/wit/deps/bar/bar.wit")?[0].0;
resolver.select_world(package_id, "bar-world".into())?;
assert!(resolver
.interfaces
Expand Down
4 changes: 2 additions & 2 deletions crates/wit-parser/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,8 @@ impl SourceMap {
Some(mut pkg) => match explicit_pkgs.is_empty() {
true => {
pkg.source_map = self;
Ok(vec!(pkg))
},
Ok(vec![pkg])
}
false => {
bail!("WIT files cannot mix top-level explicit `package` declarations with other declaration kinds");
}
Expand Down
4 changes: 2 additions & 2 deletions crates/wit-parser/src/ast/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ impl<'a> Resolver<'a> {
Some(name) => name.clone(),
None => {
if self.decl_lists.is_empty() {
return Ok(None)
return Ok(None);
}
bail!("no `package` header was found in any WIT file for this package")
},
}
};

// First populate information about foreign dependencies and the general
Expand Down
6 changes: 3 additions & 3 deletions crates/wit-parser/src/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl DecodedWasm {
pub fn packages(&self) -> Vec<PackageId> {
match self {
DecodedWasm::WitPackages(_, ids) => ids.clone(),
DecodedWasm::Component(resolve, world) => vec!(resolve.worlds[*world].package.unwrap()),
DecodedWasm::Component(resolve, world) => vec![resolve.worlds[*world].package.unwrap()],
}
}
}
Expand All @@ -382,12 +382,12 @@ pub fn decode_reader(reader: impl Read) -> Result<DecodedWasm> {
WitEncodingVersion::V1 => {
log::debug!("decoding a v1 WIT package encoded as wasm");
let (resolve, pkg) = info.decode_wit_v1_package()?;
Ok(DecodedWasm::WitPackages(resolve, vec!(pkg)))
Ok(DecodedWasm::WitPackages(resolve, vec![pkg]))
}
WitEncodingVersion::V2 => {
log::debug!("decoding a v2 WIT package encoded as wasm");
let (resolve, pkg) = info.decode_wit_v2_package()?;
Ok(DecodedWasm::WitPackages(resolve, vec!(pkg)))
Ok(DecodedWasm::WitPackages(resolve, vec![pkg]))
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/wit-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub use docs::PackageDocs;
pub mod abi;
mod ast;
use ast::lex::Span;
pub use ast::{parse_use_path, ParsedUsePath};
pub use ast::SourceMap;
pub use ast::{parse_use_path, ParsedUsePath};
mod sizealign;
pub use sizealign::*;
mod resolve;
Expand Down
3 changes: 1 addition & 2 deletions crates/wit-smith/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ pub fn smith(config: &Config, u: &mut Unstructured<'_>) -> Result<Vec<u8>> {
}
};
last = Some(id);
},
}
// An empty vector means we had a bunch of empty wit files here.
None => return Err(arbitrary::Error::NotEnoughData),
}

}
let pkg = last.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/src/roundtrip_wit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn run(u: &mut Unstructured<'_>) -> Result<()> {
if pkgs2.len() != 1 {
panic!("rountrip WIT test smithed file with multiple packages")
}

let pkg2 = pkgs2[0];
let wasm2 =
wit_component::encode(Some(true), &resolve2, pkg2).expect("failed to encode WIT document");
Expand Down Expand Up @@ -86,7 +86,7 @@ fn roundtrip_through_printing(file: &str, resolve: &Resolve, wasm: &[u8]) {
for (id, pkg) in resolve.packages.iter() {
let mut map = SourceMap::new();
let pkg_name = &pkg.name;
let doc = WitPrinter::default().print(resolve, vec!(id)).unwrap();
let doc = WitPrinter::default().print(resolve, vec![id]).unwrap();
write_file(&format!("{file}-{pkg_name}.wit"), &doc);
map.push(format!("{pkg_name}.wit").as_ref(), doc);
let unresolved = map.parse().unwrap();
Expand Down

0 comments on commit b4e83ed

Please sign in to comment.