Skip to content

Commit 0921e1f

Browse files
alexcrichtoncalebcartwright
authored andcommitted
Improve support for wasm32-wasi
This commit has a few tweaks necessary to get a wasi binary of `rustfmt` working. Timers were flagged as being allowed on wasi targets (but still not allowed on wasm32), and path canonicalization errors are now also ignored. This is also somewhat beneficial for other filesystems as well where canonicalization sometimes does not work in esoteric situations.
1 parent a190c4b commit 0921e1f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl Config {
263263
dir.to_path_buf()
264264
};
265265

266-
current = dunce::canonicalize(current)?;
266+
current = dunce::canonicalize(&current).unwrap_or(current);
267267
let mut paths = Vec::new();
268268

269269
loop {

src/formatting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ enum Timer {
245245

246246
impl Timer {
247247
fn start() -> Timer {
248-
if cfg!(target_arch = "wasm32") {
248+
if cfg!(all(target_arch = "wasm32", not(target_os = "wasi"))) {
249249
Timer::Disabled
250250
} else {
251251
Timer::Initialized(Instant::now())

0 commit comments

Comments
 (0)