1
Fork 0

Rollup merge of #126075 - compiler-errors:remove-debugwithinfcx, r=lcnr

Remove `DebugWithInfcx` machinery

This PR removes `DebugWithInfcx` after having a lot of second thoughts about it due to recent type system uplifting work. We could add it back later if we want, but I don't think the amount of boilerplate in the complier and the existence of (kindof) hacks like `NoInfcx` currently justify the existence of `DebugWithInfcx`, especially since it's not even being used anywhere in the compiler currently.

The motivation for `DebugWithInfcx` is that we want to be able to print infcx-aware information, such as universe information[^1] (though if there are other usages that I'm overlooking, please let me know). I think there are probably more tailored solutions that can specifically be employed in places where this infcx-aware printing is necessary. For example, one way of achieving this is by implementing a custom `FmtPrinter` which overloads `ty_infer_name` (perhaps also extending it to have overrideable stubs for printing placeholders too) to print the `?u.i` name for an infer var. This will necessitate uplifting `Print` from `rustc_middle::ty::print`, but this seems a bit more extensible and reusable than `DebugWithInfcx`.

One of the problems w/ `DebugWithInfcx` is its opt-in-ness. Even if a compiler dev adds a new `debug!(ty)` in a context where there is an `infcx` we can access, they have to *opt-in* to using `DebugWithInfcx` with something like `debug!(infcx.with(ty))`. This feels to me like it risks a lot of boilerplate, and very easy to just forget adding it at all, especially in cases like `#[instrument]`.

A second problem is the `NoInfcx` type itself. It's necessary to have this dummy infcx implementation since we often want to print types outside of the scope of a valid `Infcx`. Right now, `NoInfcx` is only *partially* a valid implementation of `InferCtxtLike`, except for the methods that we specifically need for `DebugWithInfcx`. As I work on uplifting the trait solver, I actually want to add a lot more methods to `InferCtxtLike` and having to add `unreachable!("this should never be called")` stubs for uplifted methods like `next_ty_var` is quite annoying.

In reality, I actually only *really* care about the second problem -- we could, perhaps, instead just try to get rid of `NoInfcx` and just just duplicate `Debug` and `DebugWithInfcx` for most types. If we're okay with duplicating all these implementations (though most of them would just be trivial `#[derive(Debug, DebugWithInfcx)]`), I'd be okay with that too 🤔

r? `@BoxyUwU` `@lcnr` would like to know your thoughts -- happy to discuss this further, mainly trying to bring this problem up

[^1]: Which in my experience is only really necessary when we're debugging things like generalizer bugs.
This commit is contained in:
Guillaume Gomez 2024-06-12 15:44:58 +02:00 committed by GitHub
commit 99d0feedb8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 105 additions and 477 deletions

View file

@ -1,5 +1,5 @@
use super::flags::FlagComputation; use super::flags::FlagComputation;
use super::{DebruijnIndex, DebugWithInfcx, InferCtxtLike, TyCtxt, TypeFlags, WithInfcx}; use super::{DebruijnIndex, TypeFlags};
use crate::arena::Arena; use crate::arena::Arena;
use rustc_data_structures::aligned::{align_of, Aligned}; use rustc_data_structures::aligned::{align_of, Aligned};
use rustc_serialize::{Encodable, Encoder}; use rustc_serialize::{Encodable, Encoder};
@ -162,14 +162,6 @@ impl<H, T: fmt::Debug> fmt::Debug for RawList<H, T> {
(**self).fmt(f) (**self).fmt(f)
} }
} }
impl<'tcx, H, T: DebugWithInfcx<TyCtxt<'tcx>>> DebugWithInfcx<TyCtxt<'tcx>> for RawList<H, T> {
fn fmt<Infcx: InferCtxtLike<Interner = TyCtxt<'tcx>>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
fmt::Debug::fmt(&this.map(|this| this.as_slice()), f)
}
}
impl<H, S: Encoder, T: Encodable<S>> Encodable<S> for RawList<H, T> { impl<H, S: Encoder, T: Encodable<S>> Encodable<S> for RawList<H, T> {
#[inline] #[inline]

View file

@ -61,7 +61,6 @@ use rustc_span::{ExpnId, ExpnKind, Span};
use rustc_target::abi::{Align, FieldIdx, Integer, IntegerType, VariantIdx}; use rustc_target::abi::{Align, FieldIdx, Integer, IntegerType, VariantIdx};
pub use rustc_target::abi::{ReprFlags, ReprOptions}; pub use rustc_target::abi::{ReprFlags, ReprOptions};
pub use rustc_type_ir::relate::VarianceDiagInfo; pub use rustc_type_ir::relate::VarianceDiagInfo;
pub use rustc_type_ir::{DebugWithInfcx, InferCtxtLike, WithInfcx};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
pub use vtable::*; pub use vtable::*;

View file

@ -13,7 +13,7 @@ use rustc_ast_ir::visit::VisitorResult;
use rustc_hir::def::Namespace; use rustc_hir::def::Namespace;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_target::abi::TyAndLayout; use rustc_target::abi::TyAndLayout;
use rustc_type_ir::{ConstKind, DebugWithInfcx, InferCtxtLike, WithInfcx}; use rustc_type_ir::ConstKind;
use std::fmt::{self, Debug}; use std::fmt::{self, Debug};
@ -83,14 +83,6 @@ impl fmt::Debug for ty::LateParamRegion {
} }
} }
impl<'tcx> ty::DebugWithInfcx<TyCtxt<'tcx>> for Ty<'tcx> {
fn fmt<Infcx: InferCtxtLike<Interner = TyCtxt<'tcx>>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
this.data.fmt(f)
}
}
impl<'tcx> fmt::Debug for Ty<'tcx> { impl<'tcx> fmt::Debug for Ty<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
with_no_trimmed_paths!(fmt::Debug::fmt(self.kind(), f)) with_no_trimmed_paths!(fmt::Debug::fmt(self.kind(), f))
@ -121,70 +113,33 @@ impl<'tcx> fmt::Debug for ty::Clause<'tcx> {
} }
} }
impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for Pattern<'tcx> {
fn fmt<Infcx: InferCtxtLike<Interner = TyCtxt<'tcx>>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
match &**this.data {
ty::PatternKind::Range { start, end, include_end } => f
.debug_struct("Pattern::Range")
.field("start", start)
.field("end", end)
.field("include_end", include_end)
.finish(),
}
}
}
impl<'tcx> fmt::Debug for ty::consts::Expr<'tcx> { impl<'tcx> fmt::Debug for ty::consts::Expr<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f) match self.kind {
}
}
impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::consts::Expr<'tcx> {
fn fmt<Infcx: InferCtxtLike<Interner = TyCtxt<'tcx>>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
match this.data.kind {
ty::ExprKind::Binop(op) => { ty::ExprKind::Binop(op) => {
let (lhs_ty, rhs_ty, lhs, rhs) = this.data.binop_args(); let (lhs_ty, rhs_ty, lhs, rhs) = self.binop_args();
write!( write!(f, "({op:?}: ({:?}: {:?}), ({:?}: {:?}))", lhs, lhs_ty, rhs, rhs_ty,)
f,
"({op:?}: ({:?}: {:?}), ({:?}: {:?}))",
&this.wrap(lhs),
&this.wrap(lhs_ty),
&this.wrap(rhs),
&this.wrap(rhs_ty),
)
} }
ty::ExprKind::UnOp(op) => { ty::ExprKind::UnOp(op) => {
let (rhs_ty, rhs) = this.data.unop_args(); let (rhs_ty, rhs) = self.unop_args();
write!(f, "({op:?}: ({:?}: {:?}))", &this.wrap(rhs), &this.wrap(rhs_ty)) write!(f, "({op:?}: ({:?}: {:?}))", rhs, rhs_ty)
} }
ty::ExprKind::FunctionCall => { ty::ExprKind::FunctionCall => {
let (func_ty, func, args) = this.data.call_args(); let (func_ty, func, args) = self.call_args();
let args = args.collect::<Vec<_>>(); let args = args.collect::<Vec<_>>();
write!(f, "({:?}: {:?})(", &this.wrap(func), &this.wrap(func_ty))?; write!(f, "({:?}: {:?})(", func, func_ty)?;
for arg in args.iter().rev().skip(1).rev() { for arg in args.iter().rev().skip(1).rev() {
write!(f, "{:?}, ", &this.wrap(arg))?; write!(f, "{:?}, ", arg)?;
} }
if let Some(arg) = args.last() { if let Some(arg) = args.last() {
write!(f, "{:?}", &this.wrap(arg))?; write!(f, "{:?}", arg)?;
} }
write!(f, ")") write!(f, ")")
} }
ty::ExprKind::Cast(kind) => { ty::ExprKind::Cast(kind) => {
let (value_ty, value, to_ty) = this.data.cast_args(); let (value_ty, value, to_ty) = self.cast_args();
write!( write!(f, "({kind:?}: ({:?}: {:?}), {:?})", value, value_ty, to_ty)
f,
"({kind:?}: ({:?}: {:?}), {:?})",
&this.wrap(value),
&this.wrap(value_ty),
&this.wrap(to_ty)
)
} }
} }
} }
@ -192,20 +147,12 @@ impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::consts::Expr<'tcx> {
impl<'tcx> fmt::Debug for ty::Const<'tcx> { impl<'tcx> fmt::Debug for ty::Const<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f)
}
}
impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::Const<'tcx> {
fn fmt<Infcx: InferCtxtLike<Interner = TyCtxt<'tcx>>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
// If this is a value, we spend some effort to make it look nice. // If this is a value, we spend some effort to make it look nice.
if let ConstKind::Value(_, _) = this.data.kind() { if let ConstKind::Value(_, _) = self.kind() {
return ty::tls::with(move |tcx| { return ty::tls::with(move |tcx| {
// Somehow trying to lift the valtree results in lifetime errors, so we lift the // Somehow trying to lift the valtree results in lifetime errors, so we lift the
// entire constant. // entire constant.
let lifted = tcx.lift(*this.data).unwrap(); let lifted = tcx.lift(*self).unwrap();
let ConstKind::Value(ty, valtree) = lifted.kind() else { let ConstKind::Value(ty, valtree) = lifted.kind() else {
bug!("we checked that this is a valtree") bug!("we checked that this is a valtree")
}; };
@ -215,7 +162,7 @@ impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::Const<'tcx> {
}); });
} }
// Fall back to something verbose. // Fall back to something verbose.
write!(f, "{kind:?}", kind = &this.map(|data| data.kind())) write!(f, "{:?}", self.kind())
} }
} }
@ -247,32 +194,12 @@ impl<'tcx> fmt::Debug for GenericArg<'tcx> {
} }
} }
} }
impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for GenericArg<'tcx> {
fn fmt<Infcx: InferCtxtLike<Interner = TyCtxt<'tcx>>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
match this.data.unpack() {
GenericArgKind::Lifetime(lt) => write!(f, "{:?}", &this.wrap(lt)),
GenericArgKind::Const(ct) => write!(f, "{:?}", &this.wrap(ct)),
GenericArgKind::Type(ty) => write!(f, "{:?}", &this.wrap(ty)),
}
}
}
impl<'tcx> fmt::Debug for Region<'tcx> { impl<'tcx> fmt::Debug for Region<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.kind()) write!(f, "{:?}", self.kind())
} }
} }
impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for Region<'tcx> {
fn fmt<Infcx: InferCtxtLike<Interner = TyCtxt<'tcx>>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
write!(f, "{:?}", &this.map(|data| data.kind()))
}
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Atomic structs // Atomic structs

View file

@ -8,12 +8,11 @@ use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
use rustc_serialize::Decodable; use rustc_serialize::Decodable;
use tracing::debug; use tracing::debug;
use crate::debug::{DebugWithInfcx, WithInfcx};
use crate::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable}; use crate::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
use crate::inherent::*; use crate::inherent::*;
use crate::lift::Lift; use crate::lift::Lift;
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}; use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
use crate::{self as ty, InferCtxtLike, Interner, SsoHashSet}; use crate::{self as ty, Interner, SsoHashSet};
/// Binder is a binder for higher-ranked lifetimes or types. It is part of the /// Binder is a binder for higher-ranked lifetimes or types. It is part of the
/// compiler's representation for things like `for<'a> Fn(&'a isize)` /// compiler's representation for things like `for<'a> Fn(&'a isize)`
@ -56,18 +55,6 @@ where
} }
} }
impl<I: Interner, T: DebugWithInfcx<I>> DebugWithInfcx<I> for ty::Binder<I, T> {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
f.debug_tuple("Binder")
.field(&this.map(|data| data.as_ref().skip_binder()))
.field(&this.data.bound_vars())
.finish()
}
}
macro_rules! impl_binder_encode_decode { macro_rules! impl_binder_encode_decode {
($($t:ty),+ $(,)?) => { ($($t:ty),+ $(,)?) => {
$( $(

View file

@ -5,7 +5,7 @@ use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic}; use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
use std::fmt; use std::fmt;
use crate::{self as ty, DebruijnIndex, DebugWithInfcx, InferCtxtLike, Interner, WithInfcx}; use crate::{self as ty, DebruijnIndex, Interner};
use self::ConstKind::*; use self::ConstKind::*;
@ -61,28 +61,19 @@ impl<I: Interner> PartialEq for ConstKind<I> {
impl<I: Interner> fmt::Debug for ConstKind<I> { impl<I: Interner> fmt::Debug for ConstKind<I> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f)
}
}
impl<I: Interner> DebugWithInfcx<I> for ConstKind<I> {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
use ConstKind::*; use ConstKind::*;
match this.data { match self {
Param(param) => write!(f, "{param:?}"), Param(param) => write!(f, "{param:?}"),
Infer(var) => write!(f, "{:?}", &this.wrap(var)), Infer(var) => write!(f, "{:?}", &var),
Bound(debruijn, var) => crate::debug_bound_var(f, *debruijn, var), Bound(debruijn, var) => crate::debug_bound_var(f, *debruijn, var),
Placeholder(placeholder) => write!(f, "{placeholder:?}"), Placeholder(placeholder) => write!(f, "{placeholder:?}"),
Unevaluated(uv) => { Unevaluated(uv) => {
write!(f, "{:?}", &this.wrap(uv)) write!(f, "{:?}", &uv)
} }
Value(ty, valtree) => write!(f, "({valtree:?}: {:?})", &this.wrap(ty)), Value(ty, valtree) => write!(f, "({valtree:?}: {:?})", &ty),
Error(_) => write!(f, "{{const error}}"), Error(_) => write!(f, "{{const error}}"),
Expr(expr) => write!(f, "{:?}", &this.wrap(expr)), Expr(expr) => write!(f, "{:?}", &expr),
} }
} }
} }
@ -112,17 +103,9 @@ impl<I: Interner> UnevaluatedConst<I> {
impl<I: Interner> fmt::Debug for UnevaluatedConst<I> { impl<I: Interner> fmt::Debug for UnevaluatedConst<I> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f)
}
}
impl<I: Interner> DebugWithInfcx<I> for UnevaluatedConst<I> {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
f.debug_struct("UnevaluatedConst") f.debug_struct("UnevaluatedConst")
.field("def", &this.data.def) .field("def", &self.def)
.field("args", &this.wrap(this.data.args)) .field("args", &self.args)
.finish() .finish()
} }
} }
@ -175,23 +158,6 @@ impl fmt::Debug for InferConst {
} }
} }
} }
impl<I: Interner> DebugWithInfcx<I> for InferConst {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
match *this.data {
InferConst::Var(vid) => match this.infcx.universe_of_ct(vid) {
None => write!(f, "{:?}", this.data),
Some(universe) => write!(f, "?{}_{}c", vid.index(), universe.index()),
},
InferConst::EffectVar(vid) => write!(f, "?{}e", vid.index()),
InferConst::Fresh(_) => {
unreachable!()
}
}
}
}
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
impl<CTX> HashStable<CTX> for InferConst { impl<CTX> HashStable<CTX> for InferConst {

View file

@ -1,146 +0,0 @@
use crate::{
ConstVid, EffectVid, FloatVid, InferCtxtLike, IntVid, Interner, RegionVid, TyVid, UniverseIndex,
};
use core::fmt;
use std::marker::PhantomData;
pub struct NoInfcx<I>(PhantomData<I>);
impl<I: Interner> InferCtxtLike for NoInfcx<I> {
type Interner = I;
fn interner(&self) -> Self::Interner {
unreachable!()
}
fn universe_of_ty(&self, _ty: TyVid) -> Option<UniverseIndex> {
None
}
fn universe_of_lt(&self, _lt: RegionVid) -> Option<UniverseIndex> {
None
}
fn universe_of_ct(&self, _ct: ConstVid) -> Option<UniverseIndex> {
None
}
fn opportunistic_resolve_ty_var(&self, vid: TyVid) -> I::Ty {
panic!("cannot resolve {vid:?}")
}
fn opportunistic_resolve_int_var(&self, vid: IntVid) -> I::Ty {
panic!("cannot resolve {vid:?}")
}
fn opportunistic_resolve_float_var(&self, vid: FloatVid) -> I::Ty {
panic!("cannot resolve {vid:?}")
}
fn opportunistic_resolve_ct_var(&self, vid: ConstVid) -> I::Const {
panic!("cannot resolve {vid:?}")
}
fn opportunistic_resolve_effect_var(&self, vid: EffectVid) -> I::Const {
panic!("cannot resolve {vid:?}")
}
fn opportunistic_resolve_lt_var(&self, vid: crate::RegionVid) -> I::Region {
panic!("cannot resolve {vid:?}")
}
fn defining_opaque_types(&self) -> I::DefiningOpaqueTypes {
Default::default()
}
}
pub trait DebugWithInfcx<I: Interner>: fmt::Debug {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result;
}
impl<I: Interner, T: DebugWithInfcx<I> + ?Sized> DebugWithInfcx<I> for &'_ T {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
<T as DebugWithInfcx<I>>::fmt(this.map(|&data| data), f)
}
}
impl<I: Interner, T: DebugWithInfcx<I>> DebugWithInfcx<I> for [T] {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
match f.alternate() {
true => {
write!(f, "[\n")?;
for element in this.data.iter() {
write!(f, "{:?},\n", &this.wrap(element))?;
}
write!(f, "]")
}
false => {
write!(f, "[")?;
if this.data.len() > 0 {
for element in &this.data[..(this.data.len() - 1)] {
write!(f, "{:?}, ", &this.wrap(element))?;
}
if let Some(element) = this.data.last() {
write!(f, "{:?}", &this.wrap(element))?;
}
}
write!(f, "]")
}
}
}
}
pub struct WithInfcx<'a, Infcx: InferCtxtLike, T> {
pub data: T,
pub infcx: &'a Infcx,
}
impl<Infcx: InferCtxtLike, T: Copy> Copy for WithInfcx<'_, Infcx, T> {}
impl<Infcx: InferCtxtLike, T: Clone> Clone for WithInfcx<'_, Infcx, T> {
fn clone(&self) -> Self {
Self { data: self.data.clone(), infcx: self.infcx }
}
}
impl<'a, I: Interner, T> WithInfcx<'a, NoInfcx<I>, T> {
pub fn with_no_infcx(data: T) -> Self {
Self { data, infcx: &NoInfcx(PhantomData) }
}
}
impl<'a, Infcx: InferCtxtLike, T> WithInfcx<'a, Infcx, T> {
pub fn new(data: T, infcx: &'a Infcx) -> Self {
Self { data, infcx }
}
pub fn wrap<U>(self, u: U) -> WithInfcx<'a, Infcx, U> {
WithInfcx { data: u, infcx: self.infcx }
}
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> WithInfcx<'a, Infcx, U> {
WithInfcx { data: f(self.data), infcx: self.infcx }
}
pub fn as_ref(&self) -> WithInfcx<'a, Infcx, &T> {
WithInfcx { data: &self.data, infcx: self.infcx }
}
}
impl<Infcx: InferCtxtLike, T: DebugWithInfcx<Infcx::Interner>> fmt::Debug
for WithInfcx<'_, Infcx, T>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
DebugWithInfcx::fmt(self.as_ref(), f)
}
}

View file

@ -12,11 +12,11 @@ use rustc_ast_ir::Mutability;
use crate::fold::{TypeFoldable, TypeSuperFoldable}; use crate::fold::{TypeFoldable, TypeSuperFoldable};
use crate::relate::Relate; use crate::relate::Relate;
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable}; use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
use crate::{self as ty, CollectAndApply, DebugWithInfcx, Interner, UpcastFrom}; use crate::{self as ty, CollectAndApply, Interner, UpcastFrom};
pub trait Ty<I: Interner<Ty = Self>>: pub trait Ty<I: Interner<Ty = Self>>:
Copy Copy
+ DebugWithInfcx<I> + Debug
+ Hash + Hash
+ Eq + Eq
+ Into<I::GenericArg> + Into<I::GenericArg>
@ -116,7 +116,7 @@ pub trait Safety<I: Interner<Safety = Self>>: Copy + Debug + Hash + Eq + TypeVis
pub trait Region<I: Interner<Region = Self>>: pub trait Region<I: Interner<Region = Self>>:
Copy Copy
+ DebugWithInfcx<I> + Debug
+ Hash + Hash
+ Eq + Eq
+ Into<I::GenericArg> + Into<I::GenericArg>
@ -134,7 +134,7 @@ pub trait Region<I: Interner<Region = Self>>:
pub trait Const<I: Interner<Const = Self>>: pub trait Const<I: Interner<Const = Self>>:
Copy Copy
+ DebugWithInfcx<I> + Debug
+ Hash + Hash
+ Eq + Eq
+ Into<I::GenericArg> + Into<I::GenericArg>
@ -166,7 +166,7 @@ pub trait GenericsOf<I: Interner<GenericsOf = Self>> {
pub trait GenericArgs<I: Interner<GenericArgs = Self>>: pub trait GenericArgs<I: Interner<GenericArgs = Self>>:
Copy Copy
+ DebugWithInfcx<I> + Debug
+ Hash + Hash
+ Eq + Eq
+ IntoIterator<Item = I::GenericArg> + IntoIterator<Item = I::GenericArg>

View file

@ -9,7 +9,7 @@ use crate::ir_print::IrPrint;
use crate::relate::Relate; use crate::relate::Relate;
use crate::solve::inspect::CanonicalGoalEvaluationStep; use crate::solve::inspect::CanonicalGoalEvaluationStep;
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable}; use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
use crate::{self as ty, DebugWithInfcx}; use crate::{self as ty};
pub trait Interner: pub trait Interner:
Sized Sized
@ -32,7 +32,7 @@ pub trait Interner:
type GenericArgs: GenericArgs<Self>; type GenericArgs: GenericArgs<Self>;
type GenericArgsSlice: Copy + Debug + Hash + Eq + Deref<Target = [Self::GenericArg]>; type GenericArgsSlice: Copy + Debug + Hash + Eq + Deref<Target = [Self::GenericArg]>;
type GenericArg: Copy type GenericArg: Copy
+ DebugWithInfcx<Self> + Debug
+ Hash + Hash
+ Eq + Eq
+ IntoKind<Kind = ty::GenericArgKind<Self>> + IntoKind<Kind = ty::GenericArgKind<Self>>
@ -74,9 +74,9 @@ pub trait Interner:
// Things stored inside of tys // Things stored inside of tys
type ErrorGuaranteed: Copy + Debug + Hash + Eq; type ErrorGuaranteed: Copy + Debug + Hash + Eq;
type BoundExistentialPredicates: Copy + DebugWithInfcx<Self> + Hash + Eq + Relate<Self>; type BoundExistentialPredicates: Copy + Debug + Hash + Eq + Relate<Self>;
type AllocId: Copy + Debug + Hash + Eq; type AllocId: Copy + Debug + Hash + Eq;
type Pat: Copy + Debug + Hash + Eq + DebugWithInfcx<Self> + Relate<Self>; type Pat: Copy + Debug + Hash + Eq + Debug + Relate<Self>;
type Safety: Safety<Self> + TypeFoldable<Self> + Relate<Self>; type Safety: Safety<Self> + TypeFoldable<Self> + Relate<Self>;
type Abi: Abi<Self> + TypeFoldable<Self> + Relate<Self>; type Abi: Abi<Self> + TypeFoldable<Self> + Relate<Self>;
@ -86,7 +86,7 @@ pub trait Interner:
type ParamConst: Copy + Debug + Hash + Eq + ParamLike; type ParamConst: Copy + Debug + Hash + Eq + ParamLike;
type BoundConst: Copy + Debug + Hash + Eq + BoundVarLike<Self>; type BoundConst: Copy + Debug + Hash + Eq + BoundVarLike<Self>;
type ValueConst: Copy + Debug + Hash + Eq; type ValueConst: Copy + Debug + Hash + Eq;
type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Eq + Relate<Self>; type ExprConst: Copy + Debug + Hash + Eq + Relate<Self>;
// Kinds of regions // Kinds of regions
type Region: Region<Self>; type Region: Region<Self>;

