Skip to content

Commit eaa346c

Browse files
committed
---
yaml --- r: 274998 b: refs/heads/stable c: 2051a92 h: refs/heads/master
1 parent 08a93c8 commit eaa346c

File tree

45 files changed

+712
-442
lines changed

Some content is hidden

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

45 files changed

+712
-442
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: f890772383c900f9a409a4105df13b6630ebb1f5
32+
refs/heads/stable: 2051a92134bae8b4c5fd3fdeab32c78b7bd74014
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/libcollections/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#![feature(nonzero)]
4646
#![feature(num_bits_bytes)]
4747
#![feature(pattern)]
48+
#![feature(placement_in)]
49+
#![feature(placement_new_protocol)]
4850
#![feature(shared)]
4951
#![feature(slice_bytes)]
5052
#![feature(slice_patterns)]

branches/stable/src/libcollections/linked_list.rs

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121

2222
#![stable(feature = "rust1", since = "1.0.0")]
2323

24-
use alloc::boxed::Box;
24+
use alloc::boxed::{Box, IntermediateBox};
2525
use core::cmp::Ordering;
2626
use core::fmt;
2727
use core::hash::{Hasher, Hash};
2828
use core::iter::FromIterator;
2929
use core::mem;
30-
use core::ptr::Shared;
30+
use core::ops::{BoxPlace, InPlace, Place, Placer};
31+
use core::ptr::{self, Shared};
3132

3233
/// A doubly-linked list.
3334
#[stable(feature = "rust1", since = "1.0.0")]
@@ -660,6 +661,56 @@ impl<T> LinkedList<T> {
660661

661662
second_part
662663
}
664+
665+
/// Returns a place for insertion at the front of the list.
666+
///
667+
/// Using this method with placement syntax is equivalent to [`push_front`]
668+
/// (#method.push_front), but may be more efficient.
669+
///
670+
/// # Examples
671+
///
672+
/// ```
673+
/// #![feature(collection_placement)]
674+
/// #![feature(placement_in_syntax)]
675+
///
676+
/// use std::collections::LinkedList;
677+
///
678+
/// let mut list = LinkedList::new();
679+
/// list.front_place() <- 2;
680+
/// list.front_place() <- 4;
681+
/// assert!(list.iter().eq(&[4, 2]));
682+
/// ```
683+
#[unstable(feature = "collection_placement",
684+
reason = "method name and placement protocol are subject to change",
685+
issue = "30172")]
686+
pub fn front_place(&mut self) -> FrontPlace<T> {
687+
FrontPlace { list: self, node: IntermediateBox::make_place() }
688+
}
689+
690+
/// Returns a place for insertion at the back of the list.
691+
///
692+
/// Using this method with placement syntax is equivalent to [`push_back`](#method.push_back),
693+
/// but may be more efficient.
694+
///
695+
/// # Examples
696+
///
697+
/// ```
698+
/// #![feature(collection_placement)]
699+
/// #![feature(placement_in_syntax)]
700+
///
701+
/// use std::collections::LinkedList;
702+
///
703+
/// let mut list = LinkedList::new();
704+
/// list.back_place() <- 2;
705+
/// list.back_place() <- 4;
706+
/// assert!(list.iter().eq(&[2, 4]));
707+
/// ```
708+
#[unstable(feature = "collection_placement",
709+
reason = "method name and placement protocol are subject to change",
710+
issue = "30172")]
711+
pub fn back_place(&mut self) -> BackPlace<T> {
712+
BackPlace { list: self, node: IntermediateBox::make_place() }
713+
}
663714
}
664715

665716
#[stable(feature = "rust1", since = "1.0.0")]
@@ -984,6 +1035,101 @@ impl<A: Hash> Hash for LinkedList<A> {
9841035
}
9851036
}
9861037

1038+
unsafe fn finalize<T>(node: IntermediateBox<Node<T>>) -> Box<Node<T>> {
1039+
let mut node = node.finalize();
1040+
ptr::write(&mut node.next, None);
1041+
ptr::write(&mut node.prev, Rawlink::none());
1042+
node
1043+
}
1044+
1045+
/// A place for insertion at the front of a `LinkedList`.
1046+
///
1047+
/// See [`LinkedList::front_place`](struct.LinkedList.html#method.front_place) for details.
1048+
#[must_use = "places do nothing unless written to with `<-` syntax"]
1049+
#[unstable(feature = "collection_placement",
1050+
reason = "struct name and placement protocol are subject to change",
1051+
issue = "30172")]
1052+
pub struct FrontPlace<'a, T: 'a> {
1053+
list: &'a mut LinkedList<T>,
1054+
node: IntermediateBox<Node<T>>,
1055+
}
1056+
1057+
#[unstable(feature = "collection_placement",
1058+
reason = "placement protocol is subject to change",
1059+
issue = "30172")]
1060+
impl<'a, T> Placer<T> for FrontPlace<'a, T> {
1061+
type Place = Self;
1062+
1063+
fn make_place(self) -> Self {
1064+
self
1065+
}
1066+
}
1067+
1068+
#[unstable(feature = "collection_placement",
1069+
reason = "placement protocol is subject to change",
1070+
issue = "30172")]
1071+
impl<'a, T> Place<T> for FrontPlace<'a, T> {
1072+
fn pointer(&mut self) -> *mut T {
1073+
unsafe { &mut (*self.node.pointer()).value }
1074+
}
1075+
}
1076+
1077+
#[unstable(feature = "collection_placement",
1078+
reason = "placement protocol is subject to change",
1079+
issue = "30172")]
1080+
impl<'a, T> InPlace<T> for FrontPlace<'a, T> {
1081+
type Owner = ();
1082+
1083+
unsafe fn finalize(self) {
1084+
let FrontPlace { list, node } = self;
1085+
list.push_front_node(finalize(node));
1086+
}
1087+
}
1088+
1089+
/// A place for insertion at the back of a `LinkedList`.
1090+
///
1091+
/// See [`LinkedList::back_place`](struct.LinkedList.html#method.back_place) for details.
1092+
#[must_use = "places do nothing unless written to with `<-` syntax"]
1093+
#[unstable(feature = "collection_placement",
1094+
reason = "struct name and placement protocol are subject to change",
1095+
issue = "30172")]
1096+
pub struct BackPlace<'a, T: 'a> {
1097+
list: &'a mut LinkedList<T>,
1098+
node: IntermediateBox<Node<T>>,
1099+
}
1100+
1101+
#[unstable(feature = "collection_placement",
1102+
reason = "placement protocol is subject to change",
1103+
issue = "30172")]
1104+
impl<'a, T> Placer<T> for BackPlace<'a, T> {
1105+
type Place = Self;
1106+
1107+
fn make_place(self) -> Self {
1108+
self
1109+
}
1110+
}
1111+
1112+
#[unstable(feature = "collection_placement",
1113+
reason = "placement protocol is subject to change",
1114+
issue = "30172")]
1115+
impl<'a, T> Place<T> for BackPlace<'a, T> {
1116+
fn pointer(&mut self) -> *mut T {
1117+
unsafe { &mut (*self.node.pointer()).value }
1118+
}
1119+
}
1120+
1121+
#[unstable(feature = "collection_placement",
1122+
reason = "placement protocol is subject to change",
1123+
issue = "30172")]
1124+
impl<'a, T> InPlace<T> for BackPlace<'a, T> {
1125+
type Owner = ();
1126+
1127+
unsafe fn finalize(self) {
1128+
let BackPlace { list, node } = self;
1129+
list.push_back_node(finalize(node));
1130+
}
1131+
}
1132+
9871133
// Ensure that `LinkedList` and its read-only iterators are covariant in their type parameters.
9881134
#[allow(dead_code)]
9891135
fn assert_covariance() {

branches/stable/src/librustc/front/map/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
262262

263263
fn visit_pat(&mut self, pat: &'ast Pat) {
264264
let maybe_binding = match pat.node {
265-
PatIdent(_, id, _) => Some(id.node),
265+
PatKind::Ident(_, id, _) => Some(id.node),
266266
_ => None
267267
};
268268

branches/stable/src/librustc/front/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ impl<'ast> Map<'ast> {
615615
NodeVariant(v) => PathName(v.node.name),
616616
NodeLifetime(lt) => PathName(lt.name),
617617
NodeTyParam(tp) => PathName(tp.name),
618-
NodeLocal(&Pat { node: PatIdent(_,l,_), .. }) => {
618+
NodeLocal(&Pat { node: PatKind::Ident(_,l,_), .. }) => {
619619
PathName(l.node.name)
620620
},
621621
_ => panic!("no path elem for {:?}", node)

branches/stable/src/librustc/middle/cfg/construct.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use middle::ty;
1616
use syntax::ast;
1717
use syntax::ptr::P;
1818

19-
use rustc_front::hir;
19+
use rustc_front::hir::{self, PatKind};
2020

2121
struct CFGBuilder<'a, 'tcx: 'a> {
2222
tcx: &'a ty::ctxt<'tcx>,
@@ -99,35 +99,36 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
9999

100100
fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
101101
match pat.node {
102-
hir::PatIdent(_, _, None) |
103-
hir::PatEnum(_, None) |
104-
hir::PatQPath(..) |
105-
hir::PatLit(..) |
106-
hir::PatRange(..) |
107-
hir::PatWild => {
102+
PatKind::Ident(_, _, None) |
103+
PatKind::TupleStruct(_, None) |
104+
PatKind::Path(..) |
105+
PatKind::QPath(..) |
106+
PatKind::Lit(..) |
107+
PatKind::Range(..) |
108+
PatKind::Wild => {
108109
self.add_ast_node(pat.id, &[pred])
109110
}
110111

111-
hir::PatBox(ref subpat) |
112-
hir::PatRegion(ref subpat, _) |
113-
hir::PatIdent(_, _, Some(ref subpat)) => {
112+
PatKind::Box(ref subpat) |
113+
PatKind::Ref(ref subpat, _) |
114+
PatKind::Ident(_, _, Some(ref subpat)) => {
114115
let subpat_exit = self.pat(&subpat, pred);
115116
self.add_ast_node(pat.id, &[subpat_exit])
116117
}
117118

118-
hir::PatEnum(_, Some(ref subpats)) |
119-
hir::PatTup(ref subpats) => {
119+
PatKind::TupleStruct(_, Some(ref subpats)) |
120+
PatKind::Tup(ref subpats) => {
120121
let pats_exit = self.pats_all(subpats.iter(), pred);
121122
self.add_ast_node(pat.id, &[pats_exit])
122123
}
123124

124-
hir::PatStruct(_, ref subpats, _) => {
125+
PatKind::Struct(_, ref subpats, _) => {
125126
let pats_exit =
126127
self.pats_all(subpats.iter().map(|f| &f.node.pat), pred);
127128
self.add_ast_node(pat.id, &[pats_exit])
128129
}
129130

130-
hir::PatVec(ref pre, ref vec, ref post) => {
131+
PatKind::Vec(ref pre, ref vec, ref post) => {
131132
let pre_exit = self.pats_all(pre.iter(), pred);
132133
let vec_exit = self.pats_all(vec.iter(), pre_exit);
133134
let post_exit = self.pats_all(post.iter(), vec_exit);

0 commit comments

Comments
 (0)