rust-lang / rust-lang/rust-analyzer

Using css-modules crate results in macro-error but compiles and works.

Open
#8,149 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-macro S-actionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Example

src/app.css

.something {
   background: red
}

src/main.rs

use css_modules::include_css_module;

fn main() {
  let css = include_css_module!("app.css");
  println!("{}", css["something"]);
}

./build.rs :

use css_modules::CssModules;

fn main() {
    let mut css_modules = CssModules::default();

    // Include all CSS files in the src dir:
    css_modules.add_modules("src/**/*.css").unwrap();

    // Compile all modules and export CSS into one file:
    css_modules.compile("./app.css");
}

./Cargo.toml

# ...
[dependencies]
css-modules = "0.5"
[build-dependencies]
css-modules = "0.5"

Error

message: called `Result::unwrap()` on an `Err` value: StripPrefixError(())

Maybe Rust-analyzer does not find the file that Rust does.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the macro error using the provided src/app.css, src/main.rs, build.rs, and Cargo.toml example, comparing rust-analyzer's result with the successful Rust build. Start by tracing how the include_css_module! call resolves app.css and handles the build-script output. Done means the example no longer reports a macro error while retaining its existing compiled behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.