def generate_rust_project_json(self) -> None:
        """Generate a rust-analyzer compatible rust-project.json file."""
        if not self.rust_crates:
            return
        with open(os.path.join(self.environment.get_build_dir(), 'rust-project.json'),
                  'w', encoding='utf-8') as f:
            sysroot = self.environment.coredata.compilers.host['rust'].get_sysroot()
            json.dump(
                {
                    "sysroot": sysroot,
                    "sysroot_src": os.path.join(sysroot, 'lib/rustlib/src/rust/library/'),
                    "crates": [c.to_json() for c in self.rust_crates.values()],
                },
                f, indent=4)
Generate a rust-analyzer compatible rust-project.json file.
mesonbuild/backend/ninjabackend.py