Skip to main content

find_declaration_span

Function find_declaration_span 

Source
pub fn find_declaration_span(source: &str, name: &str) -> Option<Span>
Expand description

Return the source span of the declaration named name in the given source text. Returns None if no declaration matches.

The name of each item comes from CommonsItem::name rather than a list of arms here: that match is exhaustive, so a variant this lookup does not handle cannot compile, and a new one is answered the day it is added. The arms it replaces omitted Actor, and a _ => {} catch-all swallowed it — so go-to-definition on the User in by u: User found nothing whenever the index rung above it had not resolved the offset (an unanalysed or mid-edit buffer, a file outside the analysed project).

Note this deliberately matches a method by its bare name — fn Stored.retitle answers to retitle — because go-to-definition from a bare identifier depends on it. describe_item guards on FnName::Free instead and the two therefore disagree on what a bare name means, which ADR 0191 D2 records as intended rather than as drift.