首页 > 解决方案 > 在 crate `rust_out` 中找不到 `main` 函数:考虑在 vim/ale 的 crate 级别添加一个 `main` 函数

问题描述

我有一些只有另一个 modu 的 Rust 代码

// main.rs
mod foo;
fn main() {
    foo::hello();
}

// foo.rs
pub fn hello() {
    println!("Hello, world!");
}

但是 vim ale https://github.com/dense-analysis/ale一直声称:

`main` function not found in crate `rust_out`: consider adding a `main` function at the crate level

这是配置

...
Plug 'rust-lang/rust.vim'
...
let g:ale_linters = {
      \   'rust': ['rls', 'rustc', 'cargo'],
      \ }
...

cargo build运行良好,是麦酒出了问题!?

标签: vimrust

解决方案


推荐阅读