{"record":{"id":"cc1be32479a30550","repo":"rust-lang/rust-analyzer","slug":"cannot-rename-a-tool-module","errorCode":null,"errorMessage":"Cannot rename a tool module","messagePattern":"Cannot rename a tool module","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ide-db/src/rename.rs","lineNumber":111,"sourceCode":"        // self.krate() returns None if\n        // self is a built-in attr, built-in type or tool module.\n        // it is not allowed for these defs to be renamed.\n        // cases where self.krate() is None is handled below.\n        let edition = if let Some(krate) = self.krate(sema.db) {\n            // Can we not rename non-local items?\n            // Then bail if non-local\n            if !krate.origin(sema.db).is_local() {\n                bail!(\"Cannot rename a non-local definition\")\n            }\n            krate.edition(sema.db)\n        } else {\n            Edition::LATEST\n        };\n\n        match *self {\n            Definition::Module(module) => rename_mod(sema, module, new_name),\n            Definition::ToolModule(_) => {\n                bail!(\"Cannot rename a tool module\")\n            }\n            Definition::BuiltinType(_) => {\n                bail!(\"Cannot rename builtin type\")\n            }\n            Definition::BuiltinAttr(_) => {\n                bail!(\"Cannot rename a builtin attr.\")\n            }\n            Definition::SelfType(_) => bail!(\"Cannot rename `Self`\"),\n            Definition::Macro(mac) => rename_reference(\n                sema,\n                Definition::Macro(mac),\n                new_name,\n                rename_definition,\n                edition,\n                config,\n            ),\n            def => rename_reference(sema, def, new_name, rename_definition, edition, config),\n        }","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/ide-db/src/rename.rs#L93-L129","documentation":"A `bail!` guard in `Definition::rename` for the `self.krate() == None` branch: the definition is a tool module (or built-in attribute/type) that has no backing crate in the crate graph, so there is no source location to edit. This is an intentional user-facing restriction, not an internal failure; the offending input is the tool-module symbol being renamed.","triggerScenarios":"Thrown at crates/ide-db/src/rename.rs:111 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not attempt to rename tool modules (`rustfmt`, `clippy`, etc.) — they are fixed by the toolchain","Rename a user-defined module or item instead","If you need different naming, import the tool under an alias where it is used"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}