mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 06:55:15 +00:00
Revert "Lints"
This reverts commit f7e85b5295a44217bde9b6b83d188d84ee863d0c.
This commit is contained in:
parent
f3689b1146
commit
a6cf21dcf9
8 changed files with 40 additions and 37 deletions
|
@ -287,7 +287,7 @@ fn loc_possibly_negative_or_negated_term<'a>(
|
|||
) -> impl Parser<'a, Loc<Expr<'a>>, EExpr<'a>> {
|
||||
one_of![
|
||||
|arena, state: State<'a>| {
|
||||
let initial = state;
|
||||
let initial = state.clone();
|
||||
|
||||
let (_, (loc_op, loc_expr), state) = and!(loc!(unary_negate()), |a, s| parse_loc_term(
|
||||
min_indent, options, a, s
|
||||
|
@ -372,7 +372,7 @@ fn parse_expr_operator_chain<'a>(
|
|||
let (_, expr, state) =
|
||||
loc_possibly_negative_or_negated_term(min_indent, options).parse(arena, state)?;
|
||||
|
||||
let initial = state;
|
||||
let initial = state.clone();
|
||||
let end = state.pos();
|
||||
|
||||
match space0_e(min_indent, EExpr::IndentEnd).parse(arena, state) {
|
||||
|
@ -615,7 +615,7 @@ fn parse_defs_end<'a>(
|
|||
|
||||
loop {
|
||||
let state = global_state;
|
||||
let initial = state;
|
||||
let initial = state.clone();
|
||||
|
||||
let mut spaces_before_current = &[] as &[_];
|
||||
let spaces_before_current_start = state.pos();
|
||||
|
@ -643,7 +643,7 @@ fn parse_defs_end<'a>(
|
|||
min_indent,
|
||||
EPattern::IndentEnd,
|
||||
)
|
||||
.parse(arena, state)
|
||||
.parse(arena, state.clone())
|
||||
{
|
||||
Err((NoProgress, _, _)) => {
|
||||
match parse_expect.parse(arena, state) {
|
||||
|
@ -719,7 +719,8 @@ fn parse_defs_end<'a>(
|
|||
};
|
||||
|
||||
if let Some((name, name_region, args)) = opt_tag_and_args {
|
||||
if let Ok((_, loc_has, state)) = loc_has_parser(min_indent).parse(arena, state)
|
||||
if let Ok((_, loc_has, state)) =
|
||||
loc_has_parser(min_indent).parse(arena, state.clone())
|
||||
{
|
||||
let (_, (type_def, def_region), state) = finish_parsing_ability_def_help(
|
||||
start_column,
|
||||
|
@ -1062,7 +1063,7 @@ fn finish_parsing_alias_or_opaque<'a>(
|
|||
|
||||
let (expr, arguments) = expr_state
|
||||
.validate_is_type_def(arena, loc_op, kind)
|
||||
.map_err(|fail| (MadeProgress, fail, state))?;
|
||||
.map_err(|fail| (MadeProgress, fail, state.clone()))?;
|
||||
|
||||
let mut defs = Defs::default();
|
||||
|
||||
|
@ -1225,7 +1226,7 @@ mod ability {
|
|||
indent: IndentLevel,
|
||||
) -> impl Parser<'a, (u32, AbilityMember<'a>), EAbility<'a>> {
|
||||
move |arena, state: State<'a>| {
|
||||
let initial = state;
|
||||
let initial = state.clone();
|
||||
|
||||
// Put no restrictions on the indent after the spaces; we'll check it manually.
|
||||
match space0_e(0, EAbility::DemandName).parse(arena, state) {
|
||||
|
@ -1322,7 +1323,7 @@ fn finish_parsing_ability_def_help<'a>(
|
|||
let demand_parser = ability::parse_demand(demand_indent);
|
||||
|
||||
loop {
|
||||
match demand_parser.parse(arena, state) {
|
||||
match demand_parser.parse(arena, state.clone()) {
|
||||
Ok((_, (_indent, demand), next_state)) => {
|
||||
state = next_state;
|
||||
demands.push(demand);
|
||||
|
@ -1384,7 +1385,7 @@ fn parse_expr_operator<'a>(
|
|||
expr_state.spaces_after,
|
||||
);
|
||||
|
||||
expr_state.initial = state;
|
||||
expr_state.initial = state.clone();
|
||||
|
||||
let (spaces, state) = match space0_e(min_indent, EExpr::IndentEnd).parse(arena, state) {
|
||||
Err((_, _, state)) => (&[] as &[_], state),
|
||||
|
@ -1403,7 +1404,7 @@ fn parse_expr_operator<'a>(
|
|||
|
||||
let call = expr_state
|
||||
.validate_assignment_or_backpassing(arena, loc_op, EExpr::ElmStyleFunction)
|
||||
.map_err(|fail| (MadeProgress, fail, state))?;
|
||||
.map_err(|fail| (MadeProgress, fail, state.clone()))?;
|
||||
|
||||
let (value_def, def_region, state) = {
|
||||
match expr_to_pattern_help(arena, &call.value) {
|
||||
|
@ -1448,7 +1449,7 @@ fn parse_expr_operator<'a>(
|
|||
.validate_assignment_or_backpassing(arena, loc_op, |_, pos| {
|
||||
EExpr::BadOperator("<-", pos)
|
||||
})
|
||||
.map_err(|fail| (MadeProgress, fail, state))?;
|
||||
.map_err(|fail| (MadeProgress, fail, state.clone()))?;
|
||||
|
||||
let (loc_pattern, loc_body, state) = {
|
||||
match expr_to_pattern_help(arena, &call.value) {
|
||||
|
@ -1509,7 +1510,7 @@ fn parse_expr_operator<'a>(
|
|||
Ok((_, mut new_expr, state)) => {
|
||||
let new_end = state.pos();
|
||||
|
||||
expr_state.initial = state;
|
||||
expr_state.initial = state.clone();
|
||||
|
||||
// put the spaces from after the operator in front of the new_expr
|
||||
if !spaces_after_operator.is_empty() {
|
||||
|
@ -1566,7 +1567,7 @@ fn parse_expr_end<'a>(
|
|||
move |a, s| parse_loc_term_or_underscore(min_indent, options, a, s)
|
||||
);
|
||||
|
||||
match parser.parse(arena, state) {
|
||||
match parser.parse(arena, state.clone()) {
|
||||
Err((MadeProgress, f, s)) => Err((MadeProgress, f, s)),
|
||||
Ok((
|
||||
_,
|
||||
|
@ -1635,7 +1636,7 @@ fn parse_expr_end<'a>(
|
|||
|
||||
expr_state.spaces_after = &[];
|
||||
}
|
||||
expr_state.initial = state;
|
||||
expr_state.initial = state.clone();
|
||||
|
||||
match space0_e(min_indent, EExpr::IndentEnd).parse(arena, state) {
|
||||
Err((_, _, state)) => {
|
||||
|
@ -1655,7 +1656,7 @@ fn parse_expr_end<'a>(
|
|||
}
|
||||
}
|
||||
Err((NoProgress, _, _)) => {
|
||||
let before_op = state;
|
||||
let before_op = state.clone();
|
||||
// try an operator
|
||||
match loc!(operator()).parse(arena, state) {
|
||||
Err((MadeProgress, f, s)) => Err((MadeProgress, f, s)),
|
||||
|
@ -1735,7 +1736,7 @@ fn parse_expr_end<'a>(
|
|||
Err((MadeProgress, EExpr::BadOperator("->", state.pos()), state))
|
||||
} else {
|
||||
// roll back space parsing
|
||||
let state = expr_state.initial;
|
||||
let state = expr_state.initial.clone();
|
||||
|
||||
parse_expr_final(expr_state, arena, state)
|
||||
}
|
||||
|
@ -2210,7 +2211,7 @@ mod when {
|
|||
pattern_indent_level: Option<u32>,
|
||||
) -> impl Parser<'a, (u32, Vec<'a, Loc<Pattern<'a>>>), EWhen<'a>> {
|
||||
move |arena, state: State<'a>| {
|
||||
let initial = state;
|
||||
let initial = state.clone();
|
||||
|
||||
// put no restrictions on the indent after the spaces; we'll check it manually
|
||||
match space0_e(0, EWhen::IndentPattern).parse(arena, state) {
|
||||
|
|
|
@ -152,7 +152,7 @@ macro_rules! advance_state {
|
|||
}
|
||||
|
||||
pub fn parse_ident<'a>(arena: &'a Bump, state: State<'a>) -> ParseResult<'a, Ident<'a>, EExpr<'a>> {
|
||||
let initial = state;
|
||||
let initial = state.clone();
|
||||
|
||||
match parse_ident_help(arena, state) {
|
||||
Ok((progress, ident, state)) => {
|
||||
|
|
|
@ -1152,7 +1152,7 @@ where
|
|||
move |arena: &'a Bump, state: State<'a>| {
|
||||
// We have to clone this because if the optional parser fails,
|
||||
// we need to revert back to the original state.
|
||||
let original_state = state;
|
||||
let original_state = state.clone();
|
||||
|
||||
match parser.parse(arena, state) {
|
||||
Ok((progress, out1, state)) => Ok((progress, Some(out1), state)),
|
||||
|
@ -1196,7 +1196,7 @@ macro_rules! loc {
|
|||
macro_rules! skip_first {
|
||||
($p1:expr, $p2:expr) => {
|
||||
move |arena, state: $crate::state::State<'a>| {
|
||||
let original_state = state;
|
||||
let original_state = state.clone();
|
||||
|
||||
match $p1.parse(arena, state) {
|
||||
Ok((p1, _, state)) => match $p2.parse(arena, state) {
|
||||
|
@ -1215,7 +1215,7 @@ macro_rules! skip_first {
|
|||
macro_rules! skip_second {
|
||||
($p1:expr, $p2:expr) => {
|
||||
move |arena, state: $crate::state::State<'a>| {
|
||||
let original_state = state;
|
||||
let original_state = state.clone();
|
||||
|
||||
match $p1.parse(arena, state) {
|
||||
Ok((p1, out1, state)) => match $p2.parse(arena, state) {
|
||||
|
@ -1330,7 +1330,7 @@ macro_rules! and {
|
|||
move |arena: &'a bumpalo::Bump, state: $crate::state::State<'a>| {
|
||||
// We have to clone this because if the first parser passes and then
|
||||
// the second one fails, we need to revert back to the original state.
|
||||
let original_state = state;
|
||||
let original_state = state.clone();
|
||||
|
||||
match $p1.parse(arena, state) {
|
||||
Ok((p1, out1, state)) => match $p2.parse(arena, state) {
|
||||
|
@ -1709,7 +1709,7 @@ where
|
|||
Error: 'a,
|
||||
{
|
||||
move |arena: &'a Bump, state: State<'a>| {
|
||||
let old_state = state;
|
||||
let old_state = state.clone();
|
||||
|
||||
match parser.parse(arena, state) {
|
||||
Ok((_, a, s1)) => Ok((NoProgress, a, s1)),
|
||||
|
|
|
@ -86,7 +86,7 @@ fn loc_tag_pattern_arg<'a>(
|
|||
// If we encounter one, we're done parsing function args!
|
||||
move |arena, original_state: State<'a>| {
|
||||
let (_, spaces, state) = backtrackable(space0_e(min_indent, EPattern::IndentStart))
|
||||
.parse(arena, original_state)?;
|
||||
.parse(arena, original_state.clone())?;
|
||||
|
||||
let (_, loc_pat, state) = loc_parse_tag_pattern_arg(min_indent, arena, state)?;
|
||||
|
||||
|
@ -207,7 +207,7 @@ fn loc_ident_pattern_help<'a>(
|
|||
can_have_arguments: bool,
|
||||
) -> impl Parser<'a, Loc<Pattern<'a>>, EPattern<'a>> {
|
||||
move |arena: &'a Bump, state: State<'a>| {
|
||||
let original_state = state;
|
||||
let original_state = state.clone();
|
||||
|
||||
let (_, loc_ident, state) =
|
||||
specialize(|_, pos| EPattern::Start(pos), loc!(parse_ident)).parse(arena, state)?;
|
||||
|
|
|
@ -173,7 +173,7 @@ pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>, EString<'a>> {
|
|||
let start_state;
|
||||
|
||||
if state.consume_mut("\"\"\"") {
|
||||
start_state = state;
|
||||
start_state = state.clone();
|
||||
|
||||
// we will be parsing a multi-line string
|
||||
is_multiline = true;
|
||||
|
@ -182,7 +182,7 @@ pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>, EString<'a>> {
|
|||
state = consume_indent(state, indent)?;
|
||||
}
|
||||
} else if state.consume_mut("\"") {
|
||||
start_state = state;
|
||||
start_state = state.clone();
|
||||
|
||||
// we will be parsing a single-line string
|
||||
is_multiline = false;
|
||||
|
@ -321,9 +321,11 @@ pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>, EString<'a>> {
|
|||
|
||||
if state.bytes().starts_with(b"\"\"\"") {
|
||||
// ending the string; don't use the last newline
|
||||
segments.push(StrSegment::Plaintext(utf8(state, without_newline)?));
|
||||
segments
|
||||
.push(StrSegment::Plaintext(utf8(state.clone(), without_newline)?));
|
||||
} else {
|
||||
segments.push(StrSegment::Plaintext(utf8(state, with_newline)?));
|
||||
segments
|
||||
.push(StrSegment::Plaintext(utf8(state.clone(), with_newline)?));
|
||||
}
|
||||
|
||||
segment_parsed_bytes = 0;
|
||||
|
|
|
@ -25,7 +25,7 @@ pub fn parse_loc_with<'a>(
|
|||
) -> Result<Loc<ast::Expr<'a>>, SourceError<'a, SyntaxError<'a>>> {
|
||||
let state = State::new(input.trim().as_bytes());
|
||||
|
||||
match crate::expr::test_parse_expr(0, arena, state) {
|
||||
match crate::expr::test_parse_expr(0, arena, state.clone()) {
|
||||
Ok(loc_expr) => Ok(loc_expr),
|
||||
Err(fail) => Err(SyntaxError::Expr(fail, Position::default()).into_source_error(&state)),
|
||||
}
|
||||
|
|
|
@ -576,7 +576,7 @@ fn expression<'a>(
|
|||
)
|
||||
.trace("type_annotation:expression:arrow")
|
||||
]
|
||||
.parse(arena, state);
|
||||
.parse(arena, state.clone());
|
||||
|
||||
let (progress, annot, state) = match result {
|
||||
Ok((p2, (rest, _dropped_spaces), state)) => {
|
||||
|
@ -609,7 +609,7 @@ fn expression<'a>(
|
|||
word1(b',', EType::TStart)
|
||||
))
|
||||
.trace("check trailing comma")
|
||||
.parse(arena, state)?;
|
||||
.parse(arena, state.clone())?;
|
||||
|
||||
if comma.is_some() {
|
||||
// If the surrounding scope has declared that a trailing comma is not a valid state
|
||||
|
@ -628,7 +628,7 @@ fn expression<'a>(
|
|||
// Finally, try to parse a where clause if there is one.
|
||||
// The where clause must be at least as deep as where the type annotation started.
|
||||
let min_where_clause_indent = min_indent;
|
||||
match has_clause_chain(min_where_clause_indent).parse(arena, state) {
|
||||
match has_clause_chain(min_where_clause_indent).parse(arena, state.clone()) {
|
||||
Ok((where_progress, (spaces_before, has_chain), state)) => {
|
||||
use crate::ast::Spaceable;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue