mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Revert "use opaque_ty_origin_unchecked instead of destructuring HIR"
This reverts commit 5a4601fea5
.
This commit is contained in:
parent
b629c85bd7
commit
82ad5c95b6
@ -227,9 +227,17 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
||||
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
|
||||
// Check that RPITs are only constrained in their outermost
|
||||
// function, otherwise report a mismatched types error.
|
||||
if let OpaqueTyOrigin::FnReturn(parent) | OpaqueTyOrigin::AsyncFn(parent)
|
||||
= infcx.opaque_ty_origin_unchecked(opaque_type_key.def_id, hidden_type.span)
|
||||
&& parent.to_def_id() != body.source.def_id()
|
||||
if let hir::Node::Item(hir::Item {
|
||||
kind:
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
|
||||
origin:
|
||||
hir::OpaqueTyOrigin::AsyncFn(parent)
|
||||
| hir::OpaqueTyOrigin::FnReturn(parent),
|
||||
..
|
||||
}),
|
||||
..
|
||||
}) = infcx.tcx.hir().get_by_def_id(opaque_type_key.def_id.expect_local()) &&
|
||||
parent.to_def_id() != body.source.def_id()
|
||||
{
|
||||
infcx
|
||||
.report_mismatched_types(
|
||||
@ -239,7 +247,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
||||
body.source.def_id().expect_local(),
|
||||
),
|
||||
),
|
||||
infcx.tcx.mk_opaque(opaque_type_key.def_id.to_def_id(), opaque_type_key.substs),
|
||||
infcx.tcx.mk_opaque(opaque_type_key.def_id, opaque_type_key.substs),
|
||||
hidden_type.ty,
|
||||
ty::error::TypeError::Mismatch,
|
||||
)
|
||||
|
@ -438,7 +438,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "trace")]
|
||||
pub fn opaque_ty_origin_unchecked(&self, def_id: LocalDefId, span: Span) -> OpaqueTyOrigin {
|
||||
fn opaque_ty_origin_unchecked(&self, def_id: LocalDefId, span: Span) -> OpaqueTyOrigin {
|
||||
let origin = match self.tcx.hir().expect_item(def_id).kind {
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => origin,
|
||||
ref itemkind => {
|
||||
|
Loading…
Reference in New Issue
Block a user