Skip to content
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

Rust analysis always complain about depence test. #278

Open
RuofengX opened this issue Oct 19, 2024 · 1 comment
Open

Rust analysis always complain about depence test. #278

RuofengX opened this issue Oct 19, 2024 · 1 comment

Comments

@RuofengX
Copy link
Contributor

RuofengX commented Oct 19, 2024

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

  1. 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
Copy link
Owner

Lonami commented Oct 19, 2024

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.

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

No branches or pull requests

2 participants