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

@ -133,13 +133,13 @@ pub fn report_problems(
problems_reported = warnings.len();
for warning in warnings.iter() {
println!("\n{}\n", warning);
println!("\n{warning}\n");
}
} else {
problems_reported = errors.len();
for error in errors.iter() {
println!("\n{}\n", error);
println!("\n{error}\n");
}
}

View file

@ -557,14 +557,8 @@ pub fn can_problem<'b>(
doc = alloc.stack([
alloc.reflow("This string interpolation is invalid:"),
alloc.region(lines.convert_region(region)),
alloc.concat([
alloc.reflow(r"I was expecting an identifier, like "),
alloc.parser_suggestion("\\u(message)"),
alloc.reflow(" or "),
alloc.parser_suggestion("\\u(LoremIpsum.text)"),
alloc.text("."),
]),
alloc.reflow(r"Learn more about string interpolation at TODO"),
alloc.reflow(r"String interpolations cannot contain newlines or other interpolations."),
alloc.reflow(r"You can learn more about string interpolation at <https://www.roc-lang.org/tutorial#string-interpolation>"),
]);
title = SYNTAX_PROBLEM.to_string();
@ -845,7 +839,7 @@ pub fn can_problem<'b>(
alloc.reflow("An implementation of "), alloc.symbol_unqualified(member), alloc.reflow(" could not be found in this scope:"),
]),
alloc.region(lines.convert_region(region)),
alloc.tip().append(alloc.concat([alloc.reflow("consider adding a value of name "), alloc.symbol_unqualified(member), alloc.reflow(" in this scope, or using another variable that implements this ability member, like "), alloc.type_str(&format!("{{ {}: my{} }}", member_str, member_str))]))
alloc.tip().append(alloc.concat([alloc.reflow("consider adding a value of name "), alloc.symbol_unqualified(member), alloc.reflow(" in this scope, or using another variable that implements this ability member, like "), alloc.type_str(&format!("{{ {member_str}: my{member_str} }}"))]))
]);
title = IMPLEMENTATION_NOT_FOUND.to_string();
}

View file

@ -167,7 +167,7 @@ impl<'a> Renderer<'a> {
&crate::report::DEFAULT_PALETTE,
);
write!(writer, "{}", buf)
write!(writer, "{buf}")
}
#[allow(clippy::too_many_arguments)]
@ -238,6 +238,6 @@ impl<'a> Renderer<'a> {
&crate::report::DEFAULT_PALETTE,
);
write!(writer, "{}", buf)
write!(writer, "{buf}")
}
}

View file

@ -300,6 +300,15 @@ fn to_expr_report<'a>(
alloc.parser_suggestion("!"),
alloc.reflow(" and the expression after it."),
],
"<|" => vec![
alloc.reflow("Roc doesn't have a "),
alloc.parser_suggestion("<|"),
alloc.reflow(" operator. Please use parentheses "),
alloc.parser_suggestion("()"),
alloc.reflow(" or "),
alloc.parser_suggestion("|>"),
alloc.reflow(" instead."),
],
_ => vec![
alloc.reflow("I have no specific suggestion for this operator, "),
alloc.reflow("see TODO for the full list of operators in Roc."),
@ -3469,7 +3478,7 @@ fn to_provides_report<'a>(
}
}
EProvides::Provides(pos) => {
EProvides::Provides(pos) | EProvides::IndentProvides(pos) => {
let surroundings = Region::new(start, pos);
let region = LineColumnRegion::from_pos(lines.convert_pos(pos));

View file

@ -1048,7 +1048,7 @@ fn to_expr_report<'b>(
region,
Some(expr_region),
alloc.reflow("This list contains elements with different types:"),
alloc.string(format!("Its {} element is", ith)),
alloc.string(format!("Its {ith} element is")),
alloc.reflow(prev_elems_msg),
Some(alloc.reflow("Every element in a list must have the same type!")),
)
@ -1181,7 +1181,7 @@ fn to_expr_report<'b>(
if arity == 1 {
"1 argument".into()
} else {
format!("{} arguments", arity)
format!("{arity} arguments")
}
)),
]),
@ -1228,7 +1228,7 @@ fn to_expr_report<'b>(
if n == 1 {
"1 argument".into()
} else {
format!("{} arguments", n)
format!("{n} arguments")
},
arity
)),
@ -1252,7 +1252,7 @@ fn to_expr_report<'b>(
if n == 1 {
"1 argument".into()
} else {
format!("{} arguments", n)
format!("{n} arguments")
},
arity
)),
@ -1866,10 +1866,7 @@ fn format_category<'b>(
),
CallResult(None, _) => (this_is, alloc.text(":")),
LowLevelOpResult(op) => {
panic!(
"Compiler bug: invalid return type from low-level op {:?}",
op
);
panic!("Compiler bug: invalid return type from low-level op {op:?}");
}
ForeignCall => {
panic!("Compiler bug: invalid return type from foreign call",);
@ -4379,8 +4376,8 @@ fn type_problem_to_pretty<'b>(
match suggestions.get(0) {
None => alloc.nil(),
Some(nearest) => {
let typo_str = format!("{}", typo);
let nearest_str = format!("{}", nearest);
let typo_str = format!("{typo}");
let nearest_str = format!("{nearest}");
let found = alloc.text(typo_str).annotate(Annotation::Typo);
let suggestion = alloc.text(nearest_str).annotate(Annotation::TypoSuggestion);
@ -4431,7 +4428,7 @@ fn type_problem_to_pretty<'b>(
match suggestions.get(0) {
None => alloc.nil(),
Some(nearest) => {
let nearest_str = format!("{}", nearest);
let nearest_str = format!("{nearest}");
let found = alloc.text(typo_str).annotate(Annotation::Typo);
let suggestion = alloc.text(nearest_str).annotate(Annotation::TypoSuggestion);

View file

@ -438,7 +438,7 @@ impl<'a> RocDocAllocator<'a> {
}
pub fn wrapped_opaque_name(&'a self, opaque: Symbol) -> DocBuilder<'a, Self, Annotation> {
debug_assert_eq!(opaque.module_id(), self.home, "Opaque wrappings can only be defined in the same module they're defined in, but this one is defined elsewhere: {:?}", opaque);
debug_assert_eq!(opaque.module_id(), self.home, "Opaque wrappings can only be defined in the same module they're defined in, but this one is defined elsewhere: {opaque:?}");
text!(self, "@{}", opaque.as_str(self.interns)).annotate(Annotation::Opaque)
}
@ -1612,7 +1612,7 @@ pub fn to_file_problem_report<'b>(
}
_ => {
let error = std::io::Error::from(error);
let formatted = format!("{}", error);
let formatted = format!("{error}");
let doc = alloc.stack([
alloc.reflow(r"I tried to read this file:"),
alloc.string(filename).annotate(Annotation::Error).indent(4),