Skip to content

Commit 9e7ff93

Browse files
committed
---
yaml --- r: 149055 b: refs/heads/try2 c: f3a87a7 h: refs/heads/master i: 149053: 84d5d38 149051: 1ec2df6 149047: 6c5ce38 149039: f5bda0d 149023: 2e87924 148991: a70e21b v: v3
1 parent b8e520b commit 9e7ff93

File tree

9 files changed

+116
-62
lines changed

9 files changed

+116
-62
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 07c5e5d81363b6cdbca64637832620ab4870d258
8+
refs/heads/try2: f3a87a7f1ff8089742bc8dc45b812dd844109034
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
7474
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
7575
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
7676
| $$(TLIB$(1)_T_$(2)_H_$(3))/
77-
@$$(call E, compile_and_link: $$(@D)/lib$(4))
77+
@$$(call E, oxidize: $$(@D)/lib$(4))
7878
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
7979
$$(dir $$@)$$(call CFG_LIB_GLOB_$(2),$(4)))
8080
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
@@ -113,7 +113,7 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
113113
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \
114114
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
115115
| $$(TBIN$(1)_T_$(4)_H_$(3))/
116-
@$$(call E, compile_and_link: $$@)
116+
@$$(call E, oxidize: $$@)
117117
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg $(4)
118118

119119
endef

branches/try2/mk/tests.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
347347
$$(CRATEFILE_$(4)) \
348348
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
349349
$$(STDTESTDEP_$(1)_$(2)_$(3)_$(4))
350-
@$$(call E, compile_and_link: $$@)
350+
@$$(call E, oxidize: $$@)
351351
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
352352
-L "$$(RT_OUTPUT_DIR_$(2))" \
353353
-L "$$(LLVM_LIBDIR_$(2))"
@@ -835,15 +835,15 @@ define DEF_CHECK_FAST_FOR_T_H
835835
$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
836836
tmp/$$(FT).rc \
837837
$$(SREQ2_T_$(2)_H_$(3))
838-
@$$(call E, compile_and_link: $$@)
838+
@$$(call E, oxidize: $$@)
839839
$$(STAGE2_T_$(2)_H_$(3)) --crate-type=dylib --out-dir $$(@D) $$< \
840840
-L "$$(RT_OUTPUT_DIR_$(2))"
841841

