Skip to content

unresolved-module when using a #[path] attribute with a file outside of the current crate #14230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kovaxis opened this issue Mar 1, 2023 · 2 comments
Labels
C-bug Category: bug

Comments

@kovaxis
Copy link

kovaxis commented Mar 1, 2023

rust-analyzer version: 0.3.1418-standalone

rustc version: rustc 1.67.1 (d5a82bbd2 2023-02-07)

relevant settings: All default as far as I know.

platform: rust-analyzer extension on VSCode, on Linux Mint 21 Cinnamon.

Hello,

I ran into an issue using the #[path] attribute to point to a file outside the crate.
This makes rust-analyzer run into an unresolved-module error, while cargo build and cargo run work fine.

Directory structure to reproduce the issue:

/bug/Cargo.toml
/bug/src/main.rs
/foo.rs
# /bug/Cargo.toml

[package]
name = "bug"
version = "0.1.0"
edition = "2021"
//! /bug/src/main.rs

#[path = "../../foo.rs"]
mod foo;

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

pub fn hello() {
    println!("hello world!");
}

This directory structure confuses rust-analyzer but cargo itself builds and runs fine.

@kovaxis kovaxis added the C-bug Category: bug label Mar 1, 2023
@lnicola
Copy link
Member

lnicola commented Mar 2, 2023

I think this is a dupe of #3898 and maybe other issues too.

@lnicola lnicola closed this as completed Mar 2, 2023
@kovaxis
Copy link
Author

kovaxis commented Mar 3, 2023

Sorry, for some reason I couldn't find that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants