Skip to content

Commit a423aad

Browse files
committed
Run cargo fmt
1 parent e299009 commit a423aad

File tree

7 files changed

+62
-56
lines changed

7 files changed

+62
-56
lines changed

rewatch/src/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::build::compile::{mark_modules_with_deleted_deps_dirty, mark_modules_w
1212
use crate::helpers::emojis::*;
1313
use crate::helpers::{self, get_workspace_root};
1414
use crate::sourcedirs;
15-
use anyhow::{anyhow, Result};
15+
use anyhow::{Result, anyhow};
1616
use build_types::*;
1717
use console::style;
1818
use indicatif::{ProgressBar, ProgressStyle};
@@ -21,7 +21,7 @@ use serde::Serialize;
2121
use std::ffi::OsString;
2222
use std::fmt;
2323
use std::fs::File;
24-
use std::io::{stdout, Write};
24+
use std::io::{Write, stdout};
2525
use std::path::{Path, PathBuf};
2626
use std::process::Stdio;
2727
use std::time::{Duration, Instant};

rewatch/src/build/deps.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,25 @@ fn get_dep_modules(
1313
) -> AHashSet<String> {
1414
let mut deps = AHashSet::new();
1515
let ast_file = package.get_build_path().join(ast_file);
16-
match helpers::read_lines(&ast_file) { Ok(lines) => {
17-
// we skip the first line with is some null characters
18-
// the following lines in the AST are the dependency modules
19-
// we stop when we hit a line that starts with a "/", this is the path of the file.
20-
// this is the point where the dependencies end and the actual AST starts
21-
for line in lines.skip(1).flatten() {
22-
let line = line.trim().to_string();
23-
if line.starts_with('/') {
24-
break;
25-
} else if !line.is_empty() {
26-
deps.insert(line);
16+
match helpers::read_lines(&ast_file) {
17+
Ok(lines) => {
18+
// we skip the first line with is some null characters
19+
// the following lines in the AST are the dependency modules
20+
// we stop when we hit a line that starts with a "/", this is the path of the file.
21+
// this is the point where the dependencies end and the actual AST starts
22+
for line in lines.skip(1).flatten() {
23+
let line = line.trim().to_string();
24+
if line.starts_with('/') {
25+
break;
26+
} else if !line.is_empty() {
27+
deps.insert(line);
28+
}
2729
}
2830
}
29-
} _ => {
30-
panic!("Could not read file {}", ast_file.to_string_lossy());
31-
}}
31+
_ => {
32+
panic!("Could not read file {}", ast_file.to_string_lossy());
33+
}
34+
}
3235

3336
return deps
3437
.iter()

rewatch/src/build/packages.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use super::namespaces;
33
use super::packages;
44
use crate::config;
55
use crate::helpers;
6-
use crate::helpers::emojis::*;
76
use crate::helpers::StrippedVerbatimPath;
7+
use crate::helpers::emojis::*;
88
use ahash::{AHashMap, AHashSet};
9-
use anyhow::{anyhow, Result};
9+
use anyhow::{Result, anyhow};
1010
use console::style;
1111
use log::{debug, error};
1212
use rayon::prelude::*;
@@ -266,16 +266,17 @@ pub fn read_dependency(
266266
)),
267267
}?;
268268

269-
let canonical_path = match path.canonicalize().map(StrippedVerbatimPath::to_stripped_verbatim_path) {
269+
let canonical_path = match path
270+
.canonicalize()
271+
.map(StrippedVerbatimPath::to_stripped_verbatim_path)
272+
{
270273
Ok(canonical_path) => Ok(canonical_path),
271-
Err(e) => {
272-
Err(format!(
273-
"Failed canonicalizing the package \"{}\" path \"{}\" (are node_modules up-to-date?)...\nMore details: {}",
274-
package_name,
275-
path.to_string_lossy(),
276-
e
277-
))
278-
}
274+
Err(e) => Err(format!(
275+
"Failed canonicalizing the package \"{}\" path \"{}\" (are node_modules up-to-date?)...\nMore details: {}",
276+
package_name,
277+
path.to_string_lossy(),
278+
e
279+
)),
279280
}?;
280281

281282
Ok(canonical_path)
@@ -414,7 +415,11 @@ fn make_package(config: config::Config, package_path: &Path, is_pinned_dep: bool
414415
None => {
415416
if !is_root {
416417
let package_path_str = package_path.to_string_lossy();
417-
log::warn!("Package '{}' has not defined any sources, but is not the root package. This is likely a mistake. It is located: {}", config.name, package_path_str);
418+
log::warn!(
419+
"Package '{}' has not defined any sources, but is not the root package. This is likely a mistake. It is located: {}",
420+
config.name,
421+
package_path_str
422+
);
418423
}
419424

420425
AHashSet::new()

rewatch/src/build/parse.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,7 @@ pub fn generate_asts(
242242
}
243243
});
244244

245-
if has_failure {
246-
Err(stderr)
247-
} else {
248-
Ok(stderr)
249-
}
245+
if has_failure { Err(stderr) } else { Ok(stderr) }
250246
}
251247

252248
pub fn parser_args(
@@ -334,26 +330,29 @@ fn generate_ast(
334330
.args(parser_args)
335331
.output()
336332
.expect("Error converting .res to .ast"),
337-
) { Some(res_to_ast) => {
338-
let stderr = std::str::from_utf8(&res_to_ast.stderr).expect("Expect StdErr to be non-null");
339-
if helpers::contains_ascii_characters(stderr) {
340-
if res_to_ast.status.success() {
341-
Ok((ast_path, Some(stderr.to_string())))
333+
) {
334+
Some(res_to_ast) => {
335+
let stderr = std::str::from_utf8(&res_to_ast.stderr).expect("Expect StdErr to be non-null");
336+
if helpers::contains_ascii_characters(stderr) {
337+
if res_to_ast.status.success() {
338+
Ok((ast_path, Some(stderr.to_string())))
339+
} else {
340+
Err(format!("Error in {}:\n{}", package.name, stderr))
341+
}
342342
} else {
343-
Err(format!("Error in {}:\n{}", package.name, stderr))
343+
Ok((ast_path, None))
344344
}
345-
} else {
346-
Ok((ast_path, None))
347345
}
348-
} _ => {
349-
log::info!("Parsing file {}...", filename.display());
346+
_ => {
347+
log::info!("Parsing file {}...", filename.display());
350348

351-
Err(format!(
352-
"Could not find canonicalize_string_path for file {} in package {}",
353-
filename.display(),
354-
package.name
355-
))
356-
}};
349+
Err(format!(
350+
"Could not find canonicalize_string_path for file {} in package {}",
351+
filename.display(),
352+
package.name
353+
))
354+
}
355+
};
357356
if let Ok((ast_path, _)) = &result {
358357
let _ = std::fs::copy(
359358
Path::new(&build_path_abs).join(&ast_path),

rewatch/src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,10 @@ impl Config {
454454
},
455455
Ok(false) => vec![],
456456
Err(_) => {
457-
eprintln!("Could not establish Rescript Version number for uncurried mode. Defaulting to Rescript < 11, disabling uncurried mode. Please specify an exact version if you need > 11 and default uncurried mode. Version: {}", version);
457+
eprintln!(
458+
"Could not establish Rescript Version number for uncurried mode. Defaulting to Rescript < 11, disabling uncurried mode. Please specify an exact version if you need > 11 and default uncurried mode. Version: {}",
459+
version
460+
);
458461
vec![]
459462
}
460463
}

rewatch/src/helpers.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,7 @@ pub fn string_ends_with_any(s: &Path, suffixes: &[&str]) -> bool {
252252

253253
fn path_to_ast_extension(path: &Path) -> &str {
254254
let extension = path.extension().unwrap().to_str().unwrap();
255-
if extension.ends_with("i") {
256-
".iast"
257-
} else {
258-
".ast"
259-
}
255+
if extension.ends_with("i") { ".iast" } else { ".ast" }
260256
}
261257

262258
pub fn get_ast_path(source_file: &Path) -> PathBuf {

rewatch/src/watcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::build::build_types::SourceType;
33
use crate::build::clean;
44
use crate::cmd;
55
use crate::helpers;
6-
use crate::helpers::emojis::*;
76
use crate::helpers::StrippedVerbatimPath;
7+
use crate::helpers::emojis::*;
88
use crate::queue::FifoQueue;
99
use crate::queue::*;
1010
use futures_timer::Delay;

0 commit comments

Comments
 (0)