Merge remote-tracking branch 'origin/main' into abilities-syntax

This commit is contained in:
Richard Feldman 2023-08-10 20:29:27 -04:00
commit 2da41be29f
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
524 changed files with 47536 additions and 15089 deletions

View file

@ -743,8 +743,8 @@ impl<'a> CommentOrNewline<'a> {
use CommentOrNewline::*;
match self {
Newline => "\n".to_owned(),
LineComment(comment_str) => format!("#{}", comment_str),
DocComment(comment_str) => format!("##{}", comment_str),
LineComment(comment_str) => format!("#{comment_str}"),
DocComment(comment_str) => format!("##{comment_str}"),
}
}

View file

@ -2,6 +2,7 @@ use crate::ast::{
Collection, CommentOrNewline, Malformed, Spaced, Spaces, StrLiteral, TypeAnnotation,
};
use crate::blankspace::space0_e;
use crate::expr::merge_spaces;
use crate::ident::{lowercase_ident, UppercaseIdent};
use crate::parser::{optional, then};
use crate::parser::{specialize, word1, EPackageEntry, EPackageName, Parser};
@ -300,7 +301,7 @@ pub struct PackageEntry<'a> {
}
pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPackageEntry<'a>> {
map!(
map_with_arena!(
// You may optionally have a package shorthand,
// e.g. "uc" in `uc: roc/unicode 1.0.0`
//
@ -308,18 +309,25 @@ pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPac
and!(
optional(and!(
skip_second!(
specialize(|_, pos| EPackageEntry::Shorthand(pos), lowercase_ident()),
and!(
specialize(|_, pos| EPackageEntry::Shorthand(pos), lowercase_ident()),
space0_e(EPackageEntry::IndentPackage)
),
word1(b':', EPackageEntry::Colon)
),
space0_e(EPackageEntry::IndentPackage)
)),
loc!(specialize(EPackageEntry::BadPackage, package_name()))
),
move |(opt_shorthand, package_or_path)| {
move |arena, (opt_shorthand, package_or_path)| {
let entry = match opt_shorthand {
Some((shorthand, spaces_after_shorthand)) => PackageEntry {
Some(((shorthand, spaces_before_colon), spaces_after_colon)) => PackageEntry {
shorthand,
spaces_after_shorthand,
spaces_after_shorthand: merge_spaces(
arena,
spaces_before_colon,
spaces_after_colon,
),
package_name: package_or_path,
},
None => PackageEntry {

View file

@ -136,7 +136,7 @@ impl<'a> fmt::Debug for State<'a> {
write!(f, "State {{")?;
match std::str::from_utf8(self.bytes()) {
Ok(string) => write!(f, "\n\tbytes: [utf8] {:?}", string)?,
Ok(string) => write!(f, "\n\tbytes: [utf8] {string:?}")?,
Err(_) => write!(f, "\n\tbytes: [invalid utf8] {:?}", self.bytes())?,
}
@ -151,5 +151,5 @@ fn state_size() {
// cache line.
let state_size = std::mem::size_of::<State>();
let maximum = std::mem::size_of::<usize>() * 8;
assert!(state_size <= maximum, "{:?} <= {:?}", state_size, maximum);
assert!(state_size <= maximum, "{state_size:?} <= {maximum:?}");
}