File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,9 +140,12 @@ async function updateRustToolchain(formatterVersion: string) {
140140 if ( localMatch == null ) {
141141 throw new Error ( "Could not find channel in local rust-toolchain.toml." ) ;
142142 }
143+ // crates.io rust_version may be "1.84" (no patch); pad to MAJOR.MINOR.PATCH
144+ // so @std /semver can parse it.
145+ const normalize = ( v : string ) => / ^ \d + \. \d + $ / . test ( v ) ? `${ v } .0` : v ;
143146 // only bump up; never downgrade. compare as semver so 1.95.0 > 1.92.0.
144- const local = semver . parse ( localMatch [ 1 ] ) ;
145- const required = semver . parse ( requiredRustVersion ) ;
147+ const local = semver . parse ( normalize ( localMatch [ 1 ] ) ) ;
148+ const required = semver . parse ( normalize ( requiredRustVersion ) ) ;
146149 if ( semver . greaterThan ( required , local ) ) {
147150 $ . log ( `Updating Rust toolchain: ${ localMatch [ 1 ] } -> ${ requiredRustVersion } ` ) ;
148151 toolchainPath . writeTextSync ( localContent . replace ( localMatch [ 0 ] , `channel = "${ requiredRustVersion } "` ) ) ;
You can’t perform that action at this time.
0 commit comments