解决rust-analyzer加载时间过长等问题

温馨提示:最新内容仅在原文更新。

若出现下述类似的问题,可以尝试使用本文的方法进行解决。

  1. vscode 一直卡在 fetching metadata 阶段

  2. 出现报错 Blocking waiting for file lock on package cache

  3. 出现报错 proc macro command not expanded: No proc-macros present for crate rust-analyzer(unresolved-proc-macro)

  4. 出现报错 ERROR FetchBuildDataError: error: the --keep-going flag is unstable, and only available on the nightly channel of Cargo, but this is the stable channel See https://doc.xxxx-xxxx.org/book/appendix-07-nightly-rust.html for more information about Rust release channels. See https://xxxx.com/rust-lang/cargo/issues/10496 for more information about the --keep-going flag.

配置国内源

  • 参考文章 https://blog.zyxm.top/archives/rust-proxy-turbo

出现 1、2 可以尝试下述方法:

删除cargo的缓存

rm -rf ~/.cargo/.package-cache

执行 cargo metadata

重启 VSCode

出现 3、4 可以尝试下述方法:

尝试更新Rust版本

  • rustup --version 查看rustup版本

  • rustup toolchain list 查看已安装的版本

  • rustup default 【指定版本的名称】 切换到指定版本要更新Rust,可以使用以下命令:4

  • rustup update 升级所有安装的版本

  • rustup install stable 安装最新的稳定版

  • rustup install beta 安装最新的测试版

  • rustup install nightly 安装最新的每日构建版

重启 VSCode

原文地址

解决rust-analyzer加载时间过长

解决rust-analyzer加载时间过长(备用)

  • 8
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要配置rust-analyzer的代码提示,你可以按照以下步骤进行操作: 1. 确保已经在你的项目中安装了rust-analyzer插件。你可以在VSCode的插件市场中搜索并安装"rust-analyzer"插件。 2. 打开VSCode的设置(可以通过菜单栏的"文件" -> "首选项" -> "设置"或者使用快捷键Ctrl + ,打开设置)。 3. 在设置页面的搜索框中输入"rust-analyzer",找到相关的设置选项。 4. 根据你的需求,配置下列常用的代码提示相关的设置: - "rust-analyzer.enable": 设置为true以启用rust-analyzer插件。 - "rust-analyzer.completion.enable": 设置为true以启用代码补全功能。 - "rust-analyzer.completion.addCallArgumentSnippets": 设置为true以自动添加函数调用时的参数提示。 - "rust-analyzer.completion.addCallParenthesis": 设置为true以自动添加函数调用时的括号。 - "rust-analyzer.completion.postfix.enable": 设置为true以启用后缀代码补全功能,例如`.if`、`.let`等。 - "rust-analyzer.hover.enable": 设置为true以启用悬停提示功能。 - "rust-analyzer.inlayHints.enable": 设置为true以启用内联提示功能。 5. 根据你的需求,可以进一步自定义配置rust-analyzer的代码提示行为。你可以在设置中找到更多相关的选项,并根据注释进行配置。 6. 保存设置,并重启VSCode使更改生效。 通过以上步骤,你可以根据自己的喜好和需求来配置rust-analyzer的代码提示功能。请注意,具体的配置选项可能会因rust-analyzer插件版本的不同而有所差异,请参考插件的官方文档或参考其它资源获取更多定制化的配置信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

开源分享汇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值