Skip to main content

diff_surfaces_with_semantics

Function diff_surfaces_with_semantics 

Source
pub fn diff_surfaces_with_semantics<M, S>(
    old: &ApiSurface<M>,
    new: &ApiSurface<M>,
    semantics: &S,
) -> Vec<StructuralChange>
Expand description

Compare two API surfaces using language-specific semantic rules.

This is the core of the TD (Top-Down) pipeline. It matches symbols by qualified_name, then compares every field to detect additions, removals, and modifications.

The semantics parameter provides language-specific rules for:

  • Whether adding a member is breaking (is_member_addition_breaking)
  • How to group related symbols (same_family, same_identity)
  • How to rank visibility levels (visibility_rank)
  • How to parse union/literal types (parse_union_values)
  • Post-processing of the change list (post_process)

The matching pipeline is:

  1. Exact qualified_name match — symbols at the same path are compared directly.
  2. Relocation detection — symbols with the same canonical path (stripping /deprecated/ and /next/) are matched as path moves (e.g., moved to deprecated).
  3. Rename detection — remaining removed+added pairs are matched by type fingerprint and name similarity.
  4. Unmatched — remaining removed symbols are reported as removed, added as added.

Star re-export symbols (export * from './module') are filtered out.