Skip to content

Commit 0d57750

Browse files
committed
---
yaml --- r: 228463 b: refs/heads/try c: b3a9cd3 h: refs/heads/master i: 228461: 3ded86a 228459: 1629102 228455: c2821d4 228447: c7f9558 v: v3
1 parent 24773a8 commit 0d57750

File tree

101 files changed

+838
-495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+838
-495
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: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 99987a82b6977517d0bdf358fd97e2fca305d8fe
4+
refs/heads/try: b3a9cd3a69a3b6d0729dbfe1af4db8ccfc359679
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/doc/trpl/testing.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,11 @@ that our tests are entirely left out of a normal build.
250250

251251
The second change is the `use` declaration. Because we're in an inner module,
252252
we need to bring our test function into scope. This can be annoying if you have
253-
a large module, and so this is a common use of globs. Let's change our
254-
`src/lib.rs` to make use of it:
253+
a large module, and so this is a common use of the `glob` feature. Let's change
254+
our `src/lib.rs` to make use of it:
255255

256256
```rust,ignore
257+
257258
pub fn add_two(a: i32) -> i32 {
258259
a + 2
259260
}

branches/try/src/libcollections/vec.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ impl<T> Vec<T> {
231231
///
232232
/// * `ptr` needs to have been previously allocated via `String`/`Vec<T>`
233233
/// (at least, it's highly likely to be incorrect if it wasn't).
234-
/// * `length` needs to be the length that less than or equal to `capacity`.
235234
/// * `capacity` needs to be the capacity that the pointer was allocated with.
236235
///
237236
/// Violating these may cause problems like corrupting the allocator's

branches/try/src/librustc/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,14 @@ pub mod diagnostics;
9999

100100
pub mod back {
101101
pub use rustc_back::abi;
102+
pub use rustc_back::arm;
103+
pub use rustc_back::mips;
104+
pub use rustc_back::mipsel;
102105
pub use rustc_back::rpath;
103106
pub use rustc_back::svh;
107+
pub use rustc_back::target_strs;
108+
pub use rustc_back::x86;
109+
pub use rustc_back::x86_64;
104110
}
105111

106112
pub mod ast_map;

branches/try/src/librustc/metadata/tydecode.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,16 @@ fn parse_existential_bounds_<'a,'tcx, F>(st: &mut PState<'a,'tcx>,
887887
}
888888
}
889889

890+
let region_bound_will_change = match next(st) {
891+
'y' => true,
892+
'n' => false,
893+
c => panic!("parse_ty: expected y/n not '{}'", c)
894+
};
895+
890896
return ty::ExistentialBounds { region_bound: region_bound,
891897
builtin_bounds: builtin_bounds,
892-
projection_bounds: projection_bounds };
898+
projection_bounds: projection_bounds,
899+
region_bound_will_change: region_bound_will_change };
893900
}
894901

895902
fn parse_builtin_bounds<F>(st: &mut PState, mut _conv: F) -> ty::BuiltinBounds where

branches/try/src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ pub fn enc_existential_bounds<'a,'tcx>(w: &mut Encoder,
390390
}
391391

392392
mywrite!(w, ".");
393+
394+
mywrite!(w, "{}", if bs.region_bound_will_change {'y'} else {'n'});
393395
}
394396

395397
pub fn enc_region_bounds<'a, 'tcx>(w: &mut Encoder,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> {
4949

5050
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
5151

52+
fn will_change(&mut self, _: bool, _: bool) -> bool {
53+
// since we are not comparing regions, we don't care
54+
false
55+
}
56+
5257
fn relate_with_variance<T:Relate<'a,'tcx>>(&mut self,
5358
variance: ty::Variance,
5459
a: &T,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> {
3434

3535
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
3636

37+
fn will_change(&mut self, a: bool, b: bool) -> bool {
38+
// if either side changed from what it was, that could cause equality to fail
39+
a || b
40+
}
41+
3742
fn relate_with_variance<T:Relate<'a,'tcx>>(&mut self,
3843
_: ty::Variance,
3944
a: &T,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
593593
sub: Region,
594594
sup: Region) {
595595
match origin {
596-
infer::Subtype(trace) => {
596+
infer::Subtype(trace) |
597+
infer::DefaultExistentialBound(trace) => {
597598
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
598599
self.report_and_explain_type_error(trace, &terr);
599600
}
@@ -1569,7 +1570,8 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
15691570

15701571
fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
15711572
match *origin {
1572-
infer::Subtype(ref trace) => {
1573+
infer::Subtype(ref trace) |
1574+
infer::DefaultExistentialBound(ref trace) => {
15731575
let desc = match trace.origin {
15741576
infer::Misc(_) => {
15751577
"types are compatible"

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> {
3535

3636
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
3737

38+
fn will_change(&mut self, a: bool, b: bool) -> bool {
39+
// Hmm, so the result of GLB will still be a LB if one or both
40+
// sides change to 'static, but it may no longer be the GLB.
41+
// I'm going to go with `a || b` here to be conservative,
42+
// since the result of this operation may be affected, though
43+
// I think it would mostly be more accepting than before (since the result
44+
// would be a bigger region).
45+
a || b
46+
}
47+
3848
fn relate_with_variance<T:Relate<'a,'tcx>>(&mut self,
3949
variance: ty::Variance,
4050
a: &T,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx> {
3535

3636
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
3737

38+
fn will_change(&mut self, a: bool, b: bool) -> bool {
39+
// result will be 'static if a || b
40+
a || b
41+
}
42+
3843
fn relate_with_variance<T:Relate<'a,'tcx>>(&mut self,
3944
variance: ty::Variance,
4045
a: &T,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ pub enum SubregionOrigin<'tcx> {
191191
// Arose from a subtyping relation
192192
Subtype(TypeTrace<'tcx>),
193193

194+
// Arose from a subtyping relation
195+
DefaultExistentialBound(TypeTrace<'tcx>),
196+
194197
// Stack-allocated closures cannot outlive innermost loop
195198
// or function so as to ensure we only require finite stack
196199
InfStackClosure(Span),
@@ -1463,6 +1466,7 @@ impl<'tcx> SubregionOrigin<'tcx> {
14631466
pub fn span(&self) -> Span {
14641467
match *self {
14651468
Subtype(ref a) => a.span(),
1469+
DefaultExistentialBound(ref a) => a.span(),
14661470
InfStackClosure(a) => a,
14671471
InvokeClosure(a) => a,
14681472
DerefPointer(a) => a,

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,9 +1357,56 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
13571357
}
13581358
}
13591359

1360+
// Check for future hostile edges tied to a bad default
1361+
self.report_future_hostility(&graph);
1362+
13601363
(0..self.num_vars() as usize).map(|idx| var_data[idx].value).collect()
13611364
}
13621365

1366+
fn report_future_hostility(&self, graph: &RegionGraph) {
1367+
let constraints = self.constraints.borrow();
1368+
for edge in graph.all_edges() {
1369+
match constraints[&edge.data] {
1370+
SubregionOrigin::DefaultExistentialBound(_) => {
1371+
// this will become 'static in the future
1372+
}
1373+
_ => { continue; }
1374+
}
1375+
1376+
// this constraint will become a 'static constraint in the
1377+
// future, so walk outward and see if we have any hard
1378+
// bounds that could not be inferred to 'static
1379+
for nid in graph.depth_traverse(edge.target()) {
1380+
for (_, succ) in graph.outgoing_edges(nid) {
1381+
match succ.data {
1382+
ConstrainVarSubReg(_, r) => {
1383+
match r {
1384+
ty::ReStatic | ty::ReInfer(_) => {
1385+
/* OK */
1386+
}
1387+
ty::ReFree(_) | ty::ReScope(_) | ty::ReEmpty => {
1388+
span_warn!(
1389+
self.tcx.sess,
1390+
constraints[&edge.data].span(),
1391+
E0398,
1392+
"this code may fail to compile in Rust 1.3 due to \
1393+
the proposed change in object lifetime bound defaults");
1394+
return; // only issue the warning once per fn
1395+
}
1396+
ty::ReEarlyBound(..) | ty::ReLateBound(..) => {
1397+
self.tcx.sess.span_bug(
1398+
constraints[&succ.data].span(),
1399+
"relation to bound region");
1400+
}
1401+
}
1402+
}
1403+
_ => { }
1404+
}
1405+
}
1406+
}
1407+
}
1408+
}
1409+
13631410
fn construct_graph(&self) -> RegionGraph {
13641411
let num_vars = self.num_vars();
13651412

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
4545
r
4646
}
4747

48+
fn will_change(&mut self, a: bool, b: bool) -> bool {
49+
// if we have (Foo+'a) <: (Foo+'b), this requires that 'a:'b.
50+
// So if 'a becomes 'static, no additional errors can occur.
51+
// OTOH, if 'a stays the same, but 'b becomes 'static, we
52+
// could have a problem.
53+
!a && b
54+
}
55+
4856
fn relate_with_variance<T:Relate<'a,'tcx>>(&mut self,
4957
variance: ty::Variance,
5058
a: &T,
@@ -98,10 +106,12 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
98106
fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> {
99107
debug!("{}.regions({:?}, {:?}) self.cause={:?}",
100108
self.tag(), a, b, self.fields.cause);
101-
// FIXME -- we have more fine-grained information available
102-
// from the "cause" field, we could perhaps give more tailored
103-
// error messages.
104-
let origin = SubregionOrigin::Subtype(self.fields.trace.clone());
109+
let origin = match self.fields.cause {
110+
Some(Cause::ExistentialRegionBound(true)) =>
111+
SubregionOrigin::DefaultExistentialBound(self.fields.trace.clone()),
112+
_ =>
113+
SubregionOrigin::Subtype(self.fields.trace.clone()),
114+
};
105115
self.fields.infcx.region_vars.make_subregion(origin, a, b);
106116
Ok(a)
107117
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
24622462
region_bound: data_b.bounds.region_bound,
24632463
builtin_bounds: data_b.bounds.builtin_bounds,
24642464
projection_bounds: data_a.bounds.projection_bounds.clone(),
2465+
region_bound_will_change: data_b.bounds.region_bound_will_change,
24652466
};
24662467

24672468
let new_trait = tcx.mk_trait(data_a.principal.clone(), bounds);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,11 @@ pub struct ExistentialBounds<'tcx> {
19891989
pub region_bound: ty::Region,
19901990
pub builtin_bounds: BuiltinBounds,
19911991
pub projection_bounds: Vec<PolyProjectionPredicate<'tcx>>,
1992+
1993+
// If true, this TyTrait used a "default bound" in the surface
1994+
// syntax. This makes no difference to the type system but is
1995+
// handy for error reporting.
1996+
pub region_bound_will_change: bool,
19921997
}
19931998

19941999
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ pub fn super_fold_existential_bounds<'tcx, T: TypeFolder<'tcx>>(
700700
region_bound: bounds.region_bound.fold_with(this),
701701
builtin_bounds: bounds.builtin_bounds,
702702
projection_bounds: bounds.projection_bounds.fold_with(this),
703+
region_bound_will_change: bounds.region_bound_will_change,
703704
}
704705
}
705706

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> {
4242
fn tcx(&self) -> &'a ty::ctxt<'tcx> { self.tcx }
4343
fn a_is_expected(&self) -> bool { true } // irrelevant
4444

45+
fn will_change(&mut self, _: bool, _: bool) -> bool {
46+
// we're ignoring regions in this code
47+
false
48+
}
49+
4550
fn relate_with_variance<T:Relate<'a,'tcx>>(&mut self,
4651
_: ty::Variance,
4752
a: &T,

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub type RelateResult<'tcx, T> = Result<T, ty::TypeError<'tcx>>;
2424

2525
#[derive(Clone, Debug)]
2626
pub enum Cause {
27-
ExistentialRegionBound, // relating an existential region bound
27+
ExistentialRegionBound(bool), // if true, this is a default, else explicit
2828
}
2929

3030
pub trait TypeRelation<'a,'tcx> : Sized {
@@ -43,6 +43,13 @@ pub trait TypeRelation<'a,'tcx> : Sized {
4343
f(self)
4444
}
4545

46+
/// Hack for deciding whether the lifetime bound defaults change
47+
/// will be a breaking change or not. The bools indicate whether
48+
/// `a`/`b` have a default that will change to `'static`; the
49+
/// result is true if this will potentially affect the affect of
50+
/// relating `a` and `b`.
51+
fn will_change(&mut self, a: bool, b: bool) -> bool;
52+
4653
/// Generic relation routine suitable for most anything.
4754
fn relate<T:Relate<'a,'tcx>>(&mut self, a: &T, b: &T) -> RelateResult<'tcx, T> {
4855
Relate::relate(self, a, b)
@@ -377,17 +384,21 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::ExistentialBounds<'tcx> {
377384
-> RelateResult<'tcx, ty::ExistentialBounds<'tcx>>
378385
where R: TypeRelation<'a,'tcx>
379386
{
387+
let will_change = relation.will_change(a.region_bound_will_change,
388+
b.region_bound_will_change);
389+
380390
let r =
381391
try!(relation.with_cause(
382-
Cause::ExistentialRegionBound,
392+
Cause::ExistentialRegionBound(will_change),
383393
|relation| relation.relate_with_variance(ty::Contravariant,
384394
&a.region_bound,
385395
&b.region_bound)));
386396
let nb = try!(relation.relate(&a.builtin_bounds, &b.builtin_bounds));
387397
let pb = try!(relation.relate(&a.projection_bounds, &b.projection_bounds));
388398
Ok(ty::ExistentialBounds { region_bound: r,
389399
builtin_bounds: nb,
390-
projection_bounds: pb })
400+
projection_bounds: pb,
401+
region_bound_will_change: will_change })
391402
}
392403
}
393404

branches/try/src/librustc/util/ppaux.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ impl<'tcx> fmt::Display for ty::TraitTy<'tcx> {
300300
try!(write!(f, " + {}", bound));
301301
}
302302

303+
if bounds.region_bound_will_change && verbose() {
304+
try!(write!(f, " [WILL-CHANGE]"));
305+
}
306+
303307
Ok(())
304308
}
305309
}

0 commit comments

Comments
 (0)