basro / stylance-rs

Scoped CSS style imports for rust.
MIT License
43 stars 4 forks source link

fix invalid path by rust-analyzer causing panic #4

Closed blorbb closed 2 weeks ago

blorbb commented 2 weeks ago

Issue: using the nightly import_style! macro runs fine with rustc but panics in rust-analyzer.

image

Even adding the following to .vscode/settings.json does not prevent the error message for some reason.

"rust-analyzer.procMacro.ignored": {
    "stylance": ["import_style"]
}

The panic comes from the source file being SourceFile { path: "", is_real: true } when run by rust-analyzer. I added a check to see if there is no parent, and simply expand to nothing. This prevents auto-complete, but rustc errors/warnings about non-existent/unused values still works.

basro commented 2 weeks ago

Thank you for reporting and investigating this, it seems rust analyzer has changed it's behavior here, this used to work fine.

Your solution looks like a reasonable workaround, I'll see to release a new version asap.

basro commented 2 weeks ago

Your PR is included in the v0.5.1 release. Thank you for your contribution.