Skip to content

Commit 09427f6

Browse files
authored
Rollup merge of rust-lang#70551 - mark-i-m:ty-err-2, r=varkor
Make all uses of ty::Error delay a span bug r? @eddyb A second attempt at rust-lang#70245 resolves rust-lang#70866
2 parents 7d16c1d + cfdbbb5 commit 09427f6

File tree

72 files changed

+254
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+254
-225
lines changed

src/librustc_codegen_ssa/debuginfo/type_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub fn push_debuginfo_type_name<'tcx>(
195195
tcx.def_key(def_id).disambiguated_data.disambiguator
196196
));
197197
}
198-
ty::Error
198+
ty::Error(_)
199199
| ty::Infer(_)
200200
| ty::Placeholder(..)
201201
| ty::Projection(..)

src/librustc_errors/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
66
#![feature(crate_visibility_modifier)]
77
#![feature(nll)]
8+
#![feature(track_caller)]
89

910
pub use emitter::ColorConfig;
1011

@@ -621,6 +622,7 @@ impl Handler {
621622
self.inner.borrow_mut().span_bug(span, msg)
622623
}
623624

625+
#[track_caller]
624626
pub fn delay_span_bug(&self, span: impl Into<MultiSpan>, msg: &str) {
625627
self.inner.borrow_mut().delay_span_bug(span, msg)
626628
}
@@ -873,6 +875,7 @@ impl HandlerInner {
873875
self.emit_diagnostic(diag.set_span(sp));
874876
}
875877

878+
#[track_caller]
876879
fn delay_span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) {
877880
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
878881
// incrementing `err_count` by one, so we need to +1 the comparing.
@@ -883,6 +886,7 @@ impl HandlerInner {
883886
}
884887
let mut diagnostic = Diagnostic::new(Level::Bug, msg);
885888
diagnostic.set_span(sp.into());
889+
diagnostic.note(&format!("delayed at {}", std::panic::Location::caller()));
886890
self.delay_as_bug(diagnostic)
887891
}
888892

src/librustc_infer/infer/canonical/canonicalizer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
403403
| ty::Float(..)
404404
| ty::Adt(..)
405405
| ty::Str
406-
| ty::Error
406+
| ty::Error(_)
407407
| ty::Array(..)
408408
| ty::Slice(..)
409409
| ty::RawPtr(..)

src/librustc_infer/infer/canonical/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
154154
self.tcx
155155
.mk_const(ty::Const {
156156
val: ty::ConstKind::Placeholder(placeholder_mapped),
157-
ty: self.tcx.types.err, // FIXME(const_generics)
157+
ty: self.tcx.ty_error(), // FIXME(const_generics)
158158
})
159159
.into()
160160
}

src/librustc_infer/infer/freshen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
192192
| ty::Float(..)
193193
| ty::Adt(..)
194194
| ty::Str
195-
| ty::Error
195+
| ty::Error(_)
196196
| ty::Array(..)
197197
| ty::Slice(..)
198198
| ty::RawPtr(..)
@@ -250,7 +250,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
250250
ty::ConstKind::Param(_)
251251
| ty::ConstKind::Value(_)
252252
| ty::ConstKind::Unevaluated(..)
253-
| ty::ConstKind::Error => {}
253+
| ty::ConstKind::Error(_) => {}
254254
}
255255

256256
ct.super_fold_with(self)

src/librustc_infer/infer/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1751,9 +1751,10 @@ impl<'tcx> TypeTrace<'tcx> {
17511751
}
17521752

17531753
pub fn dummy(tcx: TyCtxt<'tcx>) -> TypeTrace<'tcx> {
1754+
let err = tcx.ty_error();
17541755
TypeTrace {
17551756
cause: ObligationCause::dummy(),
1756-
values: Types(ExpectedFound { expected: tcx.types.err, found: tcx.types.err }),
1757+
values: Types(ExpectedFound { expected: err, found: err }),
17571758
}
17581759
}
17591760
}

src/librustc_infer/infer/resolve.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,15 @@ impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
189189
match t.kind {
190190
ty::Infer(ty::TyVar(vid)) => {
191191
self.err = Some(FixupError::UnresolvedTy(vid));
192-
self.tcx().types.err
192+
self.tcx().ty_error()
193193
}
194194
ty::Infer(ty::IntVar(vid)) => {
195195
self.err = Some(FixupError::UnresolvedIntTy(vid));
196-
self.tcx().types.err
196+
self.tcx().ty_error()
197197
}
198198
ty::Infer(ty::FloatVar(vid)) => {
199199
self.err = Some(FixupError::UnresolvedFloatTy(vid));
200-
self.tcx().types.err
200+
self.tcx().ty_error()
201201
}
202202
ty::Infer(_) => {
203203
bug!("Unexpected type in full type resolver: {:?}", t);
@@ -228,7 +228,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
228228
match c.val {
229229
ty::ConstKind::Infer(InferConst::Var(vid)) => {
230230
self.err = Some(FixupError::UnresolvedConst(vid));
231-
return self.tcx().mk_const(ty::Const { val: ty::ConstKind::Error, ty: c.ty });
231+
return self.tcx().const_error(c.ty);
232232
}
233233
ty::ConstKind::Infer(InferConst::Fresh(_)) => {
234234
bug!("Unexpected const in full const resolver: {:?}", c);

src/librustc_infer/infer/sub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
119119
Ok(a)
120120
}
121121

122-
(&ty::Error, _) | (_, &ty::Error) => {
122+
(&ty::Error(_), _) | (_, &ty::Error(_)) => {
123123
infcx.set_tainted_by_errors();
124-
Ok(self.tcx().types.err)
124+
Ok(self.tcx().ty_error())
125125
}
126126

127127
_ => {

src/librustc_lint/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
889889
ty::Param(..)
890890
| ty::Infer(..)
891891
| ty::Bound(..)
892-
| ty::Error
892+
| ty::Error(_)
893893
| ty::Closure(..)
894894
| ty::Generator(..)
895895
| ty::GeneratorWitness(..)

src/librustc_middle/traits/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
221221
| ty::Ref(..)
222222
| ty::Str
223223
| ty::Foreign(..)
224-
| ty::Error => true,
224+
| ty::Error(_) => true,
225225

226226
// [T; N] and [T] have same properties as T.
227227
ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, ty),

0 commit comments

Comments
 (0)