{"record":{"id":"f383bb4f3dc36d8e","repo":"zed-industries/zed","slug":"self-is-not-a-named-searchoption","errorCode":null,"errorMessage":"{self:?} is not a named SearchOption","messagePattern":"(.+?) is not a named SearchOption","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/search/src/search.rs","lineNumber":115,"sourceCode":"\n    pub fn label(&self) -> &'static str {\n        match self {\n            SearchOption::WholeWord => \"Match Whole Words\",\n            SearchOption::CaseSensitive => \"Match Case Sensitivity\",\n            SearchOption::IncludeIgnored => \"Also search files ignored by configuration\",\n            SearchOption::Regex => \"Use Regular Expressions\",\n            SearchOption::OneMatchPerLine => \"One Match Per Line\",\n            SearchOption::Backwards => \"Search Backwards\",\n        }\n    }\n\n    pub fn icon(&self) -> ui::IconName {\n        match self {\n            SearchOption::WholeWord => IconName::WholeWord,\n            SearchOption::CaseSensitive => IconName::CaseSensitive,\n            SearchOption::IncludeIgnored => IconName::FileIgnored,\n            SearchOption::Regex => IconName::Regex,\n            _ => panic!(\"{self:?} is not a named SearchOption\"),\n        }\n    }\n\n    pub fn to_toggle_action(self) -> &'static dyn Action {\n        match self {\n            SearchOption::WholeWord => &ToggleWholeWord,\n            SearchOption::CaseSensitive => &ToggleCaseSensitive,\n            SearchOption::IncludeIgnored => &ToggleIncludeIgnored,\n            SearchOption::Regex => &ToggleRegex,\n            _ => panic!(\"{self:?} is not a toggle action\"),\n        }\n    }\n\n    pub fn as_button(\n        &self,\n        active: SearchOptions,\n        search_source: SearchSource,\n        focus_handle: FocusHandle,","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/search/src/search.rs#L97-L133","documentation":"SearchOption::icon() maps only the four options rendered as toolbar toggle buttons (WholeWord, CaseSensitive, IncludeIgnored, Regex) to icons; every other variant falls into the wildcard panic arm (crates/search/src/search.rs:115). It is a tripwire forcing new SearchOption variants to be classified: either a named toolbar button or something that must never be rendered as one.","triggerScenarios":"Calling SearchOption::icon() — directly or via as_button(), which builds the toolbar toggle — on SearchOption::OneMatchPerLine or SearchOption::Backwards. Typical shape: a loop over a list of 'all' options that renders each as a button.","commonSituations":"Making the search toolbar option list data-driven and feeding it every variant; adding a new SearchOption variant meant to be config-only but passed to the button builder; refactors that generalize option rendering.","solutions":["Only pass the four toggle-capable options down icon/button paths; keep an explicit const list (WholeWord, CaseSensitive, IncludeIgnored, Regex) for the toolbar.","If the new variant should be a toolbar button, add it to icon(), the label/action mapping, and to_toggle_action() in the same change.","Replace the wildcard arm with an exhaustive match so unclassified variants become compile errors instead of runtime panics.","Use the backtrace to find the caller (usually as_button via the search toolbar construction) and what variant it passed."],"exampleFix":"// before\nmatch self {\n    SearchOption::WholeWord => IconName::WholeWord,\n    _ => panic!(\"{self:?} is not a named SearchOption\"),\n}\n\n// after: exhaustive match forces classification of new variants\nmatch self {\n    SearchOption::WholeWord => IconName::WholeWord,\n    SearchOption::CaseSensitive => IconName::CaseSensitive,\n    SearchOption::IncludeIgnored => IconName::FileIgnored,\n    SearchOption::Regex => IconName::Regex,\n    SearchOption::OneMatchPerLine | SearchOption::Backwards => {\n        IconName::CaseSensitive // placeholder: decide deliberately\n    }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_toggle_button_option(option: SearchOption) -> bool {\n    matches!(\n        option,\n        SearchOption::WholeWord\n            | SearchOption::CaseSensitive\n            | SearchOption::IncludeIgnored\n            | SearchOption::Regex\n    )\n}\n\nif is_toggle_button_option(option) {\n    toolbar.child(option.as_button(active, source, focus_handle));\n}","tryCatchPattern":null,"preventionTips":["Make matches over SearchOption exhaustive (no wildcard arm) so new variants fail at compile time.","Keep one const list of toolbar options next to the enum and render only from it.","Add a unit test iterating all variants asserting icon()/to_toggle_action() are guarded or supported."],"tags":["search","ui","enum","exhaustiveness","panic","zed"],"backgroundTag":"unhandled-enum-variant","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}