Skip to content

Commit 4ca4492

Browse files
committed
---
yaml --- r: 166487 b: refs/heads/snap-stage3 c: c43efee h: refs/heads/master i: 166485: b9eb16e 166483: 59f5a29 166479: 68927cd v: v3
1 parent 6522fb0 commit 4ca4492

Some content is hidden

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

52 files changed

+1239
-249
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 18842f89f084c52588fe7cffe07f87bf6e90796a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 86d85794789e7a4557e3e92c402f57ae05b35e9e
4+
refs/heads/snap-stage3: c43efee6def9a4a4e943feef0236d3e17b3f581d
55
refs/heads/try: f5d619caf9f32458680fae55526b99582ca682dd
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/mk/cfg/x86_64-unknown-dragonfly.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ CFG_LIB_NAME_x86_64-unknown-dragonfly=lib$(1).so
77
CFG_STATIC_LIB_NAME_x86_64-unknown-dragonfly=lib$(1).a
88
CFG_LIB_GLOB_x86_64-unknown-dragonfly=lib$(1)-*.so
99
CFG_LIB_DSYM_GLOB_x86_64-unknown-dragonfly=$(1)-*.dylib.dSYM
10-
CFG_JEMALLOC_CFLAGS_x86_64-unknown-dragonfly := -I/usr/include -I/usr/local/include $(CFLAGS)
11-
CFG_GCCISH_CFLAGS_x86_64-unknown-dragonfly := -Wall -Werror -g -fPIC -I/usr/include -I/usr/local/include $(CFLAGS)
12-
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-dragonfly := -shared -fPIC -g -pthread -lrt
10+
CFG_JEMALLOC_CFLAGS_x86_64-unknown-dragonfly := -m64 -I/usr/include -I/usr/local/include $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_x86_64-unknown-dragonfly := -Wall -Werror -g -fPIC -m64 -I/usr/include -I/usr/local/include $(CFLAGS)
12+
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-dragonfly := -shared -fPIC -g -pthread -lrt -m64
1313
CFG_GCCISH_DEF_FLAG_x86_64-unknown-dragonfly := -Wl,--export-dynamic,--dynamic-list=
1414
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-dragonfly := -Wl,-whole-archive
1515
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-dragonfly := -Wl,-no-whole-archive

branches/snap-stage3/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ names, and invoked through a consistent syntax: `name!(...)`. Examples include:
640640
* `stringify!` : pretty-print the Rust expression given as an argument
641641
* `include!` : include the Rust expression in the given file
642642
* `include_str!` : include the contents of the given file as a string
643-
* `include_bin!` : include the contents of the given file as a binary blob
643+
* `include_bytes!` : include the contents of the given file as a binary blob
644644
* `error!`, `warn!`, `info!`, `debug!` : provide diagnostic information.
645645

646646
All of the above extensions are expressions with values.

branches/snap-stage3/src/etc/snapshot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def scrub(b):
3737
"macos": ["bin/rustc"],
3838
"winnt": ["bin/rustc.exe"],
3939
"freebsd": ["bin/rustc"],
40+
"dragonfly": ["bin/rustc"],
4041
}
4142

4243
winnt_runtime_deps_32 = ["libgcc_s_dw2-1.dll",
@@ -86,6 +87,8 @@ def get_kernel(triple):
8687
return "macos"
8788
if os_name == "freebsd":
8889
return "freebsd"
90+
if os_name == "dragonfly":
91+
return "dragonfly"
8992
return "linux"
9093

9194
def get_cpu(triple):

branches/snap-stage3/src/libcore/iter.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,6 +2542,64 @@ impl<A: Int> Iterator<A> for RangeStepInclusive<A> {
25422542
}
25432543
}
25442544

