[PATCH v3] scripts: generate_rust_analyzer: Add message to sysroot assertion

From: Maurice Hieronymus
Date: Mon Dec 01 2025 - 12:02:00 EST


The assertion that checks whether sysroot lies within sysroot_src
currently fails without explaining why. Add an error message that
prints both paths to make diagnosing toolchain issues easier.

Signed-off-by: Maurice Hieronymus <mhi@xxxxxxxxxxx>
---
scripts/generate_rust_analyzer.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index 147d0cc94068..446d405ef68a 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -213,8 +213,13 @@ def main():
level=logging.INFO if args.verbose else logging.WARNING
)

- # Making sure that the `sysroot` and `sysroot_src` belong to the same toolchain.
- assert args.sysroot in args.sysroot_src.parents
+ assert args.sysroot in args.sysroot_src.parents, \
+ f"""
+ It seems like your sysroot and sysroot_src do not belong to the same toolchain.
+ The sysroot folder must be inside sysroot_src.
+ sysroot={args.sysroot}
+ sysroot_src={args.sysroot_src}
+ """

rust_project = {
"crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.core_edition),

base-commit: 54e3eae855629702c566bd2e130d9f40e7f35bde
--
2.50.1