Skip to content

Commit bc0ae06

Browse files
committed
---
yaml --- r: 235003 b: refs/heads/stable c: e834c03 h: refs/heads/master i: 235001: 767f189 234999: 2c8a418 v: v3
1 parent 5469fa0 commit bc0ae06

File tree

23 files changed

+332
-428
lines changed

23 files changed

+332
-428
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 0b703787ab23f004fe9f635971933c6e9a9c6683
32+
refs/heads/stable: e834c0348fe094da4f32594278fee6b0446cb41c
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
% The Rust Pointer Guide
1+
% The (old) Rust Pointer Guide
22

3-
This content has been removed, with no direct replacement. Rust only
4-
has two built-in pointer types now,
5-
[references](book/references-and-borrowing.html) and [raw
6-
pointers](book/raw-pointers.html). Older Rusts had many more pointer
7-
types, they’re gone now.
3+
This content has moved into
4+
[the Rust Programming Language book](book/pointers.html).

branches/stable/src/doc/trpl/academic-research.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Recommended for inspiration and a better understanding of Rust's background.
1212
* [Macros that work together](https://www.cs.utah.edu/plt/publications/jfp12-draft-fcdf.pdf)
1313
* [Traits: composable units of behavior](http://scg.unibe.ch/archive/papers/Scha03aTraits.pdf)
1414
* [Alias burying](http://www.cs.uwm.edu/faculty/boyland/papers/unique-preprint.ps) - We tried something similar and abandoned it.
15-
* [External uniqueness is unique enough](http://www.cs.uu.nl/research/techreps/UU-CS-2002-048.html)
15+
* [External uniqueness is unique enough](http://www.computingscience.nl/research/techreps/repo/CS-2002/2002-048.pdf)
1616
* [Uniqueness and Reference Immutability for Safe Parallelism](https://research.microsoft.com/pubs/170528/msr-tr-2012-79.pdf)
1717
* [Region Based Memory Management](http://www.cs.ucla.edu/~palsberg/tba/papers/tofte-talpin-iandc97.pdf)
1818

@@ -26,10 +26,10 @@ Recommended for inspiration and a better understanding of Rust's background.
2626
* [Dynamic circular work stealing deque](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.170.1097&rep=rep1&type=pdf) - The Chase/Lev deque
2727
* [Work-first and help-first scheduling policies for async-finish task parallelism](http://www.cs.rice.edu/%7Eyguo/pubs/PID824943.pdf) - More general than fully-strict work stealing
2828
* [A Java fork/join calamity](http://www.coopsoft.com/ar/CalamityArticle.html) - critique of Java's fork/join library, particularly its application of work stealing to non-strict computation
29-
* [Scheduling techniques for concurrent systems](http://www.stanford.edu/~ouster/cgi-bin/papers/coscheduling.pdf)
29+
* [Scheduling techniques for concurrent systems](http://www.ece.rutgers.edu/%7Eparashar/Classes/ece572-papers/05/ps-ousterhout.pdf)
3030
* [Contention aware scheduling](http://www.blagodurov.net/files/a8-blagodurov.pdf)
3131
* [Balanced work stealing for time-sharing multicores](http://www.cse.ohio-state.edu/hpcs/WWW/HTML/publications/papers/TR-12-1.pdf)
32-
* [Three layer cake for shared-memory programming](http://dl.acm.org/citation.cfm?id=1953616&dl=ACM&coll=DL&CFID=524387192&CFTOKEN=44362705)
32+
* [Three layer cake](http://www.upcrc.illinois.edu/workshops/paraplop10/papers/paraplop10_submission_8.pdf)
3333
* [Non-blocking steal-half work queues](http://www.cs.bgu.ac.il/%7Ehendlerd/papers/p280-hendler.pdf)
3434
* [Reagents: expressing and composing fine-grained concurrency](http://www.mpi-sws.org/~turon/reagents.pdf)
3535
* [Algorithms for scalable synchronization of shared-memory multiprocessors](https://www.cs.rochester.edu/u/scott/papers/1991_TOCS_synch.pdf)

branches/stable/src/libcore/mem.rs

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -365,48 +365,11 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
365365

366366
/// Disposes of a value.
367367
///
368-
/// While this does call the argument's implementation of `Drop`, it will not
369-
/// release any borrows, as borrows are based on lexical scope.
368+
/// This function can be used to destroy any value by allowing `drop` to take ownership of its
369+
/// argument.
370370
///
371371
/// # Examples
372372
///
373-
/// Basic usage:
374-
///
375-
/// ```
376-
/// let v = vec![1, 2, 3];
377-
///
378-
/// drop(v); // explicitly drop the vector
379-
/// ```
380-
///
381-
/// Borrows are based on lexical scope, so this produces an error:
382-
///
383-
/// ```ignore
384-
/// let mut v = vec![1, 2, 3];
385-
/// let x = &v[0];
386-
///
387-
/// drop(x); // explicitly drop the reference, but the borrow still exists
388-
///
389-
/// v.push(4); // error: cannot borrow `v` as mutable because it is also
390-
/// // borrowed as immutable
391-
/// ```
392-
///
393-
/// An inner scope is needed to fix this:
394-
///
395-
/// ```
396-
/// let mut v = vec![1, 2, 3];
397-
///
398-
/// {
399-
/// let x = &v[0];
400-
///
401-
/// drop(x); // this is now redundant, as `x` is going out of scope anyway
402-
/// }
403-
///
404-
/// v.push(4); // no problems
405-
/// ```
406-
///
407-
/// Since `RefCell` enforces the borrow rules at runtime, `drop()` can
408-
/// seemingly release a borrow of one:
409-
///
410373
/// ```
411374
/// use std::cell::RefCell;
412375
///

branches/stable/src/librustc/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ Ensure that the expressions given can be evaluated as the desired integer type.
357357
See the FFI section of the Reference for more information about using a custom
358358
integer type:
359359
360-
http://doc.rust-lang.org/reference.html#ffi-attributes
360+
https://doc.rust-lang.org/reference.html#ffi-attributes
361361
"##,
362362

363363
E0109: r##"
@@ -408,7 +408,7 @@ fn main() {
408408
}
409409
```
410410
411-
See also http://doc.rust-lang.org/book/unsafe.html
411+
See also https://doc.rust-lang.org/book/unsafe.html
412412
"##,
413413

414414
E0137: r##"

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ fn fold_regions_in<'tcx, T, F>(tcx: &ty::ctxt<'tcx>,
359359
where T: TypeFoldable<'tcx>,
360360
F: FnMut(ty::Region, ty::DebruijnIndex) -> ty::Region,
361361
{
362-
ty_fold::fold_regions(tcx, unbound_value, &mut false, |region, current_depth| {
362+
unbound_value.fold_with(&mut ty_fold::RegionFolder::new(tcx, &mut |region, current_depth| {
363363
// we should only be encountering "escaping" late-bound regions here,
364364
// because the ones at the current level should have been replaced
365365
// with fresh variables
@@ -369,7 +369,7 @@ fn fold_regions_in<'tcx, T, F>(tcx: &ty::ctxt<'tcx>,
369369
});
370370

371371
fldr(region, ty::DebruijnIndex::new(current_depth))
372-
})
372+
}))
373373
}
374374

375375
impl<'a,'tcx> InferCtxtExt for InferCtxt<'a,'tcx> {
@@ -437,10 +437,11 @@ impl<'a,'tcx> InferCtxtExt for InferCtxt<'a,'tcx> {
437437
let escaping_types =
438438
self.type_variables.borrow().types_escaping_snapshot(&snapshot.type_snapshot);
439439

440-
let mut escaping_region_vars = FnvHashSet();
441-
for ty in &escaping_types {
442-
ty_fold::collect_regions(self.tcx, ty, &mut escaping_region_vars);
443-
}
440+
let escaping_region_vars: FnvHashSet<_> =
441+
escaping_types
442+
.iter()
443+
.flat_map(|&t| ty_fold::collect_regions(self.tcx, &t))
444+
.collect();
444445

445446
region_vars.retain(|&region_vid| {
446447
let r = ty::ReInfer(ty::ReVar(region_vid));
@@ -648,7 +649,7 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
648649
// binder is that we encountered in `value`. The caller is
649650
// responsible for ensuring that (a) `value` contains at least one
650651
// binder and (b) that binder is the one we want to use.
651-
let result = ty_fold::fold_regions(infcx.tcx, &value, &mut false, |r, current_depth| {
652+
let result = ty_fold::fold_regions(infcx.tcx, &value, |r, current_depth| {
652653
match inv_skol_map.get(&r) {
653654
None => r,
654655
Some(br) => {

branches/stable/src/librustc/middle/traits/fulfill.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -421,18 +421,16 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
421421
// regions. If there are, we will call this obligation an
422422
// error. Eventually we should be able to support some
423423
// cases here, I imagine (e.g., `for<'a> int : 'a`).
424-
match selcx.tcx().no_late_bound_regions(binder) {
425-
None => {
426-
errors.push(
427-
FulfillmentError::new(
428-
obligation.clone(),
429-
CodeSelectionError(Unimplemented)))
430-
}
431-
Some(ty::OutlivesPredicate(t_a, r_b)) => {
432-
register_region_obligation(t_a, r_b,
433-
obligation.cause.clone(),
434-
region_obligations);
435-
}
424+
if selcx.tcx().count_late_bound_regions(binder) != 0 {
425+
errors.push(
426+
FulfillmentError::new(
427+
obligation.clone(),
428+
CodeSelectionError(Unimplemented)));
429+
} else {
430+
let ty::OutlivesPredicate(t_a, r_b) = binder.0;
431+
register_region_obligation(t_a, r_b,
432+
obligation.cause.clone(),
433+
region_obligations);
436434
}
437435
true
438436
}
@@ -503,3 +501,5 @@ impl<'tcx> FulfilledPredicates<'tcx> {
503501
!self.set.insert(p.clone())
504502
}
505503
}
504+
505+

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

Lines changed: 70 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,16 +1713,6 @@ impl Region {
17131713
_ => false,
17141714
}
17151715
}
1716-
1717-
/// Returns the depth of `self` from the (1-based) binding level `depth`
1718-
pub fn from_depth(&self, depth: u32) -> Region {
1719-
match *self {
1720-
ty::ReLateBound(debruijn, r) => ty::ReLateBound(DebruijnIndex {
1721-
depth: debruijn.depth - (depth - 1)
1722-
}, r),
1723-
r => r
1724-
}
1725-
}
17261716
}
17271717

17281718
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
@@ -6793,6 +6783,60 @@ pub enum ExplicitSelfCategory {
67936783
ByBoxExplicitSelfCategory,
67946784
}
67956785

6786+
impl<'tcx> TyS<'tcx> {
6787+
/// Pushes all the lifetimes in the given type onto the given list. A
6788+
/// "lifetime in a type" is a lifetime specified by a reference or a lifetime
6789+
/// in a list of type substitutions. This does *not* traverse into nominal
6790+
/// types, nor does it resolve fictitious types.
6791+
pub fn accumulate_lifetimes_in_type(&self, accumulator: &mut Vec<ty::Region>) {
6792+
for ty in self.walk() {
6793+
match ty.sty {
6794+
TyRef(region, _) => {
6795+
accumulator.push(*region)
6796+
}
6797+
TyTrait(ref t) => {
6798+
accumulator.push_all(t.principal.0.substs.regions().as_slice());
6799+
}
6800+
TyEnum(_, substs) |
6801+
TyStruct(_, substs) => {
6802+
accum_substs(accumulator, substs);
6803+
}
6804+
TyClosure(_, substs) => {
6805+
accum_substs(accumulator, substs);
6806+
}
6807+
TyBool |
6808+
TyChar |
6809+
TyInt(_) |
6810+
TyUint(_) |
6811+
TyFloat(_) |
6812+
TyBox(_) |
6813+
TyStr |
6814+
TyArray(_, _) |
6815+
TySlice(_) |
6816+
TyRawPtr(_) |
6817+
TyBareFn(..) |
6818+
TyTuple(_) |
6819+
TyProjection(_) |
6820+
TyParam(_) |
6821+
TyInfer(_) |
6822+
TyError => {
6823+
}
6824+
}
6825+
}
6826+
6827+
fn accum_substs(accumulator: &mut Vec<Region>, substs: &Substs) {
6828+
match substs.regions {
6829+
subst::ErasedRegions => {}
6830+
subst::NonerasedRegions(ref regions) => {
6831+
for region in regions {
6832+
accumulator.push(*region)
6833+
}
6834+
}
6835+
}
6836+
}
6837+
}
6838+
}
6839+
67966840
/// A free variable referred to in a function.
67976841
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
67986842
pub struct Freevar {
@@ -6853,15 +6897,27 @@ impl<'tcx> ctxt<'tcx> {
68536897
|br| ty::ReFree(ty::FreeRegion{scope: all_outlive_scope, bound_region: br})).0
68546898
}
68556899

6900+
pub fn count_late_bound_regions<T>(&self, value: &Binder<T>) -> usize
6901+
where T : TypeFoldable<'tcx>
6902+
{
6903+
let (_, skol_map) = ty_fold::replace_late_bound_regions(self, value, |_| ty::ReStatic);
6904+
skol_map.len()
6905+
}
6906+
6907+
pub fn binds_late_bound_regions<T>(&self, value: &Binder<T>) -> bool
6908+
where T : TypeFoldable<'tcx>
6909+
{
6910+
self.count_late_bound_regions(value) > 0
6911+
}
6912+
68566913
/// Flattens two binding levels into one. So `for<'a> for<'b> Foo`
68576914
/// becomes `for<'a,'b> Foo`.
68586915
pub fn flatten_late_bound_regions<T>(&self, bound2_value: &Binder<Binder<T>>)
68596916
-> Binder<T>
68606917
where T: TypeFoldable<'tcx>
68616918
{
68626919
let bound0_value = bound2_value.skip_binder().skip_binder();
6863-
let value = ty_fold::fold_regions(self, bound0_value, &mut false,
6864-
|region, current_depth| {
6920+
let value = ty_fold::fold_regions(self, bound0_value, |region, current_depth| {
68656921
match region {
68666922
ty::ReLateBound(debruijn, br) if debruijn.depth >= current_depth => {
68676923
// should be true if no escaping regions from bound2_value
@@ -6877,9 +6933,9 @@ impl<'tcx> ctxt<'tcx> {
68776933
}
68786934

68796935
pub fn no_late_bound_regions<T>(&self, value: &Binder<T>) -> Option<T>
6880-
where T : TypeFoldable<'tcx> + RegionEscape
6936+
where T : TypeFoldable<'tcx>
68816937
{
6882-
if value.0.has_escaping_regions() {
6938+
if self.binds_late_bound_regions(value) {
68836939
None
68846940
} else {
68856941
Some(value.0.clone())
@@ -7039,19 +7095,6 @@ impl<'tcx> RegionEscape for Substs<'tcx> {
70397095
}
70407096
}
70417097

7042-
impl<T:RegionEscape> RegionEscape for Vec<T> {
7043-
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
7044-
self.iter().any(|t| t.has_regions_escaping_depth(depth))
7045-
}
7046-
}
7047-
7048-
impl<'tcx> RegionEscape for FnSig<'tcx> {
7049-
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
7050-
self.inputs.has_regions_escaping_depth(depth) ||
7051-
self.output.has_regions_escaping_depth(depth)
7052-
}
7053-
}
7054-
70557098
impl<'tcx,T:RegionEscape> RegionEscape for VecPerParamSpace<T> {
70567099
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
70577100
self.iter_enumerated().any(|(space, _, t)| {
@@ -7124,15 +7167,6 @@ impl<'tcx,T:RegionEscape> RegionEscape for Binder<T> {
71247167
}
71257168
}
71267169

7127-
impl<'tcx> RegionEscape for FnOutput<'tcx> {
7128-
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
7129-
match *self {
7130-
FnConverging(t) => t.has_regions_escaping_depth(depth),
7131-
FnDiverging => false
7132-
}
7133-
}
7134-
}
7135-
71367170
impl<'tcx> RegionEscape for EquatePredicate<'tcx> {
71377171
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
71387172
self.0.has_regions_escaping_depth(depth) || self.1.has_regions_escaping_depth(depth)

0 commit comments

Comments
 (0)