2545+
2546+
/// The `Step` trait identifies objects which can be stepped over in both
2547+
/// directions. The `steps_between` function provides a way to
2548+
/// compare two Step objects (it could be provided using `step()` and `Ord`,
2549+
/// but the implementation would be so inefficient as to be useless).
2550+
#[unstable = "Trait is unstable."]
2551+
pub trait Step: Ord {
2552+
/// Change self to the next object.
2553+
fn step(&mut self);
2554+
/// Change self to the previous object.
2555+
fn step_back(&mut self);
2556+
/// The steps_between two step objects.
2557+
/// a should always be less than b, so the result should never be negative.
2558+
/// Return None if it is not possible to calculate steps_between without
2559+
/// overflow.
2560+
fn steps_between(a: &Self, b: &Self) -> Option<uint>;
2561+
}
2562+
2563+
macro_rules! step_impl {
2564+
($($t:ty)*) => ($(
2565+
#[unstable = "Trait is unstable."]
2566+
impl Step for $t {
2567+
#[inline]
2568+
fn step(&mut self) { *self += 1; }
2569+
#[inline]
2570+
fn step_back(&mut self) { *self -= 1; }
2571+
#[inline]
2572+
fn steps_between(a: &$t, b: &$t) -> Option<uint> {
2573+
debug_assert!(a < b);
2574+
Some((*a - *b) as uint)
2575+
}
2576+
}
2577+
)*)
2578+
}
2579+
2580+
macro_rules! step_impl_no_between {
2581+
($($t:ty)*) => ($(
2582+
#[unstable = "Trait is unstable."]
2583+
impl Step for $t {
2584+
#[inline]
2585+
fn step(&mut self) { *self += 1; }
2586+
#[inline]
2587+
fn step_back(&mut self) { *self -= 1; }
2588+
#[inline]
2589+
fn steps_between(_a: &$t, _b: &$t) -> Option<uint> {
2590+
None
2591+
}
2592+
}
2593+
)*)
2594+
}
2595+
2596+
step_impl!(uint u8 u16 u32 int i8 i16 i32);
2597+
#[cfg(target_word_size = "64")]
2598+
step_impl!(u64 i64);
2599+
#[cfg(target_word_size = "32")]
2600+
step_impl_no_between!(u64 i64);
2601+
2602+
25452603
/// An iterator that repeats an element endlessly
25462604
#[deriving(Clone)]
25472605
#[stable]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#![allow(unknown_features, raw_pointer_deriving)]
6060
#![feature(globs, intrinsics, lang_items, macro_rules, phase)]
6161
#![feature(simd, unsafe_destructor, slicing_syntax)]
62-
#![feature(default_type_params, unboxed_closures)]
62+
#![feature(default_type_params, unboxed_closures, associated_types)]
6363
#![deny(missing_docs)]
6464

6565
mod macros;

branches/snap-stage3/src/libcore/ops.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@
5151
//! See the documentation for each trait for a minimum implementation that prints
5252
//! something to the screen.
5353
54+
use clone::Clone;
55+
use iter::{Step, Iterator,DoubleEndedIterator,ExactSizeIterator};
5456
use kinds::Sized;
57+
use option::Option::{mod, Some, None};
5558

5659
/// The `Drop` trait is used to run some code when a value goes out of scope. This
5760
/// is sometimes called a 'destructor'.
@@ -833,6 +836,79 @@ pub trait SliceMut<Sized? Idx, Sized? Result> for Sized? {
833836
fn slice_or_fail_mut<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
834837
}
835838

839+
840+
/// An unbounded range.
841+
#[deriving(Copy)]
842+
#[lang="full_range"]
843+
pub struct FullRange;
844+
845+
/// A (half-open) range which is bounded at both ends.
846+
#[deriving(Copy)]
847+
#[lang="range"]
848+
pub struct Range<Idx> {
849+
/// The lower bound of the range (inclusive).
850+
pub start: Idx,
851+
/// The upper bound of the range (exclusive).
852+
pub end: Idx,
853+
}
854+
855+
// FIXME(#19391) needs a snapshot
856+
//impl<Idx: Clone + Step<T=uint>> Iterator<Idx> for Range<Idx> {
857+
impl<Idx: Clone + Step> Iterator<Idx> for Range<Idx> {
858+
#[inline]
859+
fn next(&mut self) -> Option<Idx> {
860+
if self.start < self.end {
861+
let result = self.start.clone();
862+
self.start.step();
863+
return Some(result);
864+
}
865+
866+
return None;
867+
}
868+
869+
#[inline]
870+
fn size_hint(&self) -> (uint, Option<uint>) {
871+
if let Some(hint) = Step::steps_between(&self.end, &self.start) {
872+
(hint, Some(hint))
873+
} else {
874+
(0, None)
875+
}
876+
}
877+
}
878+
879+
impl<Idx: Clone + Step> DoubleEndedIterator<Idx> for Range<Idx> {
880+
#[inline]
881+
fn next_back(&mut self) -> Option<Idx> {
882+
if self.start < self.end {
883+
self.end.step_back();
884+
return Some(self.end.clone());
885+
}
886+
887+
return None;
888+
}
889+
}
890+
891+
impl<Idx: Clone + Step> ExactSizeIterator<Idx> for Range<Idx> {}
892+
893+
/// A range which is only bounded below.
894+
#[deriving(Copy)]
895+
#[lang="range_from"]
896+
pub struct RangeFrom<Idx> {
897+
/// The lower bound of the range (inclusive).
898+
pub start: Idx,
899+
}
900+
901+
impl<Idx: Clone + Step> Iterator<Idx> for RangeFrom<Idx> {
902+
#[inline]
903+
fn next(&mut self) -> Option<Idx> {
904+
// Deliberately overflow so we loop forever.
905+
let result = self.start.clone();
906+
self.start.step();
907+
return Some(result);
908+
}
909+
}
910+
911+
836912
/// The `Deref` trait is used to specify the functionality of dereferencing
837913
/// operations like `*v`.
838914
///

