diff options
| author | yukang <moorekang@gmail.com> | 2022-11-02 23:15:49 +0800 |
|---|---|---|
| committer | yukang <moorekang@gmail.com> | 2022-11-02 23:15:49 +0800 |
| commit | 7df9d818ab07d1d014ac46a1f462d87a2d57ce21 (patch) | |
| tree | 91fce0c9325236110fef8aec590d7ba1165a6043 | |
| parent | 126dbdc9c78446ad4cf41f5f8510a7cee59ff966 (diff) | |
| download | rust-7df9d818ab07d1d014ac46a1f462d87a2d57ce21.tar.gz rust-7df9d818ab07d1d014ac46a1f462d87a2d57ce21.zip | |
deprecate DelaySpanBugEmitted and use ErrorGuaranteed directly
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/operand.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/abstract_const.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/consts/kind.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/structural_impls.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_type_ir/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_type_ir/src/sty.rs | 10 |
8 files changed, 14 insertions, 26 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 0c212cf59e1..dd00678aa0c 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -4,7 +4,7 @@ use rustc_hir::def::Namespace; use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout}; use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter}; -use rustc_middle::ty::{ConstInt, DelaySpanBugEmitted, Ty}; +use rustc_middle::ty::{ConstInt, Ty}; use rustc_middle::{mir, ty}; use rustc_target::abi::{self, Abi, Align, HasDataLayout, Size, TagEncoding}; use rustc_target::abi::{VariantIdx, Variants}; @@ -567,7 +567,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(..) => { throw_inval!(TooGeneric) } - ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => { + ty::ConstKind::Error(reported) => { throw_inval!(AlreadyReported(reported)) } ty::ConstKind::Unevaluated(uv) => { diff --git a/compiler/rustc_middle/src/ty/abstract_const.rs b/compiler/rustc_middle/src/ty/abstract_const.rs index 1aa4df77800..e5bcd5fb27a 100644 --- a/compiler/rustc_middle/src/ty/abstract_const.rs +++ b/compiler/rustc_middle/src/ty/abstract_const.rs @@ -1,7 +1,7 @@ //! A subset of a mir body used for const evaluatability checking. use crate::mir; use crate::ty::visit::TypeVisitable; -use crate::ty::{self, DelaySpanBugEmitted, EarlyBinder, SubstsRef, Ty, TyCtxt}; +use crate::ty::{self, EarlyBinder, SubstsRef, Ty, TyCtxt}; use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::DefId; use std::cmp; @@ -43,7 +43,7 @@ impl<'tcx> AbstractConst<'tcx> { ) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> { match ct.kind() { ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv), - ty::ConstKind::Error(DelaySpanBugEmitted { reported, .. }) => Err(reported), + ty::ConstKind::Error(reported) => Err(reported), _ => Ok(None), } } diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index 4ab761e0715..c1c613f6c60 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -69,7 +69,7 @@ pub enum ConstKind<'tcx> { /// A placeholder for a const which could not be computed; this is /// propagated to avoid useless error messages. - Error(ty::DelaySpanBugEmitted), + Error(ErrorGuaranteed), } #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 94e3f3b63c8..eeb53f9714c 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -116,7 +116,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> { type BoundTy = ty::BoundTy; type PlaceholderType = ty::PlaceholderType; type InferTy = InferTy; - type DelaySpanBugEmitted = DelaySpanBugEmitted; + type ErrorGuaranteed = ErrorGuaranteed; type PredicateKind = ty::PredicateKind<'tcx>; type AllocId = crate::mir::interpret::AllocId; @@ -127,15 +127,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> { type PlaceholderRegion = ty::PlaceholderRegion; } -/// A type that is not publicly constructable. This prevents people from making [`TyKind::Error`]s -/// except through the error-reporting functions on a [`tcx`][TyCtxt]. -#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] -#[derive(TyEncodable, TyDecodable, HashStable)] -pub struct DelaySpanBugEmitted { - pub reported: ErrorGuaranteed, - _priv: (), -} - type InternedSet<'tcx, T> = ShardedHashMap<InternedInSet<'tcx, T>, ()>; pub struct CtxtInterners<'tcx> { @@ -1302,7 +1293,7 @@ impl<'tcx> TyCtxt<'tcx> { #[track_caller] pub fn ty_error_with_message<S: Into<MultiSpan>>(self, span: S, msg: &str) -> Ty<'tcx> { let reported = self.sess.delay_span_bug(span, msg); - self.mk_ty(Error(DelaySpanBugEmitted { reported, _priv: () })) + self.mk_ty(Error(reported)) } /// Like [TyCtxt::ty_error] but for constants. @@ -1325,7 +1316,7 @@ impl<'tcx> TyCtxt<'tcx> { ) -> Const<'tcx> { let reported = self.sess.delay_span_bug(span, msg); self.mk_const(ty::ConstS { - kind: ty::ConstKind::Error(DelaySpanBugEmitted { reported, _priv: () }), + kind: ty::ConstKind::Error(reported), ty, }) } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 9671d3a32f9..9267a541a59 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -80,7 +80,7 @@ pub use self::consts::{ }; pub use self::context::{ tls, CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, - CtxtInterners, DeducedParamAttrs, DelaySpanBugEmitted, FreeRegionInfo, GeneratorDiagnosticData, + CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GeneratorDiagnosticData, GeneratorInteriorTypeCause, GlobalCtxt, Lift, OnDiskCache, TyCtxt, TypeckResults, UserType, UserTypeAnnotationIndex, }; diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 2cad333e3f5..23cd93d6af4 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -240,7 +240,6 @@ TrivialTypeTraversalAndLiftImpls! { Field, interpret::Scalar, rustc_target::abi::Size, - ty::DelaySpanBugEmitted, rustc_type_ir::DebruijnIndex, ty::BoundVar, ty::Placeholder<ty::BoundVar>, diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 7fbe78aa523..7c3eb4efbc9 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -45,7 +45,7 @@ pub trait Interner { type BoundTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord; type PlaceholderType: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord; type InferTy: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord; - type DelaySpanBugEmitted: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord; + type ErrorGuaranteed: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord; type PredicateKind: Clone + Debug + Hash + PartialEq + Eq; type AllocId: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord; diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs index a4fb1480fa4..02cbb2e858f 100644 --- a/compiler/rustc_type_ir/src/sty.rs +++ b/compiler/rustc_type_ir/src/sty.rs @@ -217,7 +217,7 @@ pub enum TyKind<I: Interner> { /// A placeholder for a type which could not be computed; this is /// propagated to avoid useless error messages. - Error(I::DelaySpanBugEmitted), + Error(I::ErrorGuaranteed), } impl<I: Interner> TyKind<I> { @@ -626,7 +626,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> { // This is manually implemented because a derive would require `I: Encodable` impl<I: Interner, E: TyEncoder> Encodable<E> for TyKind<I> where - I::DelaySpanBugEmitted: Encodable<E>, + I::ErrorGuaranteed: Encodable<E>, I::AdtDef: Encodable<E>, I::SubstsRef: Encodable<E>, I::DefId: Encodable<E>, @@ -645,7 +645,6 @@ where I::BoundTy: Encodable<E>, I::PlaceholderType: Encodable<E>, I::InferTy: Encodable<E>, - I::DelaySpanBugEmitted: Encodable<E>, I::PredicateKind: Encodable<E>, I::AllocId: Encodable<E>, { @@ -744,7 +743,7 @@ where // This is manually implemented because a derive would require `I: Decodable` impl<I: Interner, D: TyDecoder<I = I>> Decodable<D> for TyKind<I> where - I::DelaySpanBugEmitted: Decodable<D>, + I::ErrorGuaranteed: Decodable<D>, I::AdtDef: Decodable<D>, I::SubstsRef: Decodable<D>, I::DefId: Decodable<D>, @@ -763,7 +762,6 @@ where I::BoundTy: Decodable<D>, I::PlaceholderType: Decodable<D>, I::InferTy: Decodable<D>, - I::DelaySpanBugEmitted: Decodable<D>, I::PredicateKind: Decodable<D>, I::AllocId: Decodable<D>, { @@ -829,7 +827,7 @@ where I::ParamTy: HashStable<CTX>, I::PlaceholderType: HashStable<CTX>, I::InferTy: HashStable<CTX>, - I::DelaySpanBugEmitted: HashStable<CTX>, + I::ErrorGuaranteed: HashStable<CTX>, { #[inline] fn hash_stable( |
