rustc: replace Repr/UserString impls with Debug/Display ones.
This commit is contained in:
parent
17e333d31b
commit
dfbc9608ce
|
@ -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) {
|
||||
|
|
|
@ -25,6 +25,7 @@ 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>),
|
||||
|
@ -400,7 +401,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
|
||||
where T : TypeFoldable<'tcx> + ty::HasProjectionTypes
|
||||
{
|
||||
let value =
|
||||
traits::fully_normalize(self.infcx,
|
||||
|
@ -454,34 +455,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 for Implication<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
Implication::RegionSubRegion(_, ref r_a, ref r_b) => {
|
||||
format!("RegionSubRegion({}, {})",
|
||||
r_a.repr(),
|
||||
r_b.repr())
|
||||
}
|
||||
|
||||
Implication::RegionSubGeneric(_, ref r, ref p) => {
|
||||
format!("RegionSubGeneric({}, {})",
|
||||
r.repr(),
|
||||
p.repr())
|
||||
}
|
||||
|
||||
Implication::RegionSubClosure(_, ref a, ref b, ref c) => {
|
||||
format!("RegionSubClosure({}, {}, {})",
|
||||
a.repr(),
|
||||
b.repr(),
|
||||
c.repr())
|
||||
}
|
||||
|
||||
Implication::Predicate(ref def_id, ref p) => {
|
||||
format!("Predicate({}, {})",
|
||||
def_id.repr(),
|
||||
p.repr())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -480,7 +480,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) =>
|
||||
|
|
|
@ -518,7 +518,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
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
/*!
|
||||
* Replace all regions bound by `binder` with skolemized regions and
|
||||
|
@ -616,7 +616,7 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
snapshot: &CombinedSnapshot,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok());
|
||||
|
||||
|
|
|
@ -160,7 +160,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>,
|
||||
|
@ -708,7 +708,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
value: &ty::Binder<T>,
|
||||
snapshot: &CombinedSnapshot)
|
||||
-> (T, SkolemizationMap)
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
/*! See `higher_ranked::skolemize_late_bound_regions` */
|
||||
|
||||
|
@ -733,7 +733,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
snapshot: &CombinedSnapshot,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
/*! See `higher_ranked::plug_leaks` */
|
||||
|
||||
|
@ -979,7 +979,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!("{}{}",
|
||||
|
@ -1033,7 +1033,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
lbrct: LateBoundRegionConversionTime,
|
||||
value: &ty::Binder<T>)
|
||||
-> (T, FnvHashMap<ty::BoundRegion,ty::Region>)
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
ty_fold::replace_late_bound_regions(
|
||||
self.tcx,
|
||||
|
@ -1099,9 +1099,9 @@ impl<'tcx> TypeTrace<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for TypeTrace<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("TypeTrace({})", self.origin.repr())
|
||||
impl<'tcx> fmt::Debug for TypeTrace<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "TypeTrace({:?})", self.origin)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1123,44 +1123,6 @@ impl TypeOrigin {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for TypeOrigin {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
MethodCompatCheck(a) => {
|
||||
format!("MethodCompatCheck({})", a.repr())
|
||||
}
|
||||
ExprAssignable(a) => {
|
||||
format!("ExprAssignable({})", a.repr())
|
||||
}
|
||||
Misc(a) => format!("Misc({})", a.repr()),
|
||||
RelateTraitRefs(a) => {
|
||||
format!("RelateTraitRefs({})", a.repr())
|
||||
}
|
||||
RelateSelfType(a) => {
|
||||
format!("RelateSelfType({})", a.repr())
|
||||
}
|
||||
RelateOutputImplTypes(a) => {
|
||||
format!("RelateOutputImplTypes({})", a.repr())
|
||||
}
|
||||
MatchExpressionArm(a, b) => {
|
||||
format!("MatchExpressionArm({}, {})", a.repr(), b.repr())
|
||||
}
|
||||
IfExpression(a) => {
|
||||
format!("IfExpression({})", a.repr())
|
||||
}
|
||||
IfExpressionWithNoElse(a) => {
|
||||
format!("IfExpressionWithNoElse({})", a.repr())
|
||||
}
|
||||
RangeExpression(a) => {
|
||||
format!("RangeExpression({})", a.repr())
|
||||
}
|
||||
EquatePredicate(a) => {
|
||||
format!("EquatePredicate({})", a.repr())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> SubregionOrigin<'tcx> {
|
||||
pub fn span(&self) -> Span {
|
||||
match *self {
|
||||
|
@ -1190,70 +1152,6 @@ impl<'tcx> SubregionOrigin<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for SubregionOrigin<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
Subtype(ref a) => {
|
||||
format!("Subtype({})", a.repr())
|
||||
}
|
||||
InfStackClosure(a) => {
|
||||
format!("InfStackClosure({})", a.repr())
|
||||
}
|
||||
InvokeClosure(a) => {
|
||||
format!("InvokeClosure({})", a.repr())
|
||||
}
|
||||
DerefPointer(a) => {
|
||||
format!("DerefPointer({})", a.repr())
|
||||
}
|
||||
FreeVariable(a, b) => {
|
||||
format!("FreeVariable({}, {})", a.repr(), b)
|
||||
}
|
||||
IndexSlice(a) => {
|
||||
format!("IndexSlice({})", a.repr())
|
||||
}
|
||||
RelateObjectBound(a) => {
|
||||
format!("RelateObjectBound({})", a.repr())
|
||||
}
|
||||
RelateParamBound(a, b) => {
|
||||
format!("RelateParamBound({},{})",
|
||||
a.repr(),
|
||||
b.repr())
|
||||
}
|
||||
RelateRegionParamBound(a) => {
|
||||
format!("RelateRegionParamBound({})",
|
||||
a.repr())
|
||||
}
|
||||
RelateDefaultParamBound(a, b) => {
|
||||
format!("RelateDefaultParamBound({},{})",
|
||||
a.repr(),
|
||||
b.repr())
|
||||
}
|
||||
Reborrow(a) => format!("Reborrow({})", a.repr()),
|
||||
ReborrowUpvar(a, b) => {
|
||||
format!("ReborrowUpvar({},{:?})", a.repr(), b)
|
||||
}
|
||||
ReferenceOutlivesReferent(_, a) => {
|
||||
format!("ReferenceOutlivesReferent({})", a.repr())
|
||||
}
|
||||
ExprTypeIsNotInScope(a, b) => {
|
||||
format!("ExprTypeIsNotInScope({}, {})",
|
||||
a.repr(),
|
||||
b.repr())
|
||||
}
|
||||
BindingTypeIsNotValidAtDecl(a) => {
|
||||
format!("BindingTypeIsNotValidAtDecl({})", a.repr())
|
||||
}
|
||||
CallRcvr(a) => format!("CallRcvr({})", a.repr()),
|
||||
CallArg(a) => format!("CallArg({})", a.repr()),
|
||||
CallReturn(a) => format!("CallReturn({})", a.repr()),
|
||||
Operand(a) => format!("Operand({})", a.repr()),
|
||||
AddrOf(a) => format!("AddrOf({})", a.repr()),
|
||||
AutoBorrow(a) => format!("AutoBorrow({})", a.repr()),
|
||||
SafeDestructor(a) => format!("SafeDestructor({})", a.repr()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RegionVariableOrigin {
|
||||
pub fn span(&self) -> Span {
|
||||
match *self {
|
||||
|
@ -1269,33 +1167,3 @@ impl RegionVariableOrigin {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for RegionVariableOrigin {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
MiscVariable(a) => {
|
||||
format!("MiscVariable({})", a.repr())
|
||||
}
|
||||
PatternRegion(a) => {
|
||||
format!("PatternRegion({})", a.repr())
|
||||
}
|
||||
AddrOfRegion(a) => {
|
||||
format!("AddrOfRegion({})", a.repr())
|
||||
}
|
||||
Autoref(a) => format!("Autoref({})", a.repr()),
|
||||
Coercion(a) => format!("Coercion({})", a.repr()),
|
||||
EarlyBoundRegion(a, b) => {
|
||||
format!("EarlyBoundRegion({},{})", a.repr(), b.repr())
|
||||
}
|
||||
LateBoundRegion(a, b, c) => {
|
||||
format!("LateBoundRegion({},{},{:?})", a.repr(), b.repr(), c)
|
||||
}
|
||||
BoundRegionInCoherence(a) => {
|
||||
format!("bound_regionInCoherence({})", a.repr())
|
||||
}
|
||||
UpvarRegion(a, b) => {
|
||||
format!("UpvarRegion({}, {})", a.repr(), b.repr())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,11 @@ 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 util::ppaux::Repr;
|
||||
|
||||
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 +69,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>),
|
||||
|
@ -959,7 +960,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 {
|
||||
|
@ -1589,31 +1590,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
|
||||
}
|
||||
|
||||
impl Repr for Constraint {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
ConstrainVarSubVar(a, b) => {
|
||||
format!("ConstrainVarSubVar({}, {})", a.repr(), b.repr())
|
||||
}
|
||||
ConstrainRegSubVar(a, b) => {
|
||||
format!("ConstrainRegSubVar({}, {})", a.repr(), b.repr())
|
||||
}
|
||||
ConstrainVarSubReg(a, b) => {
|
||||
format!("ConstrainVarSubReg({}, {})", a.repr(), b.repr())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for Verify<'tcx> {
|
||||
fn repr(&self) -> 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(), b.repr())
|
||||
write!(f, "VerifyRegSubReg({:?}, {:?})", a, b)
|
||||
}
|
||||
VerifyGenericBound(_, ref p, ref a, ref bs) => {
|
||||
format!("VerifyGenericBound({}, {}, {})",
|
||||
p.repr(), a.repr(), bs.repr())
|
||||
write!(f, "VerifyGenericBound({:?}, {:?}, {:?})", p, a, bs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1634,38 +1618,28 @@ fn lookup(values: &Vec<VarValue>, rid: ty::RegionVid) -> ty::Region {
|
|||
}
|
||||
}
|
||||
|
||||
impl Repr for VarValue {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
NoValue => format!("NoValue"),
|
||||
Value(r) => format!("Value({})", r.repr()),
|
||||
ErrorValue => format!("ErrorValue"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for RegionAndOrigin<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("RegionAndOrigin({},{})",
|
||||
impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "RegionAndOrigin({},{})",
|
||||
self.region.repr(),
|
||||
self.origin.repr())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for GenericKind<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
impl<'tcx> fmt::Debug for GenericKind<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
GenericKind::Param(ref p) => p.repr(),
|
||||
GenericKind::Projection(ref p) => p.repr(),
|
||||
GenericKind::Param(ref p) => write!(f, "{:?}", p),
|
||||
GenericKind::Projection(ref p) => write!(f, "{:?}", p),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UserString for GenericKind<'tcx> {
|
||||
fn user_string(&self) -> String {
|
||||
impl<'tcx> fmt::Display for GenericKind<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
GenericKind::Param(ref p) => p.user_string(),
|
||||
GenericKind::Projection(ref p) => p.user_string(),
|
||||
GenericKind::Param(ref p) => write!(f, "{}", p),
|
||||
GenericKind::Projection(ref p) => write!(f, "{}", p),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ 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;
|
||||
use syntax::ast;
|
||||
|
@ -277,13 +279,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for TransmuteRestriction<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("TransmuteRestriction(id={}, original=({},{}), substituted=({},{}))",
|
||||
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.repr(),
|
||||
self.original_to.repr(),
|
||||
self.substituted_from.repr(),
|
||||
self.substituted_to.repr())
|
||||
self.original_from,
|
||||
self.original_to,
|
||||
self.substituted_from,
|
||||
self.substituted_to)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,12 +84,12 @@ 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 +103,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 +127,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 +184,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
|
||||
|
@ -1569,33 +1569,36 @@ impl<'tcx> cmt_<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for cmt_<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("{{{} id:{} m:{:?} ty:{}}}",
|
||||
self.cat.repr(),
|
||||
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.repr())
|
||||
self.ty)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for categorization<'tcx> {
|
||||
fn repr(&self) -> 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(), ptr.repr(), derefs)
|
||||
write!(f, "{:?}-{:?}{}->", cmt.cat, ptr, derefs)
|
||||
}
|
||||
cat_interior(ref cmt, interior) => {
|
||||
format!("{}.{}", cmt.cat.repr(), interior.repr())
|
||||
write!(f, "{:?}.{:?}", cmt.cat, interior)
|
||||
}
|
||||
cat_downcast(ref cmt, _) => {
|
||||
format!("{}->(enum)", cmt.cat.repr())
|
||||
write!(f, "{:?}->(enum)", cmt.cat)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1614,39 +1617,33 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
impl Repr for PointerKind {
|
||||
fn repr(&self) -> 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())
|
||||
write!(f, "&{:?}", r)
|
||||
}
|
||||
BorrowedPtr(ty::MutBorrow, ref r) |
|
||||
Implicit(ty::MutBorrow, ref r) => {
|
||||
format!("&{} mut", r.repr())
|
||||
write!(f, "&{:?} mut", r)
|
||||
}
|
||||
BorrowedPtr(ty::UniqueImmBorrow, ref r) |
|
||||
Implicit(ty::UniqueImmBorrow, ref r) => {
|
||||
format!("&{} uniq", r.repr())
|
||||
}
|
||||
UnsafePtr(_) => {
|
||||
format!("*")
|
||||
write!(f, "&{:?} uniq", r)
|
||||
}
|
||||
UnsafePtr(_) => write!(f, "*")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for InteriorKind {
|
||||
fn repr(&self) -> 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, "[]"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1663,25 +1660,19 @@ fn element_kind(t: Ty) -> ElementKind {
|
|||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::ClosureKind {
|
||||
fn repr(&self) -> 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 Repr for Upvar {
|
||||
fn repr(&self) -> String {
|
||||
format!("Upvar({})", self.kind.repr())
|
||||
}
|
||||
}
|
||||
|
||||
impl UserString for Upvar {
|
||||
fn user_string(&self) -> 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,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 +38,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 +240,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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
span_err!(infcx.tcx.sess, obligation.cause.span, E0271,
|
||||
"type mismatch resolving `{}`: {}",
|
||||
predicate.user_string(),
|
||||
ty::type_err_to_str(infcx.tcx, &error.err));
|
||||
error.err);
|
||||
note_obligation_cause(infcx, obligation);
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
span_err!(infcx.tcx.sess, obligation.cause.span, E0278,
|
||||
"the requirement `{}` is not satisfied (`{}`)",
|
||||
predicate.user_string(),
|
||||
ty::type_err_to_str(infcx.tcx, &err));
|
||||
err);
|
||||
}
|
||||
|
||||
ty::Predicate::RegionOutlives(ref predicate) => {
|
||||
|
@ -227,7 +227,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
span_err!(infcx.tcx.sess, obligation.cause.span, E0279,
|
||||
"the requirement `{}` is not satisfied (`{}`)",
|
||||
predicate.user_string(),
|
||||
ty::type_err_to_str(infcx.tcx, &err));
|
||||
err);
|
||||
}
|
||||
|
||||
ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => {
|
||||
|
@ -252,7 +252,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
expected_trait_ref.self_ty().user_string(),
|
||||
expected_trait_ref.user_string(),
|
||||
actual_trait_ref.user_string(),
|
||||
ty::type_err_to_str(infcx.tcx, e));
|
||||
e);
|
||||
note_obligation_cause(infcx, obligation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
|
||||
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;
|
||||
|
@ -461,11 +462,11 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for RegionObligation<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("RegionObligation(sub_region={}, sup_type={})",
|
||||
self.sub_region.repr(),
|
||||
self.sup_type.repr())
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,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 +277,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>
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ 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
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
debug!("normalize_param_env(value={})", value.repr());
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ use std::rc::Rc;
|
|||
use syntax::ast;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ObjectSafetyViolation<'tcx> {
|
||||
/// Self : Sized declared on the trait
|
||||
SizedSelf,
|
||||
|
@ -352,19 +353,6 @@ fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
error
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ObjectSafetyViolation<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
ObjectSafetyViolation::SizedSelf =>
|
||||
format!("SizedSelf"),
|
||||
ObjectSafetyViolation::SupertraitSelf =>
|
||||
format!("SupertraitSelf"),
|
||||
ObjectSafetyViolation::Method(ref m, code) =>
|
||||
format!("Method({},{:?})", m.repr(), code),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_self<'tcx>(ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyParam(ref data) => data.space == subst::SelfSpace,
|
||||
|
|
|
@ -30,6 +30,8 @@ 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 +42,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 +56,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>>),
|
||||
|
@ -193,7 +196,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
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
normalize_with_depth(selcx, cause, 0, value)
|
||||
}
|
||||
|
@ -204,7 +207,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
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth);
|
||||
let result = normalizer.fold(value);
|
||||
|
@ -236,7 +239,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() {
|
||||
|
@ -864,7 +867,7 @@ fn confirm_param_env_candidate<'cx,'tcx>(
|
|||
&format!("Failed to unify `{}` and `{}` in projection: {}",
|
||||
obligation.repr(),
|
||||
projection.repr(),
|
||||
ty::type_err_to_str(selcx.tcx(), &e)));
|
||||
e));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -915,32 +918,6 @@ fn confirm_impl_candidate<'cx,'tcx>(
|
|||
trait_ref.repr()));
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ProjectionTyError<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
ProjectionTyError::TooManyCandidates =>
|
||||
format!("NoCandidate"),
|
||||
ProjectionTyError::TraitSelectionError(ref e) =>
|
||||
format!("TraitSelectionError({})", e.repr()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ProjectionTyCandidate<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
ProjectionTyCandidate::ParamEnv(ref data) =>
|
||||
format!("ParamEnv({})", data.repr()),
|
||||
ProjectionTyCandidate::Impl(ref data) =>
|
||||
format!("Impl({})", data.repr()),
|
||||
ProjectionTyCandidate::Closure(ref data) =>
|
||||
format!("Closure({})", data.repr()),
|
||||
ProjectionTyCandidate::FnPointer(a) =>
|
||||
format!("FnPointer(({}))", a.repr()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> {
|
||||
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Normalized<'tcx, T> {
|
||||
Normalized {
|
||||
|
@ -950,10 +927,10 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T:Repr> Repr for Normalized<'tcx, T> {
|
||||
fn repr(&self) -> String {
|
||||
format!("Normalized({},{})",
|
||||
self.value.repr(),
|
||||
self.obligations.repr())
|
||||
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,7 +44,9 @@ 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;
|
||||
|
@ -2666,14 +2668,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
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(());
|
||||
}
|
||||
|
||||
|
@ -2962,28 +2962,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for SelectionCandidate<'tcx> {
|
||||
fn repr(&self) -> 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()),
|
||||
ImplCandidate(a) => format!("ImplCandidate({})", a.repr()),
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> SelectionCache<'tcx> {
|
||||
pub fn new() -> SelectionCache<'tcx> {
|
||||
SelectionCache {
|
||||
|
@ -3031,10 +3009,9 @@ impl<'o,'tcx> Iterator for TraitObligationStackList<'o,'tcx>{
|
|||
}
|
||||
}
|
||||
|
||||
impl<'o,'tcx> Repr for TraitObligationStack<'o,'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("TraitObligationStack({})",
|
||||
self.obligation.repr())
|
||||
impl<'o,'tcx> fmt::Debug for TraitObligationStack<'o,'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "TraitObligationStack({:?})", self.obligation)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -302,24 +302,12 @@ 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>(cause: ObligationCause<'tcx>,
|
||||
recursion_depth: usize,
|
||||
|
@ -485,118 +473,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> Repr for super::Obligation<'tcx, O> {
|
||||
fn repr(&self) -> String {
|
||||
format!("Obligation(predicate={},depth={})",
|
||||
self.predicate.repr(),
|
||||
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> Repr for super::Vtable<'tcx, N> {
|
||||
fn repr(&self) -> 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(),
|
||||
write!(f, "{:?}", v),
|
||||
|
||||
super::VtableDefaultImpl(ref t) =>
|
||||
t.repr(),
|
||||
write!(f, "{:?}", t),
|
||||
|
||||
super::VtableClosure(ref d) =>
|
||||
d.repr(),
|
||||
write!(f, "{:?}", d),
|
||||
|
||||
super::VtableFnPointer(ref d) =>
|
||||
format!("VtableFnPointer({})",
|
||||
d.repr()),
|
||||
write!(f, "VtableFnPointer({:?})", d),
|
||||
|
||||
super::VtableObject(ref d) =>
|
||||
format!("VtableObject({})",
|
||||
d.repr()),
|
||||
write!(f, "VtableObject({:?})", d),
|
||||
|
||||
super::VtableParam(ref n) =>
|
||||
format!("VtableParam({})",
|
||||
n.repr()),
|
||||
write!(f, "VtableParam({:?})", n),
|
||||
|
||||
super::VtableBuiltin(ref d) =>
|
||||
d.repr()
|
||||
write!(f, "{:?}", d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N:Repr> Repr for super::VtableImplData<'tcx, N> {
|
||||
fn repr(&self) -> String {
|
||||
format!("VtableImpl(impl_def_id={}, substs={}, nested={})",
|
||||
self.impl_def_id.repr(),
|
||||
self.substs.repr(),
|
||||
self.nested.repr())
|
||||
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> Repr for super::VtableClosureData<'tcx, N> {
|
||||
fn repr(&self) -> String {
|
||||
format!("VtableClosure(closure_def_id={}, substs={}, nested={})",
|
||||
self.closure_def_id.repr(),
|
||||
self.substs.repr(),
|
||||
self.nested.repr())
|
||||
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> Repr for super::VtableBuiltinData<N> {
|
||||
fn repr(&self) -> String {
|
||||
format!("VtableBuiltin(nested={})",
|
||||
self.nested.repr())
|
||||
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> Repr for super::VtableDefaultImplData<N> {
|
||||
fn repr(&self) -> String {
|
||||
format!("VtableDefaultImplData(trait_def_id={}, nested={})",
|
||||
self.trait_def_id.repr(),
|
||||
self.nested.repr())
|
||||
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 for super::VtableObjectData<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("VtableObject(object_ty={})",
|
||||
self.object_ty.repr())
|
||||
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 for super::SelectionError<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
super::Unimplemented =>
|
||||
format!("Unimplemented"),
|
||||
|
||||
super::OutputTypeParameterMismatch(ref a, ref b, ref c) =>
|
||||
format!("OutputTypeParameterMismatch({},{},{})",
|
||||
a.repr(),
|
||||
b.repr(),
|
||||
c.repr()),
|
||||
|
||||
super::TraitNotObjectSafe(ref tr) =>
|
||||
format!("TraitNotObjectSafe({})",
|
||||
tr.repr())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for super::FulfillmentError<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("FulfillmentError({},{})",
|
||||
self.obligation.repr(),
|
||||
self.code.repr())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for super::FulfillmentErrorCode<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
super::CodeSelectionError(ref o) => o.repr(),
|
||||
super::CodeProjectionError(ref o) => o.repr(),
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,14 +564,8 @@ impl<'tcx> fmt::Debug for super::FulfillmentErrorCode<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for super::MismatchedProjectionTypes<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
self.err.repr()
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
pub use self::terr_vstore_kind::*;
|
||||
pub use self::type_err::*;
|
||||
pub use self::BuiltinBound::*;
|
||||
pub use self::InferTy::*;
|
||||
pub use self::InferRegion::*;
|
||||
pub use self::ImplOrTraitItemId::*;
|
||||
|
@ -35,6 +34,11 @@ pub use self::IntVarValue::*;
|
|||
pub use self::MethodOrigin::*;
|
||||
pub use self::CopyImplementationError::*;
|
||||
|
||||
pub use self::BuiltinBound::Send as BoundSend;
|
||||
pub use self::BuiltinBound::Sized as BoundSized;
|
||||
pub use self::BuiltinBound::Copy as BoundCopy;
|
||||
pub use self::BuiltinBound::Sync as BoundSync;
|
||||
|
||||
use ast_map::{self, LinkedPath};
|
||||
use back::svh::Svh;
|
||||
use session::Session;
|
||||
|
@ -78,7 +82,7 @@ use std::mem;
|
|||
use std::ops;
|
||||
use std::rc::Rc;
|
||||
use std::vec::IntoIter;
|
||||
use collections::enum_set::{EnumSet, CLike};
|
||||
use collections::enum_set::{self, EnumSet, CLike};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use syntax::abi;
|
||||
use syntax::ast::{CrateNum, DefId, ItemImpl, ItemTrait, LOCAL_CRATE};
|
||||
|
@ -130,7 +134,7 @@ impl ImplOrTraitItemContainer {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub enum ImplOrTraitItem<'tcx> {
|
||||
ConstTraitItem(Rc<AssociatedConst<'tcx>>),
|
||||
MethodTraitItem(Rc<Method<'tcx>>),
|
||||
|
@ -293,7 +297,7 @@ pub struct ItemVariances {
|
|||
pub regions: VecPerParamSpace<Variance>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable, Debug, Copy)]
|
||||
#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable, Copy)]
|
||||
pub enum Variance {
|
||||
Covariant, // T<A> <: T<B> iff A <: B -- e.g., function return type
|
||||
Invariant, // T<A> <: T<B> iff B == A -- e.g., type of mutable cell
|
||||
|
@ -301,7 +305,7 @@ pub enum Variance {
|
|||
Bivariant, // T<A> <: T<B> -- e.g., unused type parameter
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum AutoAdjustment<'tcx> {
|
||||
AdjustReifyFnPointer, // go from a fn-item type to a fn-pointer type
|
||||
AdjustUnsafeFnPointer, // go from a safe fn pointer to an unsafe fn pointer
|
||||
|
@ -370,7 +374,7 @@ pub enum AutoAdjustment<'tcx> {
|
|||
/// unsize: Some(Box<[i32]>),
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct AutoDerefRef<'tcx> {
|
||||
/// Step 1. Apply a number of dereferences, producing an lvalue.
|
||||
pub autoderefs: usize,
|
||||
|
@ -400,7 +404,7 @@ pub enum CustomCoerceUnsized {
|
|||
Struct(usize)
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub enum MethodOrigin<'tcx> {
|
||||
// fully statically resolved method
|
||||
MethodStatic(ast::DefId),
|
||||
|
@ -418,7 +422,7 @@ pub enum MethodOrigin<'tcx> {
|
|||
|
||||
// details for a method invoked with a receiver whose type is a type parameter
|
||||
// with a bounded trait.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub struct MethodParam<'tcx> {
|
||||
// the precise trait reference that occurs as a bound -- this may
|
||||
// be a supertrait of what the user actually typed. Note that it
|
||||
|
@ -439,7 +443,7 @@ pub struct MethodParam<'tcx> {
|
|||
}
|
||||
|
||||
// details for a method invoked with a receiver whose type is an object
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub struct MethodObject<'tcx> {
|
||||
// the (super)trait containing the method to be invoked
|
||||
pub trait_ref: TraitRef<'tcx>,
|
||||
|
@ -803,7 +807,7 @@ impl<'tcx> ctxt<'tcx> {
|
|||
self.free_region_maps.borrow()[&id].clone()
|
||||
}
|
||||
|
||||
pub fn lift<T: Lift<'tcx>>(&self, value: &T) -> Option<T::Lifted> {
|
||||
pub fn lift<T: ?Sized + Lift<'tcx>>(&self, value: &T) -> Option<T::Lifted> {
|
||||
value.lift_to_tcx(self)
|
||||
}
|
||||
}
|
||||
|
@ -825,7 +829,7 @@ impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Vec<T> {
|
||||
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for [T] {
|
||||
type Lifted = Vec<T::Lifted>;
|
||||
fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option<Self::Lifted> {
|
||||
let mut result = Vec::with_capacity(self.len());
|
||||
|
@ -1115,7 +1119,6 @@ impl<'tcx> ctxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TyS<'tcx> {
|
||||
pub sty: TypeVariants<'tcx>,
|
||||
pub flags: Cell<TypeFlags>,
|
||||
|
@ -1238,7 +1241,7 @@ pub struct BareFnTy<'tcx> {
|
|||
pub sig: PolyFnSig<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ClosureTy<'tcx> {
|
||||
pub unsafety: ast::Unsafety,
|
||||
pub abi: abi::Abi,
|
||||
|
@ -1309,7 +1312,7 @@ impl<'tcx> PolyFnSig<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct ParamTy {
|
||||
pub space: subst::ParamSpace,
|
||||
pub idx: u32,
|
||||
|
@ -1363,7 +1366,7 @@ pub struct DebruijnIndex {
|
|||
}
|
||||
|
||||
/// Representation of regions:
|
||||
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug, Copy)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Copy)]
|
||||
pub enum Region {
|
||||
// Region bound in a type or fn declaration which will be
|
||||
// substituted 'early' -- that is, at the same time when type
|
||||
|
@ -1411,7 +1414,7 @@ pub struct EarlyBoundRegion {
|
|||
/// Upvars do not get their own node-id. Instead, we use the pair of
|
||||
/// the original var id (that is, the root variable that is referenced
|
||||
/// by the upvar) and the id of the closure expression.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct UpvarId {
|
||||
pub var_id: ast::NodeId,
|
||||
pub closure_expr_id: ast::NodeId,
|
||||
|
@ -1476,7 +1479,7 @@ pub enum UpvarCapture {
|
|||
ByRef(UpvarBorrow),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
|
||||
#[derive(PartialEq, Clone, RustcEncodable, RustcDecodable, Copy)]
|
||||
pub struct UpvarBorrow {
|
||||
/// The kind of borrow: by-ref upvars have access to shared
|
||||
/// immutable borrows, which are not part of the normal language
|
||||
|
@ -1516,7 +1519,7 @@ impl Region {
|
|||
}
|
||||
|
||||
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
|
||||
RustcEncodable, RustcDecodable, Debug, Copy)]
|
||||
RustcEncodable, RustcDecodable, Copy)]
|
||||
/// A "free" region `fr` can be interpreted as "some region
|
||||
/// at least as big as the scope `fr.scope`".
|
||||
pub struct FreeRegion {
|
||||
|
@ -1525,7 +1528,7 @@ pub struct FreeRegion {
|
|||
}
|
||||
|
||||
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
|
||||
RustcEncodable, RustcDecodable, Debug, Copy)]
|
||||
RustcEncodable, RustcDecodable, Copy, Debug)]
|
||||
pub enum BoundRegion {
|
||||
/// An anonymous region parameter for a given fn (&T)
|
||||
BrAnon(u32),
|
||||
|
@ -1636,7 +1639,7 @@ pub enum TypeVariants<'tcx> {
|
|||
TyError,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TraitTy<'tcx> {
|
||||
pub principal: ty::PolyTraitRef<'tcx>,
|
||||
pub bounds: ExistentialBounds<'tcx>,
|
||||
|
@ -1707,7 +1710,7 @@ impl<'tcx> TraitTy<'tcx> {
|
|||
/// Note that a `TraitRef` introduces a level of region binding, to
|
||||
/// account for higher-ranked trait bounds like `T : for<'a> Foo<&'a
|
||||
/// U>` or higher-ranked object types.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TraitRef<'tcx> {
|
||||
pub def_id: DefId,
|
||||
pub substs: &'tcx Substs<'tcx>,
|
||||
|
@ -1842,7 +1845,7 @@ pub enum type_err<'tcx> {
|
|||
|
||||
/// Bounds suitable for a named type parameter like `A` in `fn foo<A>`
|
||||
/// as well as the existential type parameter in an object type.
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
|
||||
#[derive(PartialEq, Eq, Hash, Clone)]
|
||||
pub struct ParamBounds<'tcx> {
|
||||
pub region_bounds: Vec<ty::Region>,
|
||||
pub builtin_bounds: BuiltinBounds,
|
||||
|
@ -1855,41 +1858,57 @@ pub struct ParamBounds<'tcx> {
|
|||
/// major difference between this case and `ParamBounds` is that
|
||||
/// general purpose trait bounds are omitted and there must be
|
||||
/// *exactly one* region.
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
|
||||
#[derive(PartialEq, Eq, Hash, Clone)]
|
||||
pub struct ExistentialBounds<'tcx> {
|
||||
pub region_bound: ty::Region,
|
||||
pub builtin_bounds: BuiltinBounds,
|
||||
pub projection_bounds: Vec<PolyProjectionPredicate<'tcx>>,
|
||||
}
|
||||
|
||||
pub type BuiltinBounds = EnumSet<BuiltinBound>;
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
pub struct BuiltinBounds(EnumSet<BuiltinBound>);
|
||||
|
||||
impl BuiltinBounds {
|
||||
pub fn empty() -> BuiltinBounds {
|
||||
BuiltinBounds(EnumSet::new())
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> enum_set::Iter<BuiltinBound> {
|
||||
self.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Deref for BuiltinBounds {
|
||||
type Target = EnumSet<BuiltinBound>;
|
||||
fn deref(&self) -> &Self::Target { &self.0 }
|
||||
}
|
||||
|
||||
impl ops::DerefMut for BuiltinBounds {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a BuiltinBounds {
|
||||
type Item = BuiltinBound;
|
||||
type IntoIter = enum_set::Iter<BuiltinBound>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
(**self).into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, PartialEq, Eq, RustcDecodable, Hash,
|
||||
Debug, Copy)]
|
||||
#[repr(usize)]
|
||||
pub enum BuiltinBound {
|
||||
BoundSend,
|
||||
BoundSized,
|
||||
BoundCopy,
|
||||
BoundSync,
|
||||
}
|
||||
|
||||
pub fn empty_builtin_bounds() -> BuiltinBounds {
|
||||
EnumSet::new()
|
||||
}
|
||||
|
||||
pub fn all_builtin_bounds() -> BuiltinBounds {
|
||||
let mut set = EnumSet::new();
|
||||
set.insert(BoundSend);
|
||||
set.insert(BoundSized);
|
||||
set.insert(BoundSync);
|
||||
set
|
||||
Send,
|
||||
Sized,
|
||||
Copy,
|
||||
Sync,
|
||||
}
|
||||
|
||||
/// An existential bound that does not implement any traits.
|
||||
pub fn region_existential_bound<'tcx>(r: ty::Region) -> ExistentialBounds<'tcx> {
|
||||
ty::ExistentialBounds { region_bound: r,
|
||||
builtin_bounds: empty_builtin_bounds(),
|
||||
builtin_bounds: BuiltinBounds::empty(),
|
||||
projection_bounds: Vec::new() }
|
||||
}
|
||||
|
||||
|
@ -2024,7 +2043,7 @@ impl fmt::Debug for IntVarValue {
|
|||
/// from `T:'a` annotations appearing in the type definition. If
|
||||
/// this is `None`, then the default is inherited from the
|
||||
/// surrounding context. See RFC #599 for details.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum ObjectLifetimeDefault {
|
||||
/// Require an explicit annotation. Occurs when multiple
|
||||
/// `T:'a` constraints are found.
|
||||
|
@ -2034,7 +2053,7 @@ pub enum ObjectLifetimeDefault {
|
|||
Specific(Region),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub struct TypeParameterDef<'tcx> {
|
||||
pub name: ast::Name,
|
||||
pub def_id: ast::DefId,
|
||||
|
@ -2097,7 +2116,7 @@ impl<'tcx> Generics<'tcx> {
|
|||
}
|
||||
|
||||
/// Bounds on generics.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub struct GenericPredicates<'tcx> {
|
||||
pub predicates: VecPerParamSpace<Predicate<'tcx>>,
|
||||
}
|
||||
|
@ -2127,7 +2146,7 @@ impl<'tcx> GenericPredicates<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Predicate<'tcx> {
|
||||
/// Corresponds to `where Foo : Bar<A,B,C>`. `Foo` here would be
|
||||
/// the `Self` type of the trait reference and `A`, `B`, and `C`
|
||||
|
@ -2258,7 +2277,7 @@ impl<'tcx> Predicate<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TraitPredicate<'tcx> {
|
||||
pub trait_ref: TraitRef<'tcx>
|
||||
}
|
||||
|
@ -2306,7 +2325,7 @@ pub type PolyTypeOutlivesPredicate<'tcx> = PolyOutlivesPredicate<Ty<'tcx>, ty::R
|
|||
/// equality between arbitrary types. Processing an instance of Form
|
||||
/// #2 eventually yields one of these `ProjectionPredicate`
|
||||
/// instances to normalize the LHS.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ProjectionPredicate<'tcx> {
|
||||
pub projection_ty: ProjectionTy<'tcx>,
|
||||
pub ty: Ty<'tcx>,
|
||||
|
@ -2495,7 +2514,7 @@ impl<'tcx> Predicate<'tcx> {
|
|||
/// `[[], [U:Bar<T>]]`. Now if there were some particular reference
|
||||
/// like `Foo<isize,usize>`, then the `InstantiatedPredicates` would be `[[],
|
||||
/// [usize:Bar<isize>]]`.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub struct InstantiatedPredicates<'tcx> {
|
||||
pub predicates: VecPerParamSpace<Predicate<'tcx>>,
|
||||
}
|
||||
|
@ -3679,7 +3698,7 @@ impl<'tcx> ItemSubsts<'tcx> {
|
|||
impl<'tcx> ParamBounds<'tcx> {
|
||||
pub fn empty() -> ParamBounds<'tcx> {
|
||||
ParamBounds {
|
||||
builtin_bounds: empty_builtin_bounds(),
|
||||
builtin_bounds: BuiltinBounds::empty(),
|
||||
trait_bounds: Vec::new(),
|
||||
region_bounds: Vec::new(),
|
||||
projection_bounds: Vec::new(),
|
||||
|
@ -5316,139 +5335,133 @@ pub fn ty_sort_string(cx: &ctxt, ty: Ty) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ty::type_err<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
tls::with(|tcx| ty::type_err_to_str(tcx, self))
|
||||
}
|
||||
}
|
||||
|
||||
/// Explains the source of a type err in a short, human readable way. This is meant to be placed
|
||||
/// in parentheses after some larger message. You should also invoke `note_and_explain_type_err()`
|
||||
/// afterwards to present additional details, particularly when it comes to lifetime-related
|
||||
/// errors.
|
||||
pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
|
||||
match *err {
|
||||
terr_cyclic_ty => "cyclic type of infinite size".to_string(),
|
||||
terr_mismatch => "types differ".to_string(),
|
||||
impl<'tcx> fmt::Display for type_err<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
terr_cyclic_ty => write!(f, "cyclic type of infinite size"),
|
||||
terr_mismatch => write!(f, "types differ"),
|
||||
terr_unsafety_mismatch(values) => {
|
||||
format!("expected {} fn, found {} fn",
|
||||
write!(f, "expected {} fn, found {} fn",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_abi_mismatch(values) => {
|
||||
format!("expected {} fn, found {} fn",
|
||||
write!(f, "expected {} fn, found {} fn",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_mutability => "values differ in mutability".to_string(),
|
||||
terr_mutability => write!(f, "values differ in mutability"),
|
||||
terr_box_mutability => {
|
||||
"boxed values differ in mutability".to_string()
|
||||
write!(f, "boxed values differ in mutability")
|
||||
}
|
||||
terr_vec_mutability => "vectors differ in mutability".to_string(),
|
||||
terr_ptr_mutability => "pointers differ in mutability".to_string(),
|
||||
terr_ref_mutability => "references differ in mutability".to_string(),
|
||||
terr_vec_mutability => write!(f, "vectors differ in mutability"),
|
||||
terr_ptr_mutability => write!(f, "pointers differ in mutability"),
|
||||
terr_ref_mutability => write!(f, "references differ in mutability"),
|
||||
terr_ty_param_size(values) => {
|
||||
format!("expected a type with {} type params, \
|
||||
write!(f, "expected a type with {} type params, \
|
||||
found one with {} type params",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_fixed_array_size(values) => {
|
||||
format!("expected an array with a fixed size of {} elements, \
|
||||
write!(f, "expected an array with a fixed size of {} elements, \
|
||||
found one with {} elements",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_tuple_size(values) => {
|
||||
format!("expected a tuple with {} elements, \
|
||||
write!(f, "expected a tuple with {} elements, \
|
||||
found one with {} elements",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_arg_count => {
|
||||
"incorrect number of function parameters".to_string()
|
||||
write!(f, "incorrect number of function parameters")
|
||||
}
|
||||
terr_regions_does_not_outlive(..) => {
|
||||
"lifetime mismatch".to_string()
|
||||
write!(f, "lifetime mismatch")
|
||||
}
|
||||
terr_regions_not_same(..) => {
|
||||
"lifetimes are not the same".to_string()
|
||||
write!(f, "lifetimes are not the same")
|
||||
}
|
||||
terr_regions_no_overlap(..) => {
|
||||
"lifetimes do not intersect".to_string()
|
||||
write!(f, "lifetimes do not intersect")
|
||||
}
|
||||
terr_regions_insufficiently_polymorphic(br, _) => {
|
||||
format!("expected bound lifetime parameter {}, \
|
||||
found concrete lifetime",
|
||||
br.user_string())
|
||||
write!(f, "expected bound lifetime parameter {}, \
|
||||
found concrete lifetime", br)
|
||||
}
|
||||
terr_regions_overly_polymorphic(br, _) => {
|
||||
format!("expected concrete lifetime, \
|
||||
found bound lifetime parameter {}",
|
||||
br.user_string())
|
||||
write!(f, "expected concrete lifetime, \
|
||||
found bound lifetime parameter {}", br)
|
||||
}
|
||||
terr_sorts(values) => {
|
||||
terr_sorts(values) => tls::with(|tcx| {
|
||||
// A naive approach to making sure that we're not reporting silly errors such as:
|
||||
// (expected closure, found closure).
|
||||
let expected_str = ty_sort_string(cx, values.expected);
|
||||
let found_str = ty_sort_string(cx, values.found);
|
||||
let expected_str = ty_sort_string(tcx, values.expected);
|
||||
let found_str = ty_sort_string(tcx, values.found);
|
||||
if expected_str == found_str {
|
||||
format!("expected {}, found a different {}", expected_str, found_str)
|
||||
write!(f, "expected {}, found a different {}", expected_str, found_str)
|
||||
} else {
|
||||
format!("expected {}, found {}", expected_str, found_str)
|
||||
}
|
||||
}
|
||||
terr_traits(values) => {
|
||||
format!("expected trait `{}`, found trait `{}`",
|
||||
item_path_str(cx, values.expected),
|
||||
item_path_str(cx, values.found))
|
||||
write!(f, "expected {}, found {}", expected_str, found_str)
|
||||
}
|
||||
}),
|
||||
terr_traits(values) => tls::with(|tcx| {
|
||||
write!(f, "expected trait `{}`, found trait `{}`",
|
||||
item_path_str(tcx, values.expected),
|
||||
item_path_str(tcx, values.found))
|
||||
}),
|
||||
terr_builtin_bounds(values) => {
|
||||
if values.expected.is_empty() {
|
||||
format!("expected no bounds, found `{}`",
|
||||
values.found.user_string())
|
||||
write!(f, "expected no bounds, found `{}`",
|
||||
values.found)
|
||||
} else if values.found.is_empty() {
|
||||
format!("expected bounds `{}`, found no bounds",
|
||||
values.expected.user_string())
|
||||
write!(f, "expected bounds `{}`, found no bounds",
|
||||
values.expected)
|
||||
} else {
|
||||
format!("expected bounds `{}`, found bounds `{}`",
|
||||
values.expected.user_string(),
|
||||
values.found.user_string())
|
||||
write!(f, "expected bounds `{}`, found bounds `{}`",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
}
|
||||
terr_integer_as_char => {
|
||||
"expected an integral type, found `char`".to_string()
|
||||
write!(f, "expected an integral type, found `char`")
|
||||
}
|
||||
terr_int_mismatch(ref values) => {
|
||||
format!("expected `{:?}`, found `{:?}`",
|
||||
write!(f, "expected `{:?}`, found `{:?}`",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_float_mismatch(ref values) => {
|
||||
format!("expected `{:?}`, found `{:?}`",
|
||||
write!(f, "expected `{:?}`, found `{:?}`",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_variadic_mismatch(ref values) => {
|
||||
format!("expected {} fn, found {} function",
|
||||
write!(f, "expected {} fn, found {} function",
|
||||
if values.expected { "variadic" } else { "non-variadic" },
|
||||
if values.found { "variadic" } else { "non-variadic" })
|
||||
}
|
||||
terr_convergence_mismatch(ref values) => {
|
||||
format!("expected {} fn, found {} function",
|
||||
write!(f, "expected {} fn, found {} function",
|
||||
if values.expected { "converging" } else { "diverging" },
|
||||
if values.found { "converging" } else { "diverging" })
|
||||
}
|
||||
terr_projection_name_mismatched(ref values) => {
|
||||
format!("expected {}, found {}",
|
||||
token::get_name(values.expected),
|
||||
token::get_name(values.found))
|
||||
}
|
||||
terr_projection_bounds_length(ref values) => {
|
||||
format!("expected {} associated type bindings, found {}",
|
||||
write!(f, "expected {}, found {}",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_projection_bounds_length(ref values) => {
|
||||
write!(f, "expected {} associated type bindings, found {}",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6914,14 +6927,14 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
|
|||
}
|
||||
}
|
||||
|
||||
impl Variance {
|
||||
pub fn to_string(self) -> &'static str {
|
||||
match self {
|
||||
impl fmt::Debug for Variance {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str(match *self {
|
||||
Covariant => "+",
|
||||
Contravariant => "-",
|
||||
Invariant => "o",
|
||||
Bivariant => "*",
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7265,7 +7278,7 @@ pub fn liberate_late_bound_regions<'tcx, T>(
|
|||
all_outlive_scope: region::DestructionScopeData,
|
||||
value: &Binder<T>)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
ty_fold::replace_late_bound_regions(
|
||||
tcx, value,
|
||||
|
@ -7276,7 +7289,7 @@ pub fn count_late_bound_regions<'tcx, T>(
|
|||
tcx: &ty::ctxt<'tcx>,
|
||||
value: &Binder<T>)
|
||||
-> usize
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
let (_, skol_map) = ty_fold::replace_late_bound_regions(tcx, value, |_| ty::ReStatic);
|
||||
skol_map.len()
|
||||
|
@ -7286,7 +7299,7 @@ pub fn binds_late_bound_regions<'tcx, T>(
|
|||
tcx: &ty::ctxt<'tcx>,
|
||||
value: &Binder<T>)
|
||||
-> bool
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
count_late_bound_regions(tcx, value) > 0
|
||||
}
|
||||
|
@ -7297,7 +7310,7 @@ pub fn flatten_late_bound_regions<'tcx, T>(
|
|||
tcx: &ty::ctxt<'tcx>,
|
||||
bound2_value: &Binder<Binder<T>>)
|
||||
-> Binder<T>
|
||||
where T: TypeFoldable<'tcx> + Repr
|
||||
where T: TypeFoldable<'tcx>
|
||||
{
|
||||
let bound0_value = bound2_value.skip_binder().skip_binder();
|
||||
let value = ty_fold::fold_regions(tcx, bound0_value, |region, current_depth| {
|
||||
|
@ -7319,7 +7332,7 @@ pub fn no_late_bound_regions<'tcx, T>(
|
|||
tcx: &ty::ctxt<'tcx>,
|
||||
value: &Binder<T>)
|
||||
-> Option<T>
|
||||
where T : TypeFoldable<'tcx> + Repr + Clone
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
if binds_late_bound_regions(tcx, value) {
|
||||
None
|
||||
|
@ -7334,7 +7347,7 @@ pub fn erase_late_bound_regions<'tcx, T>(
|
|||
tcx: &ty::ctxt<'tcx>,
|
||||
value: &Binder<T>)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
ty_fold::replace_late_bound_regions(tcx, value, |_| ty::ReStatic).0
|
||||
}
|
||||
|
@ -7351,7 +7364,7 @@ pub fn anonymize_late_bound_regions<'tcx, T>(
|
|||
tcx: &ctxt<'tcx>,
|
||||
sig: &Binder<T>)
|
||||
-> Binder<T>
|
||||
where T : TypeFoldable<'tcx> + Repr,
|
||||
where T : TypeFoldable<'tcx>,
|
||||
{
|
||||
let mut counter = 0;
|
||||
ty::Binder(ty_fold::replace_late_bound_regions(tcx, sig, |_| {
|
||||
|
@ -7371,58 +7384,45 @@ impl DebruijnIndex {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for AutoAdjustment<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
impl<'tcx> fmt::Debug for AutoAdjustment<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
AdjustReifyFnPointer => {
|
||||
format!("AdjustReifyFnPointer")
|
||||
write!(f, "AdjustReifyFnPointer")
|
||||
}
|
||||
AdjustUnsafeFnPointer => {
|
||||
format!("AdjustUnsafeFnPointer")
|
||||
write!(f, "AdjustUnsafeFnPointer")
|
||||
}
|
||||
AdjustDerefRef(ref data) => {
|
||||
data.repr()
|
||||
write!(f, "{:?}", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for AutoDerefRef<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("AutoDerefRef({}, unsize={}, {})",
|
||||
self.autoderefs, self.unsize.repr(), self.autoref.repr())
|
||||
impl<'tcx> fmt::Debug for AutoDerefRef<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "AutoDerefRef({}, unsize={:?}, {:?})",
|
||||
self.autoderefs, self.unsize, self.autoref)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for AutoRef<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
impl<'tcx> fmt::Debug for TraitTy<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "TraitTy({:?},{:?})",
|
||||
self.principal,
|
||||
self.bounds)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for ty::Predicate<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
AutoPtr(a, b) => {
|
||||
format!("AutoPtr({},{:?})", a.repr(), b)
|
||||
}
|
||||
AutoUnsafe(ref a) => {
|
||||
format!("AutoUnsafe({:?})", a)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for TraitTy<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("TraitTy({},{})",
|
||||
self.principal.repr(),
|
||||
self.bounds.repr())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ty::Predicate<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
Predicate::Trait(ref a) => a.repr(),
|
||||
Predicate::Equate(ref pair) => pair.repr(),
|
||||
Predicate::RegionOutlives(ref pair) => pair.repr(),
|
||||
Predicate::TypeOutlives(ref pair) => pair.repr(),
|
||||
Predicate::Projection(ref pair) => pair.repr(),
|
||||
Predicate::Trait(ref a) => write!(f, "{:?}", a),
|
||||
Predicate::Equate(ref pair) => write!(f, "{:?}", pair),
|
||||
Predicate::RegionOutlives(ref pair) => write!(f, "{:?}", pair),
|
||||
Predicate::TypeOutlives(ref pair) => write!(f, "{:?}", pair),
|
||||
Predicate::Projection(ref pair) => write!(f, "{:?}", pair),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7628,14 +7628,6 @@ impl<'tcx> RegionEscape for ProjectionTy<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ty::ProjectionPredicate<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("ProjectionPredicate({}, {})",
|
||||
self.projection_ty.repr(),
|
||||
self.ty.repr())
|
||||
}
|
||||
}
|
||||
|
||||
pub trait HasProjectionTypes {
|
||||
fn has_projection_types(&self) -> bool;
|
||||
}
|
||||
|
@ -7870,48 +7862,46 @@ impl ReferencesError for Region
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ClosureTy<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("ClosureTy({},{},{})",
|
||||
impl<'tcx> fmt::Debug for ClosureTy<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "ClosureTy({},{:?},{})",
|
||||
self.unsafety,
|
||||
self.sig.repr(),
|
||||
self.sig,
|
||||
self.abi)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ClosureUpvar<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("ClosureUpvar({},{})",
|
||||
self.def.repr(),
|
||||
self.ty.repr())
|
||||
impl<'tcx> fmt::Debug for ClosureUpvar<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "ClosureUpvar({:?},{:?})",
|
||||
self.def,
|
||||
self.ty)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for field<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("field({},{})",
|
||||
self.name.repr(),
|
||||
self.mt.repr())
|
||||
impl<'tcx> fmt::Debug for field<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "field({},{})", self.name, self.mt)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Repr for ParameterEnvironment<'a, 'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("ParameterEnvironment(\
|
||||
free_substs={}, \
|
||||
implicit_region_bound={}, \
|
||||
caller_bounds={})",
|
||||
self.free_substs.repr(),
|
||||
self.implicit_region_bound.repr(),
|
||||
self.caller_bounds.repr())
|
||||
impl<'a, 'tcx> fmt::Debug for ParameterEnvironment<'a, 'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "ParameterEnvironment(\
|
||||
free_substs={:?}, \
|
||||
implicit_region_bound={:?}, \
|
||||
caller_bounds={:?})",
|
||||
self.free_substs,
|
||||
self.implicit_region_bound,
|
||||
self.caller_bounds)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for ObjectLifetimeDefault {
|
||||
fn repr(&self) -> String {
|
||||
impl<'tcx> fmt::Debug for ObjectLifetimeDefault {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
ObjectLifetimeDefault::Ambiguous => format!("Ambiguous"),
|
||||
ObjectLifetimeDefault::Specific(ref r) => r.repr(),
|
||||
ObjectLifetimeDefault::Ambiguous => write!(f, "Ambiguous"),
|
||||
ObjectLifetimeDefault::Specific(ref r) => write!(f, "{:?}", r),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ 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;
|
||||
|
@ -50,7 +52,7 @@ use util::ppaux::Repr;
|
|||
|
||||
/// 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 + Clone {
|
||||
pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
|
||||
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self;
|
||||
}
|
||||
|
||||
|
@ -74,7 +76,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 + Clone
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
// FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`.
|
||||
super_fold_binder(self, t)
|
||||
|
@ -197,7 +199,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T:TypeFoldable<'tcx>+Repr+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)
|
||||
}
|
||||
|
@ -885,7 +887,7 @@ 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,
|
||||
T : TypeFoldable<'tcx>,
|
||||
{
|
||||
debug!("replace_late_bound_regions({})", value.repr());
|
||||
let mut replacer = RegionReplacer::new(tcx, &mut f);
|
||||
|
@ -994,7 +996,7 @@ pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr>(tcx: &ty::ctxt<'tcx>,
|
||||
pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>>(tcx: &ty::ctxt<'tcx>,
|
||||
amount: u32, value: &T) -> T {
|
||||
debug!("shift_regions(value={}, amount={})",
|
||||
value.repr(), amount);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,9 +34,10 @@ use rustc::middle::mem_categorization as mc;
|
|||
use rustc::middle::region;
|
||||
use rustc::middle::ty::{self, Ty};
|
||||
use rustc::util::ppaux::{Repr, UserString};
|
||||
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use std::string::String;
|
||||
use syntax::ast;
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::Span;
|
||||
|
@ -329,7 +330,7 @@ impl<'tcx> Loan<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, Hash, Debug)]
|
||||
#[derive(Eq, Hash)]
|
||||
pub struct LoanPath<'tcx> {
|
||||
kind: LoanPathKind<'tcx>,
|
||||
ty: ty::Ty<'tcx>,
|
||||
|
@ -369,7 +370,7 @@ const DOWNCAST_PRINTED_OPERATOR: &'static str = " as ";
|
|||
// information that is not relevant to loan-path analysis. (In
|
||||
// particular, the distinction between how precisely a array-element
|
||||
// is tracked is irrelevant here.)
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum InteriorKind {
|
||||
InteriorField(mc::FieldName),
|
||||
InteriorElement(mc::ElementKind),
|
||||
|
@ -1148,39 +1149,38 @@ impl DataFlowOperator for LoanDataFlowOperator {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for InteriorKind {
|
||||
fn repr(&self) -> String {
|
||||
impl<'tcx> fmt::Debug for InteriorKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
InteriorField(mc::NamedField(fld)) =>
|
||||
format!("{}", token::get_name(fld)),
|
||||
InteriorField(mc::PositionalField(i)) => format!("#{}", i),
|
||||
InteriorElement(..) => "[]".to_string(),
|
||||
InteriorField(mc::NamedField(fld)) => write!(f, "{}", fld),
|
||||
InteriorField(mc::PositionalField(i)) => write!(f, "#{}", i),
|
||||
InteriorElement(..) => write!(f, "[]"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for Loan<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("Loan_{}({}, {:?}, {:?}-{:?}, {})",
|
||||
impl<'tcx> fmt::Debug for Loan<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Loan_{}({:?}, {:?}, {:?}-{:?}, {:?})",
|
||||
self.index,
|
||||
self.loan_path.repr(),
|
||||
self.loan_path,
|
||||
self.kind,
|
||||
self.gen_scope,
|
||||
self.kill_scope,
|
||||
self.restricted_paths.repr())
|
||||
self.restricted_paths)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for LoanPath<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
impl<'tcx> fmt::Debug for LoanPath<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.kind {
|
||||
LpVar(id) => {
|
||||
format!("$({})", ty::tls::with(|tcx| tcx.map.node_to_string(id)))
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.map.node_to_string(id)))
|
||||
}
|
||||
|
||||
LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => {
|
||||
let s = ty::tls::with(|tcx| tcx.map.node_to_string(var_id));
|
||||
format!("$({} captured by id={})", s, closure_expr_id)
|
||||
write!(f, "$({} captured by id={})", s, closure_expr_id)
|
||||
}
|
||||
|
||||
LpDowncast(ref lp, variant_def_id) => {
|
||||
|
@ -1189,30 +1189,30 @@ impl<'tcx> Repr for LoanPath<'tcx> {
|
|||
} else {
|
||||
variant_def_id.repr()
|
||||
};
|
||||
format!("({}{}{})", lp.repr(), DOWNCAST_PRINTED_OPERATOR, variant_str)
|
||||
write!(f, "({:?}{}{})", lp, DOWNCAST_PRINTED_OPERATOR, variant_str)
|
||||
}
|
||||
|
||||
LpExtend(ref lp, _, LpDeref(_)) => {
|
||||
format!("{}.*", lp.repr())
|
||||
write!(f, "{:?}.*", lp)
|
||||
}
|
||||
|
||||
LpExtend(ref lp, _, LpInterior(ref interior)) => {
|
||||
format!("{}.{}", lp.repr(), interior.repr())
|
||||
write!(f, "{:?}.{:?}", lp, interior)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UserString for LoanPath<'tcx> {
|
||||
fn user_string(&self) -> String {
|
||||
impl<'tcx> fmt::Display for LoanPath<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.kind {
|
||||
LpVar(id) => {
|
||||
format!("$({})", ty::tls::with(|tcx| tcx.map.node_to_user_string(id)))
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.map.node_to_user_string(id)))
|
||||
}
|
||||
|
||||
LpUpvar(ty::UpvarId{ var_id, closure_expr_id: _ }) => {
|
||||
let s = ty::tls::with(|tcx| tcx.map.node_to_user_string(var_id));
|
||||
format!("$({} captured by closure)", s)
|
||||
write!(f, "$({} captured by closure)", s)
|
||||
}
|
||||
|
||||
LpDowncast(ref lp, variant_def_id) => {
|
||||
|
@ -1221,15 +1221,15 @@ impl<'tcx> UserString for LoanPath<'tcx> {
|
|||
} else {
|
||||
variant_def_id.repr()
|
||||
};
|
||||
format!("({}{}{})", lp.user_string(), DOWNCAST_PRINTED_OPERATOR, variant_str)
|
||||
write!(f, "({}{}{})", lp, DOWNCAST_PRINTED_OPERATOR, variant_str)
|
||||
}
|
||||
|
||||
LpExtend(ref lp, _, LpDeref(_)) => {
|
||||
format!("{}.*", lp.user_string())
|
||||
write!(f, "{}.*", lp)
|
||||
}
|
||||
|
||||
LpExtend(ref lp, _, LpInterior(ref interior)) => {
|
||||
format!("{}.{}", lp.user_string(), interior.repr())
|
||||
write!(f, "{}.{:?}", lp, interior)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,8 +227,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
pub fn make_subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
|
||||
match infer::mk_subty(self.infcx, true, infer::Misc(DUMMY_SP), a, b) {
|
||||
Ok(_) => true,
|
||||
Err(ref e) => panic!("Encountered error: {}",
|
||||
ty::type_err_to_str(self.infcx.tcx, e))
|
||||
Err(ref e) => panic!("Encountered error: {}", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,8 +375,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
pub fn make_lub_ty(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match self.lub().relate(&t1, &t2) {
|
||||
Ok(t) => t,
|
||||
Err(ref e) => panic!("unexpected error computing LUB: {}",
|
||||
ty::type_err_to_str(self.infcx.tcx, e))
|
||||
Err(ref e) => panic!("unexpected error computing LUB: {}", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,7 +388,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
panic!("unexpected error computing sub({},{}): {}",
|
||||
t1.repr(),
|
||||
t2.repr(),
|
||||
ty::type_err_to_str(self.infcx.tcx, e));
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -415,8 +413,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
self.assert_eq(t, t_lub);
|
||||
}
|
||||
Err(ref e) => {
|
||||
panic!("unexpected error in LUB: {}",
|
||||
ty::type_err_to_str(self.infcx.tcx, e))
|
||||
panic!("unexpected error in LUB: {}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,6 +221,7 @@ use util::ppaux::{self, Repr};
|
|||
|
||||
use std;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::ast::{DUMMY_NODE_ID, NodeId};
|
||||
|
@ -371,13 +372,13 @@ struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> {
|
|||
pat_renaming_map: Option<&'a FnvHashMap<(NodeId, Span), NodeId>>
|
||||
}
|
||||
|
||||
impl<'a, 'p, 'blk, 'tcx> Repr for Match<'a, 'p, 'blk, 'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
impl<'a, 'p, 'blk, 'tcx> fmt::Debug for Match<'a, 'p, 'blk, 'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if ppaux::verbose() {
|
||||
// for many programs, this just take too long to serialize
|
||||
self.pats.repr()
|
||||
write!(f, "{:?}", self.pats)
|
||||
} else {
|
||||
format!("{} pats", self.pats.len())
|
||||
write!(f, "{} pats", self.pats.len())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ pub use trans::context::CrateContext;
|
|||
/// subtyping, but they are anonymized and normalized as well). This
|
||||
/// is a stronger, caching version of `ty_fold::erase_regions`.
|
||||
pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
let value1 = value.fold_with(&mut RegionEraser(cx));
|
||||
debug!("erase_regions({}) = {}",
|
||||
|
@ -88,7 +88,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T
|
|||
}
|
||||
|
||||
fn fold_binder<T>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T>
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
let u = ty::anonymize_late_bound_regions(self.tcx(), t);
|
||||
ty_fold::super_fold_binder(self, &u)
|
||||
|
@ -518,7 +518,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn monomorphize<T>(&self, value: &T) -> T
|
||||
where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
monomorphize::apply_param_substs(self.ccx.tcx(),
|
||||
self.param_substs,
|
||||
|
@ -624,7 +624,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn monomorphize<T>(&self, value: &T) -> T
|
||||
where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
monomorphize::apply_param_substs(self.tcx(),
|
||||
self.fcx.param_substs,
|
||||
|
@ -1135,7 +1135,7 @@ pub fn drain_fulfillment_cx_or_panic<'a,'tcx,T>(span: Span,
|
|||
fulfill_cx: &mut traits::FulfillmentContext<'tcx>,
|
||||
result: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
match drain_fulfillment_cx(infcx, fulfill_cx, result) {
|
||||
Ok(v) => v,
|
||||
|
@ -1159,7 +1159,7 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &infer::InferCtxt<'a,'tcx>,
|
|||
fulfill_cx: &mut traits::FulfillmentContext<'tcx>,
|
||||
result: &T)
|
||||
-> StdResult<T,Vec<traits::FulfillmentError<'tcx>>>
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
debug!("drain_fulfillment_cx(result={})",
|
||||
result.repr());
|
||||
|
|
|
@ -205,19 +205,6 @@ impl<'tcx> DropGlueKind<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for DropGlueKind<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
DropGlueKind::Ty(ty) => {
|
||||
format!("DropGlueKind::Ty({})", ty.repr())
|
||||
}
|
||||
DropGlueKind::TyContents(ty) => {
|
||||
format!("DropGlueKind::TyContents({})", ty.repr())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
g: DropGlueKind<'tcx>) -> ValueRef {
|
||||
debug!("make drop glue for {}", g.repr());
|
||||
|
|
|
@ -303,7 +303,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>,
|
|||
param_substs: &Substs<'tcx>,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
let substituted = value.subst(tcx, param_substs);
|
||||
normalize_associated_type(tcx, &substituted)
|
||||
|
@ -314,7 +314,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>,
|
|||
/// and hence we can be sure that all associated types will be
|
||||
/// completely normalized away.
|
||||
pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
|
||||
where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
debug!("normalize_associated_type(t={})", value.repr());
|
||||
|
||||
|
|
|
@ -2106,7 +2106,7 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt,
|
|||
ast_bounds: &'a [ast::TyParamBound])
|
||||
-> PartitionedBounds<'a>
|
||||
{
|
||||
let mut builtin_bounds = ty::empty_builtin_bounds();
|
||||
let mut builtin_bounds = ty::BuiltinBounds::empty();
|
||||
let mut region_bounds = Vec::new();
|
||||
let mut trait_bounds = Vec::new();
|
||||
for ast_bound in ast_bounds {
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
body_id: ast::NodeId,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
debug!("normalize_associated_types_in(value={})", value.repr());
|
||||
let mut selcx = SelectionContext::new(infcx, typer);
|
||||
|
|
|
@ -328,6 +328,7 @@ fn write_overloaded_call_method_map<'a,'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
fcx.inh.method_map.borrow_mut().insert(method_call, method_callee);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct CallResolution<'tcx> {
|
||||
call_expr: &'tcx ast::Expr,
|
||||
callee_expr: &'tcx ast::Expr,
|
||||
|
@ -337,19 +338,6 @@ struct CallResolution<'tcx> {
|
|||
closure_def_id: ast::DefId,
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for CallResolution<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("CallResolution(call_expr={}, callee_expr={}, adjusted_ty={}, \
|
||||
autoderefs={}, fn_sig={}, closure_def_id={})",
|
||||
self.call_expr.repr(),
|
||||
self.callee_expr.repr(),
|
||||
self.adjusted_ty.repr(),
|
||||
self.autoderefs,
|
||||
self.fn_sig.repr(),
|
||||
self.closure_def_id.repr())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> {
|
||||
fn resolve<'a>(&mut self, fcx: &FnCtxt<'a,'tcx>) {
|
||||
debug!("DeferredCallResolution::resolve() {}",
|
||||
|
|
|
@ -341,7 +341,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
span_err!(tcx.sess, impl_m_span, E0053,
|
||||
"method `{}` has an incompatible type for trait: {}",
|
||||
token::get_name(trait_m.name),
|
||||
ty::type_err_to_str(tcx, &terr));
|
||||
terr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
"implemented const `{}` has an incompatible type for \
|
||||
trait: {}",
|
||||
token::get_name(trait_c.name),
|
||||
ty::type_err_to_str(tcx, &terr));
|
||||
terr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -657,7 +657,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
|||
}
|
||||
|
||||
fn replace_late_bound_regions_with_fresh_var<T>(&self, value: &ty::Binder<T>) -> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
self.infcx().replace_late_bound_regions_with_fresh_var(
|
||||
self.span, infer::FnCall, value).0
|
||||
|
|
|
@ -46,18 +46,21 @@ struct ProbeContext<'a, 'tcx:'a> {
|
|||
static_candidates: Vec<CandidateSource>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct CandidateStep<'tcx> {
|
||||
self_ty: Ty<'tcx>,
|
||||
autoderefs: usize,
|
||||
unsize: bool
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Candidate<'tcx> {
|
||||
xform_self_ty: Ty<'tcx>,
|
||||
item: ty::ImplOrTraitItem<'tcx>,
|
||||
kind: CandidateKind<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum CandidateKind<'tcx> {
|
||||
InherentImplCandidate(/* Impl */ ast::DefId, subst::Substs<'tcx>,
|
||||
/* Normalize obligations */ Vec<traits::PredicateObligation<'tcx>>),
|
||||
|
@ -70,6 +73,7 @@ enum CandidateKind<'tcx> {
|
|||
ProjectionCandidate(ast::DefId, ItemIndex),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Pick<'tcx> {
|
||||
pub item: ty::ImplOrTraitItem<'tcx>,
|
||||
pub kind: PickKind<'tcx>,
|
||||
|
@ -1264,7 +1268,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
|||
/// and/or tracking the substitution and
|
||||
/// so forth.
|
||||
fn erase_late_bound_regions<T>(&self, value: &ty::Binder<T>) -> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
ty::erase_late_bound_regions(self.tcx(), value)
|
||||
}
|
||||
|
@ -1370,59 +1374,3 @@ impl<'tcx> Candidate<'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for Candidate<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("Candidate(xform_self_ty={}, kind={})",
|
||||
self.xform_self_ty.repr(),
|
||||
self.kind.repr())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for CandidateKind<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
InherentImplCandidate(ref a, ref b, ref c) =>
|
||||
format!("InherentImplCandidate({},{},{})", a.repr(), b.repr(),
|
||||
c.repr()),
|
||||
ObjectCandidate(a, b, c) =>
|
||||
format!("ObjectCandidate({},{},{})", a.repr(), b, c),
|
||||
ExtensionImplCandidate(ref a, ref b, ref c, ref d, ref e) =>
|
||||
format!("ExtensionImplCandidate({},{},{},{},{})", a.repr(), b.repr(),
|
||||
c.repr(), d, e.repr()),
|
||||
ClosureCandidate(ref a, ref b) =>
|
||||
format!("ClosureCandidate({},{})", a.repr(), b),
|
||||
WhereClauseCandidate(ref a, ref b) =>
|
||||
format!("WhereClauseCandidate({},{})", a.repr(), b),
|
||||
ProjectionCandidate(ref a, ref b) =>
|
||||
format!("ProjectionCandidate({},{})", a.repr(), b),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for CandidateStep<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("CandidateStep({}, autoderefs={}, unsize={})",
|
||||
self.self_ty.repr(),
|
||||
self.autoderefs,
|
||||
self.unsize)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for PickKind<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for Pick<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
format!("Pick(item={}, autoderefs={},
|
||||
autoref={}, unsize={}, kind={:?})",
|
||||
self.item.repr(),
|
||||
self.autoderefs,
|
||||
self.autoref.repr(),
|
||||
self.unsize.repr(),
|
||||
self.kind)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ type DeferredCallResolutionHandler<'tcx> = Box<DeferredCallResolution<'tcx>+'tcx
|
|||
|
||||
/// When type-checking an expression, we propagate downward
|
||||
/// whatever type hint we are able in the form of an `Expectation`.
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum Expectation<'tcx> {
|
||||
/// We know nothing about what type this expression should have.
|
||||
NoExpectation,
|
||||
|
@ -398,7 +398,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
|||
body_id: ast::NodeId,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
let mut fulfillment_cx = self.fulfillment_cx.borrow_mut();
|
||||
assoc::normalize_associated_types_in(&self.infcx,
|
||||
|
@ -1444,7 +1444,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
substs: &Substs<'tcx>,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
let value = value.subst(self.tcx(), substs);
|
||||
let result = self.normalize_associated_types_in(span, &value);
|
||||
|
@ -1470,7 +1470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
|
||||
fn normalize_associated_types_in<T>(&self, span: Span, value: &T) -> T
|
||||
where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr
|
||||
where T : TypeFoldable<'tcx> + HasProjectionTypes
|
||||
{
|
||||
self.inh.normalize_associated_types_in(self, span, self.body_id, value)
|
||||
}
|
||||
|
@ -3605,8 +3605,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
type_and_substs.ty) {
|
||||
Ok(()) => {}
|
||||
Err(type_error) => {
|
||||
let type_error_description =
|
||||
ty::type_err_to_str(tcx, &type_error);
|
||||
span_err!(fcx.tcx().sess, path.span, E0235,
|
||||
"structure constructor specifies a \
|
||||
structure of type `{}`, but this \
|
||||
|
@ -3616,7 +3614,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
fcx.infcx()
|
||||
.ty_to_string(
|
||||
actual_structure_type),
|
||||
type_error_description);
|
||||
type_error);
|
||||
ty::note_and_explain_type_err(tcx, &type_error, path.span);
|
||||
}
|
||||
}
|
||||
|
@ -3907,20 +3905,6 @@ impl<'tcx> Expectation<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr for Expectation<'tcx> {
|
||||
fn repr(&self) -> String {
|
||||
match *self {
|
||||
NoExpectation => format!("NoExpectation"),
|
||||
ExpectHasType(t) => format!("ExpectHasType({})",
|
||||
t.repr()),
|
||||
ExpectCastableToType(t) => format!("ExpectCastableToType({})",
|
||||
t.repr()),
|
||||
ExpectRvalueLikeUnsized(t) => format!("ExpectRvalueLikeUnsized({})",
|
||||
t.repr()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_decl_initializer<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
|
||||
local: &'tcx ast::Local,
|
||||
init: &'tcx ast::Expr)
|
||||
|
|
|
@ -536,7 +536,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
|
|||
}
|
||||
|
||||
fn fold_binder<T>(&mut self, binder: &ty::Binder<T>) -> ty::Binder<T>
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
self.binding_count += 1;
|
||||
let value = liberate_late_bound_regions(
|
||||
|
|
|
@ -2235,7 +2235,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>(
|
|||
scope: region::DestructionScopeData,
|
||||
value: &T)
|
||||
-> T
|
||||
where T : TypeFoldable<'tcx> + Repr
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
/*!
|
||||
* Convert early-bound regions into free regions; normally this is done by
|
||||
|
|
|
@ -199,11 +199,7 @@ fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
|
|||
match result {
|
||||
Ok(_) => true,
|
||||
Err(ref terr) => {
|
||||
span_err!(tcx.sess, span, E0211,
|
||||
"{}: {}",
|
||||
msg(),
|
||||
ty::type_err_to_str(tcx,
|
||||
terr));
|
||||
span_err!(tcx.sess, span, E0211, "{}: {}", msg(), terr);
|
||||
ty::note_and_explain_type_err(tcx, terr, span);
|
||||
false
|
||||
}
|
||||
|
|
|
@ -522,7 +522,7 @@ pub enum TyParamBound {
|
|||
impl TyParamBound {
|
||||
fn maybe_sized(cx: &DocContext) -> TyParamBound {
|
||||
use syntax::ast::TraitBoundModifier as TBM;
|
||||
let mut sized_bound = ty::BuiltinBound::BoundSized.clean(cx);
|
||||
let mut sized_bound = ty::BoundSized.clean(cx);
|
||||
if let TyParamBound::TraitBound(_, ref mut tbm) = sized_bound {
|
||||
*tbm = TBM::Maybe
|
||||
};
|
||||
|
|
|
@ -29,6 +29,6 @@ struct E<'a,'b:'a,T:'b>(&'a T, &'b T); //~ ERROR 'b
|
|||
struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U); //~ ERROR 'a,'b
|
||||
|
||||
#[rustc_object_lifetime_default]
|
||||
struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); //~ ERROR 'a,Ambiguous
|
||||
struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); //~ ERROR 'a,Some(Ambiguous)
|
||||
|
||||
fn main() { }
|
||||
|
|
Loading…
Reference in New Issue