Skip to content

Commit 1cc054f

Browse files
committed
---
yaml --- r: 228055 b: refs/heads/try c: 0dc0824 h: refs/heads/master i: 228053: b53fc18 228051: e73e166 228047: 17794e6 v: v3
1 parent 76cd85a commit 1cc054f

Some content is hidden

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

43 files changed

+631
-377
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: 66f757b26d0dc1a3fe5a95f9554a8927dfb3c44a
4+
refs/heads/try: 0dc08240ea755679e3daec3832a04b22a8fc90bf
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Read ["Installing Rust"] from [The Book].
7373
```
7474
7575
3. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
76-
MYSY2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
76+
MSYS2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
7777
7878
4. Navigate to Rust's source code, configure and build it:
7979

branches/try/src/libcore/atomic.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,6 @@ unsafe fn atomic_store<T>(dst: *mut T, val: T, order:Ordering) {
953953
}
954954

955955
#[inline]
956-
#[stable(feature = "rust1", since = "1.0.0")]
957956
unsafe fn atomic_load<T>(dst: *const T, order:Ordering) -> T {
958957
match order {
959958
Acquire => intrinsics::atomic_load_acq(dst),
@@ -965,7 +964,6 @@ unsafe fn atomic_load<T>(dst: *const T, order:Ordering) -> T {
965964
}
966965

967966
#[inline]
968-
#[stable(feature = "rust1", since = "1.0.0")]
969967
unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
970968
match order {
971969
Acquire => intrinsics::atomic_xchg_acq(dst, val),
@@ -978,7 +976,6 @@ unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
978976

979977
/// Returns the old value (like __sync_fetch_and_add).
980978
#[inline]
981-
#[stable(feature = "rust1", since = "1.0.0")]
982979
unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
983980
match order {
984981
Acquire => intrinsics::atomic_xadd_acq(dst, val),
@@ -991,7 +988,6 @@ unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
991988

992989
/// Returns the old value (like __sync_fetch_and_sub).
993990
#[inline]
994-
#[stable(feature = "rust1", since = "1.0.0")]
995991
unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
996992
match order {
997993
Acquire => intrinsics::atomic_xsub_acq(dst, val),
@@ -1003,7 +999,6 @@ unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
1003999
}
10041000

10051001
#[inline]
1006-
#[stable(feature = "rust1", since = "1.0.0")]
10071002
unsafe fn atomic_compare_and_swap<T>(dst: *mut T, old:T, new:T, order: Ordering) -> T {
10081003
match order {
10091004
Acquire => intrinsics::atomic_cxchg_acq(dst, old, new),
@@ -1015,7 +1010,6 @@ unsafe fn atomic_compare_and_swap<T>(dst: *mut T, old:T, new:T, order: Ordering)
10151010
}
10161011

10171012
#[inline]
1018-
#[stable(feature = "rust1", since = "1.0.0")]
10191013
unsafe fn atomic_and<T>(dst: *mut T, val: T, order: Ordering) -> T {
10201014
match order {
10211015
Acquire => intrinsics::atomic_and_acq(dst, val),
@@ -1027,7 +1021,6 @@ unsafe fn atomic_and<T>(dst: *mut T, val: T, order: Ordering) -> T {
10271021
}
10281022

10291023
#[inline]
1030-
#[stable(feature = "rust1", since = "1.0.0")]
10311024
unsafe fn atomic_nand<T>(dst: *mut T, val: T, order: Ordering) -> T {
10321025
match order {
10331026
Acquire => intrinsics::atomic_nand_acq(dst, val),
@@ -1040,7 +1033,6 @@ unsafe fn atomic_nand<T>(dst: *mut T, val: T, order: Ordering) -> T {
10401033

10411034

10421035
#[inline]
1043-
#[stable(feature = "rust1", since = "1.0.0")]
10441036
unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
10451037
match order {
10461038
Acquire => intrinsics::atomic_or_acq(dst, val),
@@ -1053,7 +1045,6 @@ unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
10531045

10541046

10551047
#[inline]
1056-
#[stable(feature = "rust1", since = "1.0.0")]
10571048
unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
10581049
match order {
10591050
Acquire => intrinsics::atomic_xor_acq(dst, val),

branches/try/src/libcore/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,8 +2655,8 @@ macro_rules! step_impl_signed {
26552655
#[allow(trivial_numeric_casts)]
26562656
fn steps_between(start: &$t, end: &$t, by: &$t) -> Option<usize> {
26572657
if *by == 0 { return None; }
2658-
let mut diff: usize;
2659-
let mut by_u: usize;
2658+
let diff: usize;
2659+
let by_u: usize;
26602660
if *by > 0 {
26612661
if *start >= *end {
26622662
return Some(0);

branches/try/src/libfmt_macros/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl<'a> Parser<'a> {
399399
}
400400
Some(..) | None => { return &self.input[..0]; }
401401
};
402-
let mut end;
402+
let end;
403403
loop {
404404
match self.cur.clone().next() {
405405
Some((_, c)) if c.is_xid_continue() => {

branches/try/src/librustc/diagnostics.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,42 @@ static mut FOO: Option<Box<usize>> = None;
11601160
// error: mutable statics are not allowed to have destructors
11611161
static mut BAR: Option<Vec<i32>> = None;
11621162
```
1163+
"##,
1164+
1165+
E0398: r##"
1166+
In Rust 1.3, the default object lifetime bounds are expected to
1167+
change, as described in RFC #1156 [1]. You are getting a warning
1168+
because the compiler thinks it is possible that this change will cause
1169+
a compilation error in your code. It is possible, though unlikely,
1170+
that this is a false alarm.
1171+
1172+
The heart of the change is that where `&'a Box<SomeTrait>` used to
1173+
default to `&'a Box<SomeTrait+'a>`, it now defaults to `&'a
1174+
Box<SomeTrait+'static>` (here, `SomeTrait` is the name of some trait
1175+
type). Note that the only types which are affected are references to
1176+
boxes, like `&Box<SomeTrait>` or `&[Box<SomeTrait>]`. More common
1177+
types like `&SomeTrait` or `Box<SomeTrait>` are unaffected.
1178+
1179+
To silence this warning, edit your code to use an explicit bound.
1180+
Most of the time, this means that you will want to change the
1181+
signature of a function that you are calling. For example, if
1182+
the error is reported on a call like `foo(x)`, and `foo` is
1183+
defined as follows:
1184+
1185+
```
1186+
fn foo(arg: &Box<SomeTrait>) { ... }
1187+
```
1188+
1189+
you might change it to:
1190+
1191+
```
1192+
fn foo<'a>(arg: &Box<SomeTrait+'a>) { ... }
1193+
```
1194+
1195+
This explicitly states that you expect the trait object `SomeTrait` to
1196+
contain references (with a maximum lifetime of `'a`).
1197+
1198+
[1]: https://github.com/rust-lang/rfcs/pull/1156
11631199
"##
11641200

11651201
}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,15 +843,15 @@ fn parse_type_param_def_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
843843

844844
fn parse_object_lifetime_default<'a,'tcx, F>(st: &mut PState<'a,'tcx>,
845845
conv: &mut F)
846-
-> Option<ty::ObjectLifetimeDefault>
846+
-> ty::ObjectLifetimeDefault
847847
where F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
848848
{
849849
match next(st) {
850-
'n' => None,
851-
'a' => Some(ty::ObjectLifetimeDefault::Ambiguous),
850+
'a' => ty::ObjectLifetimeDefault::Ambiguous,
851+
'b' => ty::ObjectLifetimeDefault::BaseDefault,
852852
's' => {
853853
let region = parse_region_(st, conv);
854-
Some(ty::ObjectLifetimeDefault::Specific(region))
854+
ty::ObjectLifetimeDefault::Specific(region)
855855
}
856856
_ => panic!("parse_object_lifetime_default: bad input")
857857
}
@@ -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: 6 additions & 4 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,
@@ -414,12 +416,12 @@ pub fn enc_type_param_def<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>,
414416

415417
fn enc_object_lifetime_default<'a, 'tcx>(w: &mut Encoder,
416418
cx: &ctxt<'a, 'tcx>,
417-
default: Option<ty::ObjectLifetimeDefault>)
419+
default: ty::ObjectLifetimeDefault)
418420
{
419421
match default {
420-
None => mywrite!(w, "n"),
421-
Some(ty::ObjectLifetimeDefault::Ambiguous) => mywrite!(w, "a"),
422-
Some(ty::ObjectLifetimeDefault::Specific(r)) => {
422+
ty::ObjectLifetimeDefault::Ambiguous => mywrite!(w, "a"),
423+
ty::ObjectLifetimeDefault::BaseDefault => mywrite!(w, "b"),
424+
ty::ObjectLifetimeDefault::Specific(r) => {
423425
mywrite!(w, "s");
424426
enc_region(w, cx, r);
425427
}

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/combine.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub struct CombineFields<'a, 'tcx: 'a> {
5656
pub infcx: &'a InferCtxt<'a, 'tcx>,
5757
pub a_is_expected: bool,
5858
pub trace: TypeTrace<'tcx>,
59+
pub cause: Option<ty_relate::Cause>,
5960
}
6061

6162
pub fn super_combine_tys<'a,'tcx:'a,R>(infcx: &InferCtxt<'a, 'tcx>,

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: 5 additions & 3 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 = ty::terr_regions_does_not_outlive(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"
@@ -1854,7 +1856,7 @@ impl LifeGiver {
18541856
}
18551857

18561858
fn give_lifetime(&self) -> ast::Lifetime {
1857-
let mut lifetime;
1859+
let lifetime;
18581860
loop {
18591861
let mut s = String::from("'");
18601862
s.push_str(&num_to_string(self.counter.get()));

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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ pub enum SubregionOrigin<'tcx> {
194194
// Arose from a subtyping relation
195195
Subtype(TypeTrace<'tcx>),
196196

197+
// Arose from a subtyping relation
198+
DefaultExistentialBound(TypeTrace<'tcx>),
199+
197200
// Stack-allocated closures cannot outlive innermost loop
198201
// or function so as to ensure we only require finite stack
199202
InfStackClosure(Span),
@@ -658,7 +661,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
658661
-> CombineFields<'a, 'tcx> {
659662
CombineFields {infcx: self,
660663
a_is_expected: a_is_expected,
661-
trace: trace}
664+
trace: trace,
665+
cause: None}
662666
}
663667

664668
// public so that it can be used from the rustc_driver unit tests
@@ -1464,6 +1468,7 @@ impl<'tcx> SubregionOrigin<'tcx> {
14641468
pub fn span(&self) -> Span {
14651469
match *self {
14661470
Subtype(ref a) => a.span(),
1471+
DefaultExistentialBound(ref a) => a.span(),
14671472
InfStackClosure(a) => a,
14681473
InvokeClosure(a) => a,
14691474
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
@@ -1358,9 +1358,56 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
13581358
}
13591359
}
13601360

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

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

0 commit comments

Comments
 (0)