Skip to content

Commit 032145a

Browse files
authored
Upgrade Rust to 1.91.0 (#8007)
* Upgrade Rust to 1.91.0 * Get Rust version from Cargo.toml * Add note about Rust version to CONTRIBUTING.md * CHANGELOG
1 parent 75a5381 commit 032145a

File tree

11 files changed

+81
-66
lines changed

11 files changed

+81
-66
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,24 @@ jobs:
110110
uses: actions/cache@v4
111111
with:
112112
path: rewatch/target
113-
key: rewatch-build-v2-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}
113+
key: rewatch-build-v3-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}
114+
115+
- name: Determine Rust toolchain version
116+
id: rust-version
117+
shell: bash
118+
run: |
119+
version="$(awk -F '"' '/^rust-version[[:space:]]*=/ { print $2; exit }' rewatch/Cargo.toml)"
120+
if [ -z "$version" ]; then
121+
echo "rust-version missing in rewatch/Cargo.toml" >&2
122+
exit 1
123+
fi
124+
echo "version=${version}" >> "$GITHUB_OUTPUT"
114125
115126
- name: Install rust toolchain
116127
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
117128
uses: dtolnay/rust-toolchain@master
118129
with:
119-
toolchain: 1.88.0
130+
toolchain: ${{ steps.rust-version.outputs.version }}
120131
targets: ${{ matrix.rust-target }}
121132
components: clippy, rustfmt
122133

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
- Rename Core to Stdlib in tests/tests. https://github.com/rescript-lang/rescript/pull/8005
3636
- CI: Build on `windows-2025` runners. https://github.com/rescript-lang/rescript/pull/8006
37+
- Rewatch: upgrade Rust to 1.91.0. https://github.com/rescript-lang/rescript/pull/8007
3738

3839
# 12.0.0-rc.3
3940

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Happy hacking!
1818
- [Yarn CLI](https://yarnpkg.com/getting-started/install) (can be installed with `corepack`, Homebrew, etc)
1919
- C compiler toolchain (usually installed with `xcode` on Mac)
2020
- Python <= 3.11 (required to build ninja)
21-
- Rust toolchain (required to build rewatch; follow the instructions at https://www.rust-lang.org/tools/install)
21+
- Rust toolchain (required to build rewatch; follow the instructions at https://www.rust-lang.org/tools/install and install the version listed as `rust-version` in `rewatch/Cargo.toml`)
2222
- `opam` (OCaml Package Manager) v2.2.0 or newer
2323
- VSCode (+ [OCaml Platform Extension](https://marketplace.visualstudio.com/items?itemName=ocamllabs.ocaml-platform))
2424

rewatch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rescript"
33
version = "12.0.0-rc.4"
44
edition = "2024"
5-
rust-version = "1.88"
5+
rust-version = "1.91"
66

77
[dependencies]
88
ahash = "0.8.3"

rewatch/src/build/clean.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,11 @@ pub fn cleanup_previous_build(
175175
// we do this by checking if the cmt file is newer than the AST file. We always compile the
176176
// interface AND implementation. For some reason the CMI file is not always rewritten if it
177177
// doesn't have any changes, that's why we just look at the CMT file.
178-
if let Some(cmt_last_modified) = cmt_last_modified {
179-
if cmt_last_modified > ast_last_modified && !deleted_interfaces.contains(module_name) {
180-
module.compile_dirty = false;
181-
}
178+
if let Some(cmt_last_modified) = cmt_last_modified
179+
&& cmt_last_modified > ast_last_modified
180+
&& !deleted_interfaces.contains(module_name)
181+
{
182+
module.compile_dirty = false;
182183
}
183184

184185
match &mut module.source_type {
@@ -302,11 +303,11 @@ fn has_compile_warnings(module: &Module) -> bool {
302303
pub fn cleanup_after_build(build_state: &BuildCommandState) {
303304
build_state.modules.par_iter().for_each(|(_module_name, module)| {
304305
let package = build_state.get_package(&module.package_name).unwrap();
305-
if has_parse_warnings(module) {
306-
if let SourceType::SourceFile(source_file) = &module.source_type {
307-
remove_iast(package, &source_file.implementation.path);
308-
remove_ast(package, &source_file.implementation.path);
309-
}
306+
if has_parse_warnings(module)
307+
&& let SourceType::SourceFile(source_file) = &module.source_type
308+
{
309+
remove_iast(package, &source_file.implementation.path);
310+
remove_ast(package, &source_file.implementation.path);
310311
}
311312
if has_compile_warnings(module) {
312313
// only retain AST file if the compilation doesn't have warnings, we remove the AST in favor

rewatch/src/build/compile.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,11 @@ pub fn compile(
368368
// so editor tooling can surface it from .compiler.log
369369
let mut touched_packages = AHashSet::<String>::new();
370370
for module_name in cycle.iter() {
371-
if let Some(module) = build_state.get_module(module_name) {
372-
if touched_packages.insert(module.package_name.clone()) {
373-
if let Some(package) = build_state.get_package(&module.package_name) {
374-
logs::append(package, &message);
375-
}
376-
}
371+
if let Some(module) = build_state.get_module(module_name)
372+
&& touched_packages.insert(module.package_name.clone())
373+
&& let Some(package) = build_state.get_package(&module.package_name)
374+
{
375+
logs::append(package, &message);
377376
}
378377
}
379378

@@ -795,24 +794,23 @@ fn compile_file(
795794

796795
// copy js file
797796
root_config.get_package_specs().iter().for_each(|spec| {
798-
if spec.in_source {
799-
if let SourceType::SourceFile(SourceFile {
797+
if spec.in_source
798+
&& let SourceType::SourceFile(SourceFile {
800799
implementation: Implementation { path, .. },
801800
..
802801
}) = &module.source_type
803-
{
804-
let source = helpers::get_source_file_from_rescript_file(
805-
&Path::new(&package.path).join(path),
806-
&root_config.get_suffix(spec),
807-
);
808-
let destination = helpers::get_source_file_from_rescript_file(
809-
&package.get_build_path().join(path),
810-
&root_config.get_suffix(spec),
811-
);
812-
813-
if source.exists() {
814-
let _ = std::fs::copy(&source, &destination).expect("copying source file failed");
815-
}
802+
{
803+
let source = helpers::get_source_file_from_rescript_file(
804+
&Path::new(&package.path).join(path),
805+
&root_config.get_suffix(spec),
806+
);
807+
let destination = helpers::get_source_file_from_rescript_file(
808+
&package.get_build_path().join(path),
809+
&root_config.get_suffix(spec),
810+
);
811+
812+
if source.exists() {
813+
let _ = std::fs::copy(&source, &destination).expect("copying source file failed");
816814
}
817815
}
818816
});
@@ -912,10 +910,9 @@ pub fn mark_modules_with_expired_deps_dirty(build_state: &mut BuildCommandState)
912910

913911
if let (Some(last_compiled_dependent), Some(last_compiled)) =
914912
(dependent_module.last_compiled_cmt, module.last_compiled_cmt)
913+
&& last_compiled_dependent < last_compiled
915914
{
916-
if last_compiled_dependent < last_compiled {
917-
modules_with_expired_deps.insert(dependent.to_string());
918-
}
915+
modules_with_expired_deps.insert(dependent.to_string());
919916
}
920917
}
921918
}

rewatch/src/build/logs.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ pub fn initialize(packages: &AHashMap<String, Package>) {
5555
packages.par_iter().for_each(|(name, package)| {
5656
File::create(get_log_file_path(package, Location::Bs))
5757
.map(|file| write_to_log_file(file, name, &format!("#Start({})\n", helpers::get_system_time())))
58-
.expect(&("Cannot create compiler log for package ".to_owned() + name));
58+
.unwrap_or_else(|err| {
59+
panic!("Cannot create compiler log for package {name}: {err}");
60+
});
5961
})
6062
}
6163

@@ -64,10 +66,12 @@ pub fn append(package: &packages::Package, str: &str) {
6466
.append(true)
6567
.open(get_log_file_path(package, Location::Bs))
6668
.map(|file| write_to_log_file(file, &package.name, str))
67-
.expect(
68-
&("Cannot write compilerlog: ".to_owned()
69-
+ &get_log_file_path(package, Location::Bs).to_string_lossy()),
70-
);
69+
.unwrap_or_else(|err| {
70+
panic!(
71+
"Cannot write compilerlog: {} ({err})",
72+
get_log_file_path(package, Location::Bs).to_string_lossy()
73+
);
74+
});
7175
}
7276

7377
pub fn finalize(packages: &AHashMap<String, Package>) {

rewatch/src/build/packages.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,10 @@ fn get_unallowed_dependents(
882882
for deps_package_name in dependencies {
883883
if let Some(deps_package) = packages.get(deps_package_name) {
884884
let deps_allowed_dependents = deps_package.config.allowed_dependents.to_owned();
885-
if let Some(allowed_dependents) = deps_allowed_dependents {
886-
if !allowed_dependents.contains(package_name) {
887-
return Some(deps_package_name.to_string());
888-
}
885+
if let Some(allowed_dependents) = deps_allowed_dependents
886+
&& !allowed_dependents.contains(package_name)
887+
{
888+
return Some(deps_package_name.to_string());
889889
}
890890
}
891891
}

rewatch/src/format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ fn get_files_in_scope() -> Result<Vec<String>> {
4545
&& let Some(source_files) = &package.source_files
4646
{
4747
for (path, _metadata) in source_files {
48-
if let Some(extension) = path.extension() {
49-
if extension == "res" || extension == "resi" {
50-
files.push(package.path.join(path).to_string_lossy().into_owned());
51-
}
48+
if let Some(extension) = path.extension()
49+
&& (extension == "res" || extension == "resi")
50+
{
51+
files.push(package.path.join(path).to_string_lossy().into_owned());
5252
}
5353
}
5454
}

rewatch/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ fn main() -> Result<()> {
1818

1919
let mut command = cli.command;
2020

21-
if let cli::Command::Build(build_args) = &command {
22-
if build_args.watch {
23-
log::warn!("`rescript build -w` is deprecated. Please use `rescript watch` instead.");
24-
command = cli::Command::Watch(build_args.clone().into());
25-
}
21+
if let cli::Command::Build(build_args) = &command
22+
&& build_args.watch
23+
{
24+
log::warn!("`rescript build -w` is deprecated. Please use `rescript watch` instead.");
25+
command = cli::Command::Watch(build_args.clone().into());
2626
}
2727

2828
let is_tty: bool = Term::stdout().is_term() && Term::stderr().is_term();

0 commit comments

Comments
 (0)