{"record":{"id":"97e91539aba0665e","repo":"rust-lang/rust-analyzer","slug":"no-references-found-at-position","errorCode":null,"errorMessage":"No references found at position","messagePattern":"No references found at position","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ide/src/rename.rs","lineNumber":111,"sourceCode":"\n            Ok(match kind {\n                SyntaxKind::LIFETIME => {\n                    TextRange::new(frange.range.start() + TextSize::from(1), frange.range.end())\n                }\n                _ => frange.range,\n            })\n        })\n        .reduce(|acc, cur| match (acc, cur) {\n            // ensure all ranges are the same\n            (Ok(acc_inner), Ok(cur_inner)) if acc_inner == cur_inner => Ok(acc_inner),\n            (e @ Err(_), _) | (_, e @ Err(_)) => e,\n            _ => bail!(\"inconsistent text range\"),\n        });\n\n    match res {\n        // ensure at least one definition was found\n        Some(res) => res.map(|range| RangeInfo::new(range, ())),\n        None => bail!(\"No references found at position\"),\n    }\n}\n\n// Feature: Rename\n//\n// Renames the item below the cursor and all of its references\n//\n// | Editor  | Shortcut |\n// |---------|----------|\n// | VS Code | <kbd>F2</kbd> |\n//\n// ![Rename](https://user-images.githubusercontent.com/48062697/113065582-055aae80-91b1-11eb-8ade-2b58e6d81883.gif)\n//\n// #### Magic Renames\n//\n// rust-analyzer supports some special renames that do additional magic:\n//\n//  - **Anonymous lifetime renames**. You can rename `'_` to any lifetime name (the new name must start with `'`),","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/ide/src/rename.rs#L93-L129","documentation":"prepare_rename (and rename) require that at least one renamable definition exists at the given FilePosition. If find_definitions returns nothing that can be renamed (or reduce produced no entries), the operation cannot proceed and this error is thrown. It is the standard 'cursor is not on a renamable symbol' error surfaced to editors.","triggerScenarios":"Calling prepare_rename at an offset on whitespace, comments, string literals, keywords, or non-identifier tokens; also raised by rename via format_err when sema cannot attach the file or when no SourceChange ops are produced.","commonSituations":"Editors firing rename while the cursor is at end-of-line, inside a comment or doc text, on a crate/attribute path segment that is not renamable, or on stale positions after the file changed without a document sync.","solutions":["Place the cursor directly on the identifier/name token to rename and retry.","Check that the file content and cursor position sent to the LSP server are in sync (re-send didChange/didOpen).","Use find references or hover first to confirm the symbol is semantically resolvable at that position."],"exampleFix":"// before: rename request at offset inside a comment\n// fn foo() {}  <- cursor here\n// after: request at offset on `foo` token itself\nfn foo() {}\n","handlingStrategy":"validation","validationCode":"// Check the position resolves to a symbol before renaming\nlet symbol = client.hover(file_uri, position).await?;\nif symbol.is_none() {\n    // cursor not on a renamable item; skip rename\n}","typeGuard":"fn position_on_token(line: &str, col: usize) -> bool {\n    !line.is_empty() && col <= line.len()\n        && line[..col].chars().last()\n            .map_or(false, |c| c.is_alphanumeric() || c == '_')\n}","tryCatchPattern":"match prepare_rename(db, pos) {\n    Ok(info) => start_rename_session(info),\n    Err(e) if e.to_string().contains(\"No references found\") => {\n        notify_user(\"Place the cursor on an identifier to rename\");\n    }\n    Err(e) => report(e),\n}","preventionTips":["Cursor must sit on the identifier, not on whitespace/comments/literals","Refresh the document position after edits before issuing rename","Use hover or document-highlight as a pre-check that the symbol resolves","Handle the LSP PrepareRenameResponse::None case gracefully in editors"],"tags":["rust-analyzer","rename","lsp","not-found"],"backgroundTag":"rename-target-not-found","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"}