Skip to content

Commit fe30f62

Browse files
committed
Remove pub use of TypeError in ty.rs
1 parent 754aaea commit fe30f62

File tree

10 files changed

+45
-41
lines changed

10 files changed

+45
-41
lines changed

src/librustc/middle/infer/combine.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf};
4343

4444
use middle::ty::{TyVar};
4545
use middle::ty::{IntType, UintType};
46-
use middle::ty::{self, Ty};
46+
use middle::ty::{self, Ty, TypeError};
4747
use middle::ty_fold;
4848
use middle::ty_fold::{TypeFolder, TypeFoldable};
4949
use middle::ty_relate::{self, Relate, RelateResult, TypeRelation};
@@ -108,7 +108,7 @@ pub fn super_combine_tys<'a,'tcx:'a,R>(infcx: &InferCtxt<'a, 'tcx>,
108108
// All other cases of inference are errors
109109
(&ty::TyInfer(_), _) |
110110
(_, &ty::TyInfer(_)) => {
111-
Err(ty::Sorts(ty_relate::expected_found(relation, &a, &b)))
111+
Err(TypeError::Sorts(ty_relate::expected_found(relation, &a, &b)))
112112
}
113113

114114

@@ -278,7 +278,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
278278
};
279279
let u = ty.fold_with(&mut generalize);
280280
if generalize.cycle_detected {
281-
Err(ty::CyclicTy)
281+
Err(TypeError::CyclicTy)
282282
} else {
283283
Ok(u)
284284
}
@@ -384,13 +384,13 @@ fn int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::Int
384384
-> ty::TypeError<'tcx>
385385
{
386386
let (a, b) = v;
387-
ty::IntMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
387+
TypeError::IntMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
388388
}
389389

390390
fn float_unification_error<'tcx>(a_is_expected: bool,
391391
v: (ast::FloatTy, ast::FloatTy))
392392
-> ty::TypeError<'tcx>
393393
{
394394
let (a, b) = v;
395-
ty::FloatMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
395+
TypeError::FloatMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
396396
}

src/librustc/middle/infer/error_reporting.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ use middle::def;
7777
use middle::infer;
7878
use middle::region;
7979
use middle::subst;
80-
use middle::ty::{self, Ty, HasTypeFlags};
80+
use middle::ty::{self, Ty, TypeError, HasTypeFlags};
8181
use middle::ty::{Region, ReFree};
8282