branches/snap-stage3/src/libcoretest/ops.rs

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

1111
use test::Bencher;
12+
use core::ops::{Range, FullRange, RangeFrom};
1213

1314
// Overhead of dtors
1415

@@ -27,3 +28,35 @@ fn alloc_obj_with_dtor(b: &mut Bencher) {
2728
HasDtor { _x : 10 };
2829
})
2930
}
31+
32+
// Test the Range structs without the syntactic sugar.
33+
34+
#[test]
35+
fn test_range() {
36+
let r = Range { start: 2u, end: 10 };
37+
let mut count = 0u;
38+
for (i, ri) in r.enumerate() {
39+
assert!(ri == i + 2);
40+
assert!(ri >= 2u && ri < 10u);
41+
count += 1;
42+
}
43+
assert!(count == 8);
44+
}
45+
46+
#[test]
47+
fn test_range_from() {
48+
let r = RangeFrom { start: 2u };
49+
let mut count = 0u;
50+
for (i, ri) in r.take(10).enumerate() {
51+
assert!(ri == i + 2);
52+
assert!(ri >= 2u && ri < 12u);
53+
count += 1;
54+
}
55+
assert!(count == 10);
56+
}
57+
58+
#[test]
59+
fn test_full_range() {
60+
// Not much to test.
61+
let _ = FullRange;
62+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ pub mod types {
10951095
pub type sighandler_t = size_t;
10961096
}
10971097
pub mod bsd44 {
1098+
use types::common::c95::{c_void};
10981099
use types::os::arch::c95::{c_char, c_int, c_uint};
10991100

11001101
pub type socklen_t = u32;
@@ -1167,6 +1168,17 @@ pub mod types {
11671168
pub sun_family: sa_family_t,
11681169
pub sun_path: [c_char, ..104]
11691170
}
1171+
#[repr(C)]
1172+
#[deriving(Copy)] pub struct ifaddrs {
1173+
pub ifa_next: *mut ifaddrs,
1174+
pub ifa_name: *mut c_char,
1175+
pub ifa_flags: c_uint,
1176+
pub ifa_addr: *mut sockaddr,
1177+
pub ifa_netmask: *mut sockaddr,
1178+
pub ifa_dstaddr: *mut sockaddr,
1179+
pub ifa_data: *mut c_void
1180+
}
1181+
11701182
}
11711183
}
11721184

branches/snap-stage3/src/librustc/middle/cfg/construct.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
439439
start.iter().chain(end.iter()).map(|x| &**x))
440440
}
441441

442+
ast::ExprRange(ref start, ref end) => {
443+
let fields = Some(&**start).into_iter()
444+
.chain(end.as_ref().map(|e| &**e).into_iter());
445+
self.straightline(expr, pred, fields)
446+
}
447+
442448
ast::ExprUnary(_, ref e) if self.is_method_call(expr) => {
443449
self.call(expr, pred, &**e, None::<ast::Expr>.iter())
444450
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
465465
assert!(overloaded);
466466
}
467467

468+
ast::ExprRange(ref start, ref end) => {
469+
self.consume_expr(&**start);
470+
end.as_ref().map(|e| self.consume_expr(&**e));
471+
}
472+
468473
ast::ExprCall(ref callee, ref args) => { // callee(args)
469474
self.walk_callee(expr, &**callee);
470475
self.consume_exprs(args);

branches/snap-stage3/src/librustc/middle/infer/error_reporting.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
366366
infer::MatchExpressionArm(_, _) => "match arms have incompatible types",
367367
infer::IfExpression(_) => "if and else have incompatible types",
368368
infer::IfExpressionWithNoElse(_) => "if may be missing an else clause",
369+
infer::RangeExpression(_) => "start and end of range have incompatible types",
369370
infer::EquatePredicate(_) => "equality predicate not satisfied",
370371
};
371372

