{"record":{"id":"39826fea97bb4d2e","repo":"rust-lang/rust-analyzer","slug":"renaming-aliases-is-currently-unsupported","errorCode":null,"errorMessage":"Renaming aliases is currently unsupported","messagePattern":"Renaming aliases is currently unsupported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ide/src/rename.rs","lineNumber":334,"sourceCode":"            let kind = name_like.syntax().kind();\n            let range = sema\n                .original_range_opt(name_like.syntax())\n                .ok_or_else(|| format_err!(\"No references found at position\"))?;\n            let res = match &name_like {\n                // renaming aliases would rename the item being aliased as the HIR doesn't track aliases yet\n                ast::NameLike::Name(name)\n                    if name\n                        .syntax()\n                        .parent().is_some_and(|it| ast::Rename::can_cast(it.kind()))\n                        // FIXME: uncomment this once we resolve to usages to extern crate declarations\n                        // && name\n                        //     .syntax()\n                        //     .ancestors()\n                        //     .nth(2)\n                        //     .map_or(true, |it| !ast::ExternCrate::can_cast(it.kind()))\n                        =>\n                {\n                    bail!(\"Renaming aliases is currently unsupported\")\n                }\n                ast::NameLike::Name(name) => NameClass::classify(sema, name)\n                    .map(|class| match class {\n                        NameClass::Definition(it) | NameClass::ConstReference(it) => it,\n                        NameClass::PatFieldShorthand { local_def, field_ref: _, adt_subst: _ } => {\n                            Definition::Local(local_def)\n                        }\n                    })\n                    .ok_or_else(|| format_err!(\"No references found at position\")),\n                ast::NameLike::NameRef(name_ref) => {\n                    NameRefClass::classify(sema, name_ref)\n                        .map(|class| match class {\n                            NameRefClass::Definition(def, _) => def,\n                            NameRefClass::FieldShorthand { local_ref, field_ref: _, adt_subst: _ } => {\n                                Definition::Local(local_ref)\n                            }\n                            NameRefClass::ExternCrateShorthand { decl, .. } => {\n                                Definition::ExternCrateDecl(decl)","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/ide/src/rename.rs#L316-L352","documentation":"find_definitions (used by both prepare_rename and rename) classifies the name at the cursor; when the name is an alias/extern-crate style name it classifies as a def whose renaming is explicitly not implemented, so it bails with this error. It is a deliberate unsupported-feature guard, not a resolution failure.","triggerScenarios":"Calling prepare_rename or rename with the cursor on a crate alias (e.g. `use foo as bar;` where bar is the alias binding, or an `extern crate` alias) — the NameClassify arm for aliases hits `bail!(\"Renaming aliases is currently unsupported\")`.","commonSituations":"Renaming the alias in `use some_crate as sc;` or `extern crate serde as s;`; editors exposing F2 on such aliases get this unsupported-operation error.","solutions":["Manually edit the alias in the use/extern crate statement and update references with find-references.","Rename the original item (cursor on the source path) instead of the alias binding."],"exampleFix":"// before: rename attempted on alias binding\nuse some_crate as sc; // F2 on `sc` -> unsupported\n// after: edit manually\nuse some_crate as some_crate_alias;\n","handlingStrategy":"try-catch","validationCode":"// Pre-check: renaming aliases is unsupported; detect alias bindings in use trees\n// e.g. `use foo as bar;` - cursor on `bar` is an alias\ncursor_text_on_use_tree_alias(position).map(|_| {\n    Err(\"renaming aliases is unsupported; edit the alias manually\")\n})","typeGuard":null,"tryCatchPattern":"match rename(db, pos, new_name, &config) {\n    Ok(change) => apply(change),\n    Err(e) if e.to_string().contains(\"Renaming aliases is currently unsupported\") => {\n        open_editor_at(pos); // let the user edit the alias manually\n    }\n    Err(e) => report(e),\n}","preventionTips":["Do not offer rename on alias bindings of use/extern crate statements","Disable the rename action when syntax kind is an alias binding","Update aliases manually together with find-references results"],"tags":["rust-analyzer","rename","unsupported","alias"],"backgroundTag":"rename-unsupported-target","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"}