-1

I have the following kind of layout that runs fine, but VS Code / rust-analyser choke on it. I want at least my utility functions and macros to show documentation on hover. I realise rustdoc still has a problem documenting normal stuff, so I'm willing to access everything via lib.rs. But I tried several times (utils only, or even also business logic) managing only to access functions, not macros.

It's worse: as it is, VS code can't even jump to definition or declaration. The latest version (detailed below) added horrible squiggles, saying "unresolved module, can't find module file: utils/f.rs" etc.

// src/main.rs
#[macro_use]
pub mod utils {
    #[macro_use]
    pub mod f;
}

pub mod x;

fn main() {
    x::x();
}
// src/utils/f.rs
/** I'm a happy macro */
macro_rules! m {
    () => { println!("McRoe"); };
}

/** I'm a happy function */
pub fn f() {
    println!("Fun K. Shen");
}
// src/x.rs
use crate::utils::f::*;

/** I'm business logic */
pub fn x() {
    m!();
    f();
}
Version: 1.78.2
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:47:05.613Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 6.1.0-0.deb11.5-amd64
Sandboxed: No
rust-analyzer: 0.4.1521@linux-x64
Daniel
  • 521
  • 1
  • 4
  • 13

1 Answers1

0

After digging through various aspects (I had set rust-analyser to nightly, went back to stable, realised VS code has its own with totally different version number, so uninstalled mine, strace showed it doesn't even try to access the files…) all to no avail, I found the problem:

VS code doesn't know that files reside in directories , so the poor thing didn't know where to look for the other files, even though it had them open.

When I started from scratch, this time out of desperation opening not files but my directory (folder as they call it) and clicking in their explorer to open the files, lo and behold everything works.

Talk about an intuitive UI, where higher up menu items don't work and you have to go the indirect way!

Daniel
  • 521
  • 1
  • 4
  • 13