windows fixes, error improvements

This commit is contained in:
Anton-4 2022-11-15 17:09:16 +01:00
parent 29230921e6
commit e9d8d13b02
No known key found for this signature in database
GPG key ID: A13F4A6E21141925
6 changed files with 64 additions and 19 deletions

View file

@ -223,7 +223,11 @@ fn run_command(mut command: Command, flaky_fail_counter: usize) {
run_command(command, flaky_fail_counter + 1)
}
} else {
panic!("{} failed: {}", command_str, error_str);
if error_str.contains("lld-link: error: failed to write the output file: Permission denied") {
panic!("{} failed with:\n\n {}\n\nWorkaround:\n\n Re-run the cargo command that triggered this build.", command_str, error_str);
} else {
panic!("{} failed with:\n\n {}\n", command_str, error_str);
}
}
}
},

View file

@ -13,6 +13,12 @@ pub mod spaces;
use bumpalo::{collections::String, Bump};
use roc_parse::ast::Module;
#[cfg(windows)]
const NEWLINE: &str = "\r\n";
#[cfg(not(windows))]
const NEWLINE: &str = "\n";
#[derive(Debug)]
pub struct Ast<'a> {
pub module: Module<'a>,
@ -99,7 +105,9 @@ impl<'a> Buf<'a> {
pub fn newline(&mut self) {
self.spaces_to_flush = 0;
self.text.push('\n');
self.text.push_str(NEWLINE);
self.beginning_of_line = true;
}
@ -183,14 +191,14 @@ fn fmt_text_eof(text: &mut bumpalo::collections::String<'_>) {
// There's some whitespace at the end of this file, but the first
// whitespace char after the last non-whitespace char isn't a newline.
// So replace that whitespace char (and everything after it) with a newline.
text.replace_range(last_whitespace_index.., "\n");
text.replace_range(last_whitespace_index.., NEWLINE);
}
None => {
debug_assert!(last_whitespace_index == text.len());
debug_assert!(!text.ends_with(char::is_whitespace));
// This doesn't end in whitespace at all, so add a newline.
text.push('\n');
text.push_str(NEWLINE);
}
}
}