Skip to content

Commit 7c6b0f8

Browse files
committed
---
yaml --- r: 233852 b: refs/heads/beta c: 6a69bdd h: refs/heads/master v: v3
1 parent d348275 commit 7c6b0f8

File tree

31 files changed

+326
-170
lines changed

31 files changed

+326
-170
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: c01eb691d03f9d89aa5160beed4295d1b777ebf5
26+
refs/heads/beta: 6a69bdd9e92051d7efb9babb509027e522cc4f4c
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/libcollectionstest/str.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,37 @@ fn test_bytes_revator() {
833833
}
834834
}
835835

836+
#[test]
837+
fn test_bytesator_nth() {
838+
let s = "ศไทย中华Việt Nam";
839+
let v = [
840+
224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
841+
184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
842+
109
843+
];
844+
845+
let mut b = s.bytes();
846+
assert_eq!(b.nth(2).unwrap(), v[2]);
847+
assert_eq!(b.nth(10).unwrap(), v[10]);
848+
assert_eq!(b.nth(200), None);
849+
}
850+
851+
#[test]
852+
fn test_bytesator_count() {
853+
let s = "ศไทย中华Việt Nam";
854+
855+
let b = s.bytes();
856+
assert_eq!(b.count(), 28)
857+
}
858+
859+
#[test]
860+
fn test_bytesator_last() {
861+
let s = "ศไทย中华Việt Nam";
862+
863+
let b = s.bytes();
864+
assert_eq!(b.last().unwrap(), 109)
865+
}
866+
836867
#[test]
837868
fn test_char_indicesator() {
838869
let s = "ศไทย中华Việt Nam";

branches/beta/src/libcore/str/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,21 @@ impl<'a> Iterator for Bytes<'a> {
411411
fn size_hint(&self) -> (usize, Option<usize>) {
412412
self.0.size_hint()
413413
}
414+
415+
#[inline]
416+
fn count(self) -> usize {
417+
self.0.count()
418+
}
419+
420+
#[inline]
421+
fn last(self) -> Option<Self::Item> {
422+
self.0.last()
423+
}
424+
425+
#[inline]
426+
fn nth(&mut self, n: usize) -> Option<Self::Item> {
427+
self.0.nth(n)
428+
}
414429
}
415430

416431
#[stable(feature = "rust1", since = "1.0.0")]

branches/beta/src/liblibc/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3614,6 +3614,7 @@ pub mod consts {
36143614
pub mod posix08 {
36153615
use types::os::arch::c95::c_int;
36163616
pub const O_CLOEXEC: c_int = 0x80000;
3617+
pub const F_DUPFD_CLOEXEC: c_int = 1030;
36173618
}
36183619
#[cfg(any(target_arch = "arm",
36193620
target_arch = "aarch64",
@@ -4285,11 +4286,13 @@ pub mod consts {
42854286
pub mod posix08 {
42864287
use types::os::arch::c95::c_int;
42874288
pub const O_CLOEXEC: c_int = 0x100000;
4289+
pub const F_DUPFD_CLOEXEC: c_int = 17;
42884290
}
42894291
#[cfg(target_os = "dragonfly")]
42904292
pub mod posix08 {
42914293
use types::os::arch::c95::c_int;
42924294
pub const O_CLOEXEC: c_int = 0x20000;
4295+
pub const F_DUPFD_CLOEXEC: c_int = 17;
42934296
}
42944297
pub mod bsd44 {
42954298
use types::os::arch::c95::c_int;
@@ -4657,7 +4660,6 @@ pub mod consts {
46574660
pub const F_GETLK : c_int = 7;
46584661
pub const F_SETLK : c_int = 8;
46594662
pub const F_SETLKW : c_int = 9;
4660-
pub const F_DUPFD_CLOEXEC : c_int = 10;
46614663

46624664
pub const SIGTRAP : c_int = 5;
46634665
pub const SIG_IGN: size_t = 1;
@@ -4739,11 +4741,13 @@ pub mod consts {
47394741
pub mod posix08 {
47404742
use types::os::arch::c95::c_int;
47414743
pub const O_CLOEXEC: c_int = 0x10000;
4744+
pub const F_DUPFD_CLOEXEC: c_int = 10;
47424745
}
47434746
#[cfg(target_os = "netbsd")]
47444747
pub mod posix08 {
47454748
use types::os::arch::c95::c_int;
47464749
pub const O_CLOEXEC: c_int = 0x400000;
4750+
pub const F_DUPFD_CLOEXEC: c_int = 12;
47474751
}
47484752
pub mod bsd44 {
47494753
use types::os::arch::c95::c_int;
@@ -5186,6 +5190,7 @@ pub mod consts {
51865190
pub mod posix08 {
51875191
use types::os::arch::c95::c_int;
51885192
pub const O_CLOEXEC: c_int = 0x1000000;
5193+
pub const F_DUPFD_CLOEXEC: c_int = 67;
51895194
}
51905195
pub mod bsd44 {
51915196
use types::os::arch::c95::c_int;

branches/beta/src/librustc/ast_map/blocks.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use syntax::abi;
2828
use syntax::ast::{Block, FnDecl, NodeId};
2929
use syntax::ast;
3030
use syntax::codemap::Span;
31-
use syntax::visit;
31+
use syntax::visit::FnKind;
3232

3333
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
3434
/// and a body (as well as a NodeId, a span, etc).
@@ -50,7 +50,7 @@ pub trait MaybeFnLike { fn is_fn_like(&self) -> bool; }
5050
pub struct FnParts<'a> {
5151
pub decl: &'a FnDecl,
5252
pub body: &'a Block,
53-
pub kind: visit::FnKind<'a>,
53+
pub kind: FnKind<'a>,
5454
pub span: Span,
5555
pub id: NodeId,
5656
}
@@ -186,15 +186,15 @@ impl<'a> FnLikeNode<'a> {
186186
|c: ClosureParts| c.id)
187187
}
188188

189-
pub fn kind(self) -> visit::FnKind<'a> {
190-
let item = |p: ItemFnParts<'a>| -> visit::FnKind<'a> {
191-
visit::FkItemFn(p.ident, p.generics, p.unsafety, p.constness, p.abi, p.vis)
189+
pub fn kind(self) -> FnKind<'a> {
190+
let item = |p: ItemFnParts<'a>| -> FnKind<'a> {
191+
FnKind::ItemFn(p.ident, p.generics, p.unsafety, p.constness, p.abi, p.vis)
192192
};
193193
let closure = |_: ClosureParts| {
194-
visit::FkClosure
194+
FnKind::Closure
195195
};
196196
let method = |_, ident, sig: &'a ast::MethodSig, vis, _, _| {
197-
visit::FkMethod(ident, sig, vis)
197+
FnKind::Method(ident, sig, vis)
198198
};
199199
self.handle(item, method, closure)
200200
}

branches/beta/src/librustc/lint/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use syntax::codemap::Span;
4343
use syntax::visit::{Visitor, FnKind};
4444
use syntax::parse::token::InternedString;
4545
use syntax::{ast, ast_util, visit};
46+
use syntax::diagnostic;
4647

4748
/// Information about the registered lints.
4849
///
@@ -141,7 +142,7 @@ impl LintStore {
141142
match (sess, from_plugin) {
142143
// We load builtin lints first, so a duplicate is a compiler bug.
143144
// Use early_error when handling -W help with no crate.
144-
(None, _) => early_error(&msg[..]),
145+
(None, _) => early_error(diagnostic::Auto, &msg[..]),
145146
(Some(sess), false) => sess.bug(&msg[..]),
146147

147148
// A duplicate name from a plugin is a user error.
@@ -166,7 +167,7 @@ impl LintStore {
166167
match (sess, from_plugin) {
167168
// We load builtin lints first, so a duplicate is a compiler bug.
168169
// Use early_error when handling -W help with no crate.
169-
(None, _) => early_error(&msg[..]),
170+
(None, _) => early_error(diagnostic::Auto, &msg[..]),
170171
(Some(sess), false) => sess.bug(&msg[..]),
171172

172173
// A duplicate name from a plugin is a user error.

branches/beta/src/librustc/middle/check_const.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use util::nodemap::NodeMap;
3838

3939
use syntax::ast;
4040
use syntax::codemap::Span;
41-
use syntax::visit::{self, Visitor};
41+
use syntax::visit::{self, FnKind, Visitor};
4242

4343
use std::collections::hash_map::Entry;
4444
use std::cmp::Ordering;
@@ -142,7 +142,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
142142
}
143143

144144
fn fn_like(&mut self,
145-
fk: visit::FnKind,
145+
fk: FnKind,
146146
fd: &ast::FnDecl,
147147
b: &ast::Block,
148148
s: Span,
@@ -157,10 +157,10 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
157157
}
158158

159159
let mode = match fk {
160-
visit::FkItemFn(_, _, _, ast::Constness::Const, _, _) => {
160+
FnKind::ItemFn(_, _, _, ast::Constness::Const, _, _) => {
161161
Mode::ConstFn
162162
}
163-
visit::FkMethod(_, m, _) => {
163+
FnKind::Method(_, m, _) => {
164164
if m.constness == ast::Constness::Const {
165165
Mode::ConstFn
166166
} else {
@@ -352,7 +352,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
352352
}
353353

354354
fn visit_fn(&mut self,
355-
fk: visit::FnKind<'v>,
355+
fk: FnKind<'v>,
356356
fd: &'v ast::FnDecl,
357357
b: &'v ast::Block,
358358
s: Span,

branches/beta/src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
10071007
sp: Span,
10081008
fn_id: NodeId) {
10091009
match kind {
1010-
visit::FkClosure => {}
1010+
FnKind::Closure => {}
10111011
_ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id),
10121012
}
10131013

branches/beta/src/librustc/middle/const_eval.rs

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

11-
#![allow(non_camel_case_types)]
11+
//#![allow(non_camel_case_types)]
1212

1313
use self::ConstVal::*;
1414
use self::ErrKind::*;
@@ -26,10 +26,10 @@ use middle::astconv_util::ast_ty_to_prim_ty;
2626
use util::num::ToPrimitive;
2727

2828
use syntax::ast::{self, Expr};
29-
use syntax::codemap::Span;
29+
use syntax::codemap::{self, Span};
3030
use syntax::parse::token::InternedString;
3131
use syntax::ptr::P;
32-
use syntax::{codemap, visit};
32+
use syntax::visit::FnKind;
3333

3434
use std::borrow::{Cow, IntoCow};
3535
use std::num::wrapping::OverflowingOps;
@@ -246,10 +246,10 @@ pub fn lookup_const_fn_by_id<'tcx>(tcx: &ty::ctxt<'tcx>, def_id: DefId)
246246
};
247247

248248
match fn_like.kind() {
249-
visit::FkItemFn(_, _, _, ast::Constness::Const, _, _) => {
249+
FnKind::ItemFn(_, _, _, ast::Constness::Const, _, _) => {
250250
Some(fn_like)
251251
}
252-
visit::FkMethod(_, m, _) => {
252+
FnKind::Method(_, m, _) => {
253253
if m.constness == ast::Constness::Const {
254254
Some(fn_like)
255255
} else {

branches/beta/src/librustc/middle/effect.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use middle::ty::MethodCall;
1919
use syntax::ast;
2020
use syntax::codemap::Span;
2121
use syntax::visit;
22-
use syntax::visit::Visitor;
22+
use syntax::visit::{FnKind, Visitor};
2323

2424
#[derive(Copy, Clone)]
2525
struct UnsafeContext {
@@ -75,13 +75,13 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
7575
}
7676

7777
impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
78-
fn visit_fn(&mut self, fn_kind: visit::FnKind<'v>, fn_decl: &'v ast::FnDecl,
78+
fn visit_fn(&mut self, fn_kind: FnKind<'v>, fn_decl: &'v ast::FnDecl,
7979
block: &'v ast::Block, span: Span, _: ast::NodeId) {
8080

8181
let (is_item_fn, is_unsafe_fn) = match fn_kind {
82-
visit::FkItemFn(_, _, unsafety, _, _, _) =>
82+
FnKind::ItemFn(_, _, unsafety, _, _, _) =>
8383
(true, unsafety == ast::Unsafety::Unsafe),
84-
visit::FkMethod(_, sig, _) =>
84+
FnKind::Method(_, sig, _) =>
8585
(true, sig.unsafety == ast::Unsafety::Unsafe),
8686
_ => (false, false),
8787
};

branches/beta/src/librustc/middle/intrinsicck.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::fmt;
1919
use syntax::abi::RustIntrinsic;
2020
use syntax::ast;
2121
use syntax::codemap::Span;
22-
use syntax::visit::Visitor;
22+
use syntax::visit::{FnKind, Visitor};
2323
use syntax::visit;
2424

2525
pub fn check_crate(tcx: &ctxt) {
@@ -216,16 +216,16 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
216216
}
217217

218218
impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
219-
fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
219+
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v ast::FnDecl,
220220
b: &'v ast::Block, s: Span, id: ast::NodeId) {
221221
match fk {
222-
visit::FkItemFn(..) | visit::FkMethod(..) => {
222+
FnKind::ItemFn(..) | FnKind::Method(..) => {
223223
let param_env = ty::ParameterEnvironment::for_item(self.tcx, id);
224224
self.param_envs.push(param_env);
225225
visit::walk_fn(self, fk, fd, b, s);
226226
self.param_envs.pop();
227227
}
228-
visit::FkClosure(..) => {
228+
FnKind::Closure(..) => {
229229
visit::walk_fn(self, fk, fd, b, s);
230230
}
231231
}

branches/beta/src/librustc/middle/resolve_lifetime.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use syntax::codemap::Span;
3030
use syntax::parse::token::special_idents;
3131
use syntax::print::pprust::lifetime_to_string;
3232
use syntax::visit;
33-
use syntax::visit::Visitor;
33+
use syntax::visit::{FnKind, Visitor};
3434
use util::nodemap::NodeMap;
3535

3636
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
@@ -173,20 +173,20 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
173173
replace(&mut self.labels_in_fn, saved);
174174
}
175175

176-
fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
176+
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v ast::FnDecl,
177177
b: &'v ast::Block, s: Span, _: ast::NodeId) {
178178
match fk {
179-
visit::FkItemFn(_, generics, _, _, _, _) => {
179+
FnKind::ItemFn(_, generics, _, _, _, _) => {
180180
self.visit_early_late(subst::FnSpace, generics, |this| {
181181
this.walk_fn(fk, fd, b, s)
182182
})
183183
}
184-
visit::FkMethod(_, sig, _) => {
184+
FnKind::Method(_, sig, _) => {
185185
self.visit_early_late(subst::FnSpace, &sig.generics, |this| {
186186
this.walk_fn(fk, fd, b, s)
187187
})
188188
}
189-
visit::FkClosure(..) => {
189+
FnKind::Closure(..) => {
190190
self.walk_fn(fk, fd, b, s)
191191
}
192192
}
@@ -470,21 +470,21 @@ impl<'a> LifetimeContext<'a> {
470470
// labels of the function body and swaps them in before visiting
471471
// the function body itself.
472472
fn walk_fn<'b>(&mut self,
473-
fk: visit::FnKind,
473+
fk: FnKind,
474474
fd: &ast::FnDecl,
475475
fb: &'b ast::Block,
476476
_span: Span) {
477477
match fk {
478-
visit::FkItemFn(_, generics, _, _, _, _) => {
478+
FnKind::ItemFn(_, generics, _, _, _, _) => {
479479
visit::walk_fn_decl(self, fd);
480480
self.visit_generics(generics);
481481
}
482-
visit::FkMethod(_, sig, _) => {
482+
FnKind::Method(_, sig, _) => {
483483
visit::walk_fn_decl(self, fd);
484484
self.visit_generics(&sig.generics);
485485
self.visit_explicit_self(&sig.explicit_self);
486486
}
487-
visit::FkClosure(..) => {
487+
FnKind::Closure(..) => {
488488
visit::walk_fn_decl(self, fd);
489489
}
490490
}

0 commit comments

Comments
 (0)