Skip to main content

Module impl_wf_check

Module impl_wf_check 

Source
Expand description

This pass enforces various “well-formedness constraints” on impls. Logically, it is part of wfcheck – but we do it early so that we can stop compilation afterwards, since part of the trait matching infrastructure gets very grumpy if these conditions don’t hold. In particular, if there are type parameters that are not part of the impl, then coherence will report strange inference ambiguity errors; if impls have duplicate items, we get misleading specialization errors. These things can (and probably should) be fixed, but for the moment it’s easier to do these checks early.

Re-exports§

use std::debug_assert_matches; 🔒
use min_specialization::check_min_specialization; 🔒
use rustc_data_structures::fx::FxHashSet; 🔒
use rustc_errors::Applicability; 🔒
use rustc_hir::def::DefKind; 🔒
use rustc_hir::def_id::LocalDefId; 🔒
use rustc_middle::ty; 🔒
use rustc_middle::ty::TyCtxt; 🔒
use rustc_middle::ty::TypeVisitableExt; 🔒
use rustc_middle::ty::Unnormalized; 🔒
use rustc_span::ErrorGuaranteed; 🔒
use rustc_span::kw; 🔒
use crate::constrained_generic_params as cgp; 🔒
use crate::diagnostics::UnconstrainedGenericParameter; 🔒
use crate::diagnostics::remove_or_use_generic::suggest_to_remove_or_use_generic; 🔒
use rustc_errors::codes::*; 🔒

Modules§

min_specialization 🔒
Minimal Specialization

Functions§

check_impl_wf 🔒
Checks that all the type/lifetime parameters on an impl also appear in the trait ref or self type (or are constrained by a where-clause). These rules are needed to ensure that, given a trait ref like <T as Trait<U>>, we can derive the values of all parameters on the impl (which is needed to make specialization possible).
enforce_impl_lifetime_params_are_constrained 🔒
enforce_impl_non_lifetime_params_are_constrained 🔒