Skip to main content

returns_wrapped_self

Function returns_wrapped_self 

Source
pub fn returns_wrapped_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool
Expand description

Returns true when the function is a “wrapped” constructor that returns Option<Self> / Result<Self, _> rather than a bare Self.

get_type classifies these as FnKind::Constructor, but for the wrapped forms the None/Err paths do not produce a Self, so a struct invariant can only be meaningfully discharged on the Some/Ok paths. This helper lets verify_struct_invariants skip the benign Unknown results on the non-Self paths. (Box<Self> is intentionally not included: every path still produces a Self behind the pointer.)