Skip to content

Commit 268decb

Browse files
committed
make all uses of ty::Error or ConstKind::Error delay a span bug
1 parent f315c35 commit 268decb

File tree

71 files changed

+279
-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.

71 files changed

+279
-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_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),

src/librustc_middle/ty/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl TypeRelation<'tcx> for Match<'tcx> {
7979
Err(TypeError::Sorts(relate::expected_found(self, &a, &b)))
8080
}
8181

82-
(&ty::Error, _) | (_, &ty::Error) => Ok(self.tcx().types.err),
82+
(&ty::Error(_), _) | (_, &ty::Error(_)) => Ok(self.tcx().ty_error()),
8383

8484
_ => relate::super_relate_tys(self, a, b),
8585
}

0 commit comments

Comments
 (0)