Auto merge of #26351 - eddyb:tls-tcx, r=nikomatsakis
Pre-requisite for splitting the type context into global and local parts. The `Repr` and `UserString` traits were also replaced by `Debug` and `Display`.
This commit is contained in:
commit
e4efb47b9d
116 changed files with 3577 additions and 4529 deletions
|
|
@ -51,6 +51,7 @@
|
|||
#![feature(ref_slice)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(rustc_private)]
|
||||
#![feature(scoped_tls)]
|
||||
#![feature(slice_bytes)]
|
||||
#![feature(slice_extras)]
|
||||
#![feature(slice_patterns)]
|
||||
|
|
|
|||
|
|
@ -898,7 +898,7 @@ fn parse_builtin_bounds<F>(st: &mut PState, mut _conv: F) -> ty::BuiltinBounds w
|
|||
fn parse_builtin_bounds_<F>(st: &mut PState, _conv: &mut F) -> ty::BuiltinBounds where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
let mut builtin_bounds = ty::empty_builtin_bounds();
|
||||
let mut builtin_bounds = ty::BuiltinBounds::empty();
|
||||
|
||||
loop {
|
||||
match next(st) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
use middle::def;
|
||||
use middle::ty::{self, Ty};
|
||||
use syntax::ast;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
pub const NO_REGIONS: usize = 1;
|
||||
pub const NO_TPS: usize = 2;
|
||||
|
|
@ -63,7 +62,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
|
|||
let def = match tcx.def_map.borrow().get(&ast_ty.id) {
|
||||
None => {
|
||||
tcx.sess.span_bug(ast_ty.span,
|
||||
&format!("unbound path {}", path.repr(tcx)))
|
||||
&format!("unbound path {:?}", path))
|
||||
}
|
||||
Some(d) => d.full_def()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ use middle::privacy::{AllPublic, LastMod};
|
|||
use middle::subst;
|
||||
use middle::subst::VecPerParamSpace;
|
||||
use middle::ty::{self, Ty, MethodCall, MethodCallee, MethodOrigin};
|
||||
use util::ppaux::ty_to_string;
|
||||
|
||||
use syntax::{ast, ast_util, codemap, fold};
|
||||
use syntax::codemap::Span;
|
||||
|
|
@ -1623,8 +1622,8 @@ fn decode_side_tables(dcx: &DecodeContext,
|
|||
}
|
||||
c::tag_table_node_type => {
|
||||
let ty = val_dsr.read_ty(dcx);
|
||||
debug!("inserting ty for node {}: {}",
|
||||
id, ty_to_string(dcx.tcx, ty));
|
||||
debug!("inserting ty for node {}: {:?}",
|
||||
id, ty);
|
||||
dcx.tcx.node_type_insert(id, ty);
|
||||
}
|
||||
c::tag_table_item_subst => {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ use middle::mem_categorization as mc;
|
|||
use middle::traits;
|
||||
use middle::ty::{self, Ty};
|
||||
use util::nodemap::NodeMap;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
|
|
@ -300,7 +299,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
debug!("visit_item(item={})", i.repr(self.tcx));
|
||||
debug!("visit_item(item={})", self.tcx.map.node_to_string(i.id));
|
||||
match i.node {
|
||||
ast::ItemStatic(_, ast::MutImmutable, ref expr) => {
|
||||
self.check_static_type(&**expr);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ use syntax::print::pprust::pat_to_string;
|
|||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use syntax::visit::{self, Visitor, FnKind};
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::nodemap::FnvHashMap;
|
||||
|
||||
pub const DUMMY_WILD_PAT: &'static Pat = &Pat {
|
||||
|
|
@ -209,9 +208,8 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
|
|||
if !type_is_empty(cx.tcx, pat_ty) {
|
||||
// We know the type is inhabited, so this must be wrong
|
||||
span_err!(cx.tcx.sess, ex.span, E0002,
|
||||
"non-exhaustive patterns: type {} is non-empty",
|
||||
ty_to_string(cx.tcx, pat_ty)
|
||||
);
|
||||
"non-exhaustive patterns: type {} is non-empty",
|
||||
pat_ty);
|
||||
}
|
||||
// If the type *is* empty, it's vacuously exhaustive
|
||||
return;
|
||||
|
|
@ -244,11 +242,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
|
|||
span_warn!(cx.tcx.sess, p.span, E0170,
|
||||
"pattern binding `{}` is named the same as one \
|
||||
of the variants of the type `{}`",
|
||||
&token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty));
|
||||
&token::get_ident(ident.node), pat_ty);
|
||||
fileline_help!(cx.tcx.sess, p.span,
|
||||
"if you meant to match on a variant, \
|
||||
consider making the path in the pattern qualified: `{}::{}`",
|
||||
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node));
|
||||
pat_ty, &token::get_ident(ident.node));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ use middle::expr_use_visitor as euv;
|
|||
use middle::mem_categorization as mc;
|
||||
use middle::ty::ParameterEnvironment;
|
||||
use middle::ty;
|
||||
use util::ppaux::ty_to_string;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
|
|
@ -59,11 +58,11 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
|
|||
span: Span,
|
||||
cmt: mc::cmt<'tcx>,
|
||||
_: euv::ConsumeMode) {
|
||||
debug!("consume; cmt: {:?}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty));
|
||||
debug!("consume; cmt: {:?}; type: {:?}", *cmt, cmt.ty);
|
||||
if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) {
|
||||
span_err!(self.tcx.sess, span, E0161,
|
||||
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
|
||||
ty_to_string(self.tcx, cmt.ty));
|
||||
cmt.ty);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use middle::pat_util::def_to_path;
|
|||
use middle::ty::{self, Ty};
|
||||
use middle::astconv_util::ast_ty_to_prim_ty;
|
||||
use util::num::ToPrimitive;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use syntax::ast::{self, Expr};
|
||||
use syntax::ast_util;
|
||||
|
|
@ -1030,8 +1029,8 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
|
|||
rcvr_self,
|
||||
Vec::new()));
|
||||
let trait_substs = tcx.mk_substs(trait_substs);
|
||||
debug!("resolve_trait_associated_const: trait_substs={}",
|
||||
trait_substs.repr(tcx));
|
||||
debug!("resolve_trait_associated_const: trait_substs={:?}",
|
||||
trait_substs);
|
||||
let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id,
|
||||
substs: trait_substs });
|
||||
|
||||
|
|
@ -1052,10 +1051,10 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
|
|||
}
|
||||
Err(e) => {
|
||||
tcx.sess.span_bug(ti.span,
|
||||
&format!("Encountered error `{}` when trying \
|
||||
&format!("Encountered error `{:?}` when trying \
|
||||
to select an implementation for \
|
||||
constant trait item reference.",
|
||||
e.repr(tcx)))
|
||||
e))
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ use self::UnsafeContext::*;
|
|||
use middle::def;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty::MethodCall;
|
||||
use util::ppaux;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
|
|
@ -66,8 +65,8 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
|
|||
ast::ExprIndex(ref base, _) => ty::node_id_to_type(self.tcx, base.id),
|
||||
_ => return
|
||||
};
|
||||
debug!("effect: checking index with base type {}",
|
||||
ppaux::ty_to_string(self.tcx, base_type));
|
||||
debug!("effect: checking index with base type {:?}",
|
||||
base_type);
|
||||
match base_type.sty {
|
||||
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty {
|
||||
span_err!(self.tcx.sess, e.span, E0134,
|
||||
|
|
@ -142,8 +141,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
|||
ast::ExprMethodCall(_, _, _) => {
|
||||
let method_call = MethodCall::expr(expr.id);
|
||||
let base_type = self.tcx.method_map.borrow().get(&method_call).unwrap().ty;
|
||||
debug!("effect: method call case, base type is {}",
|
||||
ppaux::ty_to_string(self.tcx, base_type));
|
||||
debug!("effect: method call case, base type is {:?}",
|
||||
base_type);
|
||||
if type_is_unsafe_function(base_type) {
|
||||
self.require_unsafe(expr.span,
|
||||
"invocation of unsafe method")
|
||||
|
|
@ -151,16 +150,16 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
|||
}
|
||||
ast::ExprCall(ref base, _) => {
|
||||
let base_type = ty::node_id_to_type(self.tcx, base.id);
|
||||
debug!("effect: call case, base type is {}",
|
||||
ppaux::ty_to_string(self.tcx, base_type));
|
||||
debug!("effect: call case, base type is {:?}",
|
||||
base_type);
|
||||
if type_is_unsafe_function(base_type) {
|
||||
self.require_unsafe(expr.span, "call to unsafe function")
|
||||
}
|
||||
}
|
||||
ast::ExprUnary(ast::UnDeref, ref base) => {
|
||||
let base_type = ty::node_id_to_type(self.tcx, base.id);
|
||||
debug!("effect: unary case, base type is {}",
|
||||
ppaux::ty_to_string(self.tcx, base_type));
|
||||
debug!("effect: unary case, base type is {:?}",
|
||||
base_type);
|
||||
if let ty::TyRawPtr(_) = base_type.sty {
|
||||
self.require_unsafe(expr.span, "dereference of raw pointer")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ use middle::ty::{self};
|
|||
use middle::ty::{MethodCall, MethodObject, MethodTraitObject};
|
||||
use middle::ty::{MethodOrigin, MethodParam, MethodTypeParam};
|
||||
use middle::ty::{MethodStatic, MethodStaticClosure};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use syntax::{ast, ast_util};
|
||||
use syntax::ptr::P;
|
||||
|
|
@ -362,8 +361,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
consume_id: ast::NodeId,
|
||||
consume_span: Span,
|
||||
cmt: mc::cmt<'tcx>) {
|
||||
debug!("delegate_consume(consume_id={}, cmt={})",
|
||||
consume_id, cmt.repr(self.tcx()));
|
||||
debug!("delegate_consume(consume_id={}, cmt={:?})",
|
||||
consume_id, cmt);
|
||||
|
||||
let mode = copy_or_move(self.typer, &cmt, DirectRefMove);
|
||||
self.delegate.consume(consume_id, consume_span, cmt, mode);
|
||||
|
|
@ -376,7 +375,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
}
|
||||
|
||||
pub fn consume_expr(&mut self, expr: &ast::Expr) {
|
||||
debug!("consume_expr(expr={})", expr.repr(self.tcx()));
|
||||
debug!("consume_expr(expr={:?})", expr);
|
||||
|
||||
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
||||
self.delegate_consume(expr.id, expr.span, cmt);
|
||||
|
|
@ -397,8 +396,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
r: ty::Region,
|
||||
bk: ty::BorrowKind,
|
||||
cause: LoanCause) {
|
||||
debug!("borrow_expr(expr={}, r={}, bk={})",
|
||||
expr.repr(self.tcx()), r.repr(self.tcx()), bk.repr(self.tcx()));
|
||||
debug!("borrow_expr(expr={:?}, r={:?}, bk={:?})",
|
||||
expr, r, bk);
|
||||
|
||||
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
||||
self.delegate.borrow(expr.id, expr.span, cmt, r, bk, cause);
|
||||
|
|
@ -414,7 +413,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
}
|
||||
|
||||
pub fn walk_expr(&mut self, expr: &ast::Expr) {
|
||||
debug!("walk_expr(expr={})", expr.repr(self.tcx()));
|
||||
debug!("walk_expr(expr={:?})", expr);
|
||||
|
||||
self.walk_adjustment(expr);
|
||||
|
||||
|
|
@ -618,8 +617,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
|
||||
fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) {
|
||||
let callee_ty = return_if_err!(self.typer.expr_ty_adjusted(callee));
|
||||
debug!("walk_callee: callee={} callee_ty={}",
|
||||
callee.repr(self.tcx()), callee_ty.repr(self.tcx()));
|
||||
debug!("walk_callee: callee={:?} callee_ty={:?}",
|
||||
callee, callee_ty);
|
||||
let call_scope = region::CodeExtent::from_node_id(call.id);
|
||||
match callee_ty.sty {
|
||||
ty::TyBareFn(..) => {
|
||||
|
|
@ -637,7 +636,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
None => {
|
||||
self.tcx().sess.span_bug(
|
||||
callee.span,
|
||||
&format!("unexpected callee type {}", callee_ty.repr(self.tcx())))
|
||||
&format!("unexpected callee type {}", callee_ty))
|
||||
}
|
||||
};
|
||||
match overloaded_call_type {
|
||||
|
|
@ -811,7 +810,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
fn walk_autoderefs(&mut self,
|
||||
expr: &ast::Expr,
|
||||
autoderefs: usize) {
|
||||
debug!("walk_autoderefs expr={} autoderefs={}", expr.repr(self.tcx()), autoderefs);
|
||||
debug!("walk_autoderefs expr={:?} autoderefs={}", expr, autoderefs);
|
||||
|
||||
for i in 0..autoderefs {
|
||||
let deref_id = ty::MethodCall::autoderef(expr.id, i as u32);
|
||||
|
|
@ -828,8 +827,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
let (m, r) = match self_ty.sty {
|
||||
ty::TyRef(r, ref m) => (m.mutbl, r),
|
||||
_ => self.tcx().sess.span_bug(expr.span,
|
||||
&format!("bad overloaded deref type {}",
|
||||
method_ty.repr(self.tcx())))
|
||||
&format!("bad overloaded deref type {:?}",
|
||||
method_ty))
|
||||
};
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
self.delegate.borrow(expr.id, expr.span, cmt,
|
||||
|
|
@ -842,9 +841,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
fn walk_autoderefref(&mut self,
|
||||
expr: &ast::Expr,
|
||||
adj: &ty::AutoDerefRef<'tcx>) {
|
||||
debug!("walk_autoderefref expr={} adj={}",
|
||||
expr.repr(self.tcx()),
|
||||
adj.repr(self.tcx()));
|
||||
debug!("walk_autoderefref expr={:?} adj={:?}",
|
||||
expr,
|
||||
adj);
|
||||
|
||||
self.walk_autoderefs(expr, adj.autoderefs);
|
||||
|
||||
|
|
@ -875,9 +874,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
opt_autoref: Option<ty::AutoRef<'tcx>>)
|
||||
-> mc::cmt<'tcx>
|
||||
{
|
||||
debug!("walk_autoref(expr.id={} cmt_derefd={} opt_autoref={:?})",
|
||||
debug!("walk_autoref(expr.id={} cmt_derefd={:?} opt_autoref={:?})",
|
||||
expr.id,
|
||||
cmt_base.repr(self.tcx()),
|
||||
cmt_base,
|
||||
opt_autoref);
|
||||
|
||||
let cmt_base_ty = cmt_base.ty;
|
||||
|
|
@ -901,9 +900,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
}
|
||||
|
||||
ty::AutoUnsafe(m) => {
|
||||
debug!("walk_autoref: expr.id={} cmt_base={}",
|
||||
debug!("walk_autoref: expr.id={} cmt_base={:?}",
|
||||
expr.id,
|
||||
cmt_base.repr(self.tcx()));
|
||||
cmt_base);
|
||||
|
||||
// Converting from a &T to *T (or &mut T to *mut T) is
|
||||
// treated as borrowing it for the enclosing temporary
|
||||
|
|
@ -1011,8 +1010,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
cmt_discr: mc::cmt<'tcx>,
|
||||
pat: &ast::Pat,
|
||||
mode: &mut TrackMatchMode) {
|
||||
debug!("determine_pat_move_mode cmt_discr={} pat={}", cmt_discr.repr(self.tcx()),
|
||||
pat.repr(self.tcx()));
|
||||
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr,
|
||||
pat);
|
||||
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| {
|
||||
let tcx = self.tcx();
|
||||
let def_map = &self.tcx().def_map;
|
||||
|
|
@ -1043,8 +1042,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
cmt_discr: mc::cmt<'tcx>,
|
||||
pat: &ast::Pat,
|
||||
match_mode: MatchMode) {
|
||||
debug!("walk_pat cmt_discr={} pat={}", cmt_discr.repr(self.tcx()),
|
||||
pat.repr(self.tcx()));
|
||||
debug!("walk_pat cmt_discr={:?} pat={:?}", cmt_discr,
|
||||
pat);
|
||||
|
||||
let mc = &self.mc;
|
||||
let typer = self.typer;
|
||||
|
|
@ -1054,9 +1053,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
if pat_util::pat_is_binding(def_map, pat) {
|
||||
let tcx = typer.tcx();
|
||||
|
||||
debug!("binding cmt_pat={} pat={} match_mode={:?}",
|
||||
cmt_pat.repr(tcx),
|
||||
pat.repr(tcx),
|
||||
debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}",
|
||||
cmt_pat,
|
||||
pat,
|
||||
match_mode);
|
||||
|
||||
// pat_ty: the type of the binding being produced.
|
||||
|
|
@ -1160,9 +1159,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
mc.cat_downcast(pat, cmt_pat, cmt_pat_ty, variant_did)
|
||||
};
|
||||
|
||||
debug!("variant downcast_cmt={} pat={}",
|
||||
downcast_cmt.repr(tcx),
|
||||
pat.repr(tcx));
|
||||
debug!("variant downcast_cmt={:?} pat={:?}",
|
||||
downcast_cmt,
|
||||
pat);
|
||||
|
||||
delegate.matched_pat(pat, downcast_cmt, match_mode);
|
||||
}
|
||||
|
|
@ -1172,9 +1171,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
// namespace; we encounter the former on
|
||||
// e.g. patterns for unit structs).
|
||||
|
||||
debug!("struct cmt_pat={} pat={}",
|
||||
cmt_pat.repr(tcx),
|
||||
pat.repr(tcx));
|
||||
debug!("struct cmt_pat={:?} pat={:?}",
|
||||
cmt_pat,
|
||||
pat);
|
||||
|
||||
delegate.matched_pat(pat, cmt_pat, match_mode);
|
||||
}
|
||||
|
|
@ -1192,9 +1191,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
// pattern.
|
||||
|
||||
if !tcx.sess.has_errors() {
|
||||
let msg = format!("Pattern has unexpected type: {:?} and type {}",
|
||||
let msg = format!("Pattern has unexpected type: {:?} and type {:?}",
|
||||
def,
|
||||
cmt_pat.ty.repr(tcx));
|
||||
cmt_pat.ty);
|
||||
tcx.sess.span_bug(pat.span, &msg)
|
||||
}
|
||||
}
|
||||
|
|
@ -1209,9 +1208,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
// reported.
|
||||
|
||||
if !tcx.sess.has_errors() {
|
||||
let msg = format!("Pattern has unexpected def: {:?} and type {}",
|
||||
let msg = format!("Pattern has unexpected def: {:?} and type {:?}",
|
||||
def,
|
||||
cmt_pat.ty.repr(tcx));
|
||||
cmt_pat.ty);
|
||||
tcx.sess.span_bug(pat.span, &msg[..])
|
||||
}
|
||||
}
|
||||
|
|
@ -1237,7 +1236,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
}
|
||||
|
||||
fn walk_captures(&mut self, closure_expr: &ast::Expr) {
|
||||
debug!("walk_captures({})", closure_expr.repr(self.tcx()));
|
||||
debug!("walk_captures({:?})", closure_expr);
|
||||
|
||||
ty::with_freevars(self.tcx(), closure_expr.id, |freevars| {
|
||||
for freevar in freevars {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ use middle::implicator::Implication;
|
|||
use middle::ty::{self, FreeRegion};
|
||||
use util::common::can_reach;
|
||||
use util::nodemap::FnvHashMap;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct FreeRegionMap {
|
||||
|
|
@ -29,11 +28,10 @@ impl FreeRegionMap {
|
|||
}
|
||||
|
||||
pub fn relate_free_regions_from_implications<'tcx>(&mut self,
|
||||
tcx: &ty::ctxt<'tcx>,
|
||||
implications: &[Implication<'tcx>])
|
||||
{
|
||||
for implication in implications {
|
||||
debug!("implication: {}", implication.repr(tcx));
|
||||
debug!("implication: {:?}", implication);
|
||||
match *implication {
|
||||
Implication::RegionSubRegion(_, ty::ReFree(free_a), ty::ReFree(free_b)) => {
|
||||
self.relate_free_regions(free_a, free_b);
|
||||
|
|
@ -50,7 +48,7 @@ impl FreeRegionMap {
|
|||
pub fn relate_free_regions_from_predicates<'tcx>(&mut self,
|
||||
tcx: &ty::ctxt<'tcx>,
|
||||
predicates: &[ty::Predicate<'tcx>]) {
|
||||
debug!("relate_free_regions_from_predicates(predicates={})", predicates.repr(tcx));
|
||||
debug!("relate_free_regions_from_predicates(predicates={:?})", predicates);
|
||||
for predicate in predicates {
|
||||
match *predicate {
|
||||
ty::Predicate::Projection(..) |
|
||||
|
|
@ -68,9 +66,9 @@ impl FreeRegionMap {
|
|||
_ => {
|
||||
// All named regions are instantiated with free regions.
|
||||
tcx.sess.bug(
|
||||
&format!("record_region_bounds: non free region: {} / {}",
|
||||
r_a.repr(tcx),
|
||||
r_b.repr(tcx)));
|
||||
&format!("record_region_bounds: non free region: {:?} / {:?}",
|
||||
r_a,
|
||||
r_b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ use syntax::codemap::Span;
|
|||
|
||||
use util::common::ErrorReported;
|
||||
use util::nodemap::FnvHashSet;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
// Helper functions related to manipulating region types.
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Implication<'tcx> {
|
||||
RegionSubRegion(Option<Ty<'tcx>>, ty::Region, ty::Region),
|
||||
RegionSubGeneric(Option<Ty<'tcx>>, ty::Region, GenericKind<'tcx>),
|
||||
|
|
@ -53,10 +53,10 @@ pub fn implications<'a,'tcx>(
|
|||
span: Span)
|
||||
-> Vec<Implication<'tcx>>
|
||||
{
|
||||
debug!("implications(body_id={}, ty={}, outer_region={})",
|
||||
debug!("implications(body_id={}, ty={:?}, outer_region={:?})",
|
||||
body_id,
|
||||
ty.repr(closure_typer.tcx()),
|
||||
outer_region.repr(closure_typer.tcx()));
|
||||
ty,
|
||||
outer_region);
|
||||
|
||||
let mut stack = Vec::new();
|
||||
stack.push((outer_region, None));
|
||||
|
|
@ -68,7 +68,7 @@ pub fn implications<'a,'tcx>(
|
|||
out: Vec::new(),
|
||||
visited: FnvHashSet() };
|
||||
wf.accumulate_from_ty(ty);
|
||||
debug!("implications: out={}", wf.out.repr(closure_typer.tcx()));
|
||||
debug!("implications: out={:?}", wf.out);
|
||||
wf.out
|
||||
}
|
||||
|
||||
|
|
@ -78,8 +78,8 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) {
|
||||
debug!("accumulate_from_ty(ty={})",
|
||||
ty.repr(self.tcx()));
|
||||
debug!("accumulate_from_ty(ty={:?})",
|
||||
ty);
|
||||
|
||||
// When expanding out associated types, we can visit a cyclic
|
||||
// set of types. Issue #23003.
|
||||
|
|
@ -312,8 +312,8 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
|
|||
fn accumulate_from_assoc_types_transitive(&mut self,
|
||||
data: &ty::PolyTraitPredicate<'tcx>)
|
||||
{
|
||||
debug!("accumulate_from_assoc_types_transitive({})",
|
||||
data.repr(self.tcx()));
|
||||
debug!("accumulate_from_assoc_types_transitive({:?})",
|
||||
data);
|
||||
|
||||
for poly_trait_ref in traits::supertraits(self.tcx(), data.to_poly_trait_ref()) {
|
||||
match ty::no_late_bound_regions(self.tcx(), &poly_trait_ref) {
|
||||
|
|
@ -326,8 +326,8 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
|
|||
fn accumulate_from_assoc_types(&mut self,
|
||||
trait_ref: ty::TraitRef<'tcx>)
|
||||
{
|
||||
debug!("accumulate_from_assoc_types({})",
|
||||
trait_ref.repr(self.tcx()));
|
||||
debug!("accumulate_from_assoc_types({:?})",
|
||||
trait_ref);
|
||||
|
||||
let trait_def_id = trait_ref.def_id;
|
||||
let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id);
|
||||
|
|
@ -336,8 +336,8 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
|
|||
.iter()
|
||||
.map(|&name| ty::mk_projection(self.tcx(), trait_ref.clone(), name))
|
||||
.collect();
|
||||
debug!("accumulate_from_assoc_types: assoc_type_projections={}",
|
||||
assoc_type_projections.repr(self.tcx()));
|
||||
debug!("accumulate_from_assoc_types: assoc_type_projections={:?}",
|
||||
assoc_type_projections);
|
||||
let tys = match self.fully_normalize(&assoc_type_projections) {
|
||||
Ok(tys) => { tys }
|
||||
Err(ErrorReported) => { return; }
|
||||
|
|
@ -400,7 +400,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn fully_normalize<T>(&self, value: &T) -> Result<T,ErrorReported>
|
||||
where T : TypeFoldable<'tcx> + ty::HasProjectionTypes + Clone + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx> + ty::HasProjectionTypes
|
||||
{
|
||||
let value =
|
||||
traits::fully_normalize(self.infcx,
|
||||
|
|
@ -454,34 +454,3 @@ pub fn object_region_bounds<'tcx>(
|
|||
let predicates = ty::predicates(tcx, open_ty, ¶m_bounds);
|
||||
ty::required_region_bounds(tcx, open_ty, predicates)
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for Implication<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
Implication::RegionSubRegion(_, ref r_a, ref r_b) => {
|
||||
format!("RegionSubRegion({}, {})",
|
||||
r_a.repr(tcx),
|
||||
r_b.repr(tcx))
|
||||
}
|
||||
|
||||
Implication::RegionSubGeneric(_, ref r, ref p) => {
|
||||
format!("RegionSubGeneric({}, {})",
|
||||
r.repr(tcx),
|
||||
p.repr(tcx))
|
||||
}
|
||||
|
||||
Implication::RegionSubClosure(_, ref a, ref b, ref c) => {
|
||||
format!("RegionSubClosure({}, {}, {})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx),
|
||||
c.repr(tcx))
|
||||
}
|
||||
|
||||
Implication::Predicate(ref def_id, ref p) => {
|
||||
format!("Predicate({}, {})",
|
||||
def_id.repr(tcx),
|
||||
p.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ use super::type_variable::{BiTo};
|
|||
use middle::ty::{self, Ty};
|
||||
use middle::ty::TyVar;
|
||||
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
|
||||
use util::ppaux::{Repr};
|
||||
|
||||
pub struct Bivariate<'a, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'tcx>
|
||||
|
|
@ -73,8 +72,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
debug!("{}.tys({}, {})", self.tag(),
|
||||
a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx));
|
||||
debug!("{}.tys({:?}, {:?})", self.tag(),
|
||||
a, b);
|
||||
if a == b { return Ok(a); }
|
||||
|
||||
let infcx = self.fields.infcx;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ use middle::ty::{self, Ty};
|
|||
use middle::ty_fold;
|
||||
use middle::ty_fold::{TypeFolder, TypeFoldable};
|
||||
use middle::ty_relate::{self, Relate, RelateResult, TypeRelation};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
|
|
@ -187,7 +186,6 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
|||
b_vid: ty::TyVid)
|
||||
-> RelateResult<'tcx, ()>
|
||||
{
|
||||
let tcx = self.infcx.tcx;
|
||||
let mut stack = Vec::new();
|
||||
stack.push((a_ty, dir, b_vid));
|
||||
loop {
|
||||
|
|
@ -213,10 +211,10 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
|||
Some(e) => e,
|
||||
};
|
||||
|
||||
debug!("instantiate(a_ty={} dir={:?} b_vid={})",
|
||||
a_ty.repr(tcx),
|
||||
debug!("instantiate(a_ty={:?} dir={:?} b_vid={:?})",
|
||||
a_ty,
|
||||
dir,
|
||||
b_vid.repr(tcx));
|
||||
b_vid);
|
||||
|
||||
// Check whether `vid` has been instantiated yet. If not,
|
||||
// make a generalized form of `ty` and instantiate with
|
||||
|
|
@ -230,10 +228,10 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
|||
EqTo => self.generalize(a_ty, b_vid, false),
|
||||
BiTo | SupertypeOf | SubtypeOf => self.generalize(a_ty, b_vid, true),
|
||||
});
|
||||
debug!("instantiate(a_ty={}, dir={:?}, \
|
||||
b_vid={}, generalized_ty={})",
|
||||
a_ty.repr(tcx), dir, b_vid.repr(tcx),
|
||||
generalized_ty.repr(tcx));
|
||||
debug!("instantiate(a_ty={:?}, dir={:?}, \
|
||||
b_vid={:?}, generalized_ty={:?})",
|
||||
a_ty, dir, b_vid,
|
||||
generalized_ty);
|
||||
self.infcx.type_variables
|
||||
.borrow_mut()
|
||||
.instantiate_and_push(
|
||||
|
|
@ -335,8 +333,8 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
|
|||
ty::ReEarlyBound(..) => {
|
||||
self.tcx().sess.span_bug(
|
||||
self.span,
|
||||
&format!("Encountered early bound region when generalizing: {}",
|
||||
r.repr(self.tcx())));
|
||||
&format!("Encountered early bound region when generalizing: {:?}",
|
||||
r));
|
||||
}
|
||||
|
||||
// Always make a fresh region variable for skolemized regions;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use super::type_variable::{EqTo};
|
|||
use middle::ty::{self, Ty};
|
||||
use middle::ty::TyVar;
|
||||
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
|
||||
use util::ppaux::{Repr};
|
||||
|
||||
pub struct Equate<'a, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'tcx>
|
||||
|
|
@ -45,8 +44,8 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
debug!("{}.tys({}, {})", self.tag(),
|
||||
a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx));
|
||||
debug!("{}.tys({:?}, {:?})", self.tag(),
|
||||
a, b);
|
||||
if a == b { return Ok(a); }
|
||||
|
||||
let infcx = self.fields.infcx;
|
||||
|
|
@ -75,10 +74,10 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
debug!("{}.regions({:?}, {:?})",
|
||||
self.tag(),
|
||||
a.repr(self.fields.infcx.tcx),
|
||||
b.repr(self.fields.infcx.tcx));
|
||||
a,
|
||||
b);
|
||||
let origin = Subtype(self.fields.trace.clone());
|
||||
self.fields.infcx.region_vars.make_eqregion(origin, a, b);
|
||||
Ok(a)
|
||||
|
|
|
|||
|
|
@ -75,25 +75,141 @@ use std::collections::HashSet;
|
|||
use ast_map;
|
||||
use middle::def;
|
||||
use middle::infer;
|
||||
use middle::region;
|
||||
use middle::subst;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty::{Region, ReFree};
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::char::from_u32;
|
||||
use std::string::String;
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use syntax::ast_util::name_to_dummy_lifetime;
|
||||
use syntax::owned_slice::OwnedSlice;
|
||||
use syntax::codemap;
|
||||
use syntax::codemap::{Pos, Span};
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust;
|
||||
use syntax::ptr::P;
|
||||
use util::ppaux::bound_region_to_string;
|
||||
use util::ppaux::note_and_explain_region;
|
||||
|
||||
// Note: only import UserString, not Repr, since user-facing error
|
||||
// messages shouldn't include debug serializations.
|
||||
use util::ppaux::UserString;
|
||||
pub fn note_and_explain_region(tcx: &ty::ctxt,
|
||||
prefix: &str,
|
||||
region: ty::Region,
|
||||
suffix: &str) {
|
||||
fn item_scope_tag(item: &ast::Item) -> &'static str {
|
||||
match item.node {
|
||||
ast::ItemImpl(..) => "impl",
|
||||
ast::ItemStruct(..) => "struct",
|
||||
ast::ItemEnum(..) => "enum",
|
||||
ast::ItemTrait(..) => "trait",
|
||||
ast::ItemFn(..) => "function body",
|
||||
_ => "item"
|
||||
}
|
||||
}
|
||||
|
||||
fn explain_span(tcx: &ty::ctxt, heading: &str, span: Span)
|
||||
-> (String, Option<Span>) {
|
||||
let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo);
|
||||
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
|
||||
Some(span))
|
||||
}
|
||||
|
||||
let (description, span) = match region {
|
||||
ty::ReScope(scope) => {
|
||||
let new_string;
|
||||
let unknown_scope = || {
|
||||
format!("{}unknown scope: {:?}{}. Please report a bug.",
|
||||
prefix, scope, suffix)
|
||||
};
|
||||
let span = match scope.span(&tcx.map) {
|
||||
Some(s) => s,
|
||||
None => return tcx.sess.note(&unknown_scope())
|
||||
};
|
||||
let tag = match tcx.map.find(scope.node_id()) {
|
||||
Some(ast_map::NodeBlock(_)) => "block",
|
||||
Some(ast_map::NodeExpr(expr)) => match expr.node {
|
||||
ast::ExprCall(..) => "call",
|
||||
ast::ExprMethodCall(..) => "method call",
|
||||
ast::ExprMatch(_, _, ast::MatchSource::IfLetDesugar { .. }) => "if let",
|
||||
ast::ExprMatch(_, _, ast::MatchSource::WhileLetDesugar) => "while let",
|
||||
ast::ExprMatch(_, _, ast::MatchSource::ForLoopDesugar) => "for",
|
||||
ast::ExprMatch(..) => "match",
|
||||
_ => "expression",
|
||||
},
|
||||
Some(ast_map::NodeStmt(_)) => "statement",
|
||||
Some(ast_map::NodeItem(it)) => item_scope_tag(&*it),
|
||||
Some(_) | None => {
|
||||
return tcx.sess.span_note(span, &unknown_scope());
|
||||
}
|
||||
};
|
||||
let scope_decorated_tag = match scope {
|
||||
region::CodeExtent::Misc(_) => tag,
|
||||
region::CodeExtent::ParameterScope { .. } => {
|
||||
"scope of parameters for function"
|
||||
}
|
||||
region::CodeExtent::DestructionScope(_) => {
|
||||
new_string = format!("destruction scope surrounding {}", tag);
|
||||
&new_string[..]
|
||||
}
|
||||
region::CodeExtent::Remainder(r) => {
|
||||
new_string = format!("block suffix following statement {}",
|
||||
r.first_statement_index);
|
||||
&new_string[..]
|
||||
}
|
||||
};
|
||||
explain_span(tcx, scope_decorated_tag, span)
|
||||
}
|
||||
|
||||
ty::ReFree(ref fr) => {
|
||||
let prefix = match fr.bound_region {
|
||||
ty::BrAnon(idx) => {
|
||||
format!("the anonymous lifetime #{} defined on", idx + 1)
|
||||
}
|
||||
ty::BrFresh(_) => "an anonymous lifetime defined on".to_owned(),
|
||||
_ => {
|
||||
format!("the lifetime {} as defined on",
|
||||
fr.bound_region)
|
||||
}
|
||||
};
|
||||
|
||||
match tcx.map.find(fr.scope.node_id) {
|
||||
Some(ast_map::NodeBlock(ref blk)) => {
|
||||
let (msg, opt_span) = explain_span(tcx, "block", blk.span);
|
||||
(format!("{} {}", prefix, msg), opt_span)
|
||||
}
|
||||
Some(ast_map::NodeItem(it)) => {
|
||||
let tag = item_scope_tag(&*it);
|
||||
let (msg, opt_span) = explain_span(tcx, tag, it.span);
|
||||
(format!("{} {}", prefix, msg), opt_span)
|
||||
}
|
||||
Some(_) | None => {
|
||||
// this really should not happen
|
||||
(format!("{} unknown free region bounded by scope {:?}",
|
||||
prefix, fr.scope), None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ty::ReStatic => ("the static lifetime".to_owned(), None),
|
||||
|
||||
ty::ReEmpty => ("the empty lifetime".to_owned(), None),
|
||||
|
||||
ty::ReEarlyBound(ref data) => {
|
||||
(format!("{}", token::get_name(data.name)), None)
|
||||
}
|
||||
|
||||
// I believe these cases should not occur (except when debugging,
|
||||
// perhaps)
|
||||
ty::ReInfer(_) | ty::ReLateBound(..) => {
|
||||
(format!("lifetime {:?}", region), None)
|
||||
}
|
||||
};
|
||||
let message = format!("{}{}{}", prefix, description, suffix);
|
||||
if let Some(span) = span {
|
||||
tcx.sess.span_note(span, &message);
|
||||
} else {
|
||||
tcx.sess.note(&message);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ErrorReporting<'tcx> {
|
||||
fn report_region_errors(&self,
|
||||
|
|
@ -110,7 +226,7 @@ pub trait ErrorReporting<'tcx> {
|
|||
|
||||
fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<String>;
|
||||
|
||||
fn expected_found_str<T: UserString<'tcx> + Resolvable<'tcx>>(
|
||||
fn expected_found_str<T: fmt::Display + Resolvable<'tcx>>(
|
||||
&self,
|
||||
exp_found: &ty::expected_found<T>)
|
||||
-> Option<String>;
|
||||
|
|
@ -162,7 +278,7 @@ trait ErrorReportingHelpers<'tcx> {
|
|||
ident: ast::Ident,
|
||||
opt_explicit_self: Option<&ast::ExplicitSelf_>,
|
||||
generics: &ast::Generics,
|
||||
span: codemap::Span);
|
||||
span: Span);
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
|
|
@ -361,7 +477,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
"{}: {} ({})",
|
||||
trace.origin,
|
||||
expected_found_str,
|
||||
ty::type_err_to_str(self.tcx, terr));
|
||||
terr);
|
||||
|
||||
match trace.origin {
|
||||
infer::MatchExpressionArm(_, arm_span) =>
|
||||
|
|
@ -388,7 +504,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn expected_found_str<T: UserString<'tcx> + Resolvable<'tcx>>(
|
||||
fn expected_found_str<T: fmt::Display + Resolvable<'tcx>>(
|
||||
&self,
|
||||
exp_found: &ty::expected_found<T>)
|
||||
-> Option<String>
|
||||
|
|
@ -404,8 +520,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
Some(format!("expected `{}`, found `{}`",
|
||||
expected.user_string(self.tcx),
|
||||
found.user_string(self.tcx)))
|
||||
expected,
|
||||
found))
|
||||
}
|
||||
|
||||
fn report_generic_bound_failure(&self,
|
||||
|
|
@ -421,9 +537,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
let labeled_user_string = match bound_kind {
|
||||
GenericKind::Param(ref p) =>
|
||||
format!("the parameter type `{}`", p.user_string(self.tcx)),
|
||||
format!("the parameter type `{}`", p),
|
||||
GenericKind::Projection(ref p) =>
|
||||
format!("the associated type `{}`", p.user_string(self.tcx)),
|
||||
format!("the associated type `{}`", p),
|
||||
};
|
||||
|
||||
match sub {
|
||||
|
|
@ -435,8 +551,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
origin.span(),
|
||||
&format!(
|
||||
"consider adding an explicit lifetime bound `{}: {}`...",
|
||||
bound_kind.user_string(self.tcx),
|
||||
sub.user_string(self.tcx)));
|
||||
bound_kind,
|
||||
sub));
|
||||
}
|
||||
|
||||
ty::ReStatic => {
|
||||
|
|
@ -447,7 +563,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
origin.span(),
|
||||
&format!(
|
||||
"consider adding an explicit lifetime bound `{}: 'static`...",
|
||||
bound_kind.user_string(self.tcx)));
|
||||
bound_kind));
|
||||
}
|
||||
|
||||
_ => {
|
||||
|
|
@ -459,7 +575,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
origin.span(),
|
||||
&format!(
|
||||
"consider adding an explicit lifetime bound for `{}`",
|
||||
bound_kind.user_string(self.tcx)));
|
||||
bound_kind));
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
&format!("{} must be valid for ", labeled_user_string),
|
||||
|
|
@ -1431,7 +1547,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
ident: ast::Ident,
|
||||
opt_explicit_self: Option<&ast::ExplicitSelf_>,
|
||||
generics: &ast::Generics,
|
||||
span: codemap::Span) {
|
||||
span: Span) {
|
||||
let suggested_fn = pprust::fun_to_string(decl, unsafety, constness, ident,
|
||||
opt_explicit_self, generics);
|
||||
let msg = format!("consider using an explicit lifetime \
|
||||
|
|
@ -1441,6 +1557,13 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn report_inference_failure(&self,
|
||||
var_origin: RegionVariableOrigin) {
|
||||
let br_string = |br: ty::BoundRegion| {
|
||||
let mut s = br.to_string();
|
||||
if !s.is_empty() {
|
||||
s.push_str(" ");
|
||||
}
|
||||
s
|
||||
};
|
||||
let var_description = match var_origin {
|
||||
infer::MiscVariable(_) => "".to_string(),
|
||||
infer::PatternRegion(_) => " for pattern".to_string(),
|
||||
|
|
@ -1448,17 +1571,15 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
infer::Autoref(_) => " for autoref".to_string(),
|
||||
infer::Coercion(_) => " for automatic coercion".to_string(),
|
||||
infer::LateBoundRegion(_, br, infer::FnCall) => {
|
||||
format!(" for {}in function call",
|
||||
bound_region_to_string(self.tcx, "lifetime parameter ", true, br))
|
||||
format!(" for lifetime parameter {}in function call",
|
||||
br_string(br))
|
||||
}
|
||||
infer::LateBoundRegion(_, br, infer::HigherRankedType) => {
|
||||
format!(" for {}in generic type",
|
||||
bound_region_to_string(self.tcx, "lifetime parameter ", true, br))
|
||||
format!(" for lifetime parameter {}in generic type", br_string(br))
|
||||
}
|
||||
infer::LateBoundRegion(_, br, infer::AssocTypeProjection(type_name)) => {
|
||||
format!(" for {}in trait containing associated type `{}`",
|
||||
bound_region_to_string(self.tcx, "lifetime parameter ", true, br),
|
||||
token::get_name(type_name))
|
||||
format!(" for lifetime parameter {}in trait containing associated type `{}`",
|
||||
br_string(br), token::get_name(type_name))
|
||||
}
|
||||
infer::EarlyBoundRegion(_, name) => {
|
||||
format!(" for lifetime parameter `{}`",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use super::Subtype;
|
|||
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
/// "Greatest lower bound" (common subtype)
|
||||
pub struct Glb<'a, 'tcx: 'a> {
|
||||
|
|
@ -55,10 +54,10 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
debug!("{}.regions({:?}, {:?})",
|
||||
self.tag(),
|
||||
a.repr(self.fields.infcx.tcx),
|
||||
b.repr(self.fields.infcx.tcx));
|
||||
a,
|
||||
b);
|
||||
|
||||
let origin = Subtype(self.fields.trace.clone());
|
||||
Ok(self.fields.infcx.region_vars.glb_regions(origin, a, b))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ use middle::ty_fold::{self, TypeFoldable};
|
|||
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
|
||||
use syntax::codemap::Span;
|
||||
use util::nodemap::{FnvHashMap, FnvHashSet};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
pub trait HigherRankedRelations<'a,'tcx> {
|
||||
fn higher_ranked_sub<T>(&self, a: &Binder<T>, b: &Binder<T>) -> RelateResult<'tcx, Binder<T>>
|
||||
|
|
@ -46,10 +45,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
-> RelateResult<'tcx, Binder<T>>
|
||||
where T: Relate<'a,'tcx>
|
||||
{
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
debug!("higher_ranked_sub(a={}, b={})",
|
||||
a.repr(tcx), b.repr(tcx));
|
||||
debug!("higher_ranked_sub(a={:?}, b={:?})",
|
||||
a, b);
|
||||
|
||||
// Rather than checking the subtype relationship between `a` and `b`
|
||||
// as-is, we need to do some extra work here in order to make sure
|
||||
|
|
@ -75,8 +72,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
let (b_prime, skol_map) =
|
||||
self.infcx.skolemize_late_bound_regions(b, snapshot);
|
||||
|
||||
debug!("a_prime={}", a_prime.repr(tcx));
|
||||
debug!("b_prime={}", b_prime.repr(tcx));
|
||||
debug!("a_prime={:?}", a_prime);
|
||||
debug!("b_prime={:?}", b_prime);
|
||||
|
||||
// Compare types now that bound regions have been replaced.
|
||||
let result = try!(self.sub().relate(&a_prime, &b_prime));
|
||||
|
|
@ -98,8 +95,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
debug!("higher_ranked_sub: OK result={}",
|
||||
result.repr(tcx));
|
||||
debug!("higher_ranked_sub: OK result={:?}",
|
||||
result);
|
||||
|
||||
Ok(ty::Binder(result))
|
||||
});
|
||||
|
|
@ -125,7 +122,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
try!(self.lub().relate(&a_with_fresh, &b_with_fresh));
|
||||
let result0 =
|
||||
self.infcx.resolve_type_vars_if_possible(&result0);
|
||||
debug!("lub result0 = {}", result0.repr(self.tcx()));
|
||||
debug!("lub result0 = {:?}", result0);
|
||||
|
||||
// Generalize the regions appearing in result0 if possible
|
||||
let new_vars = self.infcx.region_vars_confined_to_snapshot(snapshot);
|
||||
|
|
@ -137,10 +134,10 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
|r, debruijn| generalize_region(self.infcx, span, snapshot, debruijn,
|
||||
&new_vars, &a_map, r));
|
||||
|
||||
debug!("lub({},{}) = {}",
|
||||
a.repr(self.tcx()),
|
||||
b.repr(self.tcx()),
|
||||
result1.repr(self.tcx()));
|
||||
debug!("lub({:?},{:?}) = {:?}",
|
||||
a,
|
||||
b,
|
||||
result1);
|
||||
|
||||
Ok(ty::Binder(result1))
|
||||
});
|
||||
|
|
@ -198,8 +195,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
fn higher_ranked_glb<T>(&self, a: &Binder<T>, b: &Binder<T>) -> RelateResult<'tcx, Binder<T>>
|
||||
where T: Relate<'a,'tcx>
|
||||
{
|
||||
debug!("higher_ranked_glb({}, {})",
|
||||
a.repr(self.tcx()), b.repr(self.tcx()));
|
||||
debug!("higher_ranked_glb({:?}, {:?})",
|
||||
a, b);
|
||||
|
||||
// Make a snapshot so we can examine "all bindings that were
|
||||
// created as part of this type comparison".
|
||||
|
|
@ -219,7 +216,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
try!(self.glb().relate(&a_with_fresh, &b_with_fresh));
|
||||
let result0 =
|
||||
self.infcx.resolve_type_vars_if_possible(&result0);
|
||||
debug!("glb result0 = {}", result0.repr(self.tcx()));
|
||||
debug!("glb result0 = {:?}", result0);
|
||||
|
||||
// Generalize the regions appearing in result0 if possible
|
||||
let new_vars = self.infcx.region_vars_confined_to_snapshot(snapshot);
|
||||
|
|
@ -233,10 +230,10 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
&a_map, &a_vars, &b_vars,
|
||||
r));
|
||||
|
||||
debug!("glb({},{}) = {}",
|
||||
a.repr(self.tcx()),
|
||||
b.repr(self.tcx()),
|
||||
result1.repr(self.tcx()));
|
||||
debug!("glb({:?},{:?}) = {:?}",
|
||||
a,
|
||||
b,
|
||||
result1);
|
||||
|
||||
Ok(ty::Binder(result1))
|
||||
});
|
||||
|
|
@ -451,9 +448,9 @@ impl<'a,'tcx> InferCtxtExt for InferCtxt<'a,'tcx> {
|
|||
!escaping_region_vars.contains(&r)
|
||||
});
|
||||
|
||||
debug!("region_vars_confined_to_snapshot: region_vars={} escaping_types={}",
|
||||
region_vars.repr(self.tcx),
|
||||
escaping_types.repr(self.tcx));
|
||||
debug!("region_vars_confined_to_snapshot: region_vars={:?} escaping_types={:?}",
|
||||
region_vars,
|
||||
escaping_types);
|
||||
|
||||
region_vars
|
||||
}
|
||||
|
|
@ -520,7 +517,7 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
binder: &ty::Binder<T>,
|
||||
snapshot: &CombinedSnapshot)
|
||||
-> (T, SkolemizationMap)
|
||||
where T : TypeFoldable<'tcx> + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
/*!
|
||||
* Replace all regions bound by `binder` with skolemized regions and
|
||||
|
|
@ -534,10 +531,10 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
infcx.region_vars.new_skolemized(br, &snapshot.region_vars_snapshot)
|
||||
});
|
||||
|
||||
debug!("skolemize_bound_regions(binder={}, result={}, map={})",
|
||||
binder.repr(infcx.tcx),
|
||||
result.repr(infcx.tcx),
|
||||
map.repr(infcx.tcx));
|
||||
debug!("skolemize_bound_regions(binder={:?}, result={:?}, map={:?})",
|
||||
binder,
|
||||
result,
|
||||
map);
|
||||
|
||||
(result, map)
|
||||
}
|
||||
|
|
@ -555,8 +552,8 @@ pub fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
|||
* hold. See `README.md` for more details.
|
||||
*/
|
||||
|
||||
debug!("leak_check: skol_map={}",
|
||||
skol_map.repr(infcx.tcx));
|
||||
debug!("leak_check: skol_map={:?}",
|
||||
skol_map);
|
||||
|
||||
let new_vars = infcx.region_vars_confined_to_snapshot(snapshot);
|
||||
for (&skol_br, &skol) in skol_map {
|
||||
|
|
@ -573,10 +570,10 @@ pub fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
|||
}
|
||||
};
|
||||
|
||||
debug!("{} (which replaced {}) is tainted by {}",
|
||||
skol.repr(infcx.tcx),
|
||||
skol_br.repr(infcx.tcx),
|
||||
tainted_region.repr(infcx.tcx));
|
||||
debug!("{:?} (which replaced {:?}) is tainted by {:?}",
|
||||
skol,
|
||||
skol_br,
|
||||
tainted_region);
|
||||
|
||||
// A is not as polymorphic as B:
|
||||
return Err((skol_br, tainted_region));
|
||||
|
|
@ -618,13 +615,13 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
snapshot: &CombinedSnapshot,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok());
|
||||
|
||||
debug!("plug_leaks(skol_map={}, value={})",
|
||||
skol_map.repr(infcx.tcx),
|
||||
value.repr(infcx.tcx));
|
||||
debug!("plug_leaks(skol_map={:?}, value={:?})",
|
||||
skol_map,
|
||||
value);
|
||||
|
||||
// Compute a mapping from the "taint set" of each skolemized
|
||||
// region back to the `ty::BoundRegion` that it originally
|
||||
|
|
@ -640,8 +637,8 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
})
|
||||
.collect();
|
||||
|
||||
debug!("plug_leaks: inv_skol_map={}",
|
||||
inv_skol_map.repr(infcx.tcx));
|
||||
debug!("plug_leaks: inv_skol_map={:?}",
|
||||
inv_skol_map);
|
||||
|
||||
// Remove any instantiated type variables from `value`; those can hide
|
||||
// references to regions from the `fold_regions` code below.
|
||||
|
|
@ -669,8 +666,8 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
}
|
||||
});
|
||||
|
||||
debug!("plug_leaks: result={}",
|
||||
result.repr(infcx.tcx));
|
||||
debug!("plug_leaks: result={:?}",
|
||||
result);
|
||||
|
||||
result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ use super::InferCtxt;
|
|||
use middle::ty::TyVar;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty_relate::{RelateResult, TypeRelation};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
pub trait LatticeDir<'f,'tcx> : TypeRelation<'f,'tcx> {
|
||||
fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>;
|
||||
|
|
@ -51,10 +50,10 @@ pub fn super_lattice_tys<'a,'tcx,L:LatticeDir<'a,'tcx>>(this: &mut L,
|
|||
-> RelateResult<'tcx, Ty<'tcx>>
|
||||
where 'tcx: 'a
|
||||
{
|
||||
debug!("{}.lattice_tys({}, {})",
|
||||
debug!("{}.lattice_tys({:?}, {:?})",
|
||||
this.tag(),
|
||||
a.repr(this.tcx()),
|
||||
b.repr(this.tcx()));
|
||||
a,
|
||||
b);
|
||||
|
||||
if a == b {
|
||||
return Ok(a);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use super::Subtype;
|
|||
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
/// "Least upper bound" (common supertype)
|
||||
pub struct Lub<'a, 'tcx: 'a> {
|
||||
|
|
@ -55,10 +54,10 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
debug!("{}.regions({:?}, {:?})",
|
||||
self.tag(),
|
||||
a.repr(self.tcx()),
|
||||
b.repr(self.tcx()));
|
||||
a,
|
||||
b);
|
||||
|
||||
let origin = Subtype(self.fields.trace.clone());
|
||||
Ok(self.fields.infcx.region_vars.lub_regions(origin, a, b))
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@ use syntax::ast;
|
|||
use syntax::codemap;
|
||||
use syntax::codemap::Span;
|
||||
use util::nodemap::FnvHashMap;
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
use self::combine::CombineFields;
|
||||
use self::region_inference::{RegionVarBindings, RegionSnapshot};
|
||||
|
|
@ -161,7 +159,7 @@ pub enum ValuePairs<'tcx> {
|
|||
/// encounter an error or subtyping constraint.
|
||||
///
|
||||
/// See `error_reporting.rs` for more details.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub struct TypeTrace<'tcx> {
|
||||
origin: TypeOrigin,
|
||||
values: ValuePairs<'tcx>,
|
||||
|
|
@ -331,8 +329,8 @@ pub fn common_supertype<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
b: Ty<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
debug!("common_supertype({}, {})",
|
||||
a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
debug!("common_supertype({:?}, {:?})",
|
||||
a, b);
|
||||
|
||||
let trace = TypeTrace {
|
||||
origin: origin,
|
||||
|
|
@ -356,7 +354,7 @@ pub fn mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
b: Ty<'tcx>)
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
debug!("mk_subty({:?} <: {:?})", a, b);
|
||||
cx.sub_types(a_is_expected, origin, a, b)
|
||||
}
|
||||
|
||||
|
|
@ -364,7 +362,7 @@ pub fn can_mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> UnitResult<'tcx> {
|
||||
debug!("can_mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
debug!("can_mk_subty({:?} <: {:?})", a, b);
|
||||
cx.probe(|_| {
|
||||
let trace = TypeTrace {
|
||||
origin: Misc(codemap::DUMMY_SP),
|
||||
|
|
@ -384,7 +382,7 @@ pub fn mk_subr<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
origin: SubregionOrigin<'tcx>,
|
||||
a: ty::Region,
|
||||
b: ty::Region) {
|
||||
debug!("mk_subr({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
debug!("mk_subr({:?} <: {:?})", a, b);
|
||||
let snapshot = cx.region_vars.start_snapshot();
|
||||
cx.region_vars.make_subregion(origin, a, b);
|
||||
cx.region_vars.commit(snapshot);
|
||||
|
|
@ -397,7 +395,7 @@ pub fn mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
b: Ty<'tcx>)
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("mk_eqty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
debug!("mk_eqty({:?} <: {:?})", a, b);
|
||||
cx.commit_if_ok(|_| cx.eq_types(a_is_expected, origin, a, b))
|
||||
}
|
||||
|
||||
|
|
@ -408,8 +406,8 @@ pub fn mk_sub_poly_trait_refs<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
b: ty::PolyTraitRef<'tcx>)
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("mk_sub_trait_refs({} <: {})",
|
||||
a.repr(cx.tcx), b.repr(cx.tcx));
|
||||
debug!("mk_sub_trait_refs({:?} <: {:?})",
|
||||
a, b);
|
||||
cx.commit_if_ok(|_| cx.sub_poly_trait_refs(a_is_expected, origin, a.clone(), b.clone()))
|
||||
}
|
||||
|
||||
|
|
@ -638,7 +636,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
b: Ty<'tcx>)
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("sub_types({} <: {})", a.repr(self.tcx), b.repr(self.tcx));
|
||||
debug!("sub_types({:?} <: {:?})", a, b);
|
||||
self.commit_if_ok(|_| {
|
||||
let trace = TypeTrace::types(origin, a_is_expected, a, b);
|
||||
self.sub(a_is_expected, trace).relate(&a, &b).map(|_| ())
|
||||
|
|
@ -665,9 +663,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
b: ty::TraitRef<'tcx>)
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("sub_trait_refs({} <: {})",
|
||||
a.repr(self.tcx),
|
||||
b.repr(self.tcx));
|
||||
debug!("sub_trait_refs({:?} <: {:?})",
|
||||
a,
|
||||
b);
|
||||
self.commit_if_ok(|_| {
|
||||
let trace = TypeTrace {
|
||||
origin: origin,
|
||||
|
|
@ -684,9 +682,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
b: ty::PolyTraitRef<'tcx>)
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
debug!("sub_poly_trait_refs({} <: {})",
|
||||
a.repr(self.tcx),
|
||||
b.repr(self.tcx));
|
||||
debug!("sub_poly_trait_refs({:?} <: {:?})",
|
||||
a,
|
||||
b);
|
||||
self.commit_if_ok(|_| {
|
||||
let trace = TypeTrace {
|
||||
origin: origin,
|
||||
|
|
@ -709,7 +707,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
value: &ty::Binder<T>,
|
||||
snapshot: &CombinedSnapshot)
|
||||
-> (T, SkolemizationMap)
|
||||
where T : TypeFoldable<'tcx> + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
/*! See `higher_ranked::skolemize_late_bound_regions` */
|
||||
|
||||
|
|
@ -734,7 +732,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
snapshot: &CombinedSnapshot,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
/*! See `higher_ranked::plug_leaks` */
|
||||
|
||||
|
|
@ -862,8 +860,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
|
||||
ty_to_string(self.tcx,
|
||||
self.resolve_type_vars_if_possible(&t))
|
||||
self.resolve_type_vars_if_possible(&t).to_string()
|
||||
}
|
||||
|
||||
pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String {
|
||||
|
|
@ -872,8 +869,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn trait_ref_to_string(&self, t: &ty::TraitRef<'tcx>) -> String {
|
||||
let t = self.resolve_type_vars_if_possible(t);
|
||||
t.user_string(self.tcx)
|
||||
self.resolve_type_vars_if_possible(t).to_string()
|
||||
}
|
||||
|
||||
pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
|
||||
|
|
@ -981,7 +977,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
Some(t) if ty::type_is_error(t) => (),
|
||||
_ => {
|
||||
let error_str = err.map_or("".to_string(), |t_err| {
|
||||
format!(" ({})", ty::type_err_to_str(self.tcx, t_err))
|
||||
format!(" ({})", t_err)
|
||||
});
|
||||
|
||||
self.tcx.sess.span_err(sp, &format!("{}{}",
|
||||
|
|
@ -1035,7 +1031,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
lbrct: LateBoundRegionConversionTime,
|
||||
value: &ty::Binder<T>)
|
||||
-> (T, FnvHashMap<ty::BoundRegion,ty::Region>)
|
||||
where T : TypeFoldable<'tcx> + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
ty_fold::replace_late_bound_regions(
|
||||
self.tcx,
|
||||
|
|
@ -1049,18 +1045,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
kind: GenericKind<'tcx>,
|
||||
a: ty::Region,
|
||||
bs: Vec<ty::Region>) {
|
||||
debug!("verify_generic_bound({}, {} <: {})",
|
||||
kind.repr(self.tcx),
|
||||
a.repr(self.tcx),
|
||||
bs.repr(self.tcx));
|
||||
debug!("verify_generic_bound({:?}, {:?} <: {:?})",
|
||||
kind,
|
||||
a,
|
||||
bs);
|
||||
|
||||
self.region_vars.verify_generic_bound(origin, kind, a, bs);
|
||||
}
|
||||
|
||||
pub fn can_equate<'b,T>(&'b self, a: &T, b: &T) -> UnitResult<'tcx>
|
||||
where T: Relate<'b,'tcx> + Repr<'tcx>
|
||||
where T: Relate<'b,'tcx> + fmt::Debug
|
||||
{
|
||||
debug!("can_equate({}, {})", a.repr(self.tcx), b.repr(self.tcx));
|
||||
debug!("can_equate({:?}, {:?})", a, b);
|
||||
self.probe(|_| {
|
||||
// Gin up a dummy trace, since this won't be committed
|
||||
// anyhow. We should make this typetrace stuff more
|
||||
|
|
@ -1101,9 +1097,9 @@ impl<'tcx> TypeTrace<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for TypeTrace<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
format!("TypeTrace({})", self.origin.repr(tcx))
|
||||
impl<'tcx> fmt::Debug for TypeTrace<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "TypeTrace({:?})", self.origin)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1125,44 +1121,6 @@ impl TypeOrigin {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for TypeOrigin {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
MethodCompatCheck(a) => {
|
||||
format!("MethodCompatCheck({})", a.repr(tcx))
|
||||
}
|
||||
ExprAssignable(a) => {
|
||||
format!("ExprAssignable({})", a.repr(tcx))
|
||||
}
|
||||
Misc(a) => format!("Misc({})", a.repr(tcx)),
|
||||
RelateTraitRefs(a) => {
|
||||
format!("RelateTraitRefs({})", a.repr(tcx))
|
||||
}
|
||||
RelateSelfType(a) => {
|
||||
format!("RelateSelfType({})", a.repr(tcx))
|
||||
}
|
||||
RelateOutputImplTypes(a) => {
|
||||
format!("RelateOutputImplTypes({})", a.repr(tcx))
|
||||
}
|
||||
MatchExpressionArm(a, b) => {
|
||||
format!("MatchExpressionArm({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
IfExpression(a) => {
|
||||
format!("IfExpression({})", a.repr(tcx))
|
||||
}
|
||||
IfExpressionWithNoElse(a) => {
|
||||
format!("IfExpressionWithNoElse({})", a.repr(tcx))
|
||||
}
|
||||
RangeExpression(a) => {
|
||||
format!("RangeExpression({})", a.repr(tcx))
|
||||
}
|
||||
EquatePredicate(a) => {
|
||||
format!("EquatePredicate({})", a.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> SubregionOrigin<'tcx> {
|
||||
pub fn span(&self) -> Span {
|
||||
match *self {
|
||||
|
|
@ -1192,70 +1150,6 @@ impl<'tcx> SubregionOrigin<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for SubregionOrigin<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
Subtype(ref a) => {
|
||||
format!("Subtype({})", a.repr(tcx))
|
||||
}
|
||||
InfStackClosure(a) => {
|
||||
format!("InfStackClosure({})", a.repr(tcx))
|
||||
}
|
||||
InvokeClosure(a) => {
|
||||
format!("InvokeClosure({})", a.repr(tcx))
|
||||
}
|
||||
DerefPointer(a) => {
|
||||
format!("DerefPointer({})", a.repr(tcx))
|
||||
}
|
||||
FreeVariable(a, b) => {
|
||||
format!("FreeVariable({}, {})", a.repr(tcx), b)
|
||||
}
|
||||
IndexSlice(a) => {
|
||||
format!("IndexSlice({})", a.repr(tcx))
|
||||
}
|
||||
RelateObjectBound(a) => {
|
||||
format!("RelateObjectBound({})", a.repr(tcx))
|
||||
}
|
||||
RelateParamBound(a, b) => {
|
||||
format!("RelateParamBound({},{})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
}
|
||||
RelateRegionParamBound(a) => {
|
||||
format!("RelateRegionParamBound({})",
|
||||
a.repr(tcx))
|
||||
}
|
||||
RelateDefaultParamBound(a, b) => {
|
||||
format!("RelateDefaultParamBound({},{})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
}
|
||||
Reborrow(a) => format!("Reborrow({})", a.repr(tcx)),
|
||||
ReborrowUpvar(a, b) => {
|
||||
format!("ReborrowUpvar({},{:?})", a.repr(tcx), b)
|
||||
}
|
||||
ReferenceOutlivesReferent(_, a) => {
|
||||
format!("ReferenceOutlivesReferent({})", a.repr(tcx))
|
||||
}
|
||||
ExprTypeIsNotInScope(a, b) => {
|
||||
format!("ExprTypeIsNotInScope({}, {})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
}
|
||||
BindingTypeIsNotValidAtDecl(a) => {
|
||||
format!("BindingTypeIsNotValidAtDecl({})", a.repr(tcx))
|
||||
}
|
||||
CallRcvr(a) => format!("CallRcvr({})", a.repr(tcx)),
|
||||
CallArg(a) => format!("CallArg({})", a.repr(tcx)),
|
||||
CallReturn(a) => format!("CallReturn({})", a.repr(tcx)),
|
||||
Operand(a) => format!("Operand({})", a.repr(tcx)),
|
||||
AddrOf(a) => format!("AddrOf({})", a.repr(tcx)),
|
||||
AutoBorrow(a) => format!("AutoBorrow({})", a.repr(tcx)),
|
||||
SafeDestructor(a) => format!("SafeDestructor({})", a.repr(tcx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RegionVariableOrigin {
|
||||
pub fn span(&self) -> Span {
|
||||
match *self {
|
||||
|
|
@ -1271,33 +1165,3 @@ impl RegionVariableOrigin {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for RegionVariableOrigin {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
MiscVariable(a) => {
|
||||
format!("MiscVariable({})", a.repr(tcx))
|
||||
}
|
||||
PatternRegion(a) => {
|
||||
format!("PatternRegion({})", a.repr(tcx))
|
||||
}
|
||||
AddrOfRegion(a) => {
|
||||
format!("AddrOfRegion({})", a.repr(tcx))
|
||||
}
|
||||
Autoref(a) => format!("Autoref({})", a.repr(tcx)),
|
||||
Coercion(a) => format!("Coercion({})", a.repr(tcx)),
|
||||
EarlyBoundRegion(a, b) => {
|
||||
format!("EarlyBoundRegion({},{})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
LateBoundRegion(a, b, c) => {
|
||||
format!("LateBoundRegion({},{},{:?})", a.repr(tcx), b.repr(tcx), c)
|
||||
}
|
||||
BoundRegionInCoherence(a) => {
|
||||
format!("bound_regionInCoherence({})", a.repr(tcx))
|
||||
}
|
||||
UpvarRegion(a, b) => {
|
||||
format!("UpvarRegion({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ use super::Constraint;
|
|||
use middle::infer::SubregionOrigin;
|
||||
use middle::infer::region_inference::RegionVarBindings;
|
||||
use util::nodemap::{FnvHashMap, FnvHashSet};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::Entry::Vacant;
|
||||
|
|
@ -191,13 +190,13 @@ impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
|
|||
Node::RegionVid(n_vid) =>
|
||||
dot::LabelText::label(format!("{:?}", n_vid)),
|
||||
Node::Region(n_rgn) =>
|
||||
dot::LabelText::label(format!("{}", n_rgn.repr(self.tcx))),
|
||||
dot::LabelText::label(format!("{:?}", n_rgn)),
|
||||
}
|
||||
}
|
||||
fn edge_label(&self, e: &Edge) -> dot::LabelText {
|
||||
match *e {
|
||||
Edge::Constraint(ref c) =>
|
||||
dot::LabelText::label(format!("{}", self.map.get(c).unwrap().repr(self.tcx))),
|
||||
dot::LabelText::label(format!("{:?}", self.map.get(c).unwrap())),
|
||||
Edge::EnclScope(..) =>
|
||||
dot::LabelText::label(format!("(enclosed)")),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh};
|
|||
use middle::ty_relate::RelateResult;
|
||||
use util::common::indenter;
|
||||
use util::nodemap::{FnvHashMap, FnvHashSet};
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::cmp::Ordering::{self, Less, Greater, Equal};
|
||||
use std::fmt;
|
||||
use std::iter::repeat;
|
||||
use std::u32;
|
||||
use syntax::ast;
|
||||
|
|
@ -68,7 +68,7 @@ pub enum Verify<'tcx> {
|
|||
VerifyGenericBound(GenericKind<'tcx>, SubregionOrigin<'tcx>, Region, Vec<Region>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub enum GenericKind<'tcx> {
|
||||
Param(ty::ParamTy),
|
||||
Projection(ty::ProjectionTy<'tcx>),
|
||||
|
|
@ -323,8 +323,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
if self.in_snapshot() {
|
||||
self.undo_log.borrow_mut().push(AddVar(vid));
|
||||
}
|
||||
debug!("created new region variable {:?} with origin {}",
|
||||
vid, origin.repr(self.tcx));
|
||||
debug!("created new region variable {:?} with origin {:?}",
|
||||
vid, origin);
|
||||
return vid;
|
||||
}
|
||||
|
||||
|
|
@ -391,8 +391,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
// cannot add constraints once regions are resolved
|
||||
assert!(self.values_are_none());
|
||||
|
||||
debug!("RegionVarBindings: add_constraint({})",
|
||||
constraint.repr(self.tcx));
|
||||
debug!("RegionVarBindings: add_constraint({:?})",
|
||||
constraint);
|
||||
|
||||
if self.constraints.borrow_mut().insert(constraint, origin).is_none() {
|
||||
if self.in_snapshot() {
|
||||
|
|
@ -406,8 +406,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
// cannot add verifys once regions are resolved
|
||||
assert!(self.values_are_none());
|
||||
|
||||
debug!("RegionVarBindings: add_verify({})",
|
||||
verify.repr(self.tcx));
|
||||
debug!("RegionVarBindings: add_verify({:?})",
|
||||
verify);
|
||||
|
||||
let mut verifys = self.verifys.borrow_mut();
|
||||
let index = verifys.len();
|
||||
|
|
@ -425,8 +425,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
|
||||
let mut givens = self.givens.borrow_mut();
|
||||
if givens.insert((sub, sup)) {
|
||||
debug!("add_given({} <= {:?})",
|
||||
sub.repr(self.tcx),
|
||||
debug!("add_given({:?} <= {:?})",
|
||||
sub,
|
||||
sup);
|
||||
|
||||
self.undo_log.borrow_mut().push(AddGiven(sub, sup));
|
||||
|
|
@ -452,10 +452,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
// cannot add constraints once regions are resolved
|
||||
assert!(self.values_are_none());
|
||||
|
||||
debug!("RegionVarBindings: make_subregion({}, {}) due to {}",
|
||||
sub.repr(self.tcx),
|
||||
sup.repr(self.tcx),
|
||||
origin.repr(self.tcx));
|
||||
debug!("RegionVarBindings: make_subregion({:?}, {:?}) due to {:?}",
|
||||
sub,
|
||||
sup,
|
||||
origin);
|
||||
|
||||
match (sub, sup) {
|
||||
(ReEarlyBound(..), ReEarlyBound(..)) => {
|
||||
|
|
@ -471,9 +471,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
(_, ReLateBound(..)) => {
|
||||
self.tcx.sess.span_bug(
|
||||
origin.span(),
|
||||
&format!("cannot relate bound region: {} <= {}",
|
||||
sub.repr(self.tcx),
|
||||
sup.repr(self.tcx)));
|
||||
&format!("cannot relate bound region: {:?} <= {:?}",
|
||||
sub,
|
||||
sup));
|
||||
}
|
||||
(_, ReStatic) => {
|
||||
// all regions are subregions of static, so we can ignore this
|
||||
|
|
@ -510,9 +510,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
// cannot add constraints once regions are resolved
|
||||
assert!(self.values_are_none());
|
||||
|
||||
debug!("RegionVarBindings: lub_regions({}, {})",
|
||||
a.repr(self.tcx),
|
||||
b.repr(self.tcx));
|
||||
debug!("RegionVarBindings: lub_regions({:?}, {:?})",
|
||||
a,
|
||||
b);
|
||||
match (a, b) {
|
||||
(ReStatic, _) | (_, ReStatic) => {
|
||||
ReStatic // nothing lives longer than static
|
||||
|
|
@ -535,9 +535,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
// cannot add constraints once regions are resolved
|
||||
assert!(self.values_are_none());
|
||||
|
||||
debug!("RegionVarBindings: glb_regions({}, {})",
|
||||
a.repr(self.tcx),
|
||||
b.repr(self.tcx));
|
||||
debug!("RegionVarBindings: glb_regions({:?}, {:?})",
|
||||
a,
|
||||
b);
|
||||
match (a, b) {
|
||||
(ReStatic, r) | (r, ReStatic) => {
|
||||
// static lives longer than everything else
|
||||
|
|
@ -563,7 +563,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
}
|
||||
Some(ref values) => {
|
||||
let r = lookup(values, rid);
|
||||
debug!("resolve_var({:?}) = {}", rid, r.repr(self.tcx));
|
||||
debug!("resolve_var({:?}) = {:?}", rid, r);
|
||||
r
|
||||
}
|
||||
}
|
||||
|
|
@ -620,7 +620,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
/// made---`r0` itself will be the first entry. This is used when checking whether skolemized
|
||||
/// regions are being improperly related to other regions.
|
||||
pub fn tainted(&self, mark: &RegionSnapshot, r0: Region) -> Vec<Region> {
|
||||
debug!("tainted(mark={:?}, r0={})", mark, r0.repr(self.tcx));
|
||||
debug!("tainted(mark={:?}, r0={:?})", mark, r0);
|
||||
let _indenter = indenter();
|
||||
|
||||
// `result_set` acts as a worklist: we explore all outgoing
|
||||
|
|
@ -731,9 +731,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
(ReEarlyBound(..), _) |
|
||||
(_, ReEarlyBound(..)) => {
|
||||
self.tcx.sess.bug(
|
||||
&format!("cannot relate bound region: LUB({}, {})",
|
||||
a.repr(self.tcx),
|
||||
b.repr(self.tcx)));
|
||||
&format!("cannot relate bound region: LUB({:?}, {:?})",
|
||||
a,
|
||||
b));
|
||||
}
|
||||
|
||||
(ReStatic, _) | (_, ReStatic) => {
|
||||
|
|
@ -836,9 +836,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
(ReEarlyBound(..), _) |
|
||||
(_, ReEarlyBound(..)) => {
|
||||
self.tcx.sess.bug(
|
||||
&format!("cannot relate bound region: GLB({}, {})",
|
||||
a.repr(self.tcx),
|
||||
b.repr(self.tcx)));
|
||||
&format!("cannot relate bound region: GLB({:?}, {:?})",
|
||||
a,
|
||||
b));
|
||||
}
|
||||
|
||||
(ReStatic, r) | (r, ReStatic) => {
|
||||
|
|
@ -959,7 +959,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
enum Classification { Expanding, Contracting }
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum VarValue { NoValue, Value(Region), ErrorValue }
|
||||
|
||||
struct VarData {
|
||||
|
|
@ -1013,18 +1013,18 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
fn dump_constraints(&self) {
|
||||
debug!("----() Start constraint listing ()----");
|
||||
for (idx, (constraint, _)) in self.constraints.borrow().iter().enumerate() {
|
||||
debug!("Constraint {} => {}", idx, constraint.repr(self.tcx));
|
||||
debug!("Constraint {} => {:?}", idx, constraint);
|
||||
}
|
||||
}
|
||||
|
||||
fn expansion(&self, free_regions: &FreeRegionMap, var_data: &mut [VarData]) {
|
||||
self.iterate_until_fixed_point("Expansion", |constraint| {
|
||||
debug!("expansion: constraint={} origin={}",
|
||||
constraint.repr(self.tcx),
|
||||
debug!("expansion: constraint={:?} origin={:?}",
|
||||
constraint,
|
||||
self.constraints.borrow()
|
||||
.get(constraint)
|
||||
.unwrap()
|
||||
.repr(self.tcx));
|
||||
);
|
||||
match *constraint {
|
||||
ConstrainRegSubVar(a_region, b_vid) => {
|
||||
let b_data = &mut var_data[b_vid.index as usize];
|
||||
|
|
@ -1054,10 +1054,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
b_data: &mut VarData)
|
||||
-> bool
|
||||
{
|
||||
debug!("expand_node({}, {:?} == {})",
|
||||
a_region.repr(self.tcx),
|
||||
debug!("expand_node({:?}, {:?} == {:?})",
|
||||
a_region,
|
||||
b_vid,
|
||||
b_data.value.repr(self.tcx));
|
||||
b_data.value);
|
||||
|
||||
// Check if this relationship is implied by a given.
|
||||
match a_region {
|
||||
|
|
@ -1073,8 +1073,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
b_data.classification = Expanding;
|
||||
match b_data.value {
|
||||
NoValue => {
|
||||
debug!("Setting initial value of {:?} to {}",
|
||||
b_vid, a_region.repr(self.tcx));
|
||||
debug!("Setting initial value of {:?} to {:?}",
|
||||
b_vid, a_region);
|
||||
|
||||
b_data.value = Value(a_region);
|
||||
return true;
|
||||
|
|
@ -1086,10 +1086,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
return false;
|
||||
}
|
||||
|
||||
debug!("Expanding value of {:?} from {} to {}",
|
||||
debug!("Expanding value of {:?} from {:?} to {:?}",
|
||||
b_vid,
|
||||
cur_region.repr(self.tcx),
|
||||
lub.repr(self.tcx));
|
||||
cur_region,
|
||||
lub);
|
||||
|
||||
b_data.value = Value(lub);
|
||||
return true;
|
||||
|
|
@ -1105,12 +1105,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
free_regions: &FreeRegionMap,
|
||||
var_data: &mut [VarData]) {
|
||||
self.iterate_until_fixed_point("Contraction", |constraint| {
|
||||
debug!("contraction: constraint={} origin={}",
|
||||
constraint.repr(self.tcx),
|
||||
debug!("contraction: constraint={:?} origin={:?}",
|
||||
constraint,
|
||||
self.constraints.borrow()
|
||||
.get(constraint)
|
||||
.unwrap()
|
||||
.repr(self.tcx));
|
||||
);
|
||||
match *constraint {
|
||||
ConstrainRegSubVar(..) => {
|
||||
// This is an expansion constraint. Ignore.
|
||||
|
|
@ -1139,9 +1139,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
a_data: &mut VarData,
|
||||
b_region: Region)
|
||||
-> bool {
|
||||
debug!("contract_node({:?} == {}/{:?}, {})",
|
||||
a_vid, a_data.value.repr(self.tcx),
|
||||
a_data.classification, b_region.repr(self.tcx));
|
||||
debug!("contract_node({:?} == {:?}/{:?}, {:?})",
|
||||
a_vid, a_data.value,
|
||||
a_data.classification, b_region);
|
||||
|
||||
return match a_data.value {
|
||||
NoValue => {
|
||||
|
|
@ -1171,10 +1171,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
-> bool
|
||||
{
|
||||
if !free_regions.is_subregion_of(this.tcx, a_region, b_region) {
|
||||
debug!("Setting {:?} to ErrorValue: {} not subregion of {}",
|
||||
debug!("Setting {:?} to ErrorValue: {:?} not subregion of {:?}",
|
||||
a_vid,
|
||||
a_region.repr(this.tcx),
|
||||
b_region.repr(this.tcx));
|
||||
a_region,
|
||||
b_region);
|
||||
a_data.value = ErrorValue;
|
||||
}
|
||||
false
|
||||
|
|
@ -1192,19 +1192,19 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
if glb == a_region {
|
||||
false
|
||||
} else {
|
||||
debug!("Contracting value of {:?} from {} to {}",
|
||||
debug!("Contracting value of {:?} from {:?} to {:?}",
|
||||
a_vid,
|
||||
a_region.repr(this.tcx),
|
||||
glb.repr(this.tcx));
|
||||
a_region,
|
||||
glb);
|
||||
a_data.value = Value(glb);
|
||||
true
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
debug!("Setting {:?} to ErrorValue: no glb of {}, {}",
|
||||
debug!("Setting {:?} to ErrorValue: no glb of {:?}, {:?}",
|
||||
a_vid,
|
||||
a_region.repr(this.tcx),
|
||||
b_region.repr(this.tcx));
|
||||
a_region,
|
||||
b_region);
|
||||
a_data.value = ErrorValue;
|
||||
false
|
||||
}
|
||||
|
|
@ -1229,9 +1229,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
continue;
|
||||
}
|
||||
|
||||
debug!("ConcreteFailure: !(sub <= sup): sub={}, sup={}",
|
||||
sub.repr(self.tcx),
|
||||
sup.repr(self.tcx));
|
||||
debug!("ConcreteFailure: !(sub <= sup): sub={:?}, sup={:?}",
|
||||
sub,
|
||||
sup);
|
||||
errors.push(ConcreteFailure((*origin).clone(), sub, sup));
|
||||
}
|
||||
|
||||
|
|
@ -1431,10 +1431,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
self.tcx.sess.span_bug(
|
||||
(*self.var_origins.borrow())[node_idx.index as usize].span(),
|
||||
&format!("collect_error_for_expanding_node() could not find error \
|
||||
for var {:?}, lower_bounds={}, upper_bounds={}",
|
||||
for var {:?}, lower_bounds={:?}, upper_bounds={:?}",
|
||||
node_idx,
|
||||
lower_bounds.repr(self.tcx),
|
||||
upper_bounds.repr(self.tcx)));
|
||||
lower_bounds,
|
||||
upper_bounds));
|
||||
}
|
||||
|
||||
fn collect_error_for_contracting_node(
|
||||
|
|
@ -1478,9 +1478,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
self.tcx.sess.span_bug(
|
||||
(*self.var_origins.borrow())[node_idx.index as usize].span(),
|
||||
&format!("collect_error_for_contracting_node() could not find error \
|
||||
for var {:?}, upper_bounds={}",
|
||||
for var {:?}, upper_bounds={:?}",
|
||||
node_idx,
|
||||
upper_bounds.repr(self.tcx)));
|
||||
upper_bounds));
|
||||
}
|
||||
|
||||
fn collect_concrete_regions(&self,
|
||||
|
|
@ -1578,8 +1578,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
for (constraint, _) in self.constraints.borrow().iter() {
|
||||
let edge_changed = body(constraint);
|
||||
if edge_changed {
|
||||
debug!("Updated due to constraint {}",
|
||||
constraint.repr(self.tcx));
|
||||
debug!("Updated due to constraint {:?}",
|
||||
constraint);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1589,31 +1589,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for Constraint {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
ConstrainVarSubVar(a, b) => {
|
||||
format!("ConstrainVarSubVar({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
ConstrainRegSubVar(a, b) => {
|
||||
format!("ConstrainRegSubVar({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
ConstrainVarSubReg(a, b) => {
|
||||
format!("ConstrainVarSubReg({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for Verify<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
impl<'tcx> fmt::Debug for Verify<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
VerifyRegSubReg(_, ref a, ref b) => {
|
||||
format!("VerifyRegSubReg({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
write!(f, "VerifyRegSubReg({:?}, {:?})", a, b)
|
||||
}
|
||||
VerifyGenericBound(_, ref p, ref a, ref bs) => {
|
||||
format!("VerifyGenericBound({}, {}, {})",
|
||||
p.repr(tcx), a.repr(tcx), bs.repr(tcx))
|
||||
write!(f, "VerifyGenericBound({:?}, {:?}, {:?})", p, a, bs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1634,38 +1617,28 @@ fn lookup(values: &Vec<VarValue>, rid: ty::RegionVid) -> ty::Region {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for VarValue {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "RegionAndOrigin({:?},{:?})",
|
||||
self.region,
|
||||
self.origin)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for GenericKind<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
NoValue => format!("NoValue"),
|
||||
Value(r) => format!("Value({})", r.repr(tcx)),
|
||||
ErrorValue => format!("ErrorValue"),
|
||||
GenericKind::Param(ref p) => write!(f, "{:?}", p),
|
||||
GenericKind::Projection(ref p) => write!(f, "{:?}", p),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for RegionAndOrigin<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("RegionAndOrigin({},{})",
|
||||
self.region.repr(tcx),
|
||||
self.origin.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for GenericKind<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
impl<'tcx> fmt::Display for GenericKind<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
GenericKind::Param(ref p) => p.repr(tcx),
|
||||
GenericKind::Projection(ref p) => p.repr(tcx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UserString<'tcx> for GenericKind<'tcx> {
|
||||
fn user_string(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
GenericKind::Param(ref p) => p.user_string(tcx),
|
||||
GenericKind::Projection(ref p) => p.user_string(tcx),
|
||||
GenericKind::Param(ref p) => write!(f, "{}", p),
|
||||
GenericKind::Projection(ref p) => write!(f, "{}", p),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
use super::{InferCtxt, fixup_err, fres, unresolved_ty, unresolved_int_ty, unresolved_float_ty};
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty_fold::{self, TypeFoldable};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// OPPORTUNISTIC TYPE RESOLVER
|
||||
|
|
@ -95,8 +94,8 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
|||
}
|
||||
ty::TyInfer(_) => {
|
||||
self.infcx.tcx.sess.bug(
|
||||
&format!("Unexpected type in full type resolver: {}",
|
||||
t.repr(self.infcx.tcx)));
|
||||
&format!("Unexpected type in full type resolver: {:?}",
|
||||
t));
|
||||
}
|
||||
_ => {
|
||||
ty_fold::super_fold_ty(self, t)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use super::type_variable::{SubtypeOf, SupertypeOf};
|
|||
use middle::ty::{self, Ty};
|
||||
use middle::ty::TyVar;
|
||||
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
|
||||
use util::ppaux::{Repr};
|
||||
|
||||
/// "Greatest lower bound" (common subtype)
|
||||
pub struct Sub<'a, 'tcx: 'a> {
|
||||
|
|
@ -49,7 +48,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
debug!("{}.tys({}, {})", self.tag(), a.repr(self.tcx()), b.repr(self.tcx()));
|
||||
debug!("{}.tys({:?}, {:?})", self.tag(), a, b);
|
||||
|
||||
if a == b { return Ok(a); }
|
||||
|
||||
|
|
@ -85,10 +84,10 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
debug!("{}.regions({:?}, {:?})",
|
||||
self.tag(),
|
||||
a.repr(self.tcx()),
|
||||
b.repr(self.tcx()));
|
||||
a,
|
||||
b);
|
||||
let origin = Subtype(self.fields.trace.clone());
|
||||
self.fields.infcx.region_vars.make_subregion(origin, a, b);
|
||||
Ok(a)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ use middle::def::DefFn;
|
|||
use middle::subst::{Subst, Substs, EnumeratedItems};
|
||||
use middle::ty::{TransmuteRestriction, ctxt, TyBareFn};
|
||||
use middle::ty::{self, Ty};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use syntax::abi::RustIntrinsic;
|
||||
use syntax::ast::DefId;
|
||||
|
|
@ -202,15 +203,15 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
|||
|
||||
match types_in_scope.next() {
|
||||
None => {
|
||||
debug!("with_each_combination(substs={})",
|
||||
substs.repr(self.tcx));
|
||||
debug!("with_each_combination(substs={:?})",
|
||||
substs);
|
||||
|
||||
callback(substs);
|
||||
}
|
||||
|
||||
Some((space, index, ¶m_ty)) => {
|
||||
debug!("with_each_combination: space={:?}, index={}, param_ty={}",
|
||||
space, index, param_ty.repr(self.tcx));
|
||||
debug!("with_each_combination: space={:?}, index={}, param_ty={:?}",
|
||||
space, index, param_ty);
|
||||
|
||||
if !ty::type_is_sized(Some(param_env), self.tcx, span, param_ty) {
|
||||
debug!("with_each_combination: param_ty is not known to be sized");
|
||||
|
|
@ -228,7 +229,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn push_transmute_restriction(&self, restriction: TransmuteRestriction<'tcx>) {
|
||||
debug!("Pushing transmute restriction: {}", restriction.repr(self.tcx));
|
||||
debug!("Pushing transmute restriction: {:?}", restriction);
|
||||
self.tcx.transmute_restrictions.borrow_mut().push(restriction);
|
||||
}
|
||||
}
|
||||
|
|
@ -277,13 +278,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for TransmuteRestriction<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("TransmuteRestriction(id={}, original=({},{}), substituted=({},{}))",
|
||||
self.id,
|
||||
self.original_from.repr(tcx),
|
||||
self.original_to.repr(tcx),
|
||||
self.substituted_from.repr(tcx),
|
||||
self.substituted_to.repr(tcx))
|
||||
impl<'tcx> fmt::Debug for TransmuteRestriction<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "TransmuteRestriction(id={}, original=({:?},{:?}), substituted=({:?},{:?}))",
|
||||
self.id,
|
||||
self.original_from,
|
||||
self.original_to,
|
||||
self.substituted_from,
|
||||
self.substituted_to)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,18 +78,16 @@ use middle::def;
|
|||
use middle::region;
|
||||
use middle::ty::{self, Ty};
|
||||
use util::nodemap::NodeMap;
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
use syntax::ast::{MutImmutable, MutMutable};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::print::pprust;
|
||||
use syntax::parse::token;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum categorization<'tcx> {
|
||||
cat_rvalue(ty::Region), // temporary val, argument is its scope
|
||||
cat_static_item,
|
||||
|
|
@ -103,14 +101,14 @@ pub enum categorization<'tcx> {
|
|||
}
|
||||
|
||||
// Represents any kind of upvar
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct Upvar {
|
||||
pub id: ty::UpvarId,
|
||||
pub kind: ty::ClosureKind
|
||||
}
|
||||
|
||||
// different kinds of pointers:
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum PointerKind {
|
||||
/// `Box<T>`
|
||||
Unique,
|
||||
|
|
@ -127,7 +125,7 @@ pub enum PointerKind {
|
|||
|
||||
// We use the term "interior" to mean "something reachable from the
|
||||
// base without a pointer dereference", e.g. a field
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum InteriorKind {
|
||||
InteriorField(FieldName),
|
||||
InteriorElement(InteriorOffsetKind, ElementKind),
|
||||
|
|
@ -184,7 +182,7 @@ pub enum Note {
|
|||
// dereference, but its type is the type *before* the dereference
|
||||
// (`@T`). So use `cmt.ty` to find the type of the value in a consistent
|
||||
// fashion. For more details, see the method `cat_pattern`
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct cmt_<'tcx> {
|
||||
pub id: ast::NodeId, // id of expr/pat producing this value
|
||||
pub span: Span, // span of same expr/pat
|
||||
|
|
@ -418,7 +416,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
}
|
||||
|
||||
fn pat_ty(&self, pat: &ast::Pat) -> McResult<Ty<'tcx>> {
|
||||
let tcx = self.typer.tcx();
|
||||
let base_ty = try!(self.typer.node_ty(pat.id));
|
||||
// FIXME (Issue #18207): This code detects whether we are
|
||||
// looking at a `ref x`, and if so, figures out what the type
|
||||
|
|
@ -436,8 +433,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
}
|
||||
_ => base_ty,
|
||||
};
|
||||
debug!("pat_ty(pat={}) base_ty={} ret_ty={}",
|
||||
pat.repr(tcx), base_ty.repr(tcx), ret_ty.repr(tcx));
|
||||
debug!("pat_ty(pat={:?}) base_ty={:?} ret_ty={:?}",
|
||||
pat, base_ty, ret_ty);
|
||||
Ok(ret_ty)
|
||||
}
|
||||
|
||||
|
|
@ -460,9 +457,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
ty::AdjustReifyFnPointer |
|
||||
ty::AdjustUnsafeFnPointer |
|
||||
ty::AdjustDerefRef(_) => {
|
||||
debug!("cat_expr({}): {}",
|
||||
adjustment.repr(self.tcx()),
|
||||
expr.repr(self.tcx()));
|
||||
debug!("cat_expr({:?}): {:?}",
|
||||
adjustment,
|
||||
expr);
|
||||
// Result is an rvalue.
|
||||
let expr_ty = try!(self.expr_ty_adjusted(expr));
|
||||
Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty))
|
||||
|
|
@ -477,9 +474,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
autoderefs: usize)
|
||||
-> McResult<cmt<'tcx>> {
|
||||
let mut cmt = try!(self.cat_expr_unadjusted(expr));
|
||||
debug!("cat_expr_autoderefd: autoderefs={}, cmt={}",
|
||||
debug!("cat_expr_autoderefd: autoderefs={}, cmt={:?}",
|
||||
autoderefs,
|
||||
cmt.repr(self.tcx()));
|
||||
cmt);
|
||||
for deref in 1..autoderefs + 1 {
|
||||
cmt = try!(self.cat_deref(expr, cmt, deref, None));
|
||||
}
|
||||
|
|
@ -487,7 +484,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
}
|
||||
|
||||
pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt<'tcx>> {
|
||||
debug!("cat_expr: id={} expr={}", expr.id, expr.repr(self.tcx()));
|
||||
debug!("cat_expr: id={} expr={:?}", expr.id, expr);
|
||||
|
||||
let expr_ty = try!(self.expr_ty(expr));
|
||||
match expr.node {
|
||||
|
|
@ -498,10 +495,10 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
|
||||
ast::ExprField(ref base, f_name) => {
|
||||
let base_cmt = try!(self.cat_expr(&**base));
|
||||
debug!("cat_expr(cat_field): id={} expr={} base={}",
|
||||
debug!("cat_expr(cat_field): id={} expr={:?} base={:?}",
|
||||
expr.id,
|
||||
expr.repr(self.tcx()),
|
||||
base_cmt.repr(self.tcx()));
|
||||
expr,
|
||||
base_cmt);
|
||||
Ok(self.cat_field(expr, base_cmt, f_name.node.name, expr_ty))
|
||||
}
|
||||
|
||||
|
|
@ -524,8 +521,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
let elem_ty = match ret_ty.sty {
|
||||
ty::TyRef(_, mt) => mt.ty,
|
||||
_ => {
|
||||
debug!("cat_expr_unadjusted: return type of overloaded index is {}?",
|
||||
ret_ty.repr(self.tcx()));
|
||||
debug!("cat_expr_unadjusted: return type of overloaded index is {:?}?",
|
||||
ret_ty);
|
||||
return Err(());
|
||||
}
|
||||
};
|
||||
|
|
@ -583,8 +580,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
expr_ty: Ty<'tcx>,
|
||||
def: def::Def)
|
||||
-> McResult<cmt<'tcx>> {
|
||||
debug!("cat_def: id={} expr={} def={:?}",
|
||||
id, expr_ty.repr(self.tcx()), def);
|
||||
debug!("cat_def: id={} expr={:?} def={:?}",
|
||||
id, expr_ty, def);
|
||||
|
||||
match def {
|
||||
def::DefStruct(..) | def::DefVariant(..) | def::DefConst(..) |
|
||||
|
|
@ -635,9 +632,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
_ => {
|
||||
self.tcx().sess.span_bug(
|
||||
span,
|
||||
&format!("Upvar of non-closure {} - {}",
|
||||
&format!("Upvar of non-closure {} - {:?}",
|
||||
fn_node_id,
|
||||
ty.repr(self.tcx())));
|
||||
ty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -746,7 +743,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
};
|
||||
|
||||
let ret = Rc::new(cmt_result);
|
||||
debug!("cat_upvar ret={}", ret.repr(self.tcx()));
|
||||
debug!("cat_upvar ret={:?}", ret);
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
|
|
@ -817,7 +814,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
note: NoteClosureEnv(upvar_id)
|
||||
};
|
||||
|
||||
debug!("env_deref ret {}", ret.repr(self.tcx()));
|
||||
debug!("env_deref ret {:?}", ret);
|
||||
|
||||
ret
|
||||
}
|
||||
|
|
@ -855,7 +852,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
ty::ReStatic
|
||||
};
|
||||
let ret = self.cat_rvalue(id, span, re, expr_ty);
|
||||
debug!("cat_rvalue_node ret {}", ret.repr(self.tcx()));
|
||||
debug!("cat_rvalue_node ret {:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
|
|
@ -872,7 +869,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
ty:expr_ty,
|
||||
note: NoteNone
|
||||
});
|
||||
debug!("cat_rvalue ret {}", ret.repr(self.tcx()));
|
||||
debug!("cat_rvalue ret {:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
|
|
@ -890,7 +887,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
ty: f_ty,
|
||||
note: NoteNone
|
||||
});
|
||||
debug!("cat_field ret {}", ret.repr(self.tcx()));
|
||||
debug!("cat_field ret {:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
|
|
@ -908,7 +905,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
ty: f_ty,
|
||||
note: NoteNone
|
||||
});
|
||||
debug!("cat_tup_field ret {}", ret.repr(self.tcx()));
|
||||
debug!("cat_tup_field ret {:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
|
|
@ -925,7 +922,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
let method_ty = self.typer.node_method_ty(method_call);
|
||||
|
||||
debug!("cat_deref: method_call={:?} method_ty={:?}",
|
||||
method_call, method_ty.map(|ty| ty.repr(self.tcx())));
|
||||
method_call, method_ty.map(|ty| ty));
|
||||
|
||||
let base_cmt = match method_ty {
|
||||
Some(method_ty) => {
|
||||
|
|
@ -943,12 +940,12 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
mt.ty,
|
||||
deref_context,
|
||||
/* implicit: */ false);
|
||||
debug!("cat_deref ret {}", ret.repr(self.tcx()));
|
||||
debug!("cat_deref ret {:?}", ret);
|
||||
ret
|
||||
}
|
||||
None => {
|
||||
debug!("Explicit deref of non-derefable type: {}",
|
||||
base_cmt_ty.repr(self.tcx()));
|
||||
debug!("Explicit deref of non-derefable type: {:?}",
|
||||
base_cmt_ty);
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
|
|
@ -991,7 +988,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
ty: deref_ty,
|
||||
note: NoteNone
|
||||
});
|
||||
debug!("cat_deref_common ret {}", ret.repr(self.tcx()));
|
||||
debug!("cat_deref_common ret {:?}", ret);
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
|
|
@ -1042,7 +1039,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
let m = base_cmt.mutbl.inherit();
|
||||
let ret = interior(elt, base_cmt.clone(), base_cmt.ty,
|
||||
m, context, element_ty);
|
||||
debug!("cat_index ret {}", ret.repr(self.tcx()));
|
||||
debug!("cat_index ret {:?}", ret);
|
||||
return Ok(ret);
|
||||
|
||||
fn interior<'tcx, N: ast_node>(elt: &N,
|
||||
|
|
@ -1096,7 +1093,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
base_cmt
|
||||
}
|
||||
};
|
||||
debug!("deref_vec ret {}", ret.repr(self.tcx()));
|
||||
debug!("deref_vec ret {:?}", ret);
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
|
|
@ -1155,7 +1152,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
ty: interior_ty,
|
||||
note: NoteNone
|
||||
});
|
||||
debug!("cat_imm_interior ret={}", ret.repr(self.tcx()));
|
||||
debug!("cat_imm_interior ret={:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
|
|
@ -1173,7 +1170,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
ty: downcast_ty,
|
||||
note: NoteNone
|
||||
});
|
||||
debug!("cat_downcast ret={}", ret.repr(self.tcx()));
|
||||
debug!("cat_downcast ret={:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
|
|
@ -1233,9 +1230,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
// step out of sync again. So you'll see below that we always
|
||||
// get the type of the *subpattern* and use that.
|
||||
|
||||
debug!("cat_pattern: id={} pat={} cmt={}",
|
||||
pat.id, pprust::pat_to_string(pat),
|
||||
cmt.repr(self.tcx()));
|
||||
debug!("cat_pattern: {:?} cmt={:?}",
|
||||
pat,
|
||||
cmt);
|
||||
|
||||
(*op)(self, cmt.clone(), pat);
|
||||
|
||||
|
|
@ -1521,7 +1518,7 @@ impl<'tcx> cmt_<'tcx> {
|
|||
let upvar = self.upvar();
|
||||
match upvar.as_ref().map(|i| &i.cat) {
|
||||
Some(&cat_upvar(ref var)) => {
|
||||
var.user_string(tcx)
|
||||
var.to_string()
|
||||
}
|
||||
Some(_) => unreachable!(),
|
||||
None => {
|
||||
|
|
@ -1561,7 +1558,7 @@ impl<'tcx> cmt_<'tcx> {
|
|||
"pattern-bound indexed content".to_string()
|
||||
}
|
||||
cat_upvar(ref var) => {
|
||||
var.user_string(tcx)
|
||||
var.to_string()
|
||||
}
|
||||
cat_downcast(ref cmt, _) => {
|
||||
cmt.descriptive_string(tcx)
|
||||
|
|
@ -1570,33 +1567,36 @@ impl<'tcx> cmt_<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for cmt_<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("{{{} id:{} m:{:?} ty:{}}}",
|
||||
self.cat.repr(tcx),
|
||||
self.id,
|
||||
self.mutbl,
|
||||
self.ty.repr(tcx))
|
||||
impl<'tcx> fmt::Debug for cmt_<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{{{:?} id:{} m:{:?} ty:{:?}}}",
|
||||
self.cat,
|
||||
self.id,
|
||||
self.mutbl,
|
||||
self.ty)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for categorization<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
impl<'tcx> fmt::Debug for categorization<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
cat_static_item |
|
||||
cat_rvalue(..) |
|
||||
cat_local(..) |
|
||||
cat_upvar(..) => {
|
||||
format!("{:?}", *self)
|
||||
cat_static_item => write!(f, "static"),
|
||||
cat_rvalue(r) => write!(f, "rvalue({:?})", r),
|
||||
cat_local(id) => {
|
||||
let name = ty::tls::with(|tcx| ty::local_var_name_str(tcx, id));
|
||||
write!(f, "local({})", name)
|
||||
}
|
||||
cat_upvar(upvar) => {
|
||||
write!(f, "upvar({:?})", upvar)
|
||||
}
|
||||
cat_deref(ref cmt, derefs, ptr) => {
|
||||
format!("{}-{}{}->", cmt.cat.repr(tcx), ptr.repr(tcx), derefs)
|
||||
write!(f, "{:?}-{:?}{}->", cmt.cat, ptr, derefs)
|
||||
}
|
||||
cat_interior(ref cmt, interior) => {
|
||||
format!("{}.{}", cmt.cat.repr(tcx), interior.repr(tcx))
|
||||
write!(f, "{:?}.{:?}", cmt.cat, interior)
|
||||
}
|
||||
cat_downcast(ref cmt, _) => {
|
||||
format!("{}->(enum)", cmt.cat.repr(tcx))
|
||||
write!(f, "{:?}->(enum)", cmt.cat)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1615,39 +1615,33 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for PointerKind {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
impl fmt::Debug for PointerKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
Unique => {
|
||||
format!("Box")
|
||||
}
|
||||
Unique => write!(f, "Box"),
|
||||
BorrowedPtr(ty::ImmBorrow, ref r) |
|
||||
Implicit(ty::ImmBorrow, ref r) => {
|
||||
format!("&{}", r.repr(tcx))
|
||||
write!(f, "&{:?}", r)
|
||||
}
|
||||
BorrowedPtr(ty::MutBorrow, ref r) |
|
||||
Implicit(ty::MutBorrow, ref r) => {
|
||||
format!("&{} mut", r.repr(tcx))
|
||||
write!(f, "&{:?} mut", r)
|
||||
}
|
||||
BorrowedPtr(ty::UniqueImmBorrow, ref r) |
|
||||
Implicit(ty::UniqueImmBorrow, ref r) => {
|
||||
format!("&{} uniq", r.repr(tcx))
|
||||
}
|
||||
UnsafePtr(_) => {
|
||||
format!("*")
|
||||
write!(f, "&{:?} uniq", r)
|
||||
}
|
||||
UnsafePtr(_) => write!(f, "*")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for InteriorKind {
|
||||
fn repr(&self, _tcx: &ty::ctxt) -> String {
|
||||
impl fmt::Debug for InteriorKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
InteriorField(NamedField(fld)) => {
|
||||
token::get_name(fld).to_string()
|
||||
}
|
||||
InteriorField(PositionalField(i)) => format!("#{}", i),
|
||||
InteriorElement(..) => "[]".to_string(),
|
||||
InteriorField(NamedField(fld)) => write!(f, "{}", fld),
|
||||
InteriorField(PositionalField(i)) => write!(f, "#{}", i),
|
||||
InteriorElement(..) => write!(f, "[]"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1664,25 +1658,19 @@ fn element_kind(t: Ty) -> ElementKind {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for ty::ClosureKind {
|
||||
fn repr(&self, _: &ty::ctxt) -> String {
|
||||
format!("Upvar({:?})", self)
|
||||
impl fmt::Debug for Upvar {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{:?}/{:?}", self.id, self.kind)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for Upvar {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
format!("Upvar({})", self.kind.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UserString<'tcx> for Upvar {
|
||||
fn user_string(&self, _: &ty::ctxt) -> String {
|
||||
impl fmt::Display for Upvar {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let kind = match self.kind {
|
||||
ty::FnClosureKind => "Fn",
|
||||
ty::FnMutClosureKind => "FnMut",
|
||||
ty::FnOnceClosureKind => "FnOnce",
|
||||
};
|
||||
format!("captured outer variable in an `{}` closure", kind)
|
||||
write!(f, "captured outer variable in an `{}` closure", kind)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ use syntax::attr::{Stability, AttrMetaMethods};
|
|||
use syntax::visit::{FnKind, Visitor};
|
||||
use syntax::feature_gate::emit_feature_err;
|
||||
use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use std::mem::replace;
|
||||
|
||||
|
|
@ -450,7 +449,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
|
|||
tcx.sess.span_bug(e.span,
|
||||
&format!("stability::check_expr: struct construction \
|
||||
of non-struct, type {:?}",
|
||||
type_.repr(tcx)));
|
||||
type_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -551,7 +550,7 @@ pub fn lookup<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability>
|
|||
}
|
||||
|
||||
fn lookup_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> {
|
||||
debug!("lookup(id={})", id.repr(tcx));
|
||||
debug!("lookup(id={:?})", id);
|
||||
|
||||
// is this definition the implementation of a trait method?
|
||||
match ty::trait_item_of_item(tcx, id) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ pub use self::RegionSubsts::*;
|
|||
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty_fold::{self, TypeFoldable, TypeFolder};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use std::fmt;
|
||||
use std::iter::IntoIterator;
|
||||
|
|
@ -29,7 +28,7 @@ use syntax::codemap::{Span, DUMMY_SP};
|
|||
/// identify each in-scope parameter by an *index* and a *parameter
|
||||
/// space* (which indices where the parameter is defined; see
|
||||
/// `ParamSpace`).
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Substs<'tcx> {
|
||||
pub types: VecPerParamSpace<Ty<'tcx>>,
|
||||
pub regions: RegionSubsts,
|
||||
|
|
@ -38,7 +37,7 @@ pub struct Substs<'tcx> {
|
|||
/// Represents the values to use when substituting lifetime parameters.
|
||||
/// If the value is `ErasedRegions`, then this subst is occurring during
|
||||
/// trans, and all region parameters will be replaced with `ty::ReStatic`.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum RegionSubsts {
|
||||
ErasedRegions,
|
||||
NonerasedRegions(VecPerParamSpace<ty::Region>)
|
||||
|
|
@ -240,13 +239,11 @@ pub struct SeparateVecsPerParamSpace<T> {
|
|||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(write!(fmt, "VecPerParamSpace {{"));
|
||||
for space in &ParamSpace::all() {
|
||||
try!(write!(fmt, "{:?}: {:?}, ", *space, self.get_slice(*space)));
|
||||
}
|
||||
try!(write!(fmt, "}}"));
|
||||
Ok(())
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "[{:?};{:?};{:?}]",
|
||||
self.get_slice(TypeSpace),
|
||||
self.get_slice(SelfSpace),
|
||||
self.get_slice(FnSpace))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -620,10 +617,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
|||
self.tcx().sess.span_bug(
|
||||
span,
|
||||
&format!("Type parameter out of range \
|
||||
when substituting in region {} (root type={}) \
|
||||
when substituting in region {} (root type={:?}) \
|
||||
(space={:?}, index={})",
|
||||
data.name.as_str(),
|
||||
self.root_ty.repr(self.tcx()),
|
||||
data.name,
|
||||
self.root_ty,
|
||||
data.space,
|
||||
data.index));
|
||||
}
|
||||
|
|
@ -675,14 +672,14 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> {
|
|||
let span = self.span.unwrap_or(DUMMY_SP);
|
||||
self.tcx().sess.span_bug(
|
||||
span,
|
||||
&format!("Type parameter `{}` ({}/{:?}/{}) out of range \
|
||||
when substituting (root type={}) substs={}",
|
||||
p.repr(self.tcx()),
|
||||
source_ty.repr(self.tcx()),
|
||||
&format!("Type parameter `{:?}` ({:?}/{:?}/{}) out of range \
|
||||
when substituting (root type={:?}) substs={:?}",
|
||||
p,
|
||||
source_ty,
|
||||
p.space,
|
||||
p.idx,
|
||||
self.root_ty.repr(self.tcx()),
|
||||
self.substs.repr(self.tcx())));
|
||||
self.root_ty,
|
||||
self.substs));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -733,14 +730,14 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> {
|
|||
/// is that only in the second case have we passed through a fn binder.
|
||||
fn shift_regions_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
debug!("shift_regions(ty={:?}, region_binders_passed={:?}, type_has_escaping_regions={:?})",
|
||||
ty.repr(self.tcx()), self.region_binders_passed, ty::type_has_escaping_regions(ty));
|
||||
ty, self.region_binders_passed, ty::type_has_escaping_regions(ty));
|
||||
|
||||
if self.region_binders_passed == 0 || !ty::type_has_escaping_regions(ty) {
|
||||
return ty;
|
||||
}
|
||||
|
||||
let result = ty_fold::shift_regions(self.tcx(), self.region_binders_passed, &ty);
|
||||
debug!("shift_regions: shifted result = {:?}", result.repr(self.tcx()));
|
||||
debug!("shift_regions: shifted result = {:?}", result);
|
||||
|
||||
result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ use middle::ty::{self, ToPolyTraitRef, Ty};
|
|||
use middle::infer::{self, InferCtxt};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct InferIsLocal(bool);
|
||||
|
|
@ -34,10 +33,10 @@ pub fn overlapping_impls(infcx: &InferCtxt,
|
|||
-> bool
|
||||
{
|
||||
debug!("impl_can_satisfy(\
|
||||
impl1_def_id={}, \
|
||||
impl2_def_id={})",
|
||||
impl1_def_id.repr(infcx.tcx),
|
||||
impl2_def_id.repr(infcx.tcx));
|
||||
impl1_def_id={:?}, \
|
||||
impl2_def_id={:?})",
|
||||
impl1_def_id,
|
||||
impl2_def_id);
|
||||
|
||||
let param_env = &ty::empty_parameter_environment(infcx.tcx);
|
||||
let selcx = &mut SelectionContext::intercrate(infcx, param_env);
|
||||
|
|
@ -53,9 +52,9 @@ fn overlap(selcx: &mut SelectionContext,
|
|||
b_def_id: ast::DefId)
|
||||
-> bool
|
||||
{
|
||||
debug!("overlap(a_def_id={}, b_def_id={})",
|
||||
a_def_id.repr(selcx.tcx()),
|
||||
b_def_id.repr(selcx.tcx()));
|
||||
debug!("overlap(a_def_id={:?}, b_def_id={:?})",
|
||||
a_def_id,
|
||||
b_def_id);
|
||||
|
||||
let (a_trait_ref, a_obligations) = impl_trait_ref_and_oblig(selcx,
|
||||
a_def_id,
|
||||
|
|
@ -65,9 +64,9 @@ fn overlap(selcx: &mut SelectionContext,
|
|||
b_def_id,
|
||||
util::fresh_type_vars_for_impl);
|
||||
|
||||
debug!("overlap: a_trait_ref={}", a_trait_ref.repr(selcx.tcx()));
|
||||
debug!("overlap: a_trait_ref={:?}", a_trait_ref);
|
||||
|
||||
debug!("overlap: b_trait_ref={}", b_trait_ref.repr(selcx.tcx()));
|
||||
debug!("overlap: b_trait_ref={:?}", b_trait_ref);
|
||||
|
||||
// Does `a <: b` hold? If not, no overlap.
|
||||
if let Err(_) = infer::mk_sub_poly_trait_refs(selcx.infcx(),
|
||||
|
|
@ -81,7 +80,6 @@ fn overlap(selcx: &mut SelectionContext,
|
|||
debug!("overlap: subtraitref check succeeded");
|
||||
|
||||
// Are any of the obligations unsatisfiable? If so, no overlap.
|
||||
let tcx = selcx.tcx();
|
||||
let infcx = selcx.infcx();
|
||||
let opt_failing_obligation =
|
||||
a_obligations.iter()
|
||||
|
|
@ -90,7 +88,7 @@ fn overlap(selcx: &mut SelectionContext,
|
|||
.find(|o| !selcx.evaluate_obligation(o));
|
||||
|
||||
if let Some(failing_obligation) = opt_failing_obligation {
|
||||
debug!("overlap: obligation unsatisfiable {}", failing_obligation.repr(tcx));
|
||||
debug!("overlap: obligation unsatisfiable {:?}", failing_obligation);
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +97,7 @@ fn overlap(selcx: &mut SelectionContext,
|
|||
|
||||
pub fn trait_ref_is_knowable<'tcx>(tcx: &ty::ctxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> bool
|
||||
{
|
||||
debug!("trait_ref_is_knowable(trait_ref={})", trait_ref.repr(tcx));
|
||||
debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref);
|
||||
|
||||
// if the orphan rules pass, that means that no ancestor crate can
|
||||
// impl this, so it's up to us.
|
||||
|
|
@ -155,7 +153,7 @@ fn impl_trait_ref_and_oblig<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
let Normalized { value: predicates, obligations: normalization_obligations2 } =
|
||||
project::normalize(selcx, ObligationCause::dummy(), &predicates);
|
||||
let impl_obligations =
|
||||
util::predicates_for_generics(selcx.tcx(), ObligationCause::dummy(), 0, &predicates);
|
||||
util::predicates_for_generics(ObligationCause::dummy(), 0, &predicates);
|
||||
|
||||
let impl_obligations: Vec<_> =
|
||||
impl_obligations.into_iter()
|
||||
|
|
@ -181,17 +179,17 @@ pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
impl_def_id: ast::DefId)
|
||||
-> Result<(), OrphanCheckErr<'tcx>>
|
||||
{
|
||||
debug!("orphan_check({})", impl_def_id.repr(tcx));
|
||||
debug!("orphan_check({:?})", impl_def_id);
|
||||
|
||||
// We only except this routine to be invoked on implementations
|
||||
// of a trait, not inherent implementations.
|
||||
let trait_ref = ty::impl_trait_ref(tcx, impl_def_id).unwrap();
|
||||
debug!("orphan_check: trait_ref={}", trait_ref.repr(tcx));
|
||||
debug!("orphan_check: trait_ref={:?}", trait_ref);
|
||||
|
||||
// If the *trait* is local to the crate, ok.
|
||||
if trait_ref.def_id.krate == ast::LOCAL_CRATE {
|
||||
debug!("trait {} is local to current crate",
|
||||
trait_ref.def_id.repr(tcx));
|
||||
debug!("trait {:?} is local to current crate",
|
||||
trait_ref.def_id);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
|
@ -203,8 +201,8 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
infer_is_local: InferIsLocal)
|
||||
-> Result<(), OrphanCheckErr<'tcx>>
|
||||
{
|
||||
debug!("orphan_check_trait_ref(trait_ref={}, infer_is_local={})",
|
||||
trait_ref.repr(tcx), infer_is_local.0);
|
||||
debug!("orphan_check_trait_ref(trait_ref={:?}, infer_is_local={})",
|
||||
trait_ref, infer_is_local.0);
|
||||
|
||||
// First, create an ordered iterator over all the type parameters to the trait, with the self
|
||||
// type appearing first.
|
||||
|
|
@ -215,14 +213,14 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
// some local type.
|
||||
for input_ty in input_tys {
|
||||
if ty_is_local(tcx, input_ty, infer_is_local) {
|
||||
debug!("orphan_check_trait_ref: ty_is_local `{}`", input_ty.repr(tcx));
|
||||
debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty);
|
||||
|
||||
// First local input type. Check that there are no
|
||||
// uncovered type parameters.
|
||||
let uncovered_tys = uncovered_tys(tcx, input_ty, infer_is_local);
|
||||
for uncovered_ty in uncovered_tys {
|
||||
if let Some(param) = uncovered_ty.walk().find(|t| is_type_parameter(t)) {
|
||||
debug!("orphan_check_trait_ref: uncovered type `{}`", param.repr(tcx));
|
||||
debug!("orphan_check_trait_ref: uncovered type `{:?}`", param);
|
||||
return Err(OrphanCheckErr::UncoveredTy(param));
|
||||
}
|
||||
}
|
||||
|
|
@ -235,7 +233,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
// parameters reachable.
|
||||
if !infer_is_local.0 {
|
||||
if let Some(param) = input_ty.walk().find(|t| is_type_parameter(t)) {
|
||||
debug!("orphan_check_trait_ref: uncovered type `{}`", param.repr(tcx));
|
||||
debug!("orphan_check_trait_ref: uncovered type `{:?}`", param);
|
||||
return Err(OrphanCheckErr::UncoveredTy(param));
|
||||
}
|
||||
}
|
||||
|
|
@ -295,7 +293,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
infer_is_local: InferIsLocal)
|
||||
-> bool
|
||||
{
|
||||
debug!("ty_is_local_constructor({})", ty.repr(tcx));
|
||||
debug!("ty_is_local_constructor({:?})", ty);
|
||||
|
||||
match ty.sty {
|
||||
ty::TyBool |
|
||||
|
|
@ -336,8 +334,8 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
ty::TyClosure(..) |
|
||||
ty::TyError => {
|
||||
tcx.sess.bug(
|
||||
&format!("ty_is_local invoked on unexpected type: {}",
|
||||
ty.repr(tcx)))
|
||||
&format!("ty_is_local invoked on unexpected type: {:?}",
|
||||
ty))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ use middle::infer::InferCtxt;
|
|||
use middle::ty::{self, AsPredicate, ReferencesError, ToPolyTraitRef, TraitRef};
|
||||
use middle::ty_fold::TypeFoldable;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
use syntax::attr::{AttributeMethods, AttrMetaMethods};
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
pub fn report_fulfillment_errors<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
errors: &Vec<FulfillmentError<'tcx>>) {
|
||||
|
|
@ -68,8 +68,8 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
if !infcx.tcx.sess.has_errors() || !predicate.references_error() {
|
||||
span_err!(infcx.tcx.sess, obligation.cause.span, E0271,
|
||||
"type mismatch resolving `{}`: {}",
|
||||
predicate.user_string(infcx.tcx),
|
||||
ty::type_err_to_str(infcx.tcx, &error.err));
|
||||
predicate,
|
||||
error.err);
|
||||
note_obligation_cause(infcx, obligation);
|
||||
}
|
||||
}
|
||||
|
|
@ -87,16 +87,16 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
item.meta().span
|
||||
};
|
||||
let def = ty::lookup_trait_def(infcx.tcx, def_id);
|
||||
let trait_str = def.trait_ref.user_string(infcx.tcx);
|
||||
let trait_str = def.trait_ref.to_string();
|
||||
if let Some(ref istring) = item.value_str() {
|
||||
let mut generic_map = def.generics.types.iter_enumerated()
|
||||
.map(|(param, i, gen)| {
|
||||
(gen.name.as_str().to_string(),
|
||||
trait_ref.substs.types.get(param, i)
|
||||
.user_string(infcx.tcx))
|
||||
.to_string())
|
||||
}).collect::<HashMap<String, String>>();
|
||||
generic_map.insert("Self".to_string(),
|
||||
trait_ref.self_ty().user_string(infcx.tcx));
|
||||
trait_ref.self_ty().to_string());
|
||||
let parser = Parser::new(&istring);
|
||||
let mut errored = false;
|
||||
let err: String = parser.filter_map(|p| {
|
||||
|
|
@ -157,13 +157,13 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
pub fn report_overflow_error<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
obligation: &Obligation<'tcx, T>)
|
||||
-> !
|
||||
where T: UserString<'tcx> + TypeFoldable<'tcx>
|
||||
where T: fmt::Display + TypeFoldable<'tcx>
|
||||
{
|
||||
let predicate =
|
||||
infcx.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
span_err!(infcx.tcx.sess, obligation.cause.span, E0275,
|
||||
"overflow evaluating the requirement `{}`",
|
||||
predicate.user_string(infcx.tcx));
|
||||
predicate);
|
||||
|
||||
suggest_new_overflow_limit(infcx.tcx, obligation.cause.span);
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
span_err!(infcx.tcx.sess, obligation.cause.span, E0276,
|
||||
"the requirement `{}` appears on the impl \
|
||||
method but not on the corresponding trait method",
|
||||
obligation.predicate.user_string(infcx.tcx));;
|
||||
obligation.predicate);;
|
||||
}
|
||||
_ => {
|
||||
match obligation.predicate {
|
||||
|
|
@ -197,8 +197,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
let trait_ref = trait_predicate.to_poly_trait_ref();
|
||||
span_err!(infcx.tcx.sess, obligation.cause.span, E0277,
|
||||
"the trait `{}` is not implemented for the type `{}`",
|
||||
trait_ref.user_string(infcx.tcx),
|
||||
trait_ref.self_ty().user_string(infcx.tcx));
|
||||
trait_ref,
|
||||
trait_ref.self_ty());
|
||||
// Check if it has a custom "#[rustc_on_unimplemented]"
|
||||
// error message, report with that message if it does
|
||||
let custom_note = report_on_unimplemented(infcx, &trait_ref.0,
|
||||
|
|
@ -216,8 +216,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
&predicate).err().unwrap();
|
||||
span_err!(infcx.tcx.sess, obligation.cause.span, E0278,
|
||||
"the requirement `{}` is not satisfied (`{}`)",
|
||||
predicate.user_string(infcx.tcx),
|
||||
ty::type_err_to_str(infcx.tcx, &err));
|
||||
predicate,
|
||||
err);
|
||||
}
|
||||
|
||||
ty::Predicate::RegionOutlives(ref predicate) => {
|
||||
|
|
@ -226,8 +226,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
&predicate).err().unwrap();
|
||||
span_err!(infcx.tcx.sess, obligation.cause.span, E0279,
|
||||
"the requirement `{}` is not satisfied (`{}`)",
|
||||
predicate.user_string(infcx.tcx),
|
||||
ty::type_err_to_str(infcx.tcx, &err));
|
||||
predicate,
|
||||
err);
|
||||
}
|
||||
|
||||
ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => {
|
||||
|
|
@ -235,7 +235,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
infcx.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
span_err!(infcx.tcx.sess, obligation.cause.span, E0280,
|
||||
"the requirement `{}` is not satisfied",
|
||||
predicate.user_string(infcx.tcx));
|
||||
predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -249,10 +249,10 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
span_err!(infcx.tcx.sess, obligation.cause.span, E0281,
|
||||
"type mismatch: the type `{}` implements the trait `{}`, \
|
||||
but the trait `{}` is required ({})",
|
||||
expected_trait_ref.self_ty().user_string(infcx.tcx),
|
||||
expected_trait_ref.user_string(infcx.tcx),
|
||||
actual_trait_ref.user_string(infcx.tcx),
|
||||
ty::type_err_to_str(infcx.tcx, e));
|
||||
expected_trait_ref.self_ty(),
|
||||
expected_trait_ref,
|
||||
actual_trait_ref,
|
||||
e);
|
||||
note_obligation_cause(infcx, obligation);
|
||||
}
|
||||
}
|
||||
|
|
@ -282,7 +282,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
infcx.tcx.sess.span_note(
|
||||
obligation.cause.span,
|
||||
&format!("method `{}` has no receiver",
|
||||
method.name.user_string(infcx.tcx)));
|
||||
method.name));
|
||||
}
|
||||
|
||||
ObjectSafetyViolation::Method(method,
|
||||
|
|
@ -291,7 +291,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
obligation.cause.span,
|
||||
&format!("method `{}` references the `Self` type \
|
||||
in its arguments or return type",
|
||||
method.name.user_string(infcx.tcx)));
|
||||
method.name));
|
||||
}
|
||||
|
||||
ObjectSafetyViolation::Method(method,
|
||||
|
|
@ -299,7 +299,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
infcx.tcx.sess.span_note(
|
||||
obligation.cause.span,
|
||||
&format!("method `{}` has generic type parameters",
|
||||
method.name.user_string(infcx.tcx)));
|
||||
method.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -316,9 +316,9 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
|
||||
let predicate = infcx.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
|
||||
debug!("maybe_report_ambiguity(predicate={}, obligation={})",
|
||||
predicate.repr(infcx.tcx),
|
||||
obligation.repr(infcx.tcx));
|
||||
debug!("maybe_report_ambiguity(predicate={:?}, obligation={:?})",
|
||||
predicate,
|
||||
obligation);
|
||||
|
||||
match predicate {
|
||||
ty::Predicate::Trait(ref data) => {
|
||||
|
|
@ -349,11 +349,11 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
span_err!(infcx.tcx.sess, obligation.cause.span, E0282,
|
||||
"unable to infer enough type information about `{}`; \
|
||||
type annotations or generic parameter binding required",
|
||||
self_ty.user_string(infcx.tcx));
|
||||
self_ty);
|
||||
} else {
|
||||
span_err!(infcx.tcx.sess, obligation.cause.span, E0283,
|
||||
"type annotations required: cannot resolve `{}`",
|
||||
predicate.user_string(infcx.tcx));;
|
||||
predicate);;
|
||||
note_obligation_cause(infcx, obligation);
|
||||
}
|
||||
}
|
||||
|
|
@ -365,8 +365,8 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
"coherence failed to report ambiguity: \
|
||||
cannot locate the impl of the trait `{}` for \
|
||||
the type `{}`",
|
||||
trait_ref.user_string(infcx.tcx),
|
||||
self_ty.user_string(infcx.tcx)));
|
||||
trait_ref,
|
||||
self_ty));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -374,7 +374,7 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
if !infcx.tcx.sess.has_errors() {
|
||||
span_err!(infcx.tcx.sess, obligation.cause.span, E0284,
|
||||
"type annotations required: cannot resolve `{}`",
|
||||
predicate.user_string(infcx.tcx));;
|
||||
predicate);;
|
||||
note_obligation_cause(infcx, obligation);
|
||||
}
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
|
||||
fn note_obligation_cause<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
obligation: &Obligation<'tcx, T>)
|
||||
where T: UserString<'tcx>
|
||||
where T: fmt::Display
|
||||
{
|
||||
note_obligation_cause_code(infcx,
|
||||
&obligation.predicate,
|
||||
|
|
@ -395,7 +395,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
predicate: &T,
|
||||
cause_span: Span,
|
||||
cause_code: &ObligationCauseCode<'tcx>)
|
||||
where T: UserString<'tcx>
|
||||
where T: fmt::Display
|
||||
{
|
||||
let tcx = infcx.tcx;
|
||||
match *cause_code {
|
||||
|
|
@ -463,7 +463,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
let parent_trait_ref = infcx.resolve_type_vars_if_possible(&data.parent_trait_ref);
|
||||
span_note!(tcx.sess, cause_span,
|
||||
"required because it appears within the type `{}`",
|
||||
parent_trait_ref.0.self_ty().user_string(infcx.tcx));
|
||||
parent_trait_ref.0.self_ty());
|
||||
let parent_predicate = parent_trait_ref.as_predicate();
|
||||
note_obligation_cause_code(infcx, &parent_predicate, cause_span, &*data.parent_code);
|
||||
}
|
||||
|
|
@ -471,8 +471,8 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
let parent_trait_ref = infcx.resolve_type_vars_if_possible(&data.parent_trait_ref);
|
||||
span_note!(tcx.sess, cause_span,
|
||||
"required because of the requirements on the impl of `{}` for `{}`",
|
||||
parent_trait_ref.user_string(infcx.tcx),
|
||||
parent_trait_ref.0.self_ty().user_string(infcx.tcx));
|
||||
parent_trait_ref,
|
||||
parent_trait_ref.0.self_ty());
|
||||
let parent_predicate = parent_trait_ref.as_predicate();
|
||||
note_obligation_cause_code(infcx, &parent_predicate, cause_span, &*data.parent_code);
|
||||
}
|
||||
|
|
@ -480,7 +480,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
span_note!(tcx.sess, cause_span,
|
||||
"the requirement `{}` appears on the impl method \
|
||||
but not on the corresponding trait method",
|
||||
predicate.user_string(infcx.tcx));
|
||||
predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
use middle::infer::InferCtxt;
|
||||
use middle::ty::{self, RegionEscape, Ty};
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::default::Default;
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use util::common::ErrorReported;
|
||||
use util::ppaux::Repr;
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
use super::CodeAmbiguity;
|
||||
|
|
@ -137,8 +137,8 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
|||
cause: ObligationCause<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
debug!("normalize_associated_type(projection_ty={})",
|
||||
projection_ty.repr(infcx.tcx));
|
||||
debug!("normalize_associated_type(projection_ty={:?})",
|
||||
projection_ty);
|
||||
|
||||
assert!(!projection_ty.has_escaping_regions());
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
|||
self.register_predicate_obligation(infcx, obligation);
|
||||
}
|
||||
|
||||
debug!("normalize_associated_type: result={}", normalized.value.repr(infcx.tcx));
|
||||
debug!("normalize_associated_type: result={:?}", normalized.value);
|
||||
|
||||
normalized.value
|
||||
}
|
||||
|
|
@ -171,12 +171,11 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn register_region_obligation<'a>(&mut self,
|
||||
infcx: &InferCtxt<'a,'tcx>,
|
||||
t_a: Ty<'tcx>,
|
||||
r_b: ty::Region,
|
||||
cause: ObligationCause<'tcx>)
|
||||
{
|
||||
register_region_obligation(infcx.tcx, t_a, r_b, cause, &mut self.region_obligations);
|
||||
register_region_obligation(t_a, r_b, cause, &mut self.region_obligations);
|
||||
}
|
||||
|
||||
pub fn register_predicate_obligation<'a>(&mut self,
|
||||
|
|
@ -190,11 +189,11 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
|||
assert!(!obligation.has_escaping_regions());
|
||||
|
||||
if self.is_duplicate_or_add(infcx.tcx, &obligation.predicate) {
|
||||
debug!("register_predicate({}) -- already seen, skip", obligation.repr(infcx.tcx));
|
||||
debug!("register_predicate({:?}) -- already seen, skip", obligation);
|
||||
return;
|
||||
}
|
||||
|
||||
debug!("register_predicate({})", obligation.repr(infcx.tcx));
|
||||
debug!("register_predicate({:?})", obligation);
|
||||
self.predicates.push(obligation);
|
||||
}
|
||||
|
||||
|
|
@ -366,7 +365,6 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
* type inference.
|
||||
*/
|
||||
|
||||
let tcx = selcx.tcx();
|
||||
match obligation.predicate {
|
||||
ty::Predicate::Trait(ref data) => {
|
||||
let trait_obligation = obligation.with(data.clone());
|
||||
|
|
@ -379,9 +377,9 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
true
|
||||
}
|
||||
Err(selection_err) => {
|
||||
debug!("predicate: {} error: {}",
|
||||
obligation.repr(tcx),
|
||||
selection_err.repr(tcx));
|
||||
debug!("predicate: {:?} error: {:?}",
|
||||
obligation,
|
||||
selection_err);
|
||||
errors.push(
|
||||
FulfillmentError::new(
|
||||
obligation.clone(),
|
||||
|
|
@ -430,7 +428,7 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
CodeSelectionError(Unimplemented)));
|
||||
} else {
|
||||
let ty::OutlivesPredicate(t_a, r_b) = binder.0;
|
||||
register_region_obligation(tcx, t_a, r_b,
|
||||
register_region_obligation(t_a, r_b,
|
||||
obligation.cause.clone(),
|
||||
region_obligations);
|
||||
}
|
||||
|
|
@ -440,9 +438,9 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
ty::Predicate::Projection(ref data) => {
|
||||
let project_obligation = obligation.with(data.clone());
|
||||
let result = project::poly_project_and_unify_type(selcx, &project_obligation);
|
||||
debug!("process_predicate: poly_project_and_unify_type({}) returned {}",
|
||||
project_obligation.repr(tcx),
|
||||
result.repr(tcx));
|
||||
debug!("process_predicate: poly_project_and_unify_type({:?}) returned {:?}",
|
||||
project_obligation,
|
||||
result);
|
||||
match result {
|
||||
Ok(Some(obligations)) => {
|
||||
new_obligations.extend(obligations);
|
||||
|
|
@ -463,16 +461,15 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for RegionObligation<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("RegionObligation(sub_region={}, sup_type={})",
|
||||
self.sub_region.repr(tcx),
|
||||
self.sup_type.repr(tcx))
|
||||
impl<'tcx> fmt::Debug for RegionObligation<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "RegionObligation(sub_region={:?}, sup_type={:?})",
|
||||
self.sub_region,
|
||||
self.sup_type)
|
||||
}
|
||||
}
|
||||
|
||||
fn register_region_obligation<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
t_a: Ty<'tcx>,
|
||||
fn register_region_obligation<'tcx>(t_a: Ty<'tcx>,
|
||||
r_b: ty::Region,
|
||||
cause: ObligationCause<'tcx>,
|
||||
region_obligations: &mut NodeMap<Vec<RegionObligation<'tcx>>>)
|
||||
|
|
@ -481,8 +478,8 @@ fn register_region_obligation<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
sub_region: r_b,
|
||||
cause: cause };
|
||||
|
||||
debug!("register_region_obligation({})",
|
||||
region_obligation.repr(tcx));
|
||||
debug!("register_region_obligation({:?})",
|
||||
region_obligation);
|
||||
|
||||
region_obligations.entry(region_obligation.cause.body_id).or_insert(vec![])
|
||||
.push(region_obligation);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use middle::infer::{self, fixup_err_to_string, InferCtxt};
|
|||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
pub use self::error_reporting::report_fulfillment_errors;
|
||||
pub use self::error_reporting::report_overflow_error;
|
||||
|
|
@ -219,7 +218,7 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
|
|||
/// ### The type parameter `N`
|
||||
///
|
||||
/// See explanation on `VtableImplData`.
|
||||
#[derive(Debug,Clone)]
|
||||
#[derive(Clone)]
|
||||
pub enum Vtable<'tcx, N> {
|
||||
/// Vtable identifying a particular impl.
|
||||
VtableImpl(VtableImplData<'tcx, N>),
|
||||
|
|
@ -277,13 +276,13 @@ pub struct VtableClosureData<'tcx, N> {
|
|||
pub nested: Vec<N>
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct VtableDefaultImplData<N> {
|
||||
pub trait_def_id: ast::DefId,
|
||||
pub nested: Vec<N>
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct VtableBuiltinData<N> {
|
||||
pub nested: Vec<N>
|
||||
}
|
||||
|
|
@ -300,12 +299,11 @@ pub struct VtableObjectData<'tcx> {
|
|||
}
|
||||
|
||||
/// Creates predicate obligations from the generic bounds.
|
||||
pub fn predicates_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>,
|
||||
generic_bounds: &ty::InstantiatedPredicates<'tcx>)
|
||||
-> PredicateObligations<'tcx>
|
||||
{
|
||||
util::predicates_for_generics(tcx, cause, 0, generic_bounds)
|
||||
util::predicates_for_generics(cause, 0, generic_bounds)
|
||||
}
|
||||
|
||||
/// Determines whether the type `ty` is known to meet `bound` and
|
||||
|
|
@ -320,8 +318,8 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
|||
span: Span)
|
||||
-> bool
|
||||
{
|
||||
debug!("type_known_to_meet_builtin_bound(ty={}, bound={:?})",
|
||||
ty.repr(infcx.tcx),
|
||||
debug!("type_known_to_meet_builtin_bound(ty={:?}, bound={:?})",
|
||||
ty,
|
||||
bound);
|
||||
|
||||
let mut fulfill_cx = FulfillmentContext::new(false);
|
||||
|
|
@ -338,16 +336,16 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
|||
// assume it is move; linear is always ok.
|
||||
match fulfill_cx.select_all_or_error(infcx, typer) {
|
||||
Ok(()) => {
|
||||
debug!("type_known_to_meet_builtin_bound: ty={} bound={:?} success",
|
||||
ty.repr(infcx.tcx),
|
||||
debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} success",
|
||||
ty,
|
||||
bound);
|
||||
true
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("type_known_to_meet_builtin_bound: ty={} bound={:?} errors={}",
|
||||
ty.repr(infcx.tcx),
|
||||
debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} errors={:?}",
|
||||
ty,
|
||||
bound,
|
||||
e.repr(infcx.tcx));
|
||||
e);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
@ -377,8 +375,8 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
|
|||
let span = cause.span;
|
||||
let body_id = cause.body_id;
|
||||
|
||||
debug!("normalize_param_env_or_error(unnormalized_env={})",
|
||||
unnormalized_env.repr(tcx));
|
||||
debug!("normalize_param_env_or_error(unnormalized_env={:?})",
|
||||
unnormalized_env);
|
||||
|
||||
let predicates: Vec<_> =
|
||||
util::elaborate_predicates(tcx, unnormalized_env.caller_bounds.clone())
|
||||
|
|
@ -393,8 +391,8 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
|
|||
// constructed, but I am not currently doing so out of laziness.
|
||||
// -nmatsakis
|
||||
|
||||
debug!("normalize_param_env_or_error: elaborated-predicates={}",
|
||||
predicates.repr(tcx));
|
||||
debug!("normalize_param_env_or_error: elaborated-predicates={:?}",
|
||||
predicates);
|
||||
|
||||
let elaborated_env = unnormalized_env.with_caller_bounds(predicates);
|
||||
|
||||
|
|
@ -434,25 +432,23 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
cause: ObligationCause<'tcx>,
|
||||
value: &T)
|
||||
-> Result<T, Vec<FulfillmentError<'tcx>>>
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
let tcx = closure_typer.tcx();
|
||||
|
||||
debug!("normalize_param_env(value={})", value.repr(tcx));
|
||||
debug!("normalize_param_env(value={:?})", value);
|
||||
|
||||
let mut selcx = &mut SelectionContext::new(infcx, closure_typer);
|
||||
let mut fulfill_cx = FulfillmentContext::new(false);
|
||||
let Normalized { value: normalized_value, obligations } =
|
||||
project::normalize(selcx, cause, value);
|
||||
debug!("normalize_param_env: normalized_value={} obligations={}",
|
||||
normalized_value.repr(tcx),
|
||||
obligations.repr(tcx));
|
||||
debug!("normalize_param_env: normalized_value={:?} obligations={:?}",
|
||||
normalized_value,
|
||||
obligations);
|
||||
for obligation in obligations {
|
||||
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
|
||||
}
|
||||
try!(fulfill_cx.select_all_or_error(infcx, closure_typer));
|
||||
let resolved_value = infcx.resolve_type_vars_if_possible(&normalized_value);
|
||||
debug!("normalize_param_env: resolved_value={}", resolved_value.repr(tcx));
|
||||
debug!("normalize_param_env: resolved_value={:?}", resolved_value);
|
||||
Ok(resolved_value)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ use middle::traits;
|
|||
use middle::ty::{self, ToPolyTraitRef, Ty};
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ObjectSafetyViolation<'tcx> {
|
||||
/// Self : Sized declared on the trait
|
||||
SizedSelf,
|
||||
|
|
@ -70,7 +70,7 @@ pub fn is_object_safe<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
result
|
||||
});
|
||||
|
||||
debug!("is_object_safe({}) = {}", trait_def_id.repr(tcx), result);
|
||||
debug!("is_object_safe({:?}) = {}", trait_def_id, result);
|
||||
|
||||
result
|
||||
}
|
||||
|
|
@ -111,9 +111,9 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
violations.push(ObjectSafetyViolation::SupertraitSelf);
|
||||
}
|
||||
|
||||
debug!("object_safety_violations_for_trait(trait_def_id={}) = {}",
|
||||
trait_def_id.repr(tcx),
|
||||
violations.repr(tcx));
|
||||
debug!("object_safety_violations_for_trait(trait_def_id={:?}) = {:?}",
|
||||
trait_def_id,
|
||||
violations);
|
||||
|
||||
violations
|
||||
}
|
||||
|
|
@ -352,19 +352,6 @@ fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
error
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for ObjectSafetyViolation<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
ObjectSafetyViolation::SizedSelf =>
|
||||
format!("SizedSelf"),
|
||||
ObjectSafetyViolation::SupertraitSelf =>
|
||||
format!("SupertraitSelf"),
|
||||
ObjectSafetyViolation::Method(ref m, code) =>
|
||||
format!("Method({},{:?})", m.repr(tcx), code),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_self<'tcx>(ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyParam(ref data) => data.space == subst::SelfSpace,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ use middle::ty::{self, AsPredicate, ReferencesError, RegionEscape,
|
|||
use middle::ty_fold::{self, TypeFoldable, TypeFolder};
|
||||
use syntax::parse::token;
|
||||
use util::common::FN_OUTPUT_NAME;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
pub type PolyProjectionObligation<'tcx> =
|
||||
Obligation<'tcx, ty::PolyProjectionPredicate<'tcx>>;
|
||||
|
|
@ -40,6 +41,7 @@ pub type ProjectionTyObligation<'tcx> =
|
|||
Obligation<'tcx, ty::ProjectionTy<'tcx>>;
|
||||
|
||||
/// When attempting to resolve `<T as TraitRef>::Name` ...
|
||||
#[derive(Debug)]
|
||||
pub enum ProjectionTyError<'tcx> {
|
||||
/// ...we found multiple sources of information and couldn't resolve the ambiguity.
|
||||
TooManyCandidates,
|
||||
|
|
@ -53,7 +55,7 @@ pub struct MismatchedProjectionTypes<'tcx> {
|
|||
pub err: ty::type_err<'tcx>
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
enum ProjectionTyCandidate<'tcx> {
|
||||
ParamEnv(ty::PolyProjectionPredicate<'tcx>),
|
||||
Impl(VtableImplData<'tcx, PredicateObligation<'tcx>>),
|
||||
|
|
@ -76,8 +78,8 @@ pub fn poly_project_and_unify_type<'cx,'tcx>(
|
|||
obligation: &PolyProjectionObligation<'tcx>)
|
||||
-> Result<Option<Vec<PredicateObligation<'tcx>>>, MismatchedProjectionTypes<'tcx>>
|
||||
{
|
||||
debug!("poly_project_and_unify_type(obligation={})",
|
||||
obligation.repr(selcx.tcx()));
|
||||
debug!("poly_project_and_unify_type(obligation={:?})",
|
||||
obligation);
|
||||
|
||||
let infcx = selcx.infcx();
|
||||
infcx.commit_if_ok(|snapshot| {
|
||||
|
|
@ -109,8 +111,8 @@ fn project_and_unify_type<'cx,'tcx>(
|
|||
obligation: &ProjectionObligation<'tcx>)
|
||||
-> Result<Option<Vec<PredicateObligation<'tcx>>>, MismatchedProjectionTypes<'tcx>>
|
||||
{
|
||||
debug!("project_and_unify_type(obligation={})",
|
||||
obligation.repr(selcx.tcx()));
|
||||
debug!("project_and_unify_type(obligation={:?})",
|
||||
obligation);
|
||||
|
||||
let Normalized { value: normalized_ty, obligations } =
|
||||
match opt_normalize_projection_type(selcx,
|
||||
|
|
@ -124,9 +126,9 @@ fn project_and_unify_type<'cx,'tcx>(
|
|||
}
|
||||
};
|
||||
|
||||
debug!("project_and_unify_type: normalized_ty={} obligations={}",
|
||||
normalized_ty.repr(selcx.tcx()),
|
||||
obligations.repr(selcx.tcx()));
|
||||
debug!("project_and_unify_type: normalized_ty={:?} obligations={:?}",
|
||||
normalized_ty,
|
||||
obligations);
|
||||
|
||||
let infcx = selcx.infcx();
|
||||
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
|
||||
|
|
@ -138,8 +140,8 @@ fn project_and_unify_type<'cx,'tcx>(
|
|||
|
||||
fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
obligation: &ProjectionObligation<'tcx>) {
|
||||
debug!("consider_unification_despite_ambiguity(obligation={})",
|
||||
obligation.repr(selcx.tcx()));
|
||||
debug!("consider_unification_despite_ambiguity(obligation={:?})",
|
||||
obligation);
|
||||
|
||||
let def_id = obligation.predicate.projection_ty.trait_ref.def_id;
|
||||
match selcx.tcx().lang_items.fn_trait_kind(def_id) {
|
||||
|
|
@ -173,7 +175,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext
|
|||
&ty::Binder(ret_type));
|
||||
|
||||
debug!("consider_unification_despite_ambiguity: ret_type={:?}",
|
||||
ret_type.repr(selcx.tcx()));
|
||||
ret_type);
|
||||
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
|
||||
let obligation_ty = obligation.predicate.ty;
|
||||
match infer::mk_eqty(infcx, true, origin, obligation_ty, ret_type) {
|
||||
|
|
@ -193,7 +195,7 @@ pub fn normalize<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx>,
|
|||
cause: ObligationCause<'tcx>,
|
||||
value: &T)
|
||||
-> Normalized<'tcx, T>
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
normalize_with_depth(selcx, cause, 0, value)
|
||||
}
|
||||
|
|
@ -204,7 +206,7 @@ pub fn normalize_with_depth<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tc
|
|||
depth: usize,
|
||||
value: &T)
|
||||
-> Normalized<'tcx, T>
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx>
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth);
|
||||
let result = normalizer.fold(value);
|
||||
|
|
@ -236,7 +238,7 @@ impl<'a,'b,'tcx> AssociatedTypeNormalizer<'a,'b,'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn fold<T:TypeFoldable<'tcx> + HasProjectionTypes + Clone>(&mut self, value: &T) -> T {
|
||||
fn fold<T:TypeFoldable<'tcx> + HasProjectionTypes>(&mut self, value: &T) -> T {
|
||||
let value = self.selcx.infcx().resolve_type_vars_if_possible(value);
|
||||
|
||||
if !value.has_projection_types() {
|
||||
|
|
@ -354,9 +356,9 @@ fn opt_normalize_projection_type<'a,'b,'tcx>(
|
|||
-> Option<NormalizedTy<'tcx>>
|
||||
{
|
||||
debug!("normalize_projection_type(\
|
||||
projection_ty={}, \
|
||||
projection_ty={:?}, \
|
||||
depth={})",
|
||||
projection_ty.repr(selcx.tcx()),
|
||||
projection_ty,
|
||||
depth);
|
||||
|
||||
let obligation = Obligation::with_depth(cause.clone(), depth, projection_ty.clone());
|
||||
|
|
@ -367,18 +369,17 @@ fn opt_normalize_projection_type<'a,'b,'tcx>(
|
|||
// an impl, where-clause etc) and hence we must
|
||||
// re-normalize it
|
||||
|
||||
debug!("normalize_projection_type: projected_ty={} depth={} obligations={}",
|
||||
projected_ty.repr(selcx.tcx()),
|
||||
debug!("normalize_projection_type: projected_ty={:?} depth={} obligations={:?}",
|
||||
projected_ty,
|
||||
depth,
|
||||
obligations.repr(selcx.tcx()));
|
||||
obligations);
|
||||
|
||||
if ty::type_has_projection(projected_ty) {
|
||||
let tcx = selcx.tcx();
|
||||
let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth);
|
||||
let normalized_ty = normalizer.fold(&projected_ty);
|
||||
|
||||
debug!("normalize_projection_type: normalized_ty={} depth={}",
|
||||
normalized_ty.repr(tcx),
|
||||
debug!("normalize_projection_type: normalized_ty={:?} depth={}",
|
||||
normalized_ty,
|
||||
depth);
|
||||
|
||||
obligations.extend(normalizer.obligations);
|
||||
|
|
@ -394,8 +395,8 @@ fn opt_normalize_projection_type<'a,'b,'tcx>(
|
|||
}
|
||||
}
|
||||
Ok(ProjectedTy::NoProgress(projected_ty)) => {
|
||||
debug!("normalize_projection_type: projected_ty={} no progress",
|
||||
projected_ty.repr(selcx.tcx()));
|
||||
debug!("normalize_projection_type: projected_ty={:?} no progress",
|
||||
projected_ty);
|
||||
Some(Normalized {
|
||||
value: projected_ty,
|
||||
obligations: vec!()
|
||||
|
|
@ -449,8 +450,8 @@ fn project_type<'cx,'tcx>(
|
|||
obligation: &ProjectionTyObligation<'tcx>)
|
||||
-> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>>
|
||||
{
|
||||
debug!("project(obligation={})",
|
||||
obligation.repr(selcx.tcx()));
|
||||
debug!("project(obligation={:?})",
|
||||
obligation);
|
||||
|
||||
let recursion_limit = selcx.tcx().sess.recursion_limit.get();
|
||||
if obligation.recursion_depth >= recursion_limit {
|
||||
|
|
@ -461,7 +462,7 @@ fn project_type<'cx,'tcx>(
|
|||
let obligation_trait_ref =
|
||||
selcx.infcx().resolve_type_vars_if_possible(&obligation.predicate.trait_ref);
|
||||
|
||||
debug!("project: obligation_trait_ref={}", obligation_trait_ref.repr(selcx.tcx()));
|
||||
debug!("project: obligation_trait_ref={:?}", obligation_trait_ref);
|
||||
|
||||
if obligation_trait_ref.references_error() {
|
||||
return Ok(ProjectedTy::Progress(selcx.tcx().types.err, vec!()));
|
||||
|
|
@ -589,12 +590,12 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>(
|
|||
env_predicates: I)
|
||||
where I: Iterator<Item=ty::Predicate<'tcx>>
|
||||
{
|
||||
debug!("assemble_candidates_from_predicates(obligation={})",
|
||||
obligation.repr(selcx.tcx()));
|
||||
debug!("assemble_candidates_from_predicates(obligation={:?})",
|
||||
obligation);
|
||||
let infcx = selcx.infcx();
|
||||
for predicate in env_predicates {
|
||||
debug!("assemble_candidates_from_predicates: predicate={}",
|
||||
predicate.repr(selcx.tcx()));
|
||||
debug!("assemble_candidates_from_predicates: predicate={:?}",
|
||||
predicate);
|
||||
match predicate {
|
||||
ty::Predicate::Projection(ref data) => {
|
||||
let same_name = data.item_name() == obligation.predicate.item_name;
|
||||
|
|
@ -611,10 +612,9 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>(
|
|||
obligation_poly_trait_ref).is_ok()
|
||||
});
|
||||
|
||||
debug!("assemble_candidates_from_predicates: candidate {} is_match {} same_name {}",
|
||||
data.repr(selcx.tcx()),
|
||||
is_match,
|
||||
same_name);
|
||||
debug!("assemble_candidates_from_predicates: candidate={:?} \
|
||||
is_match={} same_name={}",
|
||||
data, is_match, same_name);
|
||||
|
||||
if is_match {
|
||||
candidate_set.vec.push(
|
||||
|
|
@ -633,16 +633,15 @@ fn assemble_candidates_from_object_type<'cx,'tcx>(
|
|||
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
|
||||
object_ty: Ty<'tcx>)
|
||||
{
|
||||
let infcx = selcx.infcx();
|
||||
debug!("assemble_candidates_from_object_type(object_ty={})",
|
||||
object_ty.repr(infcx.tcx));
|
||||
debug!("assemble_candidates_from_object_type(object_ty={:?})",
|
||||
object_ty);
|
||||
let data = match object_ty.sty {
|
||||
ty::TyTrait(ref data) => data,
|
||||
_ => {
|
||||
selcx.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
&format!("assemble_candidates_from_object_type called with non-object: {}",
|
||||
object_ty.repr(selcx.tcx())));
|
||||
&format!("assemble_candidates_from_object_type called with non-object: {:?}",
|
||||
object_ty));
|
||||
}
|
||||
};
|
||||
let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), object_ty);
|
||||
|
|
@ -672,16 +671,16 @@ fn assemble_candidates_from_impls<'cx,'tcx>(
|
|||
return Ok(());
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("assemble_candidates_from_impls: selection error {}",
|
||||
e.repr(selcx.tcx()));
|
||||
debug!("assemble_candidates_from_impls: selection error {:?}",
|
||||
e);
|
||||
return Err(e);
|
||||
}
|
||||
};
|
||||
|
||||
match vtable {
|
||||
super::VtableImpl(data) => {
|
||||
debug!("assemble_candidates_from_impls: impl candidate {}",
|
||||
data.repr(selcx.tcx()));
|
||||
debug!("assemble_candidates_from_impls: impl candidate {:?}",
|
||||
data);
|
||||
|
||||
candidate_set.vec.push(
|
||||
ProjectionTyCandidate::Impl(data));
|
||||
|
|
@ -731,8 +730,8 @@ fn assemble_candidates_from_impls<'cx,'tcx>(
|
|||
// These traits have no associated types.
|
||||
selcx.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
&format!("Cannot project an associated type from `{}`",
|
||||
vtable.repr(selcx.tcx())));
|
||||
&format!("Cannot project an associated type from `{:?}`",
|
||||
vtable));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -745,11 +744,9 @@ fn confirm_candidate<'cx,'tcx>(
|
|||
candidate: ProjectionTyCandidate<'tcx>)
|
||||
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
|
||||
{
|
||||
let infcx = selcx.infcx();
|
||||
|
||||
debug!("confirm_candidate(candidate={}, obligation={})",
|
||||
candidate.repr(infcx.tcx),
|
||||
obligation.repr(infcx.tcx));
|
||||
debug!("confirm_candidate(candidate={:?}, obligation={:?})",
|
||||
candidate,
|
||||
obligation);
|
||||
|
||||
match candidate {
|
||||
ProjectionTyCandidate::ParamEnv(poly_projection) => {
|
||||
|
|
@ -813,9 +810,9 @@ fn confirm_callable_candidate<'cx,'tcx>(
|
|||
{
|
||||
let tcx = selcx.tcx();
|
||||
|
||||
debug!("confirm_callable_candidate({},{})",
|
||||
obligation.repr(tcx),
|
||||
fn_sig.repr(tcx));
|
||||
debug!("confirm_callable_candidate({:?},{:?})",
|
||||
obligation,
|
||||
fn_sig);
|
||||
|
||||
// the `Output` associated type is declared on `FnOnce`
|
||||
let fn_once_def_id = tcx.lang_items.fn_once_trait().unwrap();
|
||||
|
|
@ -865,10 +862,10 @@ fn confirm_param_env_candidate<'cx,'tcx>(
|
|||
Err(e) => {
|
||||
selcx.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
&format!("Failed to unify `{}` and `{}` in projection: {}",
|
||||
obligation.repr(selcx.tcx()),
|
||||
projection.repr(selcx.tcx()),
|
||||
ty::type_err_to_str(selcx.tcx(), &e)));
|
||||
&format!("Failed to unify `{:?}` and `{:?}` in projection: {}",
|
||||
obligation,
|
||||
projection,
|
||||
e));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -915,34 +912,8 @@ fn confirm_impl_candidate<'cx,'tcx>(
|
|||
}
|
||||
|
||||
selcx.tcx().sess.span_bug(obligation.cause.span,
|
||||
&format!("No associated type for {}",
|
||||
trait_ref.repr(selcx.tcx())));
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for ProjectionTyError<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
ProjectionTyError::TooManyCandidates =>
|
||||
format!("NoCandidate"),
|
||||
ProjectionTyError::TraitSelectionError(ref e) =>
|
||||
format!("TraitSelectionError({})", e.repr(tcx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for ProjectionTyCandidate<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
ProjectionTyCandidate::ParamEnv(ref data) =>
|
||||
format!("ParamEnv({})", data.repr(tcx)),
|
||||
ProjectionTyCandidate::Impl(ref data) =>
|
||||
format!("Impl({})", data.repr(tcx)),
|
||||
ProjectionTyCandidate::Closure(ref data) =>
|
||||
format!("Closure({})", data.repr(tcx)),
|
||||
ProjectionTyCandidate::FnPointer(a) =>
|
||||
format!("FnPointer(({}))", a.repr(tcx)),
|
||||
}
|
||||
}
|
||||
&format!("No associated type for {:?}",
|
||||
trait_ref));
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> {
|
||||
|
|
@ -954,10 +925,10 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Normalized<'tcx, T> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("Normalized({},{})",
|
||||
self.value.repr(tcx),
|
||||
self.obligations.repr(tcx))
|
||||
impl<'tcx, T:fmt::Debug> fmt::Debug for Normalized<'tcx, T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Normalized({:?},{:?})",
|
||||
self.value,
|
||||
self.obligations)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,12 +44,13 @@ use middle::infer::{InferCtxt, TypeFreshener};
|
|||
use middle::ty_fold::TypeFoldable;
|
||||
use middle::ty_match;
|
||||
use middle::ty_relate::TypeRelation;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use syntax::{abi, ast};
|
||||
use util::common::ErrorReported;
|
||||
use util::nodemap::FnvHashMap;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
pub struct SelectionContext<'cx, 'tcx:'cx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
|
|
@ -298,7 +299,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
/// type environment by performing unification.
|
||||
pub fn select(&mut self, obligation: &TraitObligation<'tcx>)
|
||||
-> SelectionResult<'tcx, Selection<'tcx>> {
|
||||
debug!("select({})", obligation.repr(self.tcx()));
|
||||
debug!("select({:?})", obligation);
|
||||
assert!(!obligation.predicate.has_escaping_regions());
|
||||
|
||||
let stack = self.push_stack(TraitObligationStackList::empty(), obligation);
|
||||
|
|
@ -387,8 +388,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &PredicateObligation<'tcx>)
|
||||
-> bool
|
||||
{
|
||||
debug!("evaluate_obligation({})",
|
||||
obligation.repr(self.tcx()));
|
||||
debug!("evaluate_obligation({:?})",
|
||||
obligation);
|
||||
|
||||
self.evaluate_predicate_recursively(TraitObligationStackList::empty(), obligation)
|
||||
.may_apply()
|
||||
|
|
@ -440,8 +441,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &PredicateObligation<'tcx>)
|
||||
-> EvaluationResult<'tcx>
|
||||
{
|
||||
debug!("evaluate_predicate_recursively({})",
|
||||
obligation.repr(self.tcx()));
|
||||
debug!("evaluate_predicate_recursively({:?})",
|
||||
obligation);
|
||||
|
||||
// Check the cache from the tcx of predicates that we know
|
||||
// have been proven elsewhere. This cache only contains
|
||||
|
|
@ -499,8 +500,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &TraitObligation<'tcx>)
|
||||
-> EvaluationResult<'tcx>
|
||||
{
|
||||
debug!("evaluate_obligation_recursively({})",
|
||||
obligation.repr(self.tcx()));
|
||||
debug!("evaluate_obligation_recursively({:?})",
|
||||
obligation);
|
||||
|
||||
let stack = self.push_stack(previous_stack, obligation);
|
||||
|
||||
|
|
@ -547,8 +548,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|prev| self.match_fresh_trait_refs(&stack.fresh_trait_ref,
|
||||
&prev.fresh_trait_ref)))
|
||||
{
|
||||
debug!("evaluate_stack({}) --> unbound argument, recursion --> ambiguous",
|
||||
stack.fresh_trait_ref.repr(self.tcx()));
|
||||
debug!("evaluate_stack({:?}) --> unbound argument, recursion --> ambiguous",
|
||||
stack.fresh_trait_ref);
|
||||
return EvaluatedToAmbig;
|
||||
}
|
||||
|
||||
|
|
@ -576,8 +577,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
.skip(1) // skip top-most frame
|
||||
.any(|prev| stack.fresh_trait_ref == prev.fresh_trait_ref)
|
||||
{
|
||||
debug!("evaluate_stack({}) --> recursive",
|
||||
stack.fresh_trait_ref.repr(self.tcx()));
|
||||
debug!("evaluate_stack({:?}) --> recursive",
|
||||
stack.fresh_trait_ref);
|
||||
return EvaluatedToOk;
|
||||
}
|
||||
|
||||
|
|
@ -595,9 +596,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &TraitObligation<'tcx>)
|
||||
-> bool
|
||||
{
|
||||
debug!("evaluate_impl(impl_def_id={}, obligation={})",
|
||||
impl_def_id.repr(self.tcx()),
|
||||
obligation.repr(self.tcx()));
|
||||
debug!("evaluate_impl(impl_def_id={:?}, obligation={:?})",
|
||||
impl_def_id,
|
||||
obligation);
|
||||
|
||||
self.infcx.probe(|snapshot| {
|
||||
match self.match_impl(impl_def_id, obligation, snapshot) {
|
||||
|
|
@ -643,16 +644,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// with fresh skolemized types starting from index 0.
|
||||
let cache_fresh_trait_pred =
|
||||
self.infcx.freshen(stack.obligation.predicate.clone());
|
||||
debug!("candidate_from_obligation(cache_fresh_trait_pred={}, obligation={})",
|
||||
cache_fresh_trait_pred.repr(self.tcx()),
|
||||
stack.repr(self.tcx()));
|
||||
debug!("candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})",
|
||||
cache_fresh_trait_pred,
|
||||
stack);
|
||||
assert!(!stack.obligation.predicate.has_escaping_regions());
|
||||
|
||||
match self.check_candidate_cache(&cache_fresh_trait_pred) {
|
||||
Some(c) => {
|
||||
debug!("CACHE HIT: cache_fresh_trait_pred={}, candidate={}",
|
||||
cache_fresh_trait_pred.repr(self.tcx()),
|
||||
c.repr(self.tcx()));
|
||||
debug!("CACHE HIT: cache_fresh_trait_pred={:?}, candidate={:?}",
|
||||
cache_fresh_trait_pred,
|
||||
c);
|
||||
return c;
|
||||
}
|
||||
None => { }
|
||||
|
|
@ -662,8 +663,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let candidate = self.candidate_from_obligation_no_cache(stack);
|
||||
|
||||
if self.should_update_candidate_cache(&cache_fresh_trait_pred, &candidate) {
|
||||
debug!("CACHE MISS: cache_fresh_trait_pred={}, candidate={}",
|
||||
cache_fresh_trait_pred.repr(self.tcx()), candidate.repr(self.tcx()));
|
||||
debug!("CACHE MISS: cache_fresh_trait_pred={:?}, candidate={:?}",
|
||||
cache_fresh_trait_pred, candidate);
|
||||
self.insert_candidate_cache(cache_fresh_trait_pred, candidate.clone());
|
||||
}
|
||||
|
||||
|
|
@ -692,10 +693,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
let mut candidates = candidate_set.vec;
|
||||
|
||||
debug!("assembled {} candidates for {}: {}",
|
||||
debug!("assembled {} candidates for {:?}: {:?}",
|
||||
candidates.len(),
|
||||
stack.repr(self.tcx()),
|
||||
candidates.repr(self.tcx()));
|
||||
stack,
|
||||
candidates);
|
||||
|
||||
// At this point, we know that each of the entries in the
|
||||
// candidate set is *individually* applicable. Now we have to
|
||||
|
|
@ -735,12 +736,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
.any(|j| self.candidate_should_be_dropped_in_favor_of(&candidates[i],
|
||||
&candidates[j]));
|
||||
if is_dup {
|
||||
debug!("Dropping candidate #{}/{}: {}",
|
||||
i, candidates.len(), candidates[i].repr(self.tcx()));
|
||||
debug!("Dropping candidate #{}/{}: {:?}",
|
||||
i, candidates.len(), candidates[i]);
|
||||
candidates.swap_remove(i);
|
||||
} else {
|
||||
debug!("Retaining candidate #{}/{}: {}",
|
||||
i, candidates.len(), candidates[i].repr(self.tcx()));
|
||||
debug!("Retaining candidate #{}/{}: {:?}",
|
||||
i, candidates.len(), candidates[i]);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -906,8 +907,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
match self.tcx().lang_items.to_builtin_kind(obligation.predicate.def_id()) {
|
||||
Some(ty::BoundCopy) => {
|
||||
debug!("obligation self ty is {}",
|
||||
obligation.predicate.0.self_ty().repr(self.tcx()));
|
||||
debug!("obligation self ty is {:?}",
|
||||
obligation.predicate.0.self_ty());
|
||||
|
||||
// User-defined copy impls are permitted, but only for
|
||||
// structs and enums.
|
||||
|
|
@ -957,9 +958,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let poly_trait_predicate =
|
||||
self.infcx().resolve_type_vars_if_possible(&obligation.predicate);
|
||||
|
||||
debug!("assemble_candidates_for_projected_tys({},{})",
|
||||
obligation.repr(self.tcx()),
|
||||
poly_trait_predicate.repr(self.tcx()));
|
||||
debug!("assemble_candidates_for_projected_tys({:?},{:?})",
|
||||
obligation,
|
||||
poly_trait_predicate);
|
||||
|
||||
// FIXME(#20297) -- just examining the self-type is very simplistic
|
||||
|
||||
|
|
@ -981,8 +982,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
_ => { return; }
|
||||
};
|
||||
|
||||
debug!("assemble_candidates_for_projected_tys: trait_def_id={}",
|
||||
trait_def_id.repr(self.tcx()));
|
||||
debug!("assemble_candidates_for_projected_tys: trait_def_id={:?}",
|
||||
trait_def_id);
|
||||
|
||||
let result = self.infcx.probe(|snapshot| {
|
||||
self.match_projection_obligation_against_bounds_from_trait(obligation,
|
||||
|
|
@ -1005,9 +1006,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let (skol_trait_predicate, skol_map) =
|
||||
self.infcx().skolemize_late_bound_regions(&poly_trait_predicate, snapshot);
|
||||
debug!("match_projection_obligation_against_bounds_from_trait: \
|
||||
skol_trait_predicate={} skol_map={}",
|
||||
skol_trait_predicate.repr(self.tcx()),
|
||||
skol_map.repr(self.tcx()));
|
||||
skol_trait_predicate={:?} skol_map={:?}",
|
||||
skol_trait_predicate,
|
||||
skol_map);
|
||||
|
||||
let projection_trait_ref = match skol_trait_predicate.trait_ref.self_ty().sty {
|
||||
ty::TyProjection(ref data) => &data.trait_ref,
|
||||
|
|
@ -1015,19 +1016,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
&format!("match_projection_obligation_against_bounds_from_trait() called \
|
||||
but self-ty not a projection: {}",
|
||||
skol_trait_predicate.trait_ref.self_ty().repr(self.tcx())));
|
||||
but self-ty not a projection: {:?}",
|
||||
skol_trait_predicate.trait_ref.self_ty()));
|
||||
}
|
||||
};
|
||||
debug!("match_projection_obligation_against_bounds_from_trait: \
|
||||
projection_trait_ref={}",
|
||||
projection_trait_ref.repr(self.tcx()));
|
||||
projection_trait_ref={:?}",
|
||||
projection_trait_ref);
|
||||
|
||||
let trait_predicates = ty::lookup_predicates(self.tcx(), projection_trait_ref.def_id);
|
||||
let bounds = trait_predicates.instantiate(self.tcx(), projection_trait_ref.substs);
|
||||
debug!("match_projection_obligation_against_bounds_from_trait: \
|
||||
bounds={}",
|
||||
bounds.repr(self.tcx()));
|
||||
bounds={:?}",
|
||||
bounds);
|
||||
|
||||
let matching_bound =
|
||||
util::elaborate_predicates(self.tcx(), bounds.predicates.into_vec())
|
||||
|
|
@ -1041,8 +1042,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
snapshot)));
|
||||
|
||||
debug!("match_projection_obligation_against_bounds_from_trait: \
|
||||
matching_bound={}",
|
||||
matching_bound.repr(self.tcx()));
|
||||
matching_bound={:?}",
|
||||
matching_bound);
|
||||
match matching_bound {
|
||||
None => false,
|
||||
Some(bound) => {
|
||||
|
|
@ -1088,8 +1089,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
candidates: &mut SelectionCandidateSet<'tcx>)
|
||||
-> Result<(),SelectionError<'tcx>>
|
||||
{
|
||||
debug!("assemble_candidates_from_caller_bounds({})",
|
||||
stack.obligation.repr(self.tcx()));
|
||||
debug!("assemble_candidates_from_caller_bounds({:?})",
|
||||
stack.obligation);
|
||||
|
||||
let all_bounds =
|
||||
self.param_env().caller_bounds
|
||||
|
|
@ -1155,10 +1156,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
_ => { return Ok(()); }
|
||||
};
|
||||
|
||||
debug!("assemble_unboxed_candidates: self_ty={} kind={:?} obligation={}",
|
||||
self_ty.repr(self.tcx()),
|
||||
debug!("assemble_unboxed_candidates: self_ty={:?} kind={:?} obligation={:?}",
|
||||
self_ty,
|
||||
kind,
|
||||
obligation.repr(self.tcx()));
|
||||
obligation);
|
||||
|
||||
match self.closure_typer.closure_kind(closure_def_id) {
|
||||
Some(closure_kind) => {
|
||||
|
|
@ -1221,7 +1222,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
candidates: &mut SelectionCandidateSet<'tcx>)
|
||||
-> Result<(), SelectionError<'tcx>>
|
||||
{
|
||||
debug!("assemble_candidates_from_impls(obligation={})", obligation.repr(self.tcx()));
|
||||
debug!("assemble_candidates_from_impls(obligation={:?})", obligation);
|
||||
|
||||
let def = ty::lookup_trait_def(self.tcx(), obligation.predicate.def_id());
|
||||
|
||||
|
|
@ -1247,7 +1248,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
{
|
||||
// OK to skip binder here because the tests we do below do not involve bound regions
|
||||
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
|
||||
debug!("assemble_candidates_from_default_impls(self_ty={})", self_ty.repr(self.tcx()));
|
||||
debug!("assemble_candidates_from_default_impls(self_ty={:?})", self_ty);
|
||||
|
||||
let def_id = obligation.predicate.def_id();
|
||||
|
||||
|
|
@ -1316,8 +1317,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &TraitObligation<'tcx>,
|
||||
candidates: &mut SelectionCandidateSet<'tcx>)
|
||||
{
|
||||
debug!("assemble_candidates_from_object_ty(self_ty={})",
|
||||
self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()).repr(self.tcx()));
|
||||
debug!("assemble_candidates_from_object_ty(self_ty={:?})",
|
||||
self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()));
|
||||
|
||||
// Object-safety candidates are only applicable to object-safe
|
||||
// traits. Including this check is useful because it helps
|
||||
|
|
@ -1362,8 +1363,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
debug!("assemble_candidates_from_object_ty: poly_trait_ref={}",
|
||||
poly_trait_ref.repr(self.tcx()));
|
||||
debug!("assemble_candidates_from_object_ty: poly_trait_ref={:?}",
|
||||
poly_trait_ref);
|
||||
|
||||
// see whether the object trait can be upcast to the trait we are looking for
|
||||
let upcast_trait_refs = self.upcast(poly_trait_ref, obligation);
|
||||
|
|
@ -1406,8 +1407,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let source = self.infcx.shallow_resolve(self_ty);
|
||||
let target = self.infcx.shallow_resolve(obligation.predicate.0.input_types()[0]);
|
||||
|
||||
debug!("assemble_candidates_for_unsizing(source={}, target={})",
|
||||
source.repr(self.tcx()), target.repr(self.tcx()));
|
||||
debug!("assemble_candidates_for_unsizing(source={:?}, target={:?})",
|
||||
source, target);
|
||||
|
||||
let may_apply = match (&source.sty, &target.sty) {
|
||||
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
|
||||
|
|
@ -1473,7 +1474,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
candidate: &SelectionCandidate<'tcx>)
|
||||
-> EvaluationResult<'tcx>
|
||||
{
|
||||
debug!("winnow_candidate: candidate={}", candidate.repr(self.tcx()));
|
||||
debug!("winnow_candidate: candidate={:?}", candidate);
|
||||
let result = self.infcx.probe(|_| {
|
||||
let candidate = (*candidate).clone();
|
||||
match self.confirm_candidate(stack.obligation, candidate) {
|
||||
|
|
@ -1565,8 +1566,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
{
|
||||
match self.builtin_bound(bound, stack.obligation) {
|
||||
Ok(If(..)) => {
|
||||
debug!("builtin_bound: bound={}",
|
||||
bound.repr(self.tcx()));
|
||||
debug!("builtin_bound: bound={:?}",
|
||||
bound);
|
||||
candidates.vec.push(BuiltinCandidate(bound));
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -1774,8 +1775,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
| ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||
self.tcx().sess.bug(
|
||||
&format!(
|
||||
"asked to assemble builtin bounds of unexpected type: {}",
|
||||
self_ty.repr(self.tcx())));
|
||||
"asked to assemble builtin bounds of unexpected type: {:?}",
|
||||
self_ty));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1837,8 +1838,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||
self.tcx().sess.bug(
|
||||
&format!(
|
||||
"asked to assemble constituent types of unexpected type: {}",
|
||||
t.repr(self.tcx())));
|
||||
"asked to assemble constituent types of unexpected type: {:?}",
|
||||
t));
|
||||
}
|
||||
|
||||
ty::TyBox(referent_ty) => { // Box<T>
|
||||
|
|
@ -1972,9 +1973,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
candidate: SelectionCandidate<'tcx>)
|
||||
-> Result<Selection<'tcx>,SelectionError<'tcx>>
|
||||
{
|
||||
debug!("confirm_candidate({}, {})",
|
||||
obligation.repr(self.tcx()),
|
||||
candidate.repr(self.tcx()));
|
||||
debug!("confirm_candidate({:?}, {:?})",
|
||||
obligation,
|
||||
candidate);
|
||||
|
||||
match candidate {
|
||||
BuiltinCandidate(builtin_bound) => {
|
||||
|
|
@ -2064,9 +2065,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
param: ty::PolyTraitRef<'tcx>)
|
||||
-> Vec<PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("confirm_param_candidate({},{})",
|
||||
obligation.repr(self.tcx()),
|
||||
param.repr(self.tcx()));
|
||||
debug!("confirm_param_candidate({:?},{:?})",
|
||||
obligation,
|
||||
param);
|
||||
|
||||
// During evaluation, we already checked that this
|
||||
// where-clause trait-ref could be unified with the obligation
|
||||
|
|
@ -2076,9 +2077,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
Ok(obligations) => obligations,
|
||||
Err(()) => {
|
||||
self.tcx().sess.bug(
|
||||
&format!("Where clause `{}` was applicable to `{}` but now is not",
|
||||
param.repr(self.tcx()),
|
||||
obligation.repr(self.tcx())));
|
||||
&format!("Where clause `{:?}` was applicable to `{:?}` but now is not",
|
||||
param,
|
||||
obligation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2089,16 +2090,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
-> Result<VtableBuiltinData<PredicateObligation<'tcx>>,
|
||||
SelectionError<'tcx>>
|
||||
{
|
||||
debug!("confirm_builtin_candidate({})",
|
||||
obligation.repr(self.tcx()));
|
||||
debug!("confirm_builtin_candidate({:?})",
|
||||
obligation);
|
||||
|
||||
match try!(self.builtin_bound(bound, obligation)) {
|
||||
If(nested) => Ok(self.vtable_builtin_data(obligation, bound, nested)),
|
||||
AmbiguousBuiltin | ParameterBuiltin => {
|
||||
self.tcx().sess.span_bug(
|
||||
obligation.cause.span,
|
||||
&format!("builtin bound for {} was ambig",
|
||||
obligation.repr(self.tcx())));
|
||||
&format!("builtin bound for {:?} was ambig",
|
||||
obligation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2118,8 +2119,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
let obligations = self.collect_predicates_for_types(obligation, trait_def, nested);
|
||||
|
||||
debug!("vtable_builtin_data: obligations={}",
|
||||
obligations.repr(self.tcx()));
|
||||
debug!("vtable_builtin_data: obligations={:?}",
|
||||
obligations);
|
||||
|
||||
VtableBuiltinData { nested: obligations }
|
||||
}
|
||||
|
|
@ -2134,9 +2135,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
trait_def_id: ast::DefId)
|
||||
-> VtableDefaultImplData<PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("confirm_default_impl_candidate({}, {})",
|
||||
obligation.repr(self.tcx()),
|
||||
trait_def_id.repr(self.tcx()));
|
||||
debug!("confirm_default_impl_candidate({:?}, {:?})",
|
||||
obligation,
|
||||
trait_def_id);
|
||||
|
||||
// binder is moved below
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
|
||||
|
|
@ -2145,8 +2146,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
None => {
|
||||
self.tcx().sess.bug(
|
||||
&format!(
|
||||
"asked to confirm default implementation for ambiguous type: {}",
|
||||
self_ty.repr(self.tcx())));
|
||||
"asked to confirm default implementation for ambiguous type: {:?}",
|
||||
self_ty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2156,9 +2157,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
trait_def_id: ast::DefId)
|
||||
-> VtableDefaultImplData<PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("confirm_default_impl_object_candidate({}, {})",
|
||||
obligation.repr(self.tcx()),
|
||||
trait_def_id.repr(self.tcx()));
|
||||
debug!("confirm_default_impl_object_candidate({:?}, {:?})",
|
||||
obligation,
|
||||
trait_def_id);
|
||||
|
||||
assert!(ty::has_attr(self.tcx(), trait_def_id, "rustc_reflect_like"));
|
||||
|
||||
|
|
@ -2184,8 +2185,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
_ => {
|
||||
self.tcx().sess.bug(
|
||||
&format!(
|
||||
"asked to confirm default object implementation for non-object type: {}",
|
||||
self_ty.repr(self.tcx())));
|
||||
"asked to confirm default object implementation for non-object type: {:?}",
|
||||
self_ty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2197,7 +2198,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
nested: ty::Binder<Vec<Ty<'tcx>>>)
|
||||
-> VtableDefaultImplData<PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("vtable_default_impl_data: nested={}", nested.repr(self.tcx()));
|
||||
debug!("vtable_default_impl_data: nested={:?}", nested);
|
||||
|
||||
let mut obligations = self.collect_predicates_for_types(obligation,
|
||||
trait_def_id,
|
||||
|
|
@ -2218,7 +2219,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// no Errors in that code above
|
||||
obligations.append(&mut trait_obligations.unwrap());
|
||||
|
||||
debug!("vtable_default_impl_data: obligations={}", obligations.repr(self.tcx()));
|
||||
debug!("vtable_default_impl_data: obligations={:?}", obligations);
|
||||
|
||||
VtableDefaultImplData {
|
||||
trait_def_id: trait_def_id,
|
||||
|
|
@ -2232,9 +2233,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
-> Result<VtableImplData<'tcx, PredicateObligation<'tcx>>,
|
||||
SelectionError<'tcx>>
|
||||
{
|
||||
debug!("confirm_impl_candidate({},{})",
|
||||
obligation.repr(self.tcx()),
|
||||
impl_def_id.repr(self.tcx()));
|
||||
debug!("confirm_impl_candidate({:?},{:?})",
|
||||
obligation,
|
||||
impl_def_id);
|
||||
|
||||
// First, create the substitutions by matching the impl again,
|
||||
// this time not in a probe.
|
||||
|
|
@ -2242,7 +2243,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let (substs, skol_map) =
|
||||
self.rematch_impl(impl_def_id, obligation,
|
||||
snapshot);
|
||||
debug!("confirm_impl_candidate substs={}", substs.repr(self.tcx()));
|
||||
debug!("confirm_impl_candidate substs={:?}", substs);
|
||||
Ok(self.vtable_impl(impl_def_id, substs, obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1, skol_map, snapshot))
|
||||
})
|
||||
|
|
@ -2257,11 +2258,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
snapshot: &infer::CombinedSnapshot)
|
||||
-> VtableImplData<'tcx, PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("vtable_impl(impl_def_id={}, substs={}, recursion_depth={}, skol_map={})",
|
||||
impl_def_id.repr(self.tcx()),
|
||||
substs.repr(self.tcx()),
|
||||
debug!("vtable_impl(impl_def_id={:?}, substs={:?}, recursion_depth={}, skol_map={:?})",
|
||||
impl_def_id,
|
||||
substs,
|
||||
recursion_depth,
|
||||
skol_map.repr(self.tcx()));
|
||||
skol_map);
|
||||
|
||||
let mut impl_obligations =
|
||||
self.impl_or_trait_obligations(cause,
|
||||
|
|
@ -2271,9 +2272,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
skol_map,
|
||||
snapshot);
|
||||
|
||||
debug!("vtable_impl: impl_def_id={} impl_obligations={}",
|
||||
impl_def_id.repr(self.tcx()),
|
||||
impl_obligations.repr(self.tcx()));
|
||||
debug!("vtable_impl: impl_def_id={:?} impl_obligations={:?}",
|
||||
impl_def_id,
|
||||
impl_obligations);
|
||||
|
||||
impl_obligations.append(&mut substs.obligations);
|
||||
|
||||
|
|
@ -2286,8 +2287,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &TraitObligation<'tcx>)
|
||||
-> VtableObjectData<'tcx>
|
||||
{
|
||||
debug!("confirm_object_candidate({})",
|
||||
obligation.repr(self.tcx()));
|
||||
debug!("confirm_object_candidate({:?})",
|
||||
obligation);
|
||||
|
||||
// FIXME skipping binder here seems wrong -- we should
|
||||
// probably flatten the binder from the obligation and the
|
||||
|
|
@ -2328,8 +2329,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &TraitObligation<'tcx>)
|
||||
-> Result<ty::Ty<'tcx>,SelectionError<'tcx>>
|
||||
{
|
||||
debug!("confirm_fn_pointer_candidate({})",
|
||||
obligation.repr(self.tcx()));
|
||||
debug!("confirm_fn_pointer_candidate({:?})",
|
||||
obligation);
|
||||
|
||||
// ok to skip binder; it is reintroduced below
|
||||
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
|
||||
|
|
@ -2355,20 +2356,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
-> Result<VtableClosureData<'tcx, PredicateObligation<'tcx>>,
|
||||
SelectionError<'tcx>>
|
||||
{
|
||||
debug!("confirm_closure_candidate({},{},{})",
|
||||
obligation.repr(self.tcx()),
|
||||
closure_def_id.repr(self.tcx()),
|
||||
substs.repr(self.tcx()));
|
||||
debug!("confirm_closure_candidate({:?},{:?},{:?})",
|
||||
obligation,
|
||||
closure_def_id,
|
||||
substs);
|
||||
|
||||
let Normalized {
|
||||
value: trait_ref,
|
||||
obligations
|
||||
} = self.closure_trait_ref(obligation, closure_def_id, substs);
|
||||
|
||||
debug!("confirm_closure_candidate(closure_def_id={}, trait_ref={}, obligations={})",
|
||||
closure_def_id.repr(self.tcx()),
|
||||
trait_ref.repr(self.tcx()),
|
||||
obligations.repr(self.tcx()));
|
||||
debug!("confirm_closure_candidate(closure_def_id={:?}, trait_ref={:?}, obligations={:?})",
|
||||
closure_def_id,
|
||||
trait_ref,
|
||||
obligations);
|
||||
|
||||
try!(self.confirm_poly_trait_refs(obligation.cause.clone(),
|
||||
obligation.predicate.to_poly_trait_ref(),
|
||||
|
|
@ -2436,8 +2437,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::no_late_bound_regions(tcx, &obligation.self_ty()).unwrap());
|
||||
let target = self.infcx.shallow_resolve(obligation.predicate.0.input_types()[0]);
|
||||
|
||||
debug!("confirm_builtin_unsize_candidate(source={}, target={})",
|
||||
source.repr(tcx), target.repr(tcx));
|
||||
debug!("confirm_builtin_unsize_candidate(source={:?}, target={:?})",
|
||||
source, target);
|
||||
|
||||
let mut nested = vec![];
|
||||
match (&source.sty, &target.sty) {
|
||||
|
|
@ -2613,9 +2614,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
Ok((substs, skol_map)) => (substs, skol_map),
|
||||
Err(()) => {
|
||||
self.tcx().sess.bug(
|
||||
&format!("Impl {} was matchable against {} but now is not",
|
||||
impl_def_id.repr(self.tcx()),
|
||||
obligation.repr(self.tcx())));
|
||||
&format!("Impl {:?} was matchable against {:?} but now is not",
|
||||
impl_def_id,
|
||||
obligation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2654,30 +2655,28 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.recursion_depth + 1,
|
||||
&impl_trait_ref);
|
||||
|
||||
debug!("match_impl(impl_def_id={}, obligation={}, \
|
||||
impl_trait_ref={}, skol_obligation_trait_ref={})",
|
||||
impl_def_id.repr(self.tcx()),
|
||||
obligation.repr(self.tcx()),
|
||||
impl_trait_ref.repr(self.tcx()),
|
||||
skol_obligation_trait_ref.repr(self.tcx()));
|
||||
debug!("match_impl(impl_def_id={:?}, obligation={:?}, \
|
||||
impl_trait_ref={:?}, skol_obligation_trait_ref={:?})",
|
||||
impl_def_id,
|
||||
obligation,
|
||||
impl_trait_ref,
|
||||
skol_obligation_trait_ref);
|
||||
|
||||
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
|
||||
if let Err(e) = self.infcx.sub_trait_refs(false,
|
||||
origin,
|
||||
impl_trait_ref.value.clone(),
|
||||
skol_obligation_trait_ref) {
|
||||
debug!("match_impl: failed sub_trait_refs due to `{}`",
|
||||
ty::type_err_to_str(self.tcx(), &e));
|
||||
debug!("match_impl: failed sub_trait_refs due to `{}`", e);
|
||||
return Err(());
|
||||
}
|
||||
|
||||
if let Err(e) = self.infcx.leak_check(&skol_map, snapshot) {
|
||||
debug!("match_impl: failed leak check due to `{}`",
|
||||
ty::type_err_to_str(self.tcx(), &e));
|
||||
debug!("match_impl: failed leak check due to `{}`", e);
|
||||
return Err(());
|
||||
}
|
||||
|
||||
debug!("match_impl: success impl_substs={}", impl_substs.repr(self.tcx()));
|
||||
debug!("match_impl: success impl_substs={:?}", impl_substs);
|
||||
Ok((Normalized {
|
||||
value: impl_substs,
|
||||
obligations: impl_trait_ref.obligations
|
||||
|
|
@ -2728,9 +2727,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
poly_trait_ref: ty::PolyTraitRef<'tcx>)
|
||||
-> Result<(),()>
|
||||
{
|
||||
debug!("match_poly_trait_ref: obligation={} poly_trait_ref={}",
|
||||
obligation.repr(self.tcx()),
|
||||
poly_trait_ref.repr(self.tcx()));
|
||||
debug!("match_poly_trait_ref: obligation={:?} poly_trait_ref={:?}",
|
||||
obligation,
|
||||
poly_trait_ref);
|
||||
|
||||
let origin = infer::RelateOutputImplTypes(obligation.cause.span);
|
||||
match self.infcx.sub_poly_trait_refs(false,
|
||||
|
|
@ -2769,15 +2768,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let impl_self_ty = ty::lookup_item_type(self.tcx(), impl_def_id).ty;
|
||||
let impl_self_ty = impl_self_ty.subst(self.tcx(), &impl_substs);
|
||||
|
||||
debug!("match_impl_self_types(obligation_self_ty={}, impl_self_ty={})",
|
||||
obligation_self_ty.repr(self.tcx()),
|
||||
impl_self_ty.repr(self.tcx()));
|
||||
debug!("match_impl_self_types(obligation_self_ty={:?}, impl_self_ty={:?})",
|
||||
obligation_self_ty,
|
||||
impl_self_ty);
|
||||
|
||||
match self.match_self_types(obligation_cause,
|
||||
impl_self_ty,
|
||||
obligation_self_ty) {
|
||||
Ok(()) => {
|
||||
debug!("Matched impl_substs={}", impl_substs.repr(self.tcx()));
|
||||
debug!("Matched impl_substs={:?}", impl_substs);
|
||||
Ok(impl_substs)
|
||||
}
|
||||
Err(()) => {
|
||||
|
|
@ -2889,15 +2888,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
snapshot: &infer::CombinedSnapshot)
|
||||
-> Vec<PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("impl_or_trait_obligations(def_id={})", def_id.repr(self.tcx()));
|
||||
debug!("impl_or_trait_obligations(def_id={:?})", def_id);
|
||||
|
||||
let predicates = ty::lookup_predicates(self.tcx(), def_id);
|
||||
let predicates = predicates.instantiate(self.tcx(), substs);
|
||||
let predicates = normalize_with_depth(self, cause.clone(), recursion_depth, &predicates);
|
||||
let mut predicates = self.infcx().plug_leaks(skol_map, snapshot, &predicates);
|
||||
let mut obligations =
|
||||
util::predicates_for_generics(self.tcx(),
|
||||
cause,
|
||||
util::predicates_for_generics(cause,
|
||||
recursion_depth,
|
||||
&predicates.value);
|
||||
obligations.append(&mut predicates.obligations);
|
||||
|
|
@ -2940,9 +2938,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
fn upcast(&mut self, obj_trait_ref: ty::PolyTraitRef<'tcx>, obligation: &TraitObligation<'tcx>)
|
||||
-> Vec<ty::PolyTraitRef<'tcx>>
|
||||
{
|
||||
debug!("upcast(obj_trait_ref={}, obligation={})",
|
||||
obj_trait_ref.repr(self.tcx()),
|
||||
obligation.repr(self.tcx()));
|
||||
debug!("upcast(obj_trait_ref={:?}, obligation={:?})",
|
||||
obj_trait_ref,
|
||||
obligation);
|
||||
|
||||
let obligation_def_id = obligation.predicate.def_id();
|
||||
let mut upcast_trait_refs = util::upcast(self.tcx(), obj_trait_ref, obligation_def_id);
|
||||
|
|
@ -2958,33 +2956,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.infcx.probe(|_| self.match_poly_trait_ref(obligation, upcast_trait_ref)).is_ok()
|
||||
});
|
||||
|
||||
debug!("upcast: upcast_trait_refs={}", upcast_trait_refs.repr(self.tcx()));
|
||||
debug!("upcast: upcast_trait_refs={:?}", upcast_trait_refs);
|
||||
upcast_trait_refs
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for SelectionCandidate<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
PhantomFnCandidate => format!("PhantomFnCandidate"),
|
||||
ErrorCandidate => format!("ErrorCandidate"),
|
||||
BuiltinCandidate(b) => format!("BuiltinCandidate({:?})", b),
|
||||
BuiltinObjectCandidate => format!("BuiltinObjectCandidate"),
|
||||
BuiltinUnsizeCandidate => format!("BuiltinUnsizeCandidate"),
|
||||
ParamCandidate(ref a) => format!("ParamCandidate({})", a.repr(tcx)),
|
||||
ImplCandidate(a) => format!("ImplCandidate({})", a.repr(tcx)),
|
||||
DefaultImplCandidate(t) => format!("DefaultImplCandidate({:?})", t),
|
||||
DefaultImplObjectCandidate(t) => format!("DefaultImplObjectCandidate({:?})", t),
|
||||
ProjectionCandidate => format!("ProjectionCandidate"),
|
||||
FnPointerCandidate => format!("FnPointerCandidate"),
|
||||
ObjectCandidate => format!("ObjectCandidate"),
|
||||
ClosureCandidate(c, ref s) => {
|
||||
format!("ClosureCandidate({:?},{})", c, s.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> SelectionCache<'tcx> {
|
||||
pub fn new() -> SelectionCache<'tcx> {
|
||||
SelectionCache {
|
||||
|
|
@ -3032,10 +3008,9 @@ impl<'o,'tcx> Iterator for TraitObligationStackList<'o,'tcx>{
|
|||
}
|
||||
}
|
||||
|
||||
impl<'o,'tcx> Repr<'tcx> for TraitObligationStack<'o,'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("TraitObligationStack({})",
|
||||
self.obligation.repr(tcx))
|
||||
impl<'o,'tcx> fmt::Debug for TraitObligationStack<'o,'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "TraitObligationStack({:?})", self.obligation)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use syntax::ast;
|
|||
use syntax::codemap::Span;
|
||||
use util::common::ErrorReported;
|
||||
use util::nodemap::FnvHashSet;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use super::{Obligation, ObligationCause, PredicateObligation,
|
||||
VtableImpl, VtableParam, VtableImplData, VtableDefaultImplData};
|
||||
|
|
@ -125,8 +124,8 @@ impl<'cx, 'tcx> Elaborator<'cx, 'tcx> {
|
|||
.map(|p| p.subst_supertrait(self.tcx, &data.to_poly_trait_ref()))
|
||||
.collect();
|
||||
|
||||
debug!("super_predicates: data={} predicates={}",
|
||||
data.repr(self.tcx), predicates.repr(self.tcx));
|
||||
debug!("super_predicates: data={:?} predicates={:?}",
|
||||
data, predicates);
|
||||
|
||||
// Only keep those bounds that we haven't already
|
||||
// seen. This is necessary to prevent infinite
|
||||
|
|
@ -302,33 +301,14 @@ pub fn fresh_type_vars_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
infcx.fresh_substs_for_generics(span, &impl_generics)
|
||||
}
|
||||
|
||||
impl<'tcx, N> fmt::Debug for VtableImplData<'tcx, N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableImpl({:?})", self.impl_def_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N> fmt::Debug for super::VtableClosureData<'tcx, N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableClosure({:?})", self.closure_def_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for super::VtableObjectData<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableObject(...)")
|
||||
}
|
||||
}
|
||||
|
||||
/// See `super::obligations_for_generics`
|
||||
pub fn predicates_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>,
|
||||
recursion_depth: usize,
|
||||
generic_bounds: &ty::InstantiatedPredicates<'tcx>)
|
||||
-> Vec<PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("predicates_for_generics(generic_bounds={})",
|
||||
generic_bounds.repr(tcx));
|
||||
debug!("predicates_for_generics(generic_bounds={:?})",
|
||||
generic_bounds);
|
||||
|
||||
generic_bounds.predicates.iter().map(|predicate| {
|
||||
Obligation { cause: cause.clone(),
|
||||
|
|
@ -486,118 +466,84 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
|
|||
ty::Binder((trait_ref, sig.0.output.unwrap_or(ty::mk_nil(tcx))))
|
||||
}
|
||||
|
||||
impl<'tcx,O:Repr<'tcx>> Repr<'tcx> for super::Obligation<'tcx, O> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("Obligation(predicate={},depth={})",
|
||||
self.predicate.repr(tcx),
|
||||
self.recursion_depth)
|
||||
impl<'tcx,O:fmt::Debug> fmt::Debug for super::Obligation<'tcx, O> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Obligation(predicate={:?},depth={})",
|
||||
self.predicate,
|
||||
self.recursion_depth)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::Vtable<'tcx, N> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
impl<'tcx, N:fmt::Debug> fmt::Debug for super::Vtable<'tcx, N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
super::VtableImpl(ref v) =>
|
||||
v.repr(tcx),
|
||||
write!(f, "{:?}", v),
|
||||
|
||||
super::VtableDefaultImpl(ref t) =>
|
||||
t.repr(tcx),
|
||||
write!(f, "{:?}", t),
|
||||
|
||||
super::VtableClosure(ref d) =>
|
||||
d.repr(tcx),
|
||||
write!(f, "{:?}", d),
|
||||
|
||||
super::VtableFnPointer(ref d) =>
|
||||
format!("VtableFnPointer({})",
|
||||
d.repr(tcx)),
|
||||
write!(f, "VtableFnPointer({:?})", d),
|
||||
|
||||
super::VtableObject(ref d) =>
|
||||
format!("VtableObject({})",
|
||||
d.repr(tcx)),
|
||||
write!(f, "VtableObject({:?})", d),
|
||||
|
||||
super::VtableParam(ref n) =>
|
||||
format!("VtableParam({})",
|
||||
n.repr(tcx)),
|
||||
write!(f, "VtableParam({:?})", n),
|
||||
|
||||
super::VtableBuiltin(ref d) =>
|
||||
d.repr(tcx)
|
||||
write!(f, "{:?}", d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableImplData<'tcx, N> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("VtableImpl(impl_def_id={}, substs={}, nested={})",
|
||||
self.impl_def_id.repr(tcx),
|
||||
self.substs.repr(tcx),
|
||||
self.nested.repr(tcx))
|
||||
impl<'tcx, N:fmt::Debug> fmt::Debug for super::VtableImplData<'tcx, N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableImpl(impl_def_id={:?}, substs={:?}, nested={:?})",
|
||||
self.impl_def_id,
|
||||
self.substs,
|
||||
self.nested)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableClosureData<'tcx, N> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("VtableClosure(closure_def_id={}, substs={}, nested={})",
|
||||
self.closure_def_id.repr(tcx),
|
||||
self.substs.repr(tcx),
|
||||
self.nested.repr(tcx))
|
||||
impl<'tcx, N:fmt::Debug> fmt::Debug for super::VtableClosureData<'tcx, N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableClosure(closure_def_id={:?}, substs={:?}, nested={:?})",
|
||||
self.closure_def_id,
|
||||
self.substs,
|
||||
self.nested)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableBuiltinData<N> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("VtableBuiltin(nested={})",
|
||||
self.nested.repr(tcx))
|
||||
impl<'tcx, N:fmt::Debug> fmt::Debug for super::VtableBuiltinData<N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableBuiltin(nested={:?})", self.nested)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableDefaultImplData<N> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("VtableDefaultImplData(trait_def_id={}, nested={})",
|
||||
self.trait_def_id.repr(tcx),
|
||||
self.nested.repr(tcx))
|
||||
impl<'tcx, N:fmt::Debug> fmt::Debug for super::VtableDefaultImplData<N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableDefaultImplData(trait_def_id={:?}, nested={:?})",
|
||||
self.trait_def_id,
|
||||
self.nested)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for super::VtableObjectData<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("VtableObject(object_ty={})",
|
||||
self.object_ty.repr(tcx))
|
||||
impl<'tcx> fmt::Debug for super::VtableObjectData<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableObject(object_ty={:?})", self.object_ty)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for super::SelectionError<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
super::Unimplemented =>
|
||||
format!("Unimplemented"),
|
||||
|
||||
super::OutputTypeParameterMismatch(ref a, ref b, ref c) =>
|
||||
format!("OutputTypeParameterMismatch({},{},{})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx),
|
||||
c.repr(tcx)),
|
||||
|
||||
super::TraitNotObjectSafe(ref tr) =>
|
||||
format!("TraitNotObjectSafe({})",
|
||||
tr.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for super::FulfillmentError<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
format!("FulfillmentError({},{})",
|
||||
self.obligation.repr(tcx),
|
||||
self.code.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for super::FulfillmentErrorCode<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
super::CodeSelectionError(ref o) => o.repr(tcx),
|
||||
super::CodeProjectionError(ref o) => o.repr(tcx),
|
||||
super::CodeAmbiguity => format!("Ambiguity")
|
||||
}
|
||||
impl<'tcx> fmt::Debug for super::FulfillmentError<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "FulfillmentError({:?},{:?})",
|
||||
self.obligation,
|
||||
self.code)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -611,14 +557,8 @@ impl<'tcx> fmt::Debug for super::FulfillmentErrorCode<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for super::MismatchedProjectionTypes<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
self.err.repr(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for super::MismatchedProjectionTypes<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "MismatchedProjectionTypes(..)")
|
||||
write!(f, "MismatchedProjectionTypes({:?})", self.err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -38,19 +38,20 @@ use middle::subst;
|
|||
use middle::subst::VecPerParamSpace;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::traits;
|
||||
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use syntax::abi;
|
||||
use syntax::ast;
|
||||
use syntax::owned_slice::OwnedSlice;
|
||||
use util::nodemap::FnvHashMap;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Two generic traits
|
||||
|
||||
/// The TypeFoldable trait is implemented for every type that can be folded.
|
||||
/// Basically, every type that has a corresponding method in TypeFolder.
|
||||
pub trait TypeFoldable<'tcx>: Repr<'tcx> + Clone {
|
||||
pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
|
||||
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self;
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +75,7 @@ pub trait TypeFolder<'tcx> : Sized {
|
|||
fn exit_region_binder(&mut self) { }
|
||||
|
||||
fn fold_binder<T>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T>
|
||||
where T : TypeFoldable<'tcx> + Repr<'tcx> + Clone
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
// FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`.
|
||||
super_fold_binder(self, t)
|
||||
|
|
@ -197,7 +198,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>+Clone> TypeFoldable<'tcx> for ty::Binder<T> {
|
||||
impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
|
||||
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Binder<T> {
|
||||
folder.fold_binder(self)
|
||||
}
|
||||
|
|
@ -842,13 +843,13 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx>
|
|||
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
|
||||
match r {
|
||||
ty::ReLateBound(debruijn, _) if debruijn.depth < self.current_depth => {
|
||||
debug!("RegionFolder.fold_region({}) skipped bound region (current depth={})",
|
||||
r.repr(self.tcx()), self.current_depth);
|
||||
debug!("RegionFolder.fold_region({:?}) skipped bound region (current depth={})",
|
||||
r, self.current_depth);
|
||||
r
|
||||
}
|
||||
_ => {
|
||||
debug!("RegionFolder.fold_region({}) folding free region (current_depth={})",
|
||||
r.repr(self.tcx()), self.current_depth);
|
||||
debug!("RegionFolder.fold_region({:?}) folding free region (current_depth={})",
|
||||
r, self.current_depth);
|
||||
(self.fld_r)(r, self.current_depth)
|
||||
}
|
||||
}
|
||||
|
|
@ -885,9 +886,9 @@ pub fn replace_late_bound_regions<'tcx,T,F>(tcx: &ty::ctxt<'tcx>,
|
|||
mut f: F)
|
||||
-> (T, FnvHashMap<ty::BoundRegion, ty::Region>)
|
||||
where F : FnMut(ty::BoundRegion) -> ty::Region,
|
||||
T : TypeFoldable<'tcx> + Repr<'tcx>,
|
||||
T : TypeFoldable<'tcx>,
|
||||
{
|
||||
debug!("replace_late_bound_regions({})", value.repr(tcx));
|
||||
debug!("replace_late_bound_regions({:?})", value);
|
||||
let mut replacer = RegionReplacer::new(tcx, &mut f);
|
||||
let result = value.skip_binder().fold_with(&mut replacer);
|
||||
(result, replacer.map)
|
||||
|
|
@ -916,8 +917,8 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx>
|
|||
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
|
||||
match r {
|
||||
ty::ReLateBound(debruijn, br) if debruijn.depth == self.current_depth => {
|
||||
debug!("RegionReplacer.fold_region({}) folding region (current_depth={})",
|
||||
r.repr(self.tcx()), self.current_depth);
|
||||
debug!("RegionReplacer.fold_region({:?}) folding region (current_depth={})",
|
||||
r, self.current_depth);
|
||||
let fld_r = &mut self.fld_r;
|
||||
let region = *self.map.entry(br).or_insert_with(|| fld_r(br));
|
||||
if let ty::ReLateBound(debruijn1, br) = region {
|
||||
|
|
@ -994,10 +995,10 @@ pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>>(tcx: &ty::ctxt<'tcx>,
|
||||
amount: u32, value: &T) -> T {
|
||||
debug!("shift_regions(value={}, amount={})",
|
||||
value.repr(tcx), amount);
|
||||
pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>>(tcx: &ty::ctxt<'tcx>,
|
||||
amount: u32, value: &T) -> T {
|
||||
debug!("shift_regions(value={:?}, amount={})",
|
||||
value, amount);
|
||||
|
||||
value.fold_with(&mut RegionFolder::new(tcx, &mut |region, _current_depth| {
|
||||
shift_region(region, amount)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty_relate::{self, Relate, TypeRelation, RelateResult};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
/// A type "A" *matches* "B" if the fresh types in B could be
|
||||
/// substituted with values so as to make it equal to A. Matching is
|
||||
|
|
@ -53,16 +52,16 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> {
|
||||
debug!("{}.regions({}, {})",
|
||||
debug!("{}.regions({:?}, {:?})",
|
||||
self.tag(),
|
||||
a.repr(self.tcx()),
|
||||
b.repr(self.tcx()));
|
||||
a,
|
||||
b);
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
debug!("{}.tys({}, {})", self.tag(),
|
||||
a.repr(self.tcx()), b.repr(self.tcx()));
|
||||
debug!("{}.tys({:?}, {:?})", self.tag(),
|
||||
a, b);
|
||||
if a == b { return Ok(a); }
|
||||
|
||||
match (&a.sty, &b.sty) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use middle::ty_fold::TypeFoldable;
|
|||
use std::rc::Rc;
|
||||
use syntax::abi;
|
||||
use syntax::ast;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
pub type RelateResult<'tcx, T> = Result<T, ty::type_err<'tcx>>;
|
||||
|
||||
|
|
@ -79,10 +78,10 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::mt<'tcx> {
|
|||
-> RelateResult<'tcx, ty::mt<'tcx>>
|
||||
where R: TypeRelation<'a,'tcx>
|
||||
{
|
||||
debug!("{}.mts({}, {})",
|
||||
debug!("{}.mts({:?}, {:?})",
|
||||
relation.tag(),
|
||||
a.repr(relation.tcx()),
|
||||
b.repr(relation.tcx()));
|
||||
a,
|
||||
b);
|
||||
if a.mutbl != b.mutbl {
|
||||
Err(ty::terr_mutability)
|
||||
} else {
|
||||
|
|
@ -107,10 +106,10 @@ fn relate_item_substs<'a,'tcx:'a,R>(relation: &mut R,
|
|||
-> RelateResult<'tcx, Substs<'tcx>>
|
||||
where R: TypeRelation<'a,'tcx>
|
||||
{
|
||||
debug!("substs: item_def_id={} a_subst={} b_subst={}",
|
||||
item_def_id.repr(relation.tcx()),
|
||||
a_subst.repr(relation.tcx()),
|
||||
b_subst.repr(relation.tcx()));
|
||||
debug!("substs: item_def_id={:?} a_subst={:?} b_subst={:?}",
|
||||
item_def_id,
|
||||
a_subst,
|
||||
b_subst);
|
||||
|
||||
let variances;
|
||||
let opt_variances = if relation.tcx().variance_computed.get() {
|
||||
|
|
@ -191,14 +190,13 @@ fn relate_region_params<'a,'tcx:'a,R>(relation: &mut R,
|
|||
-> RelateResult<'tcx, Vec<ty::Region>>
|
||||
where R: TypeRelation<'a,'tcx>
|
||||
{
|
||||
let tcx = relation.tcx();
|
||||
let num_region_params = a_rs.len();
|
||||
|
||||
debug!("relate_region_params(a_rs={}, \
|
||||
b_rs={}, variances={})",
|
||||
a_rs.repr(tcx),
|
||||
b_rs.repr(tcx),
|
||||
variances.repr(tcx));
|
||||
debug!("relate_region_params(a_rs={:?}, \
|
||||
b_rs={:?}, variances={:?})",
|
||||
a_rs,
|
||||
b_rs,
|
||||
variances);
|
||||
|
||||
assert_eq!(num_region_params,
|
||||
variances.map_or(num_region_params,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue