Lonami / grammers

(tele)gramme.rs - use Telegram's API from Rust
https://t.me/gramme_rs
Apache License 2.0
552 stars 111 forks source link

Rust analysis always complain about depence test. #278

Open RuofengX opened 2 days ago

RuofengX commented 2 days ago

Reproduce

  1. Use VSCode open repo folder as workspace.
  2. Use rust-analysis as lint.
  3. Open file lib/grammers-client/test/deps.rs
  4. It shows an error on include macros:

    failed to load file ../../includes/check_deps_documented.rsrust-analyzermacro-error

  5. However it's ok to run cargo test --workspace, it may be the bug of r-a

Expected Behevior

As std lib doesn't encourage include! macro used in normal code

Warning: For multi-file Rust projects, the include! macro is probably not what you are looking for. Usually, multi-file Rust projects use modules. Multi-file projects and modules are explained in the Rust-by-Example book here and the module system is explained in the Rust Book here.The included file is placed in the surrounding code unhygienically. If the included file is parsed as an expression and variables or functions share names across both files, it could result in variables or functions being different from what the included file expected. The included file is located relative to the current file (similarly to how modules are found). The provided path is interpreted in a platform-specific way at compile time. So, for instance, an invocation with a Windows path containing backslashes \ would not compile correctly on Unix.

It's better to create file links instead of include file.

Lonami commented 2 days ago

If you know of a way to reuse the code without duplicating it, that would be preferable. Using include! was simply the first thing that came to mind.