842842
$(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
843843
tmp/$$(FT_DRIVER).rs \
844844
$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
845845
$$(SREQ2_T_$(2)_H_$(3))
846-
@$$(call E, compile_and_link: $$@ $$<)
846+
@$$(call E, oxidize: $$@ $$<)
847847
$$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$< \
848848
-L "$$(RT_OUTPUT_DIR_$(2))"
849849

branches/try2/src/doc/tutorial.md

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -647,31 +647,8 @@ match mypoint {
647647

648648
## Enums
649649

650-
Enums are datatypes that have several alternate representations. For
651-
example, consider the following type:
652-
653-
~~~~
654-
# struct Point { x: f64, y: f64 }
655-
enum Shape {
656-
Circle(Point, f64),
657-
Rectangle(Point, Point)
658-
}
659-
~~~~
660-
661-
A value of this type is either a `Circle`, in which case it contains a
662-
`Point` struct and a f64, or a `Rectangle`, in which case it contains
663-
two `Point` structs. The run-time representation of such a value
664-
includes an identifier of the actual form that it holds, much like the
665-
"tagged union" pattern in C, but with better static guarantees.
666-
667-
The above declaration will define a type `Shape` that can refer to
668-
such shapes, and two functions, `Circle` and `Rectangle`, which can be
669-
used to construct values of the type (taking arguments of the
670-
specified types). So `Circle(Point { x: 0.0, y: 0.0 }, 10.0)` is the way to
671-
create a new circle.
672-
673-
Enum variants need not have parameters. This `enum` declaration,
674-
for example, is equivalent to a C enum:
650+
Enums are datatypes with several alternate representations. A simple `enum`
651+
defines one or more constants, all of which have the same type:
675652

676653
~~~~
677654
enum Direction {
@@ -682,12 +659,21 @@ enum Direction {
682659
}
683660
~~~~
684661

685-
This declaration defines `North`, `East`, `South`, and `West` as constants,
686-
all of which have type `Direction`.
662+
Each variant of this enum has a unique and constant integral discriminator
663+
value. If no explicit discriminator is specified for a variant, the value
664+
defaults to the value of the previous variant plus one. If the first variant
665+
does not have a discriminator, it defaults to 0. For example, the value of
666+
`North` is 0, `East` is 1, `South` is 2, and `West` is 3.
687667

688-
When an enum is C-like (that is, when none of the variants have
689-
parameters), it is possible to explicitly set the discriminator values
690-
to a constant value:
668+
When an enum has simple integer discriminators, you can apply the `as` cast
669+
operator to convert a variant to its discriminator value as an `int`:
670+
671+
~~~~
672+
# enum Direction { North }
673+
println!( "{:?} => {}", North, North as int );
674+
~~~~
675+
676+
It is possible to set the discriminator values to chosen constant values:
691677

692678
~~~~
693679
enum Color {
@@ -697,17 +683,30 @@ enum Color {
697683
}
698684
~~~~
699685

700-
If an explicit discriminator is not specified for a variant, the value
701-
defaults to the value of the previous variant plus one. If the first
702-
variant does not have a discriminator, it defaults to 0. For example,
703-
the value of `North` is 0, `East` is 1, `South` is 2, and `West` is 3.
686+
Variants do not have to be simple values; they may be more complex:
704687

705-
When an enum is C-like, you can apply the `as` cast operator to
706-
convert it to its discriminator value as an `int`.
688+
~~~~
689+
# struct Point { x: f64, y: f64 }
690+
enum Shape {
691+
Circle(Point, f64),
692+
Rectangle(Point, Point)
693+
}
694+
~~~~
707695

708-
For enum types with multiple variants, destructuring is the only way to
709-
get at their contents. All variant constructors can be used as
710-
patterns, as in this definition of `area`:
696+
A value of this type is either a `Circle`, in which case it contains a
697+
`Point` struct and a f64, or a `Rectangle`, in which case it contains
698+
two `Point` structs. The run-time representation of such a value
699+
includes an identifier of the actual form that it holds, much like the
700+
"tagged union" pattern in C, but with better static guarantees.
701+
702+
This declaration defines a type `Shape` that can refer to such shapes, and two
703+
functions, `Circle` and `Rectangle`, which can be used to construct values of
704+
the type. To create a new Circle, write `Circle(Point { x: 0.0, y: 0.0 },
705+
10.0)`.
706+
707+
All of these variant constructors may be used as patterns. The only way to
708+
access the contents of an enum instance is the destructuring of a match. For
709+
example:
711710

712711
~~~~
713712
use std::f64;
@@ -721,10 +720,8 @@ fn area(sh: Shape) -> f64 {
721720
}
722721
~~~~
723722

724-
You can write a lone `_` to ignore an individual field, and can
725-
ignore all fields of a variant like: `Circle(..)`. As in their
726-
introduction form, nullary enum patterns are written without
727-
parentheses.
723+
Use a lone `_` to ignore an individual field. Ignore all fields of a variant
724+
like: `Circle(..)`. Nullary enum patterns are written without parentheses:
728725

729726
~~~~
730727
# struct Point { x: f64, y: f64 }

branches/try2/src/libcollections/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn foldl<T:Clone,U>(z: T, ls: @List<U>, f: |&T, &U| -> T) -> T {
4646
/**
4747
* Search for an element that matches a given predicate
4848
*
49-
* Apply function `f` to each element of `v`, starting from the first.
49+
* Apply function `f` to each element of `ls`, starting from the first.
5050
* When function `f` returns true then an option containing the element
5151
* is returned. If `f` matches no elements then none is returned.
5252
*/

branches/try2/src/libnative/io/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
746746
super::mkerr_winbool(as_utf16_p(src.as_str().unwrap(), |src| {
747747
as_utf16_p(dst.as_str().unwrap(), |dst| {
748748
unsafe { libc::CreateSymbolicLinkW(dst, src, 0) }
749-
})
749+
}) as libc::BOOL
750750
}))
751751
}
752752

branches/try2/src/librustc/middle/region.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,17 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor,
501501
visitor.region_maps.mark_as_terminating_scope(otherwise.id);
502502
}
503503

504-
ast::ExprIf(_, then, None) => {
504+
ast::ExprIf(expr, then, None) => {
505+
visitor.region_maps.mark_as_terminating_scope(expr.id);
505506
visitor.region_maps.mark_as_terminating_scope(then.id);
506507
}
507508

508-
ast::ExprLoop(body, _) |
509-
ast::ExprWhile(_, body) => {
509+
ast::ExprLoop(body, _) => {
510+
visitor.region_maps.mark_as_terminating_scope(body.id);
511+
}
512+
513+
ast::ExprWhile(expr, body) => {
514+
visitor.region_maps.mark_as_terminating_scope(expr.id);
510515
visitor.region_maps.mark_as_terminating_scope(body.id);
511516
}
512517

branches/try2/src/libstd/libc.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ pub mod types {
970970

971971
pub type BOOL = c_int;
972972
pub type BYTE = u8;
973+
pub type BOOLEAN = BYTE;
973974
pub type CCHAR = c_char;
974975
pub type CHAR = c_char;
975976

@@ -3984,15 +3985,16 @@ pub mod funcs {
39843985

39853986
pub mod kernel32 {
39863987
use libc::types::os::arch::c95::{c_uint};
3987-
use libc::types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE};
3988-
use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPCSTR, LPSTR, LPCH,
3989-
LPDWORD, LPVOID,
3990-
LPCVOID, LPOVERLAPPED};
3991-
use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES, LPSTARTUPINFO,
3988+
use libc::types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE,
3989+
LPCWSTR, LPWSTR, LPCSTR, LPSTR,
3990+
LPCH, LPDWORD, LPVOID,
3991+
LPCVOID, LPOVERLAPPED,
3992+
LPSECURITY_ATTRIBUTES,
3993+
LPSTARTUPINFO,
39923994
LPPROCESS_INFORMATION,
39933995
LPMEMORY_BASIC_INFORMATION,
3994-
LPSYSTEM_INFO};
3995-
use libc::types::os::arch::extra::{HANDLE, LPHANDLE, LARGE_INTEGER,
3996+
LPSYSTEM_INFO, BOOLEAN,
3997+
HANDLE, LPHANDLE, LARGE_INTEGER,
39963998
PLARGE_INTEGER, LPFILETIME};
39973999

39984000
extern "system" {
@@ -4105,7 +4107,7 @@ pub mod funcs {
41054107
dwFlags: DWORD) -> BOOL;
41064108
pub fn CreateSymbolicLinkW(lpSymlinkFileName: LPCWSTR,
41074109
lpTargetFileName: LPCWSTR,
4108-
dwFlags: DWORD) -> BOOL;
4110+
dwFlags: DWORD) -> BOOLEAN;
41094111
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
41104112
lpTargetFileName: LPCWSTR,
41114113
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
12+
// This test verifies that temporaries created for `while`'s
13+
// and `if` conditions are correctly cleaned up.
14+
15+
struct Temporary;
16+
17+
static mut DROPPED: int = 0;
18+
19+
impl Drop for Temporary {
20+
fn drop(&mut self) {
21+
unsafe { DROPPED += 1; }
22+
}
23+
}
24+
25+
impl Temporary {
26+
fn do(&self) -> bool {true}
27+
}
28+
29+
fn borrow() -> ~Temporary { ~Temporary }
30+
31+
32+
pub fn main() {
33+
let mut i = 0;
34+
35+
// This loop's condition
36+
// should call `Temporary`'s
37+
// `drop` 6 times.
38+
while borrow().do() {
39+
i += 1;
40+
if i > 5 {
41+
break;
42+
}
43+
}
44+
45+
// This if condition should
46+
// call it 1 time
47+
if borrow().do() {
48+
unsafe { assert_eq!(DROPPED, 7) }
49+
}
50+
}

0 commit comments

Comments
 (0)