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

Support path attributes that don't end with .rs #17089

Open
bvanjoi opened this issue Apr 17, 2024 · 4 comments
Open

Support path attributes that don't end with .rs #17089

bvanjoi opened this issue Apr 17, 2024 · 4 comments
Labels
C-feature Category: feature request

Comments

@bvanjoi
Copy link
Contributor

bvanjoi commented Apr 17, 2024

For example:

// main.rs
#[path = "a.suffix"]
mod a;
fn main() {}

// a.suffix
pub const A: i32 = 1;

rustc main.rs can compile successfully, but ra will report errors:

image
@bvanjoi bvanjoi added the C-feature Category: feature request label Apr 17, 2024
@poliorcetics
Copy link
Contributor

Relevant docs: https://doc.rust-lang.org/reference/items/modules.html?highlight=%23%5Bpath%20%3D#the-path-attribute and wow I didn't know all of the specifications of the #[path] attribute

@poliorcetics
Copy link
Contributor

I think the issue is not that rust-analyzer doesn't understand such paths.

I tried it and got the error but the moment I open the a.suffix file and tell my editor it's a Rust file, the error disappears. I think either Rust-Analyzer or the editor filter out the files sent to RA by extension.

The fix is probably to make R-A request files in path attributes when it doesn't know about them (i.e, they don't match *.rs). I'm very much unsure about how to fix this though.

@poliorcetics
Copy link
Contributor

Yep, it happens here:

lsp_types::DocumentFilter {
language: None,
scheme: None,
pattern: Some("**/*.rs".into()),
},

@poliorcetics
Copy link
Contributor

Workaround for people ending up here

  1. Open the file that R-A fails to detect
  2. Tell your editor it's a Rust file

Editors that correctly implement the LSP spec should pick it up and send it to R-A. You'll have to do it each and every time you restart R-A though (quitting and opening the editor will do it for example)

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

No branches or pull requests

2 participants