More precisely detect cycle errors from type_of on opaque
This commit is contained in:
parent
e7b3c94b0e
commit
bf53598828
21 changed files with 238 additions and 285 deletions
|
@ -1,4 +1,5 @@
|
|||
use crate::mir;
|
||||
use crate::query::CyclePlaceholder;
|
||||
use crate::traits;
|
||||
use crate::ty::{self, Ty};
|
||||
use std::mem::{size_of, transmute_copy, MaybeUninit};
|
||||
|
@ -142,6 +143,10 @@ impl EraseType for Result<&'_ ty::List<Ty<'_>>, ty::util::AlwaysRequiresDrop> {
|
|||
[u8; size_of::<Result<&'static ty::List<Ty<'static>>, ty::util::AlwaysRequiresDrop>>()];
|
||||
}
|
||||
|
||||
impl EraseType for Result<ty::EarlyBinder<Ty<'_>>, CyclePlaceholder> {
|
||||
type Result = [u8; size_of::<Result<ty::EarlyBinder<Ty<'_>>, CyclePlaceholder>>()];
|
||||
}
|
||||
|
||||
impl<T> EraseType for Option<&'_ T> {
|
||||
type Result = [u8; size_of::<Option<&'static ()>>()];
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::mir::interpret::{
|
|||
use crate::mir::interpret::{LitToConstError, LitToConstInput};
|
||||
use crate::mir::mono::CodegenUnit;
|
||||
use crate::query::erase::{erase, restore, Erase};
|
||||
use crate::query::plumbing::{query_ensure, query_get_at, DynamicQuery};
|
||||
use crate::query::plumbing::{query_ensure, query_get_at, CyclePlaceholder, DynamicQuery};
|
||||
use crate::thir;
|
||||
use crate::traits::query::{
|
||||
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
|
||||
|
@ -243,6 +243,16 @@ rustc_queries! {
|
|||
feedable
|
||||
}
|
||||
|
||||
/// Specialized instance of `type_of` that detects cycles that are due to
|
||||
/// revealing opaque because of an auto trait bound. Unless `CyclePlaceholder` needs
|
||||
/// to be handled separately, call `type_of` instead.
|
||||
query type_of_opaque(key: DefId) -> Result<ty::EarlyBinder<Ty<'tcx>>, CyclePlaceholder> {
|
||||
desc { |tcx|
|
||||
"computing type of opaque `{path}`",
|
||||
path = tcx.def_path_str(key),
|
||||
}
|
||||
}
|
||||
|
||||
query collect_return_position_impl_trait_in_trait_tys(key: DefId)
|
||||
-> Result<&'tcx FxHashMap<DefId, ty::EarlyBinder<Ty<'tcx>>>, ErrorGuaranteed>
|
||||
{
|
||||
|
|
|
@ -630,3 +630,6 @@ impl<'tcx> TyCtxtAt<'tcx> {
|
|||
.unwrap_or_else(|| bug!("def_kind: unsupported node: {:?}", def_id))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, HashStable)]
|
||||
pub struct CyclePlaceholder(pub ErrorGuaranteed);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue