Skip to content

cant recognize tonic generated codeΒ #18748

Closed
@pdeva

Description

Code compiles and runs fine. In fact in RustRover even the 'goto definition' works (though rustrover doesnt use RA for this).

But with rust-analyzer in vscode i instead see errors. As can be seen in the screenshot though, the file it wants to load does indeed exist and has valid rust code.

rust-analyzer version: 0.3.2228

rustc version: rustc 1.83.0 (90b35a623 2024-11-26)

editor or extension: VSCode

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)

code snippet to reproduce:

build.rs

use glob::glob;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut proto_files = Vec::new();
    for entry in glob("**/*.proto")? {
        proto_files.push(entry?.display().to_string());
    }
    let includes: [&str; 0] = [];
    tonic_build::configure()
        .compile_well_known_types(true)
        .compile_protos(proto_files.as_slice(), &includes)?;

    Ok(())
}

tonic_defs.rs

pub mod helloworld {
    pub mod svc {
        tonic::include_proto!("helloworld.svc");
    }
    pub mod lib {
        tonic::include_proto!("helloworld.lib");
    }
}

Image Image Image Image

Metadata

Assignees

Labels

A-vfsBroken WindowBugs / technical debt to be addressed immediatelyC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions