diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fef0a71..5e0b9937 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,8 +90,8 @@ jobs: # https://github.com/rust-lang/rustup/issues/2441 # # for more information. - rustup toolchain install 1.88.0 --no-self-update # [ref:rust_1.88.0] - rustup default 1.88.0 # [ref:rust_1.88.0] + rustup toolchain install 1.91.0 --no-self-update # [ref:rust_1.91.0] + rustup default 1.91.0 # [ref:rust_1.91.0] # Add the targets. rustup target add x86_64-pc-windows-msvc @@ -131,8 +131,8 @@ jobs: set -euxo pipefail # Install the appropriate version of Rust. - rustup toolchain install 1.88.0 # [ref:rust_1.88.0] - rustup default 1.88.0 # [ref:rust_1.88.0] + rustup toolchain install 1.91.0 # [ref:rust_1.91.0] + rustup default 1.91.0 # [ref:rust_1.91.0] # Add the targets. rustup target add x86_64-apple-darwin @@ -207,8 +207,8 @@ jobs: set -euxo pipefail # Install the appropriate version of Rust. - rustup toolchain install 1.88.0 # [ref:rust_1.88.0] - rustup default 1.88.0 # [ref:rust_1.88.0] + rustup toolchain install 1.91.0 # [ref:rust_1.91.0] + rustup default 1.91.0 # [ref:rust_1.91.0] # Fetch the program version. VERSION="$(cargo pkgid | cut -d# -f2 | cut -d: -f2)" diff --git a/src/parser.rs b/src/parser.rs index 7a94a513..29a83968 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -244,27 +244,27 @@ fn parse_schema( let mut declarations = vec![]; // Parse the comment, if it exists. - if *position < tokens.len() { - if let token::Variant::Comment(paragraphs) = &tokens[*position].variant { - if *position + 1 < tokens.len() { - match tokens[*position + 1].variant { - token::Variant::Struct | token::Variant::Choice => { - if tokens[*position].source_range.end + 1 - < tokens[*position + 1].source_range.start - { - comment.clone_from(paragraphs); - *position += 1; - } - } - _ => { + if *position < tokens.len() + && let token::Variant::Comment(paragraphs) = &tokens[*position].variant + { + if *position + 1 < tokens.len() { + match tokens[*position + 1].variant { + token::Variant::Struct | token::Variant::Choice => { + if tokens[*position].source_range.end + 1 + < tokens[*position + 1].source_range.start + { comment.clone_from(paragraphs); *position += 1; } } - } else { - comment.clone_from(paragraphs); - *position += 1; + _ => { + comment.clone_from(paragraphs); + *position += 1; + } } + } else { + comment.clone_from(paragraphs); + *position += 1; } } @@ -276,18 +276,17 @@ fn parse_schema( // [ref:parse_import_keyword_chomp]. if let Some((name, import)) = parse_import(source_path, source_contents, tokens, position, errors) + && imports.insert(name.clone(), import.clone()).is_some() { - if imports.insert(name.clone(), import.clone()).is_some() { - errors.push(throw::( - &format!( - "An import named {} already exists in this file.", - name.code_str(), - ), - Some(source_path), - Some(&listing(source_contents, import.source_range)), - None, - )); - } + errors.push(throw::( + &format!( + "An import named {} already exists in this file.", + name.code_str(), + ), + Some(source_path), + Some(&listing(source_contents, import.source_range)), + None, + )); } } _ => { diff --git a/toast.yml b/toast.yml index 75c9e0ec..de606e4a 100644 --- a/toast.yml +++ b/toast.yml @@ -17,11 +17,11 @@ command_prefix: | cargo-offline () { cargo --frozen --offline "$@"; } # Use this wrapper for formatting code or checking that code is formatted. We use a nightly Rust - # version for the `trailing_comma` formatting option [tag:rust_fmt_nightly_2025-07-06]. The + # version for the `trailing_comma` formatting option [tag:rust_fmt_nightly_2025-11-02]. The # nightly version was chosen as the latest available release with all components present # according to this page: # https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu.html - cargo-fmt () { cargo +nightly-2025-07-06 --frozen --offline fmt --all -- "$@"; } + cargo-fmt () { cargo +nightly-2025-11-02 --frozen --offline fmt --all -- "$@"; } # Load the NVM startup file, if it exists. if [ -f "$HOME/.nvm/nvm.sh" ]; then @@ -75,18 +75,18 @@ tasks: - install_packages - create_user command: | - # Install stable Rust [tag:rust_1.88.0]. + # Install stable Rust [tag:rust_1.91.0]. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ -y \ - --default-toolchain 1.88.0 \ + --default-toolchain 1.91.0 \ --profile minimal \ --component clippy # Add Rust tools to `$PATH`. . "$HOME/.cargo/env" - # Install nightly Rust [ref:rust_fmt_nightly_2025-07-06]. - rustup toolchain install nightly-2025-07-06 --profile minimal --component rustfmt + # Install nightly Rust [ref:rust_fmt_nightly_2025-11-02]. + rustup toolchain install nightly-2025-11-02 --profile minimal --component rustfmt install_node: description: Install Node.js, a JavaScript runtime environment.