mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Merge pull request #7005 from smores56/deprecate-backpassing
Deprecate backpassing to prepare for eventual removal
This commit is contained in:
commit
7c7485bb04
37 changed files with 818 additions and 556 deletions
|
@ -1,4 +1,5 @@
|
|||
use roc_collections::all::MutSet;
|
||||
use roc_module::called_via::Suffix;
|
||||
use roc_module::ident::{Ident, Lowercase, ModuleName};
|
||||
use roc_module::symbol::DERIVABLE_ABILITIES;
|
||||
use roc_problem::can::PrecedenceProblem::BothNonAssociative;
|
||||
|
@ -246,6 +247,26 @@ pub fn can_problem<'b>(
|
|||
title = DUPLICATE_NAME.to_string();
|
||||
}
|
||||
|
||||
Problem::DeprecatedBackpassing(region) => {
|
||||
doc = alloc.stack([
|
||||
alloc.concat([
|
||||
alloc.reflow("Backpassing ("),
|
||||
alloc.backpassing_arrow(),
|
||||
alloc.reflow(") like this will soon be deprecated:"),
|
||||
]),
|
||||
alloc.region(lines.convert_region(region), severity),
|
||||
alloc.concat([
|
||||
alloc.reflow("You should use a "),
|
||||
alloc.suffix(Suffix::Bang),
|
||||
alloc.reflow(" for awaiting tasks or a "),
|
||||
alloc.suffix(Suffix::Question),
|
||||
alloc.reflow(" for trying results, and functions everywhere else."),
|
||||
]),
|
||||
]);
|
||||
|
||||
title = "BACKPASSING DEPRECATED".to_string();
|
||||
}
|
||||
|
||||
Problem::DefsOnlyUsedInRecursion(1, region) => {
|
||||
doc = alloc.stack([
|
||||
alloc.reflow("This definition is only used in recursion with itself:"),
|
||||
|
@ -270,7 +291,7 @@ pub fn can_problem<'b>(
|
|||
),
|
||||
]);
|
||||
|
||||
title = "DEFINITIONs ONLY USED IN RECURSION".to_string();
|
||||
title = "DEFINITIONS ONLY USED IN RECURSION".to_string();
|
||||
}
|
||||
Problem::ExposedButNotDefined(symbol) => {
|
||||
doc = alloc.stack([
|
||||
|
|
|
@ -1265,7 +1265,7 @@ fn to_expr_report<'b>(
|
|||
alloc.concat([
|
||||
alloc.tip(),
|
||||
alloc.reflow("Remove "),
|
||||
alloc.keyword("<-"),
|
||||
alloc.backpassing_arrow(),
|
||||
alloc.reflow(" to assign the field directly.")
|
||||
])
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ fn to_expr_report<'b>(
|
|||
alloc.concat([
|
||||
alloc.note(""),
|
||||
alloc.reflow("Record builders need a mapper function before the "),
|
||||
alloc.keyword("<-"),
|
||||
alloc.backpassing_arrow(),
|
||||
alloc.reflow(" to combine fields together with.")
|
||||
])
|
||||
}
|
||||
|
|
|
@ -509,6 +509,10 @@ impl<'a> RocDocAllocator<'a> {
|
|||
self.text(name).annotate(Annotation::Shorthand)
|
||||
}
|
||||
|
||||
pub fn backpassing_arrow(&'a self) -> DocBuilder<'a, Self, Annotation> {
|
||||
self.text("<-").annotate(Annotation::BinOp)
|
||||
}
|
||||
|
||||
pub fn binop(
|
||||
&'a self,
|
||||
content: roc_module::called_via::BinOp,
|
||||
|
@ -523,6 +527,13 @@ impl<'a> RocDocAllocator<'a> {
|
|||
self.text(content.to_string()).annotate(Annotation::UnaryOp)
|
||||
}
|
||||
|
||||
pub fn suffix(
|
||||
&'a self,
|
||||
content: roc_module::called_via::Suffix,
|
||||
) -> DocBuilder<'a, Self, Annotation> {
|
||||
self.text(content.to_string()).annotate(Annotation::UnaryOp)
|
||||
}
|
||||
|
||||
/// Turns off backticks/colors in a block
|
||||
pub fn type_block(
|
||||
&'a self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue