Skip to content

Commit f08679e

Browse files
committed
---
yaml --- r: 234995 b: refs/heads/stable c: d8680f6 h: refs/heads/master i: 234993: 8346b17 234991: db45d97 v: v3
1 parent ee9d352 commit f08679e

File tree

18 files changed

+329
-338
lines changed

18 files changed

+329
-338
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: 27975c49a643d0b2f8cbcd7854931c4c9a8c5dbf
32+
refs/heads/stable: d8680f6534ef1ffcb1affda7a1e1ea2bfc4749c2
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/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)

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

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use std::rc::Rc;
4444
use syntax::abi;
4545
use syntax::ast;
4646
use syntax::owned_slice::OwnedSlice;
47-
use util::nodemap::{FnvHashMap, FnvHashSet};
47+
use util::nodemap::FnvHashMap;
4848

4949
///////////////////////////////////////////////////////////////////////////
5050
// Two generic traits
@@ -783,51 +783,38 @@ impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where
783783
784784
pub struct RegionFolder<'a, 'tcx: 'a> {
785785
tcx: &'a ty::ctxt<'tcx>,
786-
skipped_regions: &'a mut bool,
787786
current_depth: u32,
788787
fld_r: &'a mut (FnMut(ty::Region, u32) -> ty::Region + 'a),
789788
}
790789

791790
impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
792-
pub fn new<F>(tcx: &'a ty::ctxt<'tcx>,
793-
skipped_regions: &'a mut bool,
794-
fld_r: &'a mut F) -> RegionFolder<'a, 'tcx>
791+
pub fn new<F>(tcx: &'a ty::ctxt<'tcx>, fld_r: &'a mut F) -> RegionFolder<'a, 'tcx>
795792
where F : FnMut(ty::Region, u32) -> ty::Region
796793
{
797794
RegionFolder {
798795
tcx: tcx,
799-
skipped_regions: skipped_regions,
800796
current_depth: 1,
801797
fld_r: fld_r,
802798
}
803799
}
804800
}
805801

806-
/// Collects the free and escaping regions in `value` into `region_set`. Returns
807-
/// whether any late-bound regions were skipped
808-
pub fn collect_regions<'tcx,T>(tcx: &ty::ctxt<'tcx>,
809-
value: &T,
810-
region_set: &mut FnvHashSet<ty::Region>) -> bool
802+
pub fn collect_regions<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> Vec<ty::Region>
811803
where T : TypeFoldable<'tcx>
812804
{
813-
let mut have_bound_regions = false;
814-
fold_regions(tcx, value, &mut have_bound_regions,
815-
|r, d| { region_set.insert(r.from_depth(d)); r });
816-
have_bound_regions
805+
let mut vec = Vec::new();
806+
fold_regions(tcx, value, |r, _| { vec.push(r); r });
807+
vec
817808
}
818809

819-
/// Folds the escaping and free regions in `value` using `f`, and
820-
/// sets `skipped_regions` to true if any late-bound region was found
821-
/// and skipped.
822810
pub fn fold_regions<'tcx,T,F>(tcx: &ty::ctxt<'tcx>,
823811
value: &T,
824-
skipped_regions: &mut bool,
825812
mut f: F)
826813
-> T
827814
where F : FnMut(ty::Region, u32) -> ty::Region,
828815
T : TypeFoldable<'tcx>,
829816
{
830-
value.fold_with(&mut RegionFolder::new(tcx, skipped_regions, &mut f))
817+
value.fold_with(&mut RegionFolder::new(tcx, &mut f))
831818
}
832819

833820
impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx>
@@ -847,7 +834,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx>
847834
ty::ReLateBound(debruijn, _) if debruijn.depth < self.current_depth => {
848835
debug!("RegionFolder.fold_region({:?}) skipped bound region (current depth={})",
849836
r, self.current_depth);
850-
*self.skipped_regions = true;
851837
r
852838
}
853839
_ => {
@@ -1003,7 +989,7 @@ pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>>(tcx: &ty::ctxt<'tcx>,
1003989
debug!("shift_regions(value={:?}, amount={})",
1004990
value, amount);
1005991

1006-
value.fold_with(&mut RegionFolder::new(tcx, &mut false, &mut |region, _current_depth| {
992+
value.fold_with(&mut RegionFolder::new(tcx, &mut |region, _current_depth| {
1007993
shift_region(region, amount)
1008994
}))
1009995
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
//! An iterator over the type substructure.
12-
//! WARNING: this does not keep track of the region depth.
1312
1413
use middle::ty::{self, Ty};
1514
use std::iter::Iterator;

branches/stable/src/librustc_lint/builtin.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,13 +1973,8 @@ impl LintPass for UnconditionalRecursion {
19731973
fn_id: ast::NodeId,
19741974
_: ast::Ident,
19751975
id: ast::NodeId) -> bool {
1976-
match tcx.map.get(id) {
1977-
ast_map::NodeExpr(&ast::Expr { node: ast::ExprCall(ref callee, _), .. }) => {
1978-
tcx.def_map.borrow().get(&callee.id)
1979-
.map_or(false, |def| def.def_id() == local_def(fn_id))
1980-
}
1981-
_ => false
1982-
}
1976+
tcx.def_map.borrow().get(&id)
1977+
.map_or(false, |def| def.def_id() == local_def(fn_id))
19831978
}
19841979

19851980
// check if the method call `id` refers to method `method_id`
@@ -2007,15 +2002,6 @@ impl LintPass for UnconditionalRecursion {
20072002
// method instead.
20082003
ty::MethodTypeParam(
20092004
ty::MethodParam { ref trait_ref, method_num, impl_def_id: None, }) => {
2010-
2011-
let on_self = m.substs.self_ty().map_or(false, |t| t.is_self());
2012-
if !on_self {
2013-
// we can only be recurring in a default
2014-
// method if we're being called literally
2015-
// on the `Self` type.
2016-
return false
2017-
}
2018-
20192005
tcx.trait_item(trait_ref.def_id, method_num).def_id()
20202006
}
20212007

0 commit comments

Comments
 (0)