8383
use std::cell::{Cell, RefCell};
@@ -351,8 +351,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
351351
match free_regions_from_same_fn(self.tcx, sub, sup) {
352352
Some(ref same_frs) if trace.is_some() => {
353353
let trace = trace.unwrap();
354-
let terr = ty::RegionsDoesNotOutlive(sup,
355-
sub);
354+
let terr = TypeError::RegionsDoesNotOutlive(sup,
355+
sub);
356356
trace_origins.push((trace, terr));
357357
append_to_same_regions(&mut same_regions, same_frs);
358358
}
@@ -595,7 +595,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
595595
match origin {
596596
infer::Subtype(trace) |
597597
infer::DefaultExistentialBound(trace) => {
598-
let terr = ty::RegionsDoesNotOutlive(sup, sub);
598+
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
599599
self.report_and_explain_type_error(trace, &terr);
600600
}
601601
infer::Reborrow(span) => {

src/librustc/middle/infer/higher_ranked/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::{CombinedSnapshot, InferCtxt, HigherRankedType, SkolemizationMap};
1515
use super::combine::CombineFields;
1616

1717
use middle::subst;
18-
use middle::ty::{self, Binder};
18+
use middle::ty::{self, TypeError, Binder};
1919
use middle::ty_fold::{self, TypeFoldable};
2020
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
2121
use syntax::codemap::Span;
@@ -85,11 +85,11 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
8585
Err((skol_br, tainted_region)) => {
8686
if self.a_is_expected {
8787
debug!("Not as polymorphic!");
88-
return Err(ty::RegionsInsufficientlyPolymorphic(skol_br,
88+
return Err(TypeError::RegionsInsufficientlyPolymorphic(skol_br,
8989
tainted_region));
9090
} else {
9191
debug!("Overly polymorphic!");
92-
return Err(ty::RegionsOverlyPolymorphic(skol_br,
92+
return Err(TypeError::RegionsOverlyPolymorphic(skol_br,
9393
tainted_region));
9494
}
9595
}

src/librustc/middle/infer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use middle::subst::Subst;
3232
use middle::traits::{self, FulfillmentContext, Normalized,
3333
SelectionContext, ObligationCause};
3434
use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, UnconstrainedNumeric};
35-
use middle::ty::{self, Ty, HasTypeFlags};
35+
use middle::ty::{self, Ty, TypeError, HasTypeFlags};
3636
use middle::ty_fold::{self, TypeFolder, TypeFoldable};
3737
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
3838
use rustc_data_structures::unify::{self, UnificationTable};
@@ -913,7 +913,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
913913

914914
match higher_ranked::leak_check(self, skol_map, snapshot) {
915915
Ok(()) => Ok(()),
916-
Err((br, r)) => Err(ty::RegionsInsufficientlyPolymorphic(br, r))
916+
Err((br, r)) => Err(TypeError::RegionsInsufficientlyPolymorphic(br, r))
917917
}
918918
}
919919

src/librustc/middle/infer/region_inference/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::{RegionVariableOrigin, SubregionOrigin, TypeTrace, MiscVariable};
2323
use rustc_data_structures::graph::{self, Direction, NodeIndex};
2424
use middle::free_region::FreeRegionMap;
2525
use middle::region;
26-
use middle::ty::{self, Ty};
26+
use middle::ty::{self, Ty, TypeError};
2727
use middle::ty::{BoundRegion, FreeRegion, Region, RegionVid};
2828
use middle::ty::{ReEmpty, ReStatic, ReInfer, ReFree, ReEarlyBound};
2929
use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh};
@@ -873,7 +873,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
873873
if self.tcx.region_maps.nearest_common_ancestor(fr_scope, s_id) == fr_scope {
874874
Ok(s)
875875
} else {
876-
Err(ty::RegionsNoOverlap(b, a))
876+
Err(TypeError::RegionsNoOverlap(b, a))
877877
}
878878
}
879879

@@ -892,7 +892,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
892892
if a == b {
893893
Ok(a)
894894
} else {
895-
Err(ty::RegionsNoOverlap(b, a))
895+
Err(TypeError::RegionsNoOverlap(b, a))
896896
}
897897
}
898898
}
@@ -949,7 +949,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
949949
} else if r_id == scope_b {
950950
Ok(ReScope(scope_a))
951951
} else {
952-
Err(ty::RegionsNoOverlap(region_a, region_b))
952+
Err(TypeError::RegionsNoOverlap(region_a, region_b))
953953
}
954954
}
955955
}

src/librustc/middle/ty.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// FIXME: (@jroesch) @eddyb should remove this when he renames ctxt
1212
#![allow(non_camel_case_types)]
1313

14-
pub use self::TypeError::*;
1514
pub use self::InferTy::*;
1615
pub use self::InferRegion::*;
1716
pub use self::ImplOrTraitItemId::*;
@@ -4932,6 +4931,7 @@ impl<'tcx> TyS<'tcx> {
49324931
}
49334932

