[−][src]Function rustc_typeck::check::wfcheck::check_item_well_formed

pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId)

Checks that the field types (in a struct def'n) or argument types (in an enum def'n) are well-formed, meaning that they do not require any constraints not declared in the struct definition itself. For example, this definition would be illegal:

struct Ref<'a, T> { x: &'a T }

because the type did not declare that T:'a.

We do this check as a pre-pass before checking fn bodies because if these constraints are not included it frequently leads to confusing errors in fn bodies. So it's better to check the types first.