Coding Tools & Tips

VScode

Rust Analyzer doesn’t directly analyze the code of dependencies that are enabled only by a feature flag. To fix this and enable Rust Analyzer to jump to definitions and provide better support for your sub-module, you can adjust the settings in your Rust project to ensure that the stwo feature is enabled for the workspace.

The solution is to edit Workspace Settings

  1. Open Command Palette:
    • Press Ctrl+Shift+P (or Cmd+Shift+P on macOS).
    • Type Preferences: Open Workspace Settings (JSON) and select it.
  2. Add Rust Analyzer Configuration:
    • In the settings.json file that opens, add the following configuration:
    jsonCopy code{ "rust-analyzer.cargo.features": ["stwo"] } If you already have other settings in this file, just add this line under existing ones.
  3. save and restart rust analyzer.