View file

@ -42,7 +42,6 @@ mod macros;
mod binder; mod binder;
mod canonical; mod canonical;
mod const_kind; mod const_kind;
mod debug;
mod flags; mod flags;
mod generic_arg; mod generic_arg;
mod infcx; mod infcx;
@ -59,7 +58,6 @@ pub use canonical::*;
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
pub use codec::*; pub use codec::*;
pub use const_kind::*; pub use const_kind::*;
pub use debug::{DebugWithInfcx, WithInfcx};
pub use flags::*; pub use flags::*;
pub use generic_arg::*; pub use generic_arg::*;
pub use infcx::InferCtxtLike; pub use infcx::InferCtxtLike;

View file

@ -9,7 +9,7 @@ use crate::inherent::*;
use crate::lift::Lift; use crate::lift::Lift;
use crate::upcast::Upcast; use crate::upcast::Upcast;
use crate::visit::TypeVisitableExt as _; use crate::visit::TypeVisitableExt as _;
use crate::{self as ty, DebugWithInfcx, InferCtxtLike, Interner, WithInfcx}; use crate::{self as ty, Interner};
/// `A: 'region` /// `A: 'region`
#[derive(derivative::Derivative)] #[derive(derivative::Derivative)]
@ -248,16 +248,6 @@ pub enum ExistentialPredicate<I: Interner> {
AutoTrait(I::DefId), AutoTrait(I::DefId),
} }
// FIXME: Implement this the right way after
impl<I: Interner> DebugWithInfcx<I> for ExistentialPredicate<I> {
fn fmt<Infcx: rustc_type_ir::InferCtxtLike<Interner = I>>(
this: rustc_type_ir::WithInfcx<'_, Infcx, &Self>,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
fmt::Debug::fmt(&this.data, f)
}
}
impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> { impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
/// Given an existential predicate like `?Self: PartialEq<u32>` (e.g., derived from `dyn PartialEq<u32>`), /// Given an existential predicate like `?Self: PartialEq<u32>` (e.g., derived from `dyn PartialEq<u32>`),
/// and a concrete type `self_ty`, returns a full predicate where the existentially quantified variable `?Self` /// and a concrete type `self_ty`, returns a full predicate where the existentially quantified variable `?Self`
@ -459,7 +449,8 @@ impl AliasTermKind {
Copy(bound = ""), Copy(bound = ""),
Hash(bound = ""), Hash(bound = ""),
PartialEq(bound = ""), PartialEq(bound = ""),
Eq(bound = "") Eq(bound = ""),
Debug(bound = "")
)] )]
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)] #[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))] #[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
@ -493,23 +484,6 @@ pub struct AliasTerm<I: Interner> {
_use_alias_term_new_instead: (), _use_alias_term_new_instead: (),
} }
impl<I: Interner> std::fmt::Debug for AliasTerm<I> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f)
}
}
impl<I: Interner> DebugWithInfcx<I> for AliasTerm<I> {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result {
f.debug_struct("AliasTerm")
.field("args", &this.map(|data| data.args))
.field("def_id", &this.data.def_id)
.finish()
}
}
impl<I: Interner> AliasTerm<I> { impl<I: Interner> AliasTerm<I> {
pub fn new( pub fn new(
interner: I, interner: I,

View file

@ -4,7 +4,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable}; use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
use std::fmt; use std::fmt;
use crate::{DebruijnIndex, DebugWithInfcx, InferCtxtLike, Interner, WithInfcx}; use crate::{DebruijnIndex, Interner};
use self::RegionKind::*; use self::RegionKind::*;
@ -18,18 +18,6 @@ rustc_index::newtype_index! {
pub struct RegionVid {} pub struct RegionVid {}
} }
impl<I: Interner> DebugWithInfcx<I> for RegionVid {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
match this.infcx.universe_of_lt(*this.data) {
Some(universe) => write!(f, "'?{}_{}", this.data.index(), universe.index()),
None => write!(f, "{:?}", this.data),
}
}
}
/// Representation of regions. Note that the NLL checker uses a distinct /// Representation of regions. Note that the NLL checker uses a distinct
/// representation of regions. For this reason, it internally replaces all the /// representation of regions. For this reason, it internally replaces all the
/// regions with inference variables -- the index of the variable is then used /// regions with inference variables -- the index of the variable is then used
@ -230,12 +218,9 @@ impl<I: Interner> PartialEq for RegionKind<I> {
} }
} }
impl<I: Interner> DebugWithInfcx<I> for RegionKind<I> { impl<I: Interner> fmt::Debug for RegionKind<I> {
fn fmt<Infcx: InferCtxtLike<Interner = I>>( fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
this: WithInfcx<'_, Infcx, &Self>, match self {
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
match this.data {
ReEarlyParam(data) => write!(f, "{data:?}"), ReEarlyParam(data) => write!(f, "{data:?}"),
ReBound(binder_id, bound_region) => { ReBound(binder_id, bound_region) => {
@ -247,7 +232,7 @@ impl<I: Interner> DebugWithInfcx<I> for RegionKind<I> {
ReStatic => f.write_str("'static"), ReStatic => f.write_str("'static"),
ReVar(vid) => write!(f, "{:?}", &this.wrap(vid)), ReVar(vid) => write!(f, "{:?}", &vid),
RePlaceholder(placeholder) => write!(f, "{placeholder:?}"), RePlaceholder(placeholder) => write!(f, "{placeholder:?}"),
@ -260,11 +245,6 @@ impl<I: Interner> DebugWithInfcx<I> for RegionKind<I> {
} }
} }
} }
impl<I: Interner> fmt::Debug for RegionKind<I> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f)
}
}
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
// This is not a derived impl because a derive would require `I: HashStable` // This is not a derived impl because a derive would require `I: HashStable`

View file

@ -10,7 +10,7 @@ use std::fmt;
pub use self::closure::*; pub use self::closure::*;
use self::TyKind::*; use self::TyKind::*;
use crate::inherent::*; use crate::inherent::*;
use crate::{self as ty, DebruijnIndex, DebugWithInfcx, InferCtxtLike, Interner, WithInfcx}; use crate::{self as ty, DebruijnIndex, Interner};
use rustc_ast_ir::Mutability; use rustc_ast_ir::Mutability;
@ -341,12 +341,10 @@ impl<I: Interner> PartialEq for TyKind<I> {
} }
} }
impl<I: Interner> DebugWithInfcx<I> for TyKind<I> { // This is manually implemented because a derive would require `I: Debug`
fn fmt<Infcx: InferCtxtLike<Interner = I>>( impl<I: Interner> fmt::Debug for TyKind<I> {
this: WithInfcx<'_, Infcx, &Self>, fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f: &mut fmt::Formatter<'_>, match self {
) -> fmt::Result {
match this.data {
Bool => write!(f, "bool"), Bool => write!(f, "bool"),
Char => write!(f, "char"), Char => write!(f, "char"),
Int(i) => write!(f, "{i:?}"), Int(i) => write!(f, "{i:?}"),
@ -369,27 +367,23 @@ impl<I: Interner> DebugWithInfcx<I> for TyKind<I> {
} }
Foreign(d) => f.debug_tuple("Foreign").field(d).finish(), Foreign(d) => f.debug_tuple("Foreign").field(d).finish(),
Str => write!(f, "str"), Str => write!(f, "str"),
Array(t, c) => write!(f, "[{:?}; {:?}]", &this.wrap(t), &this.wrap(c)), Array(t, c) => write!(f, "[{:?}; {:?}]", &t, &c),
Pat(t, p) => write!(f, "pattern_type!({:?} is {:?})", &this.wrap(t), &this.wrap(p)), Pat(t, p) => write!(f, "pattern_type!({:?} is {:?})", &t, &p),
Slice(t) => write!(f, "[{:?}]", &this.wrap(t)), Slice(t) => write!(f, "[{:?}]", &t),
RawPtr(ty, mutbl) => write!(f, "*{} {:?}", mutbl.ptr_str(), this.wrap(ty)), RawPtr(ty, mutbl) => write!(f, "*{} {:?}", mutbl.ptr_str(), ty),
Ref(r, t, m) => write!(f, "&{:?} {}{:?}", this.wrap(r), m.prefix_str(), this.wrap(t)), Ref(r, t, m) => write!(f, "&{:?} {}{:?}", r, m.prefix_str(), t),
FnDef(d, s) => f.debug_tuple("FnDef").field(d).field(&this.wrap(s)).finish(), FnDef(d, s) => f.debug_tuple("FnDef").field(d).field(&s).finish(),
FnPtr(s) => write!(f, "{:?}", &this.wrap(s)), FnPtr(s) => write!(f, "{:?}", &s),
Dynamic(p, r, repr) => match repr { Dynamic(p, r, repr) => match repr {
DynKind::Dyn => write!(f, "dyn {:?} + {:?}", &this.wrap(p), &this.wrap(r)), DynKind::Dyn => write!(f, "dyn {:?} + {:?}", &p, &r),
DynKind::DynStar => { DynKind::DynStar => {
write!(f, "dyn* {:?} + {:?}", &this.wrap(p), &this.wrap(r)) write!(f, "dyn* {:?} + {:?}", &p, &r)
} }
}, },
Closure(d, s) => f.debug_tuple("Closure").field(d).field(&this.wrap(s)).finish(), Closure(d, s) => f.debug_tuple("Closure").field(d).field(&s).finish(),
CoroutineClosure(d, s) => { CoroutineClosure(d, s) => f.debug_tuple("CoroutineClosure").field(d).field(&s).finish(),
f.debug_tuple("CoroutineClosure").field(d).field(&this.wrap(s)).finish() Coroutine(d, s) => f.debug_tuple("Coroutine").field(d).field(&s).finish(),
} CoroutineWitness(d, s) => f.debug_tuple("CoroutineWitness").field(d).field(&s).finish(),
Coroutine(d, s) => f.debug_tuple("Coroutine").field(d).field(&this.wrap(s)).finish(),
CoroutineWitness(d, s) => {
f.debug_tuple("CoroutineWitness").field(d).field(&this.wrap(s)).finish()
}
Never => write!(f, "!"), Never => write!(f, "!"),
Tuple(t) => { Tuple(t) => {
write!(f, "(")?; write!(f, "(")?;
@ -398,7 +392,7 @@ impl<I: Interner> DebugWithInfcx<I> for TyKind<I> {
if count > 0 { if count > 0 {
write!(f, ", ")?; write!(f, ", ")?;
} }
write!(f, "{:?}", &this.wrap(ty))?; write!(f, "{:?}", &ty)?;
count += 1; count += 1;
} }
// unary tuples need a trailing comma // unary tuples need a trailing comma
@ -407,23 +401,16 @@ impl<I: Interner> DebugWithInfcx<I> for TyKind<I> {
} }
write!(f, ")") write!(f, ")")
} }
Alias(i, a) => f.debug_tuple("Alias").field(i).field(&this.wrap(a)).finish(), Alias(i, a) => f.debug_tuple("Alias").field(i).field(&a).finish(),
Param(p) => write!(f, "{p:?}"), Param(p) => write!(f, "{p:?}"),
Bound(d, b) => crate::debug_bound_var(f, *d, b), Bound(d, b) => crate::debug_bound_var(f, *d, b),
Placeholder(p) => write!(f, "{p:?}"), Placeholder(p) => write!(f, "{p:?}"),
Infer(t) => write!(f, "{:?}", this.wrap(t)), Infer(t) => write!(f, "{:?}", t),
TyKind::Error(_) => write!(f, "{{type error}}"), TyKind::Error(_) => write!(f, "{{type error}}"),
} }
} }
} }
// This is manually implemented because a derive would require `I: Debug`
impl<I: Interner> fmt::Debug for TyKind<I> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f)
}
}
/// Represents the projection of an associated, opaque, or lazy-type-alias type. /// Represents the projection of an associated, opaque, or lazy-type-alias type.
/// ///
/// * For a projection, this would be `<Ty as Trait<...>>::N<...>`. /// * For a projection, this would be `<Ty as Trait<...>>::N<...>`.
@ -435,7 +422,8 @@ impl<I: Interner> fmt::Debug for TyKind<I> {
Copy(bound = ""), Copy(bound = ""),
Hash(bound = ""), Hash(bound = ""),
PartialEq(bound = ""), PartialEq(bound = ""),
Eq(bound = "") Eq(bound = ""),
Debug(bound = "")
)] )]
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)] #[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))] #[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
@ -555,23 +543,6 @@ impl<I: Interner> AliasTy<I> {
} }
} }
impl<I: Interner> fmt::Debug for AliasTy<I> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f)
}
}
impl<I: Interner> DebugWithInfcx<I> for AliasTy<I> {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
f.debug_struct("AliasTy")
.field("args", &this.map(|data| data.args))
.field("def_id", &this.data.def_id)
.finish()
}
}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))] #[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
pub enum IntTy { pub enum IntTy {
@ -968,24 +939,6 @@ impl fmt::Debug for InferTy {
} }
} }
impl<I: Interner> DebugWithInfcx<I> for InferTy {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
match this.data {
InferTy::TyVar(vid) => {
if let Some(universe) = this.infcx.universe_of_ty(*vid) {
write!(f, "?{}_{}t", vid.index(), universe.index())
} else {
write!(f, "{:?}", this.data)
}
}
_ => write!(f, "{:?}", this.data),
}
}
}
#[derive(derivative::Derivative)] #[derive(derivative::Derivative)]
#[derivative( #[derivative(
Clone(bound = ""), Clone(bound = ""),
@ -1078,15 +1031,7 @@ impl<I: Interner> ty::Binder<I, FnSig<I>> {
impl<I: Interner> fmt::Debug for FnSig<I> { impl<I: Interner> fmt::Debug for FnSig<I> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
WithInfcx::with_no_infcx(self).fmt(f) let sig = self;
}
}
impl<I: Interner> DebugWithInfcx<I> for FnSig<I> {
fn fmt<Infcx: InferCtxtLike<Interner = I>>(
this: WithInfcx<'_, Infcx, &Self>,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
let sig = this.data;
let FnSig { inputs_and_output: _, c_variadic, safety, abi } = sig; let FnSig { inputs_and_output: _, c_variadic, safety, abi } = sig;
write!(f, "{}", safety.prefix_str())?; write!(f, "{}", safety.prefix_str())?;
@ -1100,7 +1045,7 @@ impl<I: Interner> DebugWithInfcx<I> for FnSig<I> {
if i > 0 { if i > 0 {
write!(f, ", ")?; write!(f, ", ")?;
} }
write!(f, "{:?}", &this.wrap(ty))?; write!(f, "{:?}", &ty)?;
} }
if *c_variadic { if *c_variadic {
if inputs.is_empty() { if inputs.is_empty() {
@ -1113,7 +1058,7 @@ impl<I: Interner> DebugWithInfcx<I> for FnSig<I> {
match output.kind() { match output.kind() {
Tuple(list) if list.is_empty() => Ok(()), Tuple(list) if list.is_empty() => Ok(()),
_ => write!(f, " -> {:?}", &this.wrap(sig.output())), _ => write!(f, " -> {:?}", sig.output()),
} }
} }
} }

View file

@ -5,12 +5,15 @@
ty: Coroutine( ty: Coroutine(
DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), DefId(0:4 ~ async_await[ccf8]::a::{closure#0}),
[ [
(), (),
std::future::ResumeTy, std::future::ResumeTy,
(), (),
(), (),
CoroutineWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), CoroutineWitness(
(), DefId(0:4 ~ async_await[ccf8]::a::{closure#0}),
[],
),
(),
], ],
), ),
source_info: SourceInfo { source_info: SourceInfo {
@ -23,12 +26,15 @@
ty: Coroutine( ty: Coroutine(
DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), DefId(0:4 ~ async_await[ccf8]::a::{closure#0}),
[ [
(), (),
std::future::ResumeTy, std::future::ResumeTy,
(), (),
(), (),
CoroutineWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), CoroutineWitness(
(), DefId(0:4 ~ async_await[ccf8]::a::{closure#0}),
[],
),
(),
], ],
), ),
source_info: SourceInfo { source_info: SourceInfo {

View file

@ -1,7 +1,7 @@
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())` error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())`
--> $DIR/associated-type.rs:31:1 --> $DIR/associated-type.rs:31:1
| |

View file

@ -1,11 +1,11 @@
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), _use_alias_ty_new_instead: () }
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>` for type `for<'a> fn(&'a (), _)` error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>` for type `for<'a> fn(&'a (), _)`
--> $DIR/associated-type.rs:31:1 --> $DIR/associated-type.rs:31:1
| |

View file

@ -1,5 +1,5 @@
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, !2_0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, !2_0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), _use_alias_ty_new_instead: () }
error[E0277]: the trait bound `for<'a> T: ToUnit<'a>` is not satisfied error[E0277]: the trait bound `for<'a> T: ToUnit<'a>` is not satisfied
--> $DIR/structually-relate-aliases.rs:13:36 --> $DIR/structually-relate-aliases.rs:13:36
| |

View file

@ -25,10 +25,10 @@ help: this trait has no implementations, consider adding one
LL | trait ToUnit<'a> { LL | trait ToUnit<'a> {
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), _use_alias_ty_new_instead: () }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), _use_alias_ty_new_instead: () }
error[E0119]: conflicting implementations of trait `Overlap<fn(_)>` for type `fn(_)` error[E0119]: conflicting implementations of trait `Overlap<fn(_)>` for type `fn(_)`
--> $DIR/issue-118950-root-region.rs:19:1 --> $DIR/issue-118950-root-region.rs:19:1
| |