rename ast_*
to hir_*
in wfcheck
This commit is contained in:
parent
189e7843e8
commit
443c816261
1 changed files with 17 additions and 17 deletions
|
@ -296,31 +296,31 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
||||||
hir::ItemKind::Const(ty, ..) => {
|
hir::ItemKind::Const(ty, ..) => {
|
||||||
check_item_type(tcx, def_id, ty.span, UnsizedHandling::Forbid)
|
check_item_type(tcx, def_id, ty.span, UnsizedHandling::Forbid)
|
||||||
}
|
}
|
||||||
hir::ItemKind::Struct(_, ast_generics) => {
|
hir::ItemKind::Struct(_, hir_generics) => {
|
||||||
let res = check_type_defn(tcx, item, false);
|
let res = check_type_defn(tcx, item, false);
|
||||||
check_variances_for_type_defn(tcx, item, ast_generics);
|
check_variances_for_type_defn(tcx, item, hir_generics);
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
hir::ItemKind::Union(_, ast_generics) => {
|
hir::ItemKind::Union(_, hir_generics) => {
|
||||||
let res = check_type_defn(tcx, item, true);
|
let res = check_type_defn(tcx, item, true);
|
||||||
check_variances_for_type_defn(tcx, item, ast_generics);
|
check_variances_for_type_defn(tcx, item, hir_generics);
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
hir::ItemKind::Enum(_, ast_generics) => {
|
hir::ItemKind::Enum(_, hir_generics) => {
|
||||||
let res = check_type_defn(tcx, item, true);
|
let res = check_type_defn(tcx, item, true);
|
||||||
check_variances_for_type_defn(tcx, item, ast_generics);
|
check_variances_for_type_defn(tcx, item, hir_generics);
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
hir::ItemKind::Trait(..) => check_trait(tcx, item),
|
hir::ItemKind::Trait(..) => check_trait(tcx, item),
|
||||||
hir::ItemKind::TraitAlias(..) => check_trait(tcx, item),
|
hir::ItemKind::TraitAlias(..) => check_trait(tcx, item),
|
||||||
// `ForeignItem`s are handled separately.
|
// `ForeignItem`s are handled separately.
|
||||||
hir::ItemKind::ForeignMod { .. } => Ok(()),
|
hir::ItemKind::ForeignMod { .. } => Ok(()),
|
||||||
hir::ItemKind::TyAlias(hir_ty, ast_generics) => {
|
hir::ItemKind::TyAlias(hir_ty, hir_generics) => {
|
||||||
if tcx.type_alias_is_lazy(item.owner_id) {
|
if tcx.type_alias_is_lazy(item.owner_id) {
|
||||||
// Bounds of lazy type aliases and of eager ones that contain opaque types are respected.
|
// Bounds of lazy type aliases and of eager ones that contain opaque types are respected.
|
||||||
// E.g: `type X = impl Trait;`, `type X = (impl Trait, Y);`.
|
// E.g: `type X = impl Trait;`, `type X = (impl Trait, Y);`.
|
||||||
let res = check_item_type(tcx, def_id, hir_ty.span, UnsizedHandling::Allow);
|
let res = check_item_type(tcx, def_id, hir_ty.span, UnsizedHandling::Allow);
|
||||||
check_variances_for_type_defn(tcx, item, ast_generics);
|
check_variances_for_type_defn(tcx, item, hir_generics);
|
||||||
res
|
res
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1277,16 +1277,16 @@ fn check_item_type(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(tcx, ast_self_ty, ast_trait_ref))]
|
#[instrument(level = "debug", skip(tcx, hir_self_ty, hir_trait_ref))]
|
||||||
fn check_impl<'tcx>(
|
fn check_impl<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
item: &'tcx hir::Item<'tcx>,
|
item: &'tcx hir::Item<'tcx>,
|
||||||
ast_self_ty: &hir::Ty<'_>,
|
hir_self_ty: &hir::Ty<'_>,
|
||||||
ast_trait_ref: &Option<hir::TraitRef<'_>>,
|
hir_trait_ref: &Option<hir::TraitRef<'_>>,
|
||||||
) -> Result<(), ErrorGuaranteed> {
|
) -> Result<(), ErrorGuaranteed> {
|
||||||
enter_wf_checking_ctxt(tcx, item.span, item.owner_id.def_id, |wfcx| {
|
enter_wf_checking_ctxt(tcx, item.span, item.owner_id.def_id, |wfcx| {
|
||||||
match ast_trait_ref {
|
match hir_trait_ref {
|
||||||
Some(ast_trait_ref) => {
|
Some(hir_trait_ref) => {
|
||||||
// `#[rustc_reservation_impl]` impls are not real impls and
|
// `#[rustc_reservation_impl]` impls are not real impls and
|
||||||
// therefore don't need to be WF (the trait's `Self: Trait` predicate
|
// therefore don't need to be WF (the trait's `Self: Trait` predicate
|
||||||
// won't hold).
|
// won't hold).
|
||||||
|
@ -1294,7 +1294,7 @@ fn check_impl<'tcx>(
|
||||||
// Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
|
// Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
|
||||||
// other `Foo` impls are incoherent.
|
// other `Foo` impls are incoherent.
|
||||||
tcx.ensure().coherent_trait(trait_ref.def_id)?;
|
tcx.ensure().coherent_trait(trait_ref.def_id)?;
|
||||||
let trait_span = ast_trait_ref.path.span;
|
let trait_span = hir_trait_ref.path.span;
|
||||||
let trait_ref = wfcx.normalize(
|
let trait_ref = wfcx.normalize(
|
||||||
trait_span,
|
trait_span,
|
||||||
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
|
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
|
||||||
|
@ -1318,12 +1318,12 @@ fn check_impl<'tcx>(
|
||||||
if let Some(pred) = obligation.predicate.to_opt_poly_trait_pred()
|
if let Some(pred) = obligation.predicate.to_opt_poly_trait_pred()
|
||||||
&& pred.skip_binder().self_ty() == trait_ref.self_ty()
|
&& pred.skip_binder().self_ty() == trait_ref.self_ty()
|
||||||
{
|
{
|
||||||
obligation.cause.span = ast_self_ty.span;
|
obligation.cause.span = hir_self_ty.span;
|
||||||
}
|
}
|
||||||
if let Some(pred) = obligation.predicate.to_opt_poly_projection_pred()
|
if let Some(pred) = obligation.predicate.to_opt_poly_projection_pred()
|
||||||
&& pred.skip_binder().self_ty() == trait_ref.self_ty()
|
&& pred.skip_binder().self_ty() == trait_ref.self_ty()
|
||||||
{
|
{
|
||||||
obligation.cause.span = ast_self_ty.span;
|
obligation.cause.span = hir_self_ty.span;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!(?obligations);
|
debug!(?obligations);
|
||||||
|
@ -1337,7 +1337,7 @@ fn check_impl<'tcx>(
|
||||||
self_ty,
|
self_ty,
|
||||||
);
|
);
|
||||||
wfcx.register_wf_obligation(
|
wfcx.register_wf_obligation(
|
||||||
ast_self_ty.span,
|
hir_self_ty.span,
|
||||||
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
|
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
|
||||||
self_ty.into(),
|
self_ty.into(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue