Skip to content

fix(rust): read a single-quoted Cargo edition too - #683

Open
noahkhomer18 wants to merge 1 commit into
vibgrate:mainfrom
noahkhomer18:fix/677-cargo-single-quoted-edition
Open

noahkhomer18 wants to merge 1 commit into
vibgrate:mainfrom
noahkhomer18:fix/677-cargo-single-quoted-edition

Conversation

@noahkhomer18

Copy link
Copy Markdown

Closes #677.

TOML literal strings are single-quoted, so edition = '2021' is just as valid as the double-quoted form — and some projects and generators write it that way. extractRustEdition only matched double quotes, so those crates reported no edition, and therefore no runtime, runtimeLatest or runtimeMajorsBehind in vg scan.

The capture now takes whichever quote opened the value and matches it with a backreference:

/^\s*edition\s*=\s*(["'])(\d+)\1/m

The value must still be digits, so edition.workspace = true (tracked in #632) is untouched.

Tests: test/cargo-rust-edition.test.ts covers the single-quoted form, the double-quoted form (pinning existing behaviour) and a non-edition line.

Checks: the new file plus cargo-dependency-header are 6/6 green.

One pre-existing failure to flag: cargo-workspace-inheritance › "inherits pins for a member and leaves path and git tables unset" fails on Windows because the scanned paths come back as crates\app while the test looks up crates/app. I confirmed it fails identically with this change stashed, so it is not from this PR.

TOML literal strings are single-quoted, so edition = '2021' is as valid as the
double-quoted form and some projects and generators write it that way. The
pattern only matched double quotes, so those crates reported no edition and
therefore no runtime, runtimeLatest or runtimeMajorsBehind.

The capture now takes whichever quote opened the value and matches its
backreference, so both styles read 2021 and the value must still be digits.

Fixes vibgrate#677
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: single-quoted edition = '2021' in Cargo.toml is not read

1 participant