49344933
fn sort_string(&self, cx: &ctxt) -> String {
4934+
49354935
match self.sty {
49364936
TyBool | TyChar | TyInt(_) |
49374937
TyUint(_) | TyFloat(_) | TyStr => self.to_string(),
@@ -4977,6 +4977,8 @@ impl<'tcx> TyS<'tcx> {
49774977
/// errors.
49784978
impl<'tcx> fmt::Display for TypeError<'tcx> {
49794979
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4980+
use self::TypeError::*;
4981+
49804982
match *self {
49814983
CyclicTy => write!(f, "cyclic type of infinite size"),
49824984
Mismatch => write!(f, "types differ"),
@@ -5413,6 +5415,8 @@ impl<'tcx> ctxt<'tcx> {
54135415
}
54145416

54155417
pub fn note_and_explain_type_err(&self, err: &TypeError<'tcx>, sp: Span) {
5418+
use self::TypeError::*;
5419+
54165420
match *err {
54175421
RegionsDoesNotOutlive(subregion, superregion) => {
54185422
self.note_and_explain_region("", subregion, "...");

src/librustc/middle/ty_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> {
7878

7979
(&ty::TyInfer(_), _) |
8080
(_, &ty::TyInfer(_)) => {
81-
Err(ty::Sorts(ty_relate::expected_found(self, &a, &b)))
81+
Err(ty::TypeError::Sorts(ty_relate::expected_found(self, &a, &b)))
8282
}
8383

8484
(&ty::TyError, _) | (_, &ty::TyError) => {

src/librustc/middle/ty_relate/mod.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! type equality, etc.
1515
1616
use middle::subst::{ErasedRegions, NonerasedRegions, ParamSpace, Substs};
17-
use middle::ty::{self, Ty};
17+
use middle::ty::{self, Ty, TypeError};
1818
use middle::ty_fold::TypeFoldable;
1919
use std::rc::Rc;
2020
use syntax::abi;
@@ -101,7 +101,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeWithMutability<'tcx> {
101101
a,
102102
b);
103103
if a.mutbl != b.mutbl {
104-
Err(ty::Mutability)
104+
Err(TypeError::Mutability)
105105
} else {
106106
let mutbl = a.mutbl;
107107
let variance = match mutbl {
@@ -186,7 +186,7 @@ fn relate_type_params<'a,'tcx:'a,R>(relation: &mut R,
186186
where R: TypeRelation<'a,'tcx>
187187
{
188188
if a_tys.len() != b_tys.len() {
189-
return Err(ty::TyParamSize(expected_found(relation,
189+
return Err(TypeError::TyParamSize(expected_found(relation,
190190
&a_tys.len(),
191191
&b_tys.len())));
192192
}
@@ -256,7 +256,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::FnSig<'tcx> {
256256
where R: TypeRelation<'a,'tcx>
257257
{
258258
if a.variadic != b.variadic {
259-
return Err(ty::VariadicMismatch(
259+
return Err(TypeError::VariadicMismatch(
260260
expected_found(relation, &a.variadic, &b.variadic)));
261261
}
262262

@@ -270,7 +270,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::FnSig<'tcx> {
270270
(ty::FnDiverging, ty::FnDiverging) =>
271271
Ok(ty::FnDiverging),
272272
(a, b) =>
273-
Err(ty::ConvergenceMismatch(
273+
Err(TypeError::ConvergenceMismatch(
274274
expected_found(relation, &(a != ty::FnDiverging), &(b != ty::FnDiverging)))),
275275
});
276276

@@ -287,7 +287,7 @@ fn relate_arg_vecs<'a,'tcx:'a,R>(relation: &mut R,
287287
where R: TypeRelation<'a,'tcx>
288288
{
289289
if a_args.len() != b_args.len() {
290-
return Err(ty::ArgCount);
290+
return Err(TypeError::ArgCount);
291291
}
292292

293293
a_args.iter().zip(b_args)
@@ -303,7 +303,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ast::Unsafety {
303303
where R: TypeRelation<'a,'tcx>
304304
{
305305
if a != b {
306-
Err(ty::UnsafetyMismatch(expected_found(relation, a, b)))
306+
Err(TypeError::UnsafetyMismatch(expected_found(relation, a, b)))
307307
} else {
308308
Ok(*a)
309309
}
@@ -320,7 +320,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for abi::Abi {
320320
if a == b {
321321
Ok(*a)
322322
} else {
323-
Err(ty::AbiMismatch(expected_found(relation, a, b)))
323+
Err(TypeError::AbiMismatch(expected_found(relation, a, b)))
324324
}
325325
}
326326
}
@@ -333,7 +333,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::ProjectionTy<'tcx> {
333333
where R: TypeRelation<'a,'tcx>
334334
{
335335
if a.item_name != b.item_name {
336-
Err(ty::ProjectionNameMismatched(
336+
Err(TypeError::ProjectionNameMismatched(
337337
expected_found(relation, &a.item_name, &b.item_name)))
338338
} else {
339339
let trait_ref = try!(relation.relate(&a.trait_ref, &b.trait_ref));
@@ -368,7 +368,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for Vec<ty::PolyProjectionPredicate<'tcx>> {
368368
// so we can just iterate through the lists pairwise, so long as they are the
369369
// same length.
370370
if a.len() != b.len() {
371-
Err(ty::ProjectionBoundsLength(expected_found(relation, &a.len(), &b.len())))
371+
Err(TypeError::ProjectionBoundsLength(expected_found(relation, &a.len(), &b.len())))
372372
} else {
373373
a.iter().zip(b)
374374
.map(|(a, b)| relation.relate(a, b))
@@ -412,7 +412,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::BuiltinBounds {
412412
// Two sets of builtin bounds are only relatable if they are
413413
// precisely the same (but see the coercion code).
414414
if a != b {
415-
Err(ty::BuiltinBoundsMismatch(expected_found(relation, a, b)))
415+
Err(TypeError::BuiltinBoundsMismatch(expected_found(relation, a, b)))
416416
} else {
417417
Ok(*a)
418418
}
@@ -428,7 +428,7 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TraitRef<'tcx> {
428428
{
429429
// Different traits cannot be related
430430
if a.def_id != b.def_id {
431-
Err(ty::Traits(expected_found(relation, &a.def_id, &b.def_id)))
431+
Err(TypeError::Traits(expected_found(relation, &a.def_id, &b.def_id)))
432432
} else {
433433
let substs = try!(relate_item_substs(relation, a.def_id, a.substs, b.substs));
434434
Ok(ty::TraitRef { def_id: a.def_id, substs: relation.tcx().mk_substs(substs) })
@@ -547,7 +547,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
547547
if sz_a == sz_b {
548548
Ok(tcx.mk_array(t, sz_a))
549549
} else {
550-
Err(ty::FixedArraySize(expected_found(relation, &sz_a, &sz_b)))
550+
Err(TypeError::FixedArraySize(expected_found(relation, &sz_a, &sz_b)))
551551
}
552552
}
553553

@@ -565,10 +565,10 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
565565
.collect::<Result<_, _>>());
566566
Ok(tcx.mk_tup(ts))
567567
} else if !(as_.is_empty() || bs.is_empty()) {
568-
Err(ty::TupleSize(
568+
Err(TypeError::TupleSize(
569569
expected_found(relation, &as_.len(), &bs.len())))
570570
} else {
571-
Err(ty::Sorts(expected_found(relation, &a, &b)))
571+
Err(TypeError::Sorts(expected_found(relation, &a, &b)))
572572
}
573573
}
574574

@@ -587,7 +587,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
587587

588588
_ =>
589589
{
590-
Err(ty::Sorts(expected_found(relation, &a, &b)))
590+
Err(TypeError::Sorts(expected_found(relation, &a, &b)))
591591
}
592592
}
593593
}

src/librustc_typeck/check/coercion.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use middle::infer::{self, Coercion};
6666
use middle::traits::{self, ObligationCause};
6767
use middle::traits::{predicate_for_trait_def, report_selection_error};
6868
use middle::ty::{AutoDerefRef, AdjustDerefRef};
69-
use middle::ty::{self, TypeWithMutability, Ty};
69+
use middle::ty::{self, TypeWithMutability, Ty, TypeError};
7070
use middle::ty_relate::RelateResult;
7171
use util::common::indent;
7272

@@ -247,7 +247,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
247247
(u, cu)
248248
} else {
249249
debug!("Missing Unsize or CoerceUnsized traits");
250-
return Err(ty::Mismatch);
250+
return Err(TypeError::Mismatch);
251251
};
252252

253253
// Note, we want to avoid unnecessary unsizing. We don't want to coerce to
@@ -307,7 +307,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
307307
// Uncertain or unimplemented.
308308
Ok(None) | Err(traits::Unimplemented) => {
309309
debug!("coerce_unsized: early return - can't prove obligation");
310-
return Err(ty::Mismatch);
310+
return Err(TypeError::Mismatch);
311311
}
312312

313313
// Object safety violations or miscellaneous.
@@ -472,6 +472,6 @@ fn coerce_mutbls<'tcx>(from_mutbl: ast::Mutability,
472472
(ast::MutMutable, ast::MutMutable) |
473473
(ast::MutImmutable, ast::MutImmutable) |
474474
(ast::MutMutable, ast::MutImmutable) => Ok(None),
475-
(ast::MutImmutable, ast::MutMutable) => Err(ty::Mutability)
475+
(ast::MutImmutable, ast::MutMutable) => Err(TypeError::Mutability)
476476
}
477477
}

src/librustc_typeck/coherence/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
454454
mk_ptr: &Fn(Ty<'tcx>) -> Ty<'tcx>| {
455455
if (mt_a.mutbl, mt_b.mutbl) == (ast::MutImmutable, ast::MutMutable) {
456456
infcx.report_mismatched_types(span, mk_ptr(mt_b.ty),
457-
target, &ty::Mutability);
457+
target, &ty::TypeError::Mutability);
458458
}
459459
(mt_a.ty, mt_b.ty, unsize_trait, None)
460460
};

0 commit comments

Comments
 (0)