Rust 1.87 (released on 2025-05-15) compiles core library with edition 2024 instead of 2021 [1]. Ensure that the edition matches libcore's expectation to avoid potential breakage. [ J3m3 reported in Zulip [2] that the `rust-analyzer` target was broken after this patch -- indeed, we need to avoid `core-cfgs` since those are passed to the `rust-analyzer` target. So, instead, I tweaked the patch to create a new `core-edition` variable and explicitly mention the `--edition` flag instead of reusing `core-cfg`s. In addition, pass a new argument using this new variable to `generate_rust_analyzer.py` so that we set the right edition there. By the way, for future reference: the `filter-out` change is needed for Rust < 1.87, since otherwise we would skip the `--edition=2021` we just added, ending up with no edition flag, and thus the compiler would default to the 2015 one. [2] https://rust-for-linux.zulipchat.com/#narrow/channel/291565/topic/x/near/520206547 - Miguel ]
Showing the changes to scripts (1 of 2 files). Show all
Unified · Split
| @@ -19,7 +19,7 @@ def args_crates_cfgs(cfgs): · 18 unmodified lines | |||
| 19 | 19 | ||
| 20 | return crates_cfgs | 20 | return crates_cfgs |
| 21 | 21 | ||
| 22 | def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): | 22 | def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edition): |
| 23 | # Generate the configuration list. | 23 | # Generate the configuration list. |
| 24 | cfg = [] | 24 | cfg = [] |
| 25 | with open(objtree / "include" / "generated" / "rustc_cfg") as fd: | 25 | with open(objtree / "include" / "generated" / "rustc_cfg") as fd: |
| @@ -35,7 +35,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): · 9 unmodified lines | |||
| 35 | crates_indexes = {} | 35 | crates_indexes = {} |
| 36 | crates_cfgs = args_crates_cfgs(cfgs) | 36 | crates_cfgs = args_crates_cfgs(cfgs) |
| 37 | 37 | ||
| 38 | def append_crate(display_name, root_module, deps, cfg=[], is_workspace_member=True, is_proc_macro=False): | 38 | def append_crate(display_name, root_module, deps, cfg=[], is_workspace_member=True, is_proc_macro=False, edition="2021"): |
| 39 | crate = { | 39 | crate = { |
| 40 | "display_name": display_name, | 40 | "display_name": display_name, |
| 41 | "root_module": str(root_module), | 41 | "root_module": str(root_module), |
| @@ -43,7 +43,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): · 1 unmodified line | |||
| 43 | "is_proc_macro": is_proc_macro, | 43 | "is_proc_macro": is_proc_macro, |
| 44 | "deps": [{"crate": crates_indexes[dep], "name": dep} for dep in deps], | 44 | "deps": [{"crate": crates_indexes[dep], "name": dep} for dep in deps], |
| 45 | "cfg": cfg, | 45 | "cfg": cfg, |
| 46 | "edition": "2021", | 46 | "edition": edition, |
| 47 | "env": { | 47 | "env": { |
| 48 | "RUST_MODFILE": "This is only for rust-analyzer" | 48 | "RUST_MODFILE": "This is only for rust-analyzer" |
| 49 | } | 49 | } |
| @@ -61,6 +61,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): · 11 unmodified lines | |||
| 61 | display_name, | 61 | display_name, |
| 62 | deps, | 62 | deps, |
| 63 | cfg=[], | 63 | cfg=[], |
| 64 | edition="2021", | ||
| 64 | ): | 65 | ): |
| 65 | append_crate( | 66 | append_crate( |
| 66 | display_name, | 67 | display_name, |
| @@ -68,12 +69,13 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): · 1 unmodified line | |||
| 68 | deps, | 69 | deps, |
| 69 | cfg, | 70 | cfg, |
| 70 | is_workspace_member=False, | 71 | is_workspace_member=False, |
| 72 | edition=edition, | ||
| 71 | ) | 73 | ) |
| 72 | 74 | ||
| 73 | # NB: sysroot crates reexport items from one another so setting up our transitive dependencies | 75 | # NB: sysroot crates reexport items from one another so setting up our transitive dependencies |
| 74 | # here is important for ensuring that rust-analyzer can resolve symbols. The sources of truth | 76 | # here is important for ensuring that rust-analyzer can resolve symbols. The sources of truth |
| 75 | # for this dependency graph are `(sysroot_src / crate / "Cargo.toml" for crate in crates)`. | 77 | # for this dependency graph are `(sysroot_src / crate / "Cargo.toml" for crate in crates)`. |
| 76 | append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", [])) | 78 | append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []), edition=core_edition) |
| 77 | append_sysroot_crate("alloc", ["core"]) | 79 | append_sysroot_crate("alloc", ["core"]) |
| 78 | append_sysroot_crate("std", ["alloc", "core"]) | 80 | append_sysroot_crate("std", ["alloc", "core"]) |
| 79 | append_sysroot_crate("proc_macro", ["core", "std"]) | 81 | append_sysroot_crate("proc_macro", ["core", "std"]) |
| @@ -177,6 +179,7 @@ def main(): · 97 unmodified lines | |||
| 177 | parser = argparse.ArgumentParser() | 179 | parser = argparse.ArgumentParser() |
| 178 | parser.add_argument('--verbose', '-v', action='store_true') | 180 | parser.add_argument('--verbose', '-v', action='store_true') |
| 179 | parser.add_argument('--cfgs', action='append', default=[]) | 181 | parser.add_argument('--cfgs', action='append', default=[]) |
| 182 | parser.add_argument("core_edition") | ||
| 180 | parser.add_argument("srctree", type=pathlib.Path) | 183 | parser.add_argument("srctree", type=pathlib.Path) |
| 181 | parser.add_argument("objtree", type=pathlib.Path) | 184 | parser.add_argument("objtree", type=pathlib.Path) |
| 182 | parser.add_argument("sysroot", type=pathlib.Path) | 185 | parser.add_argument("sysroot", type=pathlib.Path) |
| @@ -193,7 +196,7 @@ def main(): · 10 unmodified lines | |||
| 193 | assert args.sysroot in args.sysroot_src.parents | 196 | assert args.sysroot in args.sysroot_src.parents |
| 194 | 197 | ||
| 195 | rust_project = { | 198 | rust_project = { |
| 196 | "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs), | 199 | "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.core_edition), |
| 197 | "sysroot": str(args.sysroot), | 200 | "sysroot": str(args.sysroot), |
| 198 | } | 201 | } |
| 199 | 202 | ||