$npx -y skills add warpdotdev/common-skills --skill fix-errorsFix compilation errors, linting issues, and test failures in the warp Rust codebase. Covers presubmit checks, WASM-specific errors, and running specific tests. Use when the user hits build errors, clippy or fmt failures, test failures, or needs to run or interpret presubmit befor
| 1 | # fix-errors |
| 2 | |
| 3 | Fix compilation errors, linting issues, and test failures in the warp Rust codebase. |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | This skill helps resolve common issues encountered during development, including: |
| 8 | - Compilation errors (unused imports, type mismatches, etc.) |
| 9 | - Linting failures (clippy warnings) |
| 10 | - Formatting violations |
| 11 | - WASM-specific errors |
| 12 | - Test failures |
| 13 | |
| 14 | Before opening or updating a pull request, all presubmit checks must pass. |
| 15 | |
| 16 | ## Presubmit Checks |
| 17 | |
| 18 | Run all presubmit checks at once: |
| 19 | |
| 20 | ```bash |
| 21 | ./script/presubmit |
| 22 | ``` |
| 23 | |
| 24 | This runs formatting, linting, and all tests. If it passes, you're ready to open a PR. |
| 25 | |
| 26 | ### Individual Checks |
| 27 | |
| 28 | Run checks separately when debugging specific issues: |
| 29 | |
| 30 | **Rust formatting:** |
| 31 | ```bash |
| 32 | cargo fmt -- --check |
| 33 | ``` |
| 34 | |
| 35 | **Clippy (full workspace):** |
| 36 | ```bash |
| 37 | cargo clippy --workspace --exclude warp_completer --all-targets --all-features --tests -- -D warnings |
| 38 | cargo clippy -p warp_completer --all-targets --tests -- -D warnings |
| 39 | ``` |
| 40 | |
| 41 | **WASM Clippy:** |
| 42 | ```bash |
| 43 | cargo clippy --target wasm32-unknown-unknown --profile release-wasm-debug_assertions --no-deps |
| 44 | ``` |
| 45 | |
| 46 | **Objective-C/C/C++ formatting:** |
| 47 | ```bash |
| 48 | ./script/run-clang-format.py -r --extensions 'c,h,cpp,m' ./crates/warpui/src/ ./app/src/ |
| 49 | ``` |
| 50 | |
| 51 | **All tests:** |
| 52 | ```bash |
| 53 | cargo nextest run --no-fail-fast --workspace --exclude command-signatures-v2 |
| 54 | cargo nextest run -p warp_completer --features v2 |
| 55 | ``` |
| 56 | |
| 57 | **Doc tests:** |
| 58 | ```bash |
| 59 | cargo test --doc |
| 60 | ``` |
| 61 | |
| 62 | ## Running Specific Tests |
| 63 | |
| 64 | **Single package:** |
| 65 | ```bash |
| 66 | cargo nextest run -p <package_name> |
| 67 | ``` |
| 68 | |
| 69 | **Filter by test name:** |
| 70 | ```bash |
| 71 | cargo nextest run -E 'test(<substring>)' |
| 72 | ``` |
| 73 | |
| 74 | **Specific package with filter:** |
| 75 | ```bash |
| 76 | cargo nextest run -p <package_name> -E 'test(<substring>)' |
| 77 | ``` |
| 78 | |
| 79 | **With output (no capture):** |
| 80 | ```bash |
| 81 | cargo nextest run -p <package> --nocapture |
| 82 | ``` |
| 83 | |
| 84 | ## Common Error Types |
| 85 | |
| 86 | ### Unused Imports |
| 87 | Remove unused `use` statements identified by the compiler. |
| 88 | |
| 89 | ### Unused Constants |
| 90 | Remove constants that are defined but never used. |
| 91 | |
| 92 | ### Unknown Imports |
| 93 | Add the correct `use` statement for undefined types. Search the codebase to find the correct module path. |
| 94 | |
| 95 | ### Type Mismatches |
| 96 | Update function calls to pass arguments of the correct type. Common fixes: |
| 97 | - Use `.as_str()` instead of `.clone()` when a `&str` is expected |
| 98 | - Use `&value` when a reference is needed |
| 99 | - Use `.to_string()` when `String` is expected but `&str` is provided |
| 100 | |
| 101 | ### Struct Field Changes |
| 102 | When a struct adds/removes fields, update all places where it's constructed or destructured: |
| 103 | - Struct initialization |
| 104 | - Pattern matching (`match`, `if let`) |
| 105 | - Destructuring assignments |
| 106 | |
| 107 | ### Function Signature Changes |
| 108 | When a function adds a new parameter, update all call sites to provide the new argument: |
| 109 | - For `bool` params: pass `true` or `false` based on context |
| 110 | - For `Option<T>` params: pass `None` as default or `Some(value)` if needed |
| 111 | |
| 112 | ### Enum Variant Changes |
| 113 | When adding a new enum variant, update exhaustive `match` statements: |
| 114 | - Add a new match arm with appropriate handling |
| 115 | - Mirror the implementation pattern of similar variants |
| 116 | |
| 117 | ### Incorrect Trait Implementation |
| 118 | Fix trait implementations that return the wrong type or don't satisfy trait bounds. |
| 119 | |
| 120 | ### WASM-Specific Errors |
| 121 | |
| 122 | WASM builds (`wasm32-unknown-unknown` target) don't support filesystem operations. Code that uses filesystem APIs must be gated behind the `local_fs` feature flag. |
| 123 | |
| 124 | **Common WASM errors:** |
| 125 | - Dead code warnings for code only used in non-WASM builds |
| 126 | - Unused code that's only relevant when `local_fs` is available |
| 127 | - Tests that require filesystem access |
| 128 | |
| 129 | **Fixes:** |
| 130 | |
| 131 | **Gate tests behind `local_fs`:** |
| 132 | ```rust |
| 133 | #[test] |
| 134 | #[cfg(feature = "local_fs")] |
| 135 | fn test_find_git_repo_with_worktree() { |
| 136 | // Test that uses filesystem operations |
| 137 | } |
| 138 | ``` |
| 139 | |
| 140 | **Conditionally allow dead code for types only used when `local_fs` is enabled:** |
| 141 | ```rust |
| 142 | #[cfg_attr(not(feature = "local_fs"), allow(dead_code))] |
| 143 | #[derive(Clone, EnumDiscriminants, Serialize)] |
| 144 | pub enum ExampleType { |
| 145 | // Variants only used when local_fs is enabled |
| 146 | Variant1, |
| 147 | Variant2, |
| 148 | Variant3, |
| 149 | } |
| 150 | ``` |
| 151 | |
| 152 | WASM errors are discovered by running: |
| 153 | |
| 154 | ```bash |
| 155 | cargo clippy --target wasm32-unknown-unknown --profile release-wasm-debug_assertions --no-deps |
| 156 | ``` |
| 157 | |
| 158 | ## Best Practices |
| 159 | |
| 160 | **Before fixing:** |
| 161 | - Read the full error message to understand the root cause |
| 162 | - Check if multiple errors are related (fixing one may resolve others) |
| 163 | - For trait/type errors, verify you understand the expected vs actual types |
| 164 | - For WASM errors, check if code needs to be gated behind `local_fs` |
| 165 | |
| 166 | **When fixing:** |
| 167 | - Fix one error type at a time when there are multiple issues |
| 168 | - Run `cargo check` frequently to verify fixes |
| 169 | - For WASM errors, run WASM clippy to verify the fix |
| 170 | - For comp |