Apply EarlyBinder
only to TraitRef
in ImplTraitHeader
This commit is contained in:
parent
8c9a75b323
commit
9669934798
22 changed files with 74 additions and 82 deletions
|
@ -25,7 +25,7 @@ use rustc_trait_selection::traits::ObligationCtxt;
|
|||
use rustc_trait_selection::traits::{self, ObligationCause};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub fn check_trait<'tcx>(
|
||||
pub(super) fn check_trait<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
impl_def_id: LocalDefId,
|
||||
|
@ -66,10 +66,9 @@ impl<'tcx> Checker<'tcx> {
|
|||
|
||||
fn visit_implementation_of_drop(checker: &Checker<'_>) -> Result<(), ErrorGuaranteed> {
|
||||
let tcx = checker.tcx;
|
||||
let header = checker.impl_header;
|
||||
let impl_did = checker.impl_def_id;
|
||||
// Destructors only work on local ADT types.
|
||||
match header.trait_ref.self_ty().kind() {
|
||||
match checker.impl_header.trait_ref.instantiate_identity().self_ty().kind() {
|
||||
ty::Adt(def, _) if def.did().is_local() => return Ok(()),
|
||||
ty::Error(_) => return Ok(()),
|
||||
_ => {}
|
||||
|
@ -86,7 +85,7 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
|
|||
let impl_did = checker.impl_def_id;
|
||||
debug!("visit_implementation_of_copy: impl_did={:?}", impl_did);
|
||||
|
||||
let self_type = impl_header.trait_ref.self_ty();
|
||||
let self_type = impl_header.trait_ref.instantiate_identity().self_ty();
|
||||
debug!("visit_implementation_of_copy: self_type={:?} (bound)", self_type);
|
||||
|
||||
let param_env = tcx.param_env(impl_did);
|
||||
|
@ -120,7 +119,7 @@ fn visit_implementation_of_const_param_ty(checker: &Checker<'_>) -> Result<(), E
|
|||
let tcx = checker.tcx;
|
||||
let header = checker.impl_header;
|
||||
let impl_did = checker.impl_def_id;
|
||||
let self_type = header.trait_ref.self_ty();
|
||||
let self_type = header.trait_ref.instantiate_identity().self_ty();
|
||||
assert!(!self_type.has_escaping_bound_vars());
|
||||
|
||||
let param_env = tcx.param_env(impl_did);
|
||||
|
@ -157,9 +156,8 @@ fn visit_implementation_of_coerce_unsized(checker: &Checker<'_>) -> Result<(), E
|
|||
|
||||
fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<(), ErrorGuaranteed> {
|
||||
let tcx = checker.tcx;
|
||||
let header = checker.impl_header;
|
||||
let impl_did = checker.impl_def_id;
|
||||
let trait_ref = header.trait_ref;
|
||||
let trait_ref = checker.impl_header.trait_ref.instantiate_identity();
|
||||
debug!("visit_implementation_of_dispatch_from_dyn: impl_did={:?}", impl_did);
|
||||
|
||||
let span = tcx.def_span(impl_did);
|
||||
|
|
|
@ -134,11 +134,12 @@ fn coherent_trait(tcx: TyCtxt<'_>, def_id: DefId) -> Result<(), ErrorGuaranteed>
|
|||
let mut res = tcx.ensure().specialization_graph_of(def_id);
|
||||
|
||||
for &impl_def_id in impls {
|
||||
let trait_header = tcx.impl_trait_header(impl_def_id).unwrap().instantiate_identity();
|
||||
let trait_def = tcx.trait_def(trait_header.trait_ref.def_id);
|
||||
let trait_header = tcx.impl_trait_header(impl_def_id).unwrap();
|
||||
let trait_ref = trait_header.trait_ref.instantiate_identity();
|
||||
let trait_def = tcx.trait_def(trait_ref.def_id);
|
||||
|
||||
res = res.and(check_impl(tcx, impl_def_id, trait_header.trait_ref, trait_def));
|
||||
res = res.and(check_object_overlap(tcx, impl_def_id, trait_header.trait_ref));
|
||||
res = res.and(check_impl(tcx, impl_def_id, trait_ref, trait_def));
|
||||
res = res.and(check_object_overlap(tcx, impl_def_id, trait_ref));
|
||||
|
||||
res = res.and(unsafety::check_item(tcx, impl_def_id, trait_header, trait_def));
|
||||
res = res.and(tcx.ensure().orphan_check_impl(impl_def_id));
|
||||
|
|
|
@ -13,9 +13,10 @@ pub(super) fn check_item(
|
|||
trait_header: ImplTraitHeader<'_>,
|
||||
trait_def: &TraitDef,
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let trait_ref = trait_header.trait_ref;
|
||||
let unsafe_attr =
|
||||
tcx.generics_of(def_id).params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle");
|
||||
let trait_ref = trait_header.trait_ref.instantiate_identity();
|
||||
|
||||
match (trait_def.unsafety, unsafe_attr, trait_header.unsafety, trait_header.polarity) {
|
||||
(Unsafety::Normal, None, Unsafety::Unsafe, Positive | Reservation) => {
|
||||
let span = tcx.def_span(def_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue