Skip to content

Commit 7df9d81

Browse files
committed
deprecate DelaySpanBugEmitted and use ErrorGuaranteed directly
1 parent 126dbdc commit 7df9d81

File tree

8 files changed

+14
-26
lines changed

8 files changed

+14
-26
lines changed

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use rustc_hir::def::Namespace;
55
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
66
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
7-
use rustc_middle::ty::{ConstInt, DelaySpanBugEmitted, Ty};
7+
use rustc_middle::ty::{ConstInt, Ty};
88
use rustc_middle::{mir, ty};
99
use rustc_target::abi::{self, Abi, Align, HasDataLayout, Size, TagEncoding};
1010
use rustc_target::abi::{VariantIdx, Variants};
@@ -567,7 +567,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
567567
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(..) => {
568568
throw_inval!(TooGeneric)
569569
}
570-
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => {
570+
ty::ConstKind::Error(reported) => {
571571
throw_inval!(AlreadyReported(reported))
572572
}
573573
ty::ConstKind::Unevaluated(uv) => {

compiler/rustc_middle/src/ty/abstract_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! A subset of a mir body used for const evaluatability checking.
22
use crate::mir;
33
use crate::ty::visit::TypeVisitable;
4-
use crate::ty::{self, DelaySpanBugEmitted, EarlyBinder, SubstsRef, Ty, TyCtxt};
4+
use crate::ty::{self, EarlyBinder, SubstsRef, Ty, TyCtxt};
55
use rustc_errors::ErrorGuaranteed;
66
use rustc_hir::def_id::DefId;
77
use std::cmp;
@@ -43,7 +43,7 @@ impl<'tcx> AbstractConst<'tcx> {
4343
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
4444
match ct.kind() {
4545
ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv),
46-
ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => Err(reported),
46+
ty::ConstKind::Error(reported) => Err(reported),
4747
_ => Ok(None),
4848
}
4949
}

compiler/rustc_middle/src/ty/consts/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub enum ConstKind<'tcx> {
6969

7070
/// A placeholder for a const which could not be computed; this is
7171
/// propagated to avoid useless error messages.
72-
Error(ty::DelaySpanBugEmitted),
72+
Error(ErrorGuaranteed),
7373
}
7474

7575
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]

compiler/rustc_middle/src/ty/context.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
116116
type BoundTy = ty::BoundTy;
117117
type PlaceholderType = ty::PlaceholderType;
118118
type InferTy = InferTy;
119-
type DelaySpanBugEmitted = DelaySpanBugEmitted;
119+
type ErrorGuaranteed = ErrorGuaranteed;
120120
type PredicateKind = ty::PredicateKind<'tcx>;
121121
type AllocId = crate::mir::interpret::AllocId;
122122

@@ -127,15 +127,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
127127
type PlaceholderRegion = ty::PlaceholderRegion;
128128
}
129129

130-
/// A type that is not publicly constructable. This prevents people from making [`TyKind::Error`]s
131-
/// except through the error-reporting functions on a [`tcx`][TyCtxt].
132-
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
133-
#[derive(TyEncodable, TyDecodable, HashStable)]
134-
pub struct DelaySpanBugEmitted {
135-
pub reported: ErrorGuaranteed,
136-
_priv: (),
137-
}
138-
139130
type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>;
140131

141132
pub struct CtxtInterners<'tcx> {
@@ -1302,7 +1293,7 @@ impl<'tcx> TyCtxt<'tcx> {
13021293
#[track_caller]
13031294
pub fn ty_error_with_message<S: Into<MultiSpan>>(self, span: S, msg: &str) -> Ty<'tcx> {
13041295
let reported = self.sess.delay_span_bug(span, msg);
1305-
self.mk_ty(Error(DelaySpanBugEmitted { reported, _priv: () }))
1296+
self.mk_ty(Error(reported))
13061297
}
13071298

13081299
/// Like [TyCtxt::ty_error] but for constants.
@@ -1325,7 +1316,7 @@ impl<'tcx> TyCtxt<'tcx> {
13251316
) -> Const<'tcx> {
13261317
let reported = self.sess.delay_span_bug(span, msg);
13271318
self.mk_const(ty::ConstS {
1328-
kind: ty::ConstKind::Error(DelaySpanBugEmitted { reported, _priv: () }),
1319+
kind: ty::ConstKind::Error(reported),
13291320
ty,
13301321
})
13311322
}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub use self::consts::{
8080
};
8181
pub use self::context::{
8282
tls, CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
83-
CtxtInterners, DeducedParamAttrs, DelaySpanBugEmitted, FreeRegionInfo, GeneratorDiagnosticData,
83+
CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GeneratorDiagnosticData,
8484
GeneratorInteriorTypeCause, GlobalCtxt, Lift, OnDiskCache, TyCtxt, TypeckResults, UserType,
8585
UserTypeAnnotationIndex,
8686
};

compiler/rustc_middle/src/ty/structural_impls.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ TrivialTypeTraversalAndLiftImpls! {
240240
Field,
241241
interpret::Scalar,
242242
rustc_target::abi::Size,
243-
ty::DelaySpanBugEmitted,
244243
rustc_type_ir::DebruijnIndex,
245244
ty::BoundVar,
246245
ty::Placeholder<ty::BoundVar>,

compiler/rustc_type_ir/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub trait Interner {
4545
type BoundTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
4646
type PlaceholderType: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
4747
type InferTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
48-
type DelaySpanBugEmitted: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
48+
type ErrorGuaranteed: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
4949
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
5050
type AllocId: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
5151

compiler/rustc_type_ir/src/sty.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub enum TyKind<I: Interner> {
217217

218218
/// A placeholder for a type which could not be computed; this is
219219
/// propagated to avoid useless error messages.
220-
Error(I::DelaySpanBugEmitted),
220+
Error(I::ErrorGuaranteed),
221221
}
222222

223223
impl<I: Interner> TyKind<I> {
@@ -626,7 +626,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> {
626626
// This is manually implemented because a derive would require `I: Encodable`
627627
impl<I: Interner, E: TyEncoder> Encodable<E> for TyKind<I>
628628
where
629-
I::DelaySpanBugEmitted: Encodable<E>,
629+
I::ErrorGuaranteed: Encodable<E>,
630630
I::AdtDef: Encodable<E>,
631631
I::SubstsRef: Encodable<E>,
632632
I::DefId: Encodable<E>,
@@ -645,7 +645,6 @@ where
645645
I::BoundTy: Encodable<E>,
646646
I::PlaceholderType: Encodable<E>,
647647
I::InferTy: Encodable<E>,
648-
I::DelaySpanBugEmitted: Encodable<E>,
649648
I::PredicateKind: Encodable<E>,
650649
I::AllocId: Encodable<E>,
651650
{
@@ -744,7 +743,7 @@ where
744743
// This is manually implemented because a derive would require `I: Decodable`
745744
impl<I: Interner, D: TyDecoder<I = I>> Decodable<D> for TyKind<I>
746745
where
747-
I::DelaySpanBugEmitted: Decodable<D>,
746+
I::ErrorGuaranteed: Decodable<D>,
748747
I::AdtDef: Decodable<D>,
749748
I::SubstsRef: Decodable<D>,
750749
I::DefId: Decodable<D>,
@@ -763,7 +762,6 @@ where
763762
I::BoundTy: Decodable<D>,
764763
I::PlaceholderType: Decodable<D>,
765764
I::InferTy: Decodable<D>,
766-
I::DelaySpanBugEmitted: Decodable<D>,
767765
I::PredicateKind: Decodable<D>,
768766
I::AllocId: Decodable<D>,
769767
{
@@ -829,7 +827,7 @@ where
829827
I::ParamTy: HashStable<CTX>,
830828
I::PlaceholderType: HashStable<CTX>,
831829
I::InferTy: HashStable<CTX>,
832-
I::DelaySpanBugEmitted: HashStable<CTX>,
830+
I::ErrorGuaranteed: HashStable<CTX>,
833831
{
834832
#[inline]
835833
fn hash_stable(

0 commit comments

Comments
 (0)