Skip to content

Conversation

@Samuka007
Copy link
Member

@Samuka007 Samuka007 commented Dec 21, 2025

rust-analyzer 现已支持 Cargo config 构建目标指定

不再使用 kernel/src/Makefile 作为 rust-analyzer 诊断来源,以更高效地生成错误内联

如果要更改目标,将 kernel/.cargo/config.toml 下的 build.target 切换为其他目标即可

另一个是,改动.cargo/config后,cargo clippy --fix 可以直接跑了

(虽然按之前的写法,clippy fix命令用 Makefile wrap 一下也没问题)

Copilot AI review requested due to automatic review settings December 21, 2025 10:19
@github-actions github-actions bot added the enhancement New feature or request label Dec 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request modernizes the rust-analyzer configuration to use Cargo's built-in analysis engine instead of Makefile-based diagnostics, enabling more efficient inlay hints generation and better IDE integration.

Key Changes:

  • Enabled Cargo's unstable build-std feature in .cargo/config.toml for no_std kernel development
  • Configured default build target to x86_64 in Cargo config (can be changed for other architectures)
  • Removed Makefile-based rust-analyzer diagnostics from VS Code settings

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
kernel/.cargo/config.toml Uncommented unstable build-std features and added default build target pointing to x86_64 target specification
.zed/settings.json Added new Zed editor configuration with rust-analyzer settings, linkedProjects, and disabled allTargets checking
.vscode/settings.json Removed Makefile-based check override and explicit cargo target settings, added allTargets false configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"rust-analyzer.check.allTargets": false,
"esbonio.sphinx.confDir": "",
"rust-analyzer.linkedProjects": [
"./kernel/Cargo.toml",
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linkedProjects configuration differs between VS Code and Zed editor settings. VS Code only includes kernel/Cargo.toml, while Zed includes kernel/Cargo.toml, build-scripts/Cargo.toml, and user/apps/tests/syscall/gvisor/runner/Cargo.toml. This creates an inconsistent development experience across different IDEs. Consider either adding the additional projects to VS Code settings or documenting why they differ.

Suggested change
"./kernel/Cargo.toml",
"./kernel/Cargo.toml",
"./build-scripts/Cargo.toml",
"./user/apps/tests/syscall/gvisor/runner/Cargo.toml"

Copilot uses AI. Check for mistakes.
@Samuka007 Samuka007 marked this pull request as draft December 21, 2025 10:25
@Samuka007
Copy link
Member Author

TODO: Resolve static check issue

@Samuka007
Copy link
Member Author

Issue: After changing default cargo config, make test default use no-std environment which breaks the unit tests in the crates that needs std. Need to override flag when executing make test

@Samuka007 Samuka007 force-pushed the feat/ide-ra-original branch 3 times, most recently from 3c4ff24 to 0572cee Compare January 3, 2026 08:06
@Samuka007 Samuka007 force-pushed the feat/ide-ra-original branch from 48cc558 to 2ec7f6d Compare January 3, 2026 09:21
@Samuka007 Samuka007 added the Request for Comments A topic requesting for comments label Jan 3, 2026
@Samuka007 Samuka007 linked an issue Jan 3, 2026 that may be closed by this pull request
@Samuka007
Copy link
Member Author

Will close #1594

@Samuka007
Copy link
Member Author

@fslongjin 把ide的目标变更做进 .cargo/config.toml 了,并且把内核从 workspace 中抽出来,这样方便区分 std 和 no-std 环境,对IDE友好(不用指定linkedProject)。跑测试也方便:见 kernel static test 的部分

另一个也可以看看 #1598

@Samuka007
Copy link
Member Author

但由于变更了目录所以变动有点大

@fslongjin
Copy link
Member

对于不同架构的编译的切换怎么弄?

@Samuka007
Copy link
Member Author

.cargo/config.toml里把默认build目标改了咯,反正改内联提示都是要改的()

[build]
target = "src/arch/x86_64/x86_64-unknown-none.json"
# target = "src/arch/riscv64/riscv64gc-unknown-none-elf.json"
# target = "src/arch/loongarch64/loongarch64-unknown-none.json"

@fslongjin
Copy link
Member

也许需要更新一下文档里面描述的,切换架构的开发步骤。

Copy link
Member Author

image.png

有点难绷,我消不掉这个,这#[test]的构建目标和代码构建目标到底怎么分的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Request for Comments A topic requesting for comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: correct cargo config with std enabled static test

2 participants