use rustc_middle::ty::trait_def::TraitSpecializationKind;
use rustc_middle::ty::{
self, AdtKind, DefIdTree, EarlyBinder, GenericParamDefKind, ToPredicate, Ty, TyCtxt,
- TypeFoldable, TypeSuperFoldable, TypeVisitor,
+ TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitor,
};
use rustc_session::parse::feature_err;
use rustc_span::symbol::{sym, Ident, Symbol};
}
let wf_tys = f(&fcx);
fcx.select_all_obligations_or_error();
- fcx.regionck_item(id, span, wf_tys);
+
+ let mut outlives_environment = OutlivesEnvironment::new(param_env);
+ outlives_environment.add_implied_bounds(&fcx.infcx, wf_tys, id);
+ fcx.infcx.check_region_obligations_and_report_errors(&outlives_environment);
});
}
}
// call individually.
tcx.infer_ctxt().enter(|infcx| {
let mut outlives_environment = OutlivesEnvironment::new(param_env);
- outlives_environment.add_implied_bounds(&infcx, wf_tys.clone(), id, DUMMY_SP);
- outlives_environment.save_implied_bounds(id);
- let region_bound_pairs = outlives_environment.region_bound_pairs_map().get(&id).unwrap();
+ outlives_environment.add_implied_bounds(&infcx, wf_tys.clone(), id);
+ let region_bound_pairs = outlives_environment.region_bound_pairs();
add_constraints(&infcx, region_bound_pairs);
- let errors = infcx.resolve_regions(id.expect_owner().to_def_id(), &outlives_environment);
+ let errors = infcx.resolve_regions(&outlives_environment);
debug!(?errors, "errors");
fcx.register_bound(
item_ty,
tcx.require_lang_item(LangItem::Sized, None),
- traits::ObligationCause::new(ty_span, fcx.body_id, traits::MiscObligation),
+ traits::ObligationCause::new(ty_span, fcx.body_id, traits::WellFormed(None)),
);
}
struct CountParams {
params: FxHashSet<u32>,
}
- impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
+ impl<'tcx> ty::visit::TypeVisitor<'tcx> for CountParams {
type BreakTy = ();
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
let implied_obligations = traits::elaborate_predicates_with_span(fcx.tcx, predicates_with_span);
for obligation in implied_obligations {
+ // We lower empty bounds like `Vec<dyn Copy>:` as
+ // `WellFormed(Vec<dyn Copy>)`, which will later get checked by
+ // regular WF checking
+ if let ty::PredicateKind::WellFormed(..) = obligation.predicate.kind().skip_binder() {
+ continue;
+ }
let pred = obligation.predicate;
// Match the existing behavior.
if pred.is_global() && !pred.has_late_bound_regions() {