1414//! type equality, etc.
1515
1616use middle:: subst:: { ErasedRegions , NonerasedRegions , ParamSpace , Substs } ;
17- use middle:: ty:: { self , Ty } ;
17+ use middle:: ty:: { self , Ty , TypeError } ;
1818use middle:: ty_fold:: TypeFoldable ;
1919use std:: rc:: Rc ;
2020use 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}
0 commit comments