Skip to content

Commit 8bc3d62

Browse files
author
Ariel Ben-Yehuda
committed
---
yaml --- r: 232503 b: refs/heads/try c: 8aeaaac h: refs/heads/master i: 232501: 846b63f 232499: 1564904 232495: 3633441 v: v3
1 parent 626f2c2 commit 8bc3d62

File tree

7 files changed

+49
-7
lines changed

7 files changed

+49
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 96e6b2fef82c13aa542713e7923d7d0a76bd698b
4+
refs/heads/try: 8aeaaac6545565345f4df7d24d6421f93f28d698
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
614614
snapshot: &CombinedSnapshot,
615615
value: &T)
616616
-> T
617-
where T : TypeFoldable<'tcx>
617+
where T : TypeFoldable<'tcx> + ty::HasTypeFlags
618618
{
619619
debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok());
620620

branches/try/src/librustc/middle/infer/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
985985
snapshot: &CombinedSnapshot,
986986
value: &T)
987987
-> T
988-
where T : TypeFoldable<'tcx>
988+
where T : TypeFoldable<'tcx> + HasTypeFlags
989989
{
990990
/*! See `higher_ranked::plug_leaks` */
991991

@@ -1256,7 +1256,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12561256
}
12571257
}
12581258

1259-
pub fn resolve_type_vars_if_possible<T:TypeFoldable<'tcx>>(&self, value: &T) -> T {
1259+
pub fn resolve_type_vars_if_possible<T>(&self, value: &T) -> T
1260+
where T: TypeFoldable<'tcx> + HasTypeFlags
1261+
{
12601262
/*!
12611263
* Where possible, replaces type/int/float variables in
12621264
* `value` with their final value. Note that region variables
@@ -1266,6 +1268,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12661268
* at will.
12671269
*/
12681270

1271+
if !value.needs_infer() {
1272+
return value.clone(); // avoid duplicated subst-folding
1273+
}
12691274
let mut r = resolve::OpportunisticTypeResolver::new(self);
12701275
value.fold_with(&mut r)
12711276
}

branches/try/src/librustc/middle/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
160160
pub fn report_overflow_error<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
161161
obligation: &Obligation<'tcx, T>)
162162
-> !
163-
where T: fmt::Display + TypeFoldable<'tcx>
163+
where T: fmt::Display + TypeFoldable<'tcx> + HasTypeFlags
164164
{
165165
let predicate =
166166
infcx.resolve_type_vars_if_possible(&obligation.predicate);

branches/try/src/librustc/middle/traits/project.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,13 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> {
927927
}
928928
}
929929

930+
impl<'tcx, T: HasTypeFlags> HasTypeFlags for Normalized<'tcx, T> {
931+
fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
932+
self.value.has_type_flags(flags) ||
933+
self.obligations.has_type_flags(flags)
934+
}
935+
}
936+
930937
impl<'tcx, T:fmt::Debug> fmt::Debug for Normalized<'tcx, T> {
931938
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
932939
write!(f, "Normalized({:?},{:?})",

branches/try/src/librustc/middle/ty.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7280,6 +7280,24 @@ impl<'tcx,T:HasTypeFlags> HasTypeFlags for VecPerParamSpace<T> {
72807280
}
72817281
}
72827282

7283+
impl HasTypeFlags for abi::Abi {
7284+
fn has_type_flags(&self, _flags: TypeFlags) -> bool {
7285+
false
7286+
}
7287+
}
7288+
7289+
impl HasTypeFlags for ast::Unsafety {
7290+
fn has_type_flags(&self, _flags: TypeFlags) -> bool {
7291+
false
7292+
}
7293+
}
7294+
7295+
impl HasTypeFlags for BuiltinBounds {
7296+
fn has_type_flags(&self, _flags: TypeFlags) -> bool {
7297+
false
7298+
}
7299+
}
7300+
72837301
impl<'tcx> HasTypeFlags for ClosureTy<'tcx> {
72847302
fn has_type_flags(&self, flags: TypeFlags) -> bool {
72857303
self.sig.has_type_flags(flags)
@@ -7292,6 +7310,12 @@ impl<'tcx> HasTypeFlags for ClosureUpvar<'tcx> {
72927310
}
72937311
}
72947312

7313+
impl<'tcx> HasTypeFlags for ExistentialBounds<'tcx> {
7314+
fn has_type_flags(&self, flags: TypeFlags) -> bool {
7315+
self.projection_bounds.has_type_flags(flags)
7316+
}
7317+
}
7318+
72957319
impl<'tcx> HasTypeFlags for ty::InstantiatedPredicates<'tcx> {
72967320
fn has_type_flags(&self, flags: TypeFlags) -> bool {
72977321
self.predicates.has_type_flags(flags)
@@ -7367,6 +7391,12 @@ impl<'tcx> HasTypeFlags for Ty<'tcx> {
73677391
}
73687392
}
73697393

7394+
impl<'tcx> HasTypeFlags for TypeAndMut<'tcx> {
7395+
fn has_type_flags(&self, flags: TypeFlags) -> bool {
7396+
self.ty.has_type_flags(flags)
7397+
}
7398+
}
7399+
73707400
impl<'tcx> HasTypeFlags for TraitRef<'tcx> {
73717401
fn has_type_flags(&self, flags: TypeFlags) -> bool {
73727402
self.substs.has_type_flags(flags)

branches/try/src/librustc/middle/ty_relate/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! type equality, etc.
1515
1616
use middle::subst::{ErasedRegions, NonerasedRegions, ParamSpace, Substs};
17-
use middle::ty::{self, Ty, TypeError};
17+
use middle::ty::{self, HasTypeFlags, Ty, TypeError};
1818
use middle::ty_fold::TypeFoldable;
1919
use std::rc::Rc;
2020
use syntax::abi;
@@ -78,7 +78,7 @@ pub trait TypeRelation<'a,'tcx> : Sized {
7878
where T: Relate<'a,'tcx>;
7979
}
8080

81-
pub trait Relate<'a,'tcx>: TypeFoldable<'tcx> {
81+
pub trait Relate<'a,'tcx>: TypeFoldable<'tcx> + HasTypeFlags {
8282
fn relate<R:TypeRelation<'a,'tcx>>(relation: &mut R,
8383
a: &Self,
8484
b: &Self)

0 commit comments

Comments
 (0)