@@ -1490,6 +1491,9 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
14901491
infer::IfExpressionWithNoElse(_) => {
14911492
format!("if may be missing an else clause")
14921493
}
1494+
infer::RangeExpression(_) => {
1495+
format!("start and end of range have compatible types")
1496+
}
14931497
infer::EquatePredicate(_) => {
14941498
format!("equality where clause is satisfied")
14951499
}

branches/snap-stage3/src/librustc/middle/infer/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ pub enum TypeOrigin {
127127
// Computing common supertype of an if expression with no else counter-part
128128
IfExpressionWithNoElse(Span),
129129

130+
// Computing common supertype in a range expression
131+
RangeExpression(Span),
132+
130133
// `where a == b`
131134
EquatePredicate(Span),
132135
}
@@ -1084,6 +1087,7 @@ impl TypeOrigin {
10841087
MatchExpressionArm(match_span, _) => match_span,
10851088
IfExpression(span) => span,
10861089
IfExpressionWithNoElse(span) => span,
1090+
RangeExpression(span) => span,
10871091
EquatePredicate(span) => span,
10881092
}
10891093
}
@@ -1117,6 +1121,9 @@ impl<'tcx> Repr<'tcx> for TypeOrigin {
11171121
IfExpressionWithNoElse(a) => {
11181122
format!("IfExpressionWithNoElse({})", a.repr(tcx))
11191123
}
1124+
RangeExpression(a) => {
1125+
format!("RangeExpression({})", a.repr(tcx))
1126+
}
11201127
EquatePredicate(a) => {
11211128
format!("EquatePredicate({})", a.repr(tcx))
11221129
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ lets_do_this! {
267267
IndexMutTraitLangItem, "index_mut", index_mut_trait;
268268
SliceTraitLangItem, "slice", slice_trait;
269269
SliceMutTraitLangItem, "slice_mut", slice_mut_trait;
270+
RangeStructLangItem, "range", range_struct;
271+
RangeFromStructLangItem, "range_from", range_from_struct;
272+
FullRangeStructLangItem, "full_range", full_range_struct;
270273

271274
UnsafeTypeLangItem, "unsafe", unsafe_type;
272275

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
514514
ast::ExprBlock(..) | ast::ExprAssign(..) | ast::ExprAssignOp(..) |
515515
ast::ExprMac(..) | ast::ExprStruct(..) | ast::ExprRepeat(..) |
516516
ast::ExprParen(..) | ast::ExprInlineAsm(..) | ast::ExprBox(..) |
517-
ast::ExprSlice(..) => {
517+
ast::ExprSlice(..) | ast::ExprRange(..) => {
518518
visit::walk_expr(ir, expr);
519519
}
520520
}
@@ -1197,6 +1197,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11971197
self.propagate_through_expr(&**e1, succ)
11981198
}
11991199

1200+
ast::ExprRange(ref e1, ref e2) => {
1201+
let succ = e2.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ));
1202+
self.propagate_through_expr(&**e1, succ)
1203+
}
1204+
12001205
ast::ExprBox(None, ref e) |
12011206
ast::ExprAddrOf(_, ref e) |
12021207
ast::ExprCast(ref e, _) |
@@ -1489,7 +1494,8 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14891494
ast::ExprBreak(..) | ast::ExprAgain(..) | ast::ExprLit(_) |
14901495
ast::ExprBlock(..) | ast::ExprMac(..) | ast::ExprAddrOf(..) |
14911496
ast::ExprStruct(..) | ast::ExprRepeat(..) | ast::ExprParen(..) |
1492-
ast::ExprClosure(..) | ast::ExprPath(..) | ast::ExprBox(..) | ast::ExprSlice(..) => {
1497+
ast::ExprClosure(..) | ast::ExprPath(..) | ast::ExprBox(..) |
1498+
ast::ExprSlice(..) | ast::ExprRange(..) => {
14931499
visit::walk_expr(this, expr);
14941500
}
14951501
ast::ExprIfLet(..) => {

0 commit comments

Comments
 (0)