Repository: nushell/nushell
File: crates/nu-parser/src/parse_patterns.rs (Rust)

Code before:
        }
    } else {
        working_set.error(ParseError::Expected("valid variable name", span));
        garbage(span)
    }
}

pub fn parse_list_pattern(working_set: &mut StateWorkingSet, span: Span) -> MatchPattern {
    let bytes = working_set.get_span_contents(span);

    let mut start = span.start;
    let mut end = span.end;

    if bytes.starts_with(b"[") {
        start += 1;
    }
    if bytes.ends_with(b"]") {
        end -= 1;
    } else {
        working_set.error(ParseError::Unclosed("]".into(), Span::new(end, end)));
    }

    let inner_span = Span::new(start, end);
    let source = working_set.get_span_contents(inner_span);

    let (output, err) = lex(source, inner_span.start, b"\n\r,", &[], true);
    if let Some(err) = err {
        working_set.error(err);
    }

    let (output, err) = lite_parse(&output);
    if let Some(err) = err {
        working_set.error(err);
    }

    let mut args = vec![];

    if !output.block.is_empty() {
        for command in &output.block[0].commands {
            let mut spans_idx = 0;

            while spans_idx < command.parts.len() {
                let contents = working_set.get_span_contents(command.parts[spans_idx]);
                if contents == b".." {
                    args.push(MatchPattern {
                        pattern: Pattern::IgnoreRest,
                        guard: None,
                        span: command.parts[spans_idx],
                    });
                    break;
                } else if contents.starts_with(b"..$") {

Review comment (suggestion):
I am inclined to say we ignore clippy on those ones as it becomes less readable that it is kind of a set instead of a string.

Code after:
            span,
        }
    } else {
        working_set.error(ParseError::Expected("valid variable name", span));
        garbage(span)
    }
}

pub fn parse_list_pattern(working_set: &mut StateWorkingSet, span: Span) -> MatchPattern {
    let bytes = working_set.get_span_contents(span);

    let mut start = span.start;
    let mut end = span.end;

    if bytes.starts_with(b"[") {
        start += 1;
    }
    if bytes.ends_with(b"]") {
        end -= 1;
    } else {
        working_set.error(ParseError::Unclosed("]".into(), Span::new(end, end)));
    }

    let inner_span = Span::new(start, end);
    let source = working_set.get_span_contents(inner_span);

    let (output, err) = lex(source, inner_span.start, &[b'\n', b'\r', b','], &[], true);
    if let Some(err) = err {
        working_set.error(err);
    }

    let (output, err) = lite_parse(&output);
    if let Some(err) = err {
        working_set.error(err);
    }

    let mut args = vec![];

    if !output.block.is_empty() {
        for command in &output.block[0].commands {
            let mut spans_idx = 0;

            while spans_idx < command.parts.len() {
                let contents = working_set.get_span_contents(command.parts[spans_idx]);
                if contents == b".." {
                    args.push(MatchPattern {
                        pattern: Pattern::IgnoreRest,
                        guard: None,
                        span: command.parts[spans_idx],
                    });
                    break;