]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #23691 - richo:dedup-typeorigin-mergable, r=eddyb
authorbors <bors@rust-lang.org>
Thu, 26 Mar 2015 05:44:26 +0000 (05:44 +0000)
committerbors <bors@rust-lang.org>
Thu, 26 Mar 2015 05:44:26 +0000 (05:44 +0000)
I've started on refactoring the error handling code to avoid the need to reparse generated errors in `span_*`, but would rather land this incrementally as one monolithic PR (and have un-fond memories of merge conflicts from various other monoliths)

r? @eddyb

1  2 
src/librustc/middle/infer/mod.rs

index a38adabee915b318b0abe2fcc50fb341743ef0d8,c25862f41c4c61b59b7984715fdfb2775406b44b..8bd3ca826a6b202561d9a041ef26d70313c3ec01
@@@ -29,6 -29,7 +29,7 @@@ use middle::ty::replace_late_bound_regi
  use middle::ty::{self, Ty};
  use middle::ty_fold::{TypeFolder, TypeFoldable};
  use std::cell::{RefCell};
+ use std::fmt;
  use std::rc::Rc;
  use syntax::ast;
  use syntax::codemap;
@@@ -128,6 -129,30 +129,30 @@@ pub enum TypeOrigin 
      EquatePredicate(Span),
  }
  
+ impl TypeOrigin {
+     fn as_str(&self) -> &'static str {
+         match self {
+             &TypeOrigin::Misc(_) |
+             &TypeOrigin::RelateSelfType(_) |
+             &TypeOrigin::RelateOutputImplTypes(_) |
+             &TypeOrigin::ExprAssignable(_) => "mismatched types",
+             &TypeOrigin::RelateTraitRefs(_) => "mismatched traits",
+             &TypeOrigin::MethodCompatCheck(_) => "method not compatible with trait",
+             &TypeOrigin::MatchExpressionArm(_, _) => "match arms have incompatible types",
+             &TypeOrigin::IfExpression(_) => "if and else have incompatible types",
+             &TypeOrigin::IfExpressionWithNoElse(_) => "if may be missing an else clause",
+             &TypeOrigin::RangeExpression(_) => "start and end of range have incompatible types",
+             &TypeOrigin::EquatePredicate(_) => "equality predicate not satisfied",
+         }
+     }
+ }
+ impl fmt::Display for TypeOrigin {
+     fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error> {
+         fmt::Display::fmt(self.as_str(), f)
+     }
+ }
  /// See `error_reporting.rs` for more details
  #[derive(Clone, Debug)]
  pub enum ValuePairs<'tcx> {
@@@ -726,15 -751,6 +751,15 @@@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> 
          })
      }
  
 +    pub fn construct_skolemized_subst(&self,
 +                                      generics: &ty::Generics<'tcx>,
 +                                      snapshot: &CombinedSnapshot)
 +                                      -> (subst::Substs<'tcx>, SkolemizationMap) {
 +        /*! See `higher_ranked::construct_skolemized_subst` */
 +
 +        higher_ranked::construct_skolemized_substs(self, generics, snapshot)
 +    }
 +
      pub fn skolemize_late_bound_regions<T>(&self,
                                             value: &ty::Binder<T>,
                                             snapshot: &CombinedSnapshot)