Skip to content

Commit 2f51347

Browse files
author
Nick Hamann
committed
---
yaml --- r: 219763 b: refs/heads/snap-stage3 c: c9c5ea7 h: refs/heads/master i: 219761: 61418b4 219759: c4caf62 v: v3
1 parent 185e86b commit 2f51347

Some content is hidden

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

66 files changed

+686
-737
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: c044791d80ea0dc5c4b57b6030a67b69f8510239
3-
refs/heads/snap-stage3: dd8fee0ae6dd6304a7ad2d5fc9cd9eda27af33f8
3+
refs/heads/snap-stage3: c9c5ea7c138af6c57da0da53517a4b5f6ccf4915
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/snap-stage3/src/libcollections/bit.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![deprecated(reason = "BitVec and BitSet have been migrated to cargo as bit-vec and bit-set",
12-
since = "1.3.0")]
13-
#![unstable(feature = "collections", reason = "deprecated")]
14-
#![allow(deprecated)]
15-
1611
// FIXME(Gankro): BitVec and BitSet are very tightly coupled. Ideally (for
1712
// maintenance), they should be in separate files/modules, with BitSet only
1813
// using BitVec's public API. This will be hard for performance though, because

branches/snap-stage3/src/libcollections/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ extern crate alloc;
7777
#[cfg(test)] extern crate test;
7878

7979
pub use binary_heap::BinaryHeap;
80-
#[allow(deprecated)]
8180
pub use bit_vec::BitVec;
82-
#[allow(deprecated)]
8381
pub use bit_set::BitSet;
8482
pub use btree_map::BTreeMap;
8583
pub use btree_set::BTreeSet;
@@ -113,13 +111,11 @@ pub mod vec_map;
113111

114112
#[unstable(feature = "bitvec", reason = "RFC 509")]
115113
pub mod bit_vec {
116-
#![allow(deprecated)]
117114
pub use bit::{BitVec, Iter};
118115
}
119116

120117
#[unstable(feature = "bitset", reason = "RFC 509")]
121118
pub mod bit_set {
122-
#![allow(deprecated)]
123119
pub use bit::{BitSet, Union, Intersection, Difference, SymmetricDifference};
124120
pub use bit::SetIter as Iter;
125121
}

branches/snap-stage3/src/librustc/ast_map/mod.rs

Lines changed: 29 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub enum Node<'ast> {
121121
NodeLifetime(&'ast Lifetime),
122122
}
123123

124-
/// Represents an entry and its parent NodeID.
124+
/// Represents an entry and its parent Node ID
125125
/// The odd layout is to bring down the total size.
126126
#[derive(Copy, Debug)]
127127
enum MapEntry<'ast> {
@@ -179,7 +179,7 @@ impl<'ast> MapEntry<'ast> {
179179
}
180180
}
181181

182-
fn parent_node(self) -> Option<NodeId> {
182+
fn parent(self) -> Option<NodeId> {
183183
Some(match self {
184184
EntryItem(id, _) => id,
185185
EntryForeignItem(id, _) => id,
@@ -283,88 +283,10 @@ impl<'ast> Map<'ast> {
283283
self.find_entry(id).and_then(|x| x.to_node())
284284
}
285285

286-
/// Similar to get_parent, returns the parent node id or id if there is no
287-
/// parent.
288-
/// This function returns the immediate parent in the AST, whereas get_parent
289-
/// returns the enclosing item. Note that this might not be the actual parent
290-
/// node in the AST - some kinds of nodes are not in the map and these will
291-
/// never appear as the parent_node. So you can always walk the parent_nodes
292-
/// from a node to the root of the ast (unless you get the same id back here
293-
/// that can happen if the id is not in the map itself or is just weird).
294-
pub fn get_parent_node(&self, id: NodeId) -> NodeId {
295-
self.find_entry(id).and_then(|x| x.parent_node()).unwrap_or(id)
296-
}
297-
298-
/// If there is some error when walking the parents (e.g., a node does not
299-
/// have a parent in the map or a node can't be found), then we return the
300-
/// last good node id we found. Note that reaching the crate root (id == 0),
301-
/// is not an error, since items in the crate module have the crate root as
302-
/// parent.
303-
fn walk_parent_nodes<F>(&self, start_id: NodeId, found: F) -> Result<NodeId, NodeId>
304-
where F: Fn(&Node<'ast>) -> bool
305-
{
306-
let mut id = start_id;
307-
loop {
308-
let parent_node = self.get_parent_node(id);
309-
if parent_node == 0 {
310-
return Ok(0);
311-
}
312-
if parent_node == id {
313-
return Err(id);
314-
}
315-
316-
let node = self.find_entry(parent_node);
317-
if node.is_none() {
318-
return Err(id);
319-
}
320-
let node = node.unwrap().to_node();
321-
match node {
322-
Some(ref node) => {
323-
if found(node) {
324-
return Ok(parent_node);
325-
}
326-
}
327-
None => {
328-
return Err(parent_node);
329-
}
330-
}
331-
id = parent_node;
332-
}
333-
}
334-
335-
/// Retrieve the NodeId for `id`'s parent item, or `id` itself if no
336-
/// parent item is in this map. The "parent item" is the closest parent node
337-
/// in the AST which is recorded by the map and is an item, either an item
338-
/// in a module, trait, or impl.
286+
/// Retrieve the parent NodeId for `id`, or `id` itself if no
287+
/// parent is registered in this map.
339288
pub fn get_parent(&self, id: NodeId) -> NodeId {
340-
match self.walk_parent_nodes(id, |node| match *node {
341-
NodeItem(_) |
342-
NodeForeignItem(_) |
343-
NodeTraitItem(_) |
344-
NodeImplItem(_) => true,
345-
_ => false,
346-
}) {
347-
Ok(id) => id,
348-
Err(id) => id,
349-
}
350-
}
351-
352-
/// Returns the nearest enclosing scope. A scope is an item or block.
353-
/// FIXME it is not clear to me that all items qualify as scopes - statics
354-
/// and associated types probably shouldn't, for example. Behaviour in this
355-
/// regard should be expected to be highly unstable.
356-
pub fn get_enclosing_scope(&self, id: NodeId) -> Option<NodeId> {
357-
match self.walk_parent_nodes(id, |node| match *node {
358-
NodeItem(_) |
359-
NodeForeignItem(_) |
360-
NodeTraitItem(_) |
361-
NodeImplItem(_) |
362-
NodeBlock(_) => true,
363-
_ => false,
364-
}) {
365-
Ok(id) => Some(id),
366-
Err(_) => None,
367-
}
289+
self.find_entry(id).and_then(|x| x.parent()).unwrap_or(id)
368290
}
369291

370292
pub fn get_parent_did(&self, id: NodeId) -> DefId {
@@ -668,15 +590,15 @@ impl<'a, 'ast> Iterator for NodesMatchingSuffix<'a, 'ast> {
668590
return None;
669591
}
670592
self.idx += 1;
671-
let name = match self.map.find_entry(idx) {
672-
Some(EntryItem(_, n)) => n.name(),
673-
Some(EntryForeignItem(_, n))=> n.name(),
674-
Some(EntryTraitItem(_, n)) => n.name(),
675-
Some(EntryImplItem(_, n)) => n.name(),
676-
Some(EntryVariant(_, n)) => n.name(),
593+
let (p, name) = match self.map.find_entry(idx) {
594+
Some(EntryItem(p, n)) => (p, n.name()),
595+
Some(EntryForeignItem(p, n))=> (p, n.name()),
596+
Some(EntryTraitItem(p, n)) => (p, n.name()),
597+
Some(EntryImplItem(p, n)) => (p, n.name()),
598+
Some(EntryVariant(p, n)) => (p, n.name()),
677599
_ => continue,
678600
};
679-
if self.matches_names(self.map.get_parent(idx), name) {
601+
if self.matches_names(p, name) {
680602
return Some(idx)
681603
}
682604
}
@@ -725,7 +647,8 @@ impl<F: FoldOps> Folder for IdAndSpanUpdater<F> {
725647
/// A Visitor that walks over an AST and collects Node's into an AST Map.
726648
struct NodeCollector<'ast> {
727649
map: Vec<MapEntry<'ast>>,
728-
parent_node: NodeId,
650+
/// The node in which we are currently mapping (an item or a method).
651+
parent: NodeId
729652
}
730653

731654
impl<'ast> NodeCollector<'ast> {
@@ -739,7 +662,7 @@ impl<'ast> NodeCollector<'ast> {
739662
}
740663

741664
fn insert(&mut self, id: NodeId, node: Node<'ast>) {
742-
let entry = MapEntry::from_node(self.parent_node, node);
665+
let entry = MapEntry::from_node(self.parent, node);
743666
self.insert_entry(id, entry);
744667
}
745668

@@ -753,10 +676,8 @@ impl<'ast> NodeCollector<'ast> {
753676
impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
754677
fn visit_item(&mut self, i: &'ast Item) {
755678
self.insert(i.id, NodeItem(i));
756-
757-
let parent_node = self.parent_node;
758-
self.parent_node = i.id;
759-
679+
let parent = self.parent;
680+
self.parent = i.id;
760681
match i.node {
761682
ItemImpl(_, _, _, _, _, ref impl_items) => {
762683
for ii in impl_items {
@@ -806,23 +727,21 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
806727
_ => {}
807728
}
808729
visit::walk_item(self, i);
809-
self.parent_node = parent_node;
730+
self.parent = parent;
810731
}
811732

812733
fn visit_trait_item(&mut self, ti: &'ast TraitItem) {
813-
let parent_node = self.parent_node;
814-
self.parent_node = ti.id;
734+
let parent = self.parent;
735+
self.parent = ti.id;
815736
visit::walk_trait_item(self, ti);
816-
self.parent_node = parent_node;
737+
self.parent = parent;
817738
}
818739

819740
fn visit_impl_item(&mut self, ii: &'ast ImplItem) {
820-
let parent_node = self.parent_node;
821-
self.parent_node = ii.id;
822-
741+
let parent = self.parent;
742+
self.parent = ii.id;
823743
visit::walk_impl_item(self, ii);
824-
825-
self.parent_node = parent_node;
744+
self.parent = parent;
826745
}
827746

828747
fn visit_pat(&mut self, pat: &'ast Pat) {
@@ -831,58 +750,38 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
831750
PatIdent(..) => NodeLocal(pat),
832751
_ => NodePat(pat)
833752
});
834-
835-
let parent_node = self.parent_node;
836-
self.parent_node = pat.id;
837753
visit::walk_pat(self, pat);
838-
self.parent_node = parent_node;
839754
}
840755

841756
fn visit_expr(&mut self, expr: &'ast Expr) {
842757
self.insert(expr.id, NodeExpr(expr));
843-
let parent_node = self.parent_node;
844-
self.parent_node = expr.id;
845758
visit::walk_expr(self, expr);
846-
self.parent_node = parent_node;
847759
}
848760

849761
fn visit_stmt(&mut self, stmt: &'ast Stmt) {
850-
let id = ast_util::stmt_id(stmt);
851-
self.insert(id, NodeStmt(stmt));
852-
let parent_node = self.parent_node;
853-
self.parent_node = id;
762+
self.insert(ast_util::stmt_id(stmt), NodeStmt(stmt));
854763
visit::walk_stmt(self, stmt);
855-
self.parent_node = parent_node;
856764
}
857765

858766
fn visit_fn(&mut self, fk: visit::FnKind<'ast>, fd: &'ast FnDecl,
859-
b: &'ast Block, s: Span, id: NodeId) {
860-
let parent_node = self.parent_node;
861-
self.parent_node = id;
767+
b: &'ast Block, s: Span, _: NodeId) {
862768
self.visit_fn_decl(fd);
863769
visit::walk_fn(self, fk, fd, b, s);
864-
self.parent_node = parent_node;
865770
}
866771

867772
fn visit_ty(&mut self, ty: &'ast Ty) {
868-
let parent_node = self.parent_node;
869-
self.parent_node = ty.id;
870773
match ty.node {
871774
TyBareFn(ref fd) => {
872775
self.visit_fn_decl(&*fd.decl);
873776
}
874777
_ => {}
875778
}
876779
visit::walk_ty(self, ty);
877-
self.parent_node = parent_node;
878780
}
879781

880782
fn visit_block(&mut self, block: &'ast Block) {
881783
self.insert(block.id, NodeBlock(block));
882-
let parent_node = self.parent_node;
883-
self.parent_node = block.id;
884784
visit::walk_block(self, block);
885-
self.parent_node = parent_node;
886785
}
887786

888787
fn visit_lifetime_ref(&mut self, lifetime: &'ast Lifetime) {
@@ -910,7 +809,7 @@ pub fn map_crate<'ast, F: FoldOps>(forest: &'ast mut Forest, fold_ops: F) -> Map
910809

911810
let mut collector = NodeCollector {
912811
map: vec![],
913-
parent_node: CRATE_NODE_ID,
812+
parent: CRATE_NODE_ID
914813
};
915814
collector.insert_entry(CRATE_NODE_ID, RootCrate);
916815
visit::walk_crate(&mut collector, &forest.krate);
@@ -965,11 +864,11 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
965864
ii: ii
966865
});
967866

968-
let ii_parent_id = fld.new_id(DUMMY_NODE_ID);
969867
let mut collector = NodeCollector {
970868
map: mem::replace(&mut *map.map.borrow_mut(), vec![]),
971-
parent_node: ii_parent_id,
869+
parent: fld.new_id(DUMMY_NODE_ID)
972870
};
871+
let ii_parent_id = collector.parent;
973872
collector.insert_entry(ii_parent_id, RootInlinedParent(ii_parent));
974873
visit::walk_inlined_item(&mut collector, &ii_parent.ii);
975874

branches/snap-stage3/src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
#![feature(vec_push_all)]
6363
#![feature(wrapping)]
6464
#![feature(cell_extras)]
65-
#![feature(page_size)]
6665
#![cfg_attr(test, feature(test))]
6766

6867
#![allow(trivial_casts)]

branches/snap-stage3/src/librustc/middle/astencode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use metadata::tydecode::{RegionParameter, ClosureSource};
2626
use metadata::tyencode;
2727
use middle::cast;
2828
use middle::check_const::ConstQualif;
29+
use middle::mem_categorization::Typer;
2930
use middle::privacy::{AllPublic, LastMod};
3031
use middle::subst;
3132
use middle::subst::VecPerParamSpace;

branches/snap-stage3/src/librustc/middle/check_const.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,14 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
110110
}
111111

112112
fn with_euv<'b, F, R>(&'b mut self, item_id: Option<ast::NodeId>, f: F) -> R where
113-
F: for<'t> FnOnce(&mut euv::ExprUseVisitor<'b, 't, 'b, 'tcx>) -> R,
113+
F: for<'t> FnOnce(&mut euv::ExprUseVisitor<'b, 't, 'tcx,
114+
ty::ParameterEnvironment<'a, 'tcx>>) -> R,
114115
{
115116
let param_env = match item_id {
116117
Some(item_id) => ty::ParameterEnvironment::for_item(self.tcx, item_id),
117118
None => self.tcx.empty_parameter_environment()
118119
};
119-
120-
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env), false);
121-
122-
f(&mut euv::ExprUseVisitor::new(self, &infcx))
120+
f(&mut euv::ExprUseVisitor::new(self, &param_env))
123121
}
124122

125123
fn global_expr(&mut self, mode: Mode, expr: &ast::Expr) -> ConstQualif {
@@ -285,11 +283,11 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
285283

286284
fn check_static_type(&self, e: &ast::Expr) {
287285
let ty = self.tcx.node_id_to_type(e.id);
288-
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None, false);
286+
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
287+
let mut fulfill_cx = traits::FulfillmentContext::new(false);
289288
let cause = traits::ObligationCause::new(e.span, e.id, traits::SharedStatic);
290-
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
291289
fulfill_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
292-
match fulfill_cx.select_all_or_error(&infcx) {
290+
match fulfill_cx.select_all_or_error(&infcx, &infcx.parameter_environment) {
293291
Ok(()) => { },
294292
Err(ref errors) => {
295293
traits::report_fulfillment_errors(&infcx, errors);

0 commit comments

Comments
 (0)