Skip to content

Commit fa3d081

Browse files
committed
---
yaml --- r: 140754 b: refs/heads/try2 c: be82449 h: refs/heads/master v: v3
1 parent 03cbc71 commit fa3d081

File tree

19 files changed

+87
-256
lines changed

19 files changed

+87
-256
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: 1bf2f68bb255cc6833d4253c4f6d071af9e05648
8+
refs/heads/try2: be82449a9a73efd7831b01a523c5f11cd27baa11
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,8 +1425,6 @@ names are effectively reserved. Some significant attributes include:
14251425
* The `test` attribute, for marking functions as unit tests.
14261426
* The `allow`, `warn`, `forbid`, and `deny` attributes, for controlling lint checks. Lint checks supported
14271427
by the compiler can be found via `rustc -W help`.
1428-
* The `deriving` attribute, for automatically generating
1429-
implementations of certain traits.
14301428

14311429
Other attributes may be added or removed during development of the language.
14321430

@@ -1528,47 +1526,6 @@ A complete list of the built-in language items follows:
15281526
> **Note:** This list is likely to become out of date. We should auto-generate it
15291527
> from `librustc/middle/lang_items.rs`.
15301528
1531-
### Deriving
1532-
1533-
The `deriving` attribute allows certain traits to be automatically
1534-
implemented for data structures. For example, the following will
1535-
create an `impl` for the `Eq` and `Clone` traits for `Foo`, the type
1536-
parameter `T` will be given the `Eq` or `Clone` constraints for the
1537-
appropriate `impl`:
1538-
1539-
~~~
1540-
#[deriving(Eq, Clone)]
1541-
struct Foo<T> {
1542-
a: int,
1543-
b: T
1544-
}
1545-
~~~
1546-
1547-
The generated `impl` for `Eq` is equivalent to
1548-
1549-
~~~
1550-
# struct Foo<T> { a: int, b: T }
1551-
impl<T: Eq> Eq for Foo<T> {
1552-
fn eq(&self, other: &Foo<T>) -> bool {
1553-
self.a == other.a && self.b == other.b
1554-
}
1555-
1556-
fn ne(&self, other: &Foo<T>) -> bool {
1557-
self.a != other.a || self.b != other.b
1558-
}
1559-
}
1560-
~~~
1561-
1562-
Supported traits for `deriving` are:
1563-
1564-
* Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`.
1565-
* Serialization: `Encodable`, `Decodable`. These require `std`.
1566-
* `Clone`, to perform deep copies.
1567-
* `IterBytes`, to iterate over the bytes in a data type.
1568-
* `Rand`, to create a random instance of a data type.
1569-
* `ToStr`, to convert to a string. For a type with this instance,
1570-
`obj.to_str()` has the same output as `fmt!("%?", obj)`.
1571-
15721529
# Statements and expressions
15731530

15741531
Rust is _primarily_ an expression language. This means that most forms of

branches/try2/doc/tutorial.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,27 +2290,6 @@ let nonsense = mycircle.radius() * mycircle.area();
22902290

22912291
> ***Note:*** Trait inheritance does not actually work with objects yet
22922292
2293-
## Deriving implementations for traits
2294-
2295-
A small number of traits in `core` and `std` can have implementations
2296-
that can be automatically derived. These instances are specified by
2297-
placing the `deriving` attribute on a data type declaration. For
2298-
example, the following will mean that `Circle` has an implementation
2299-
for `Eq` and can be used with the equality operators, and that a value
2300-
of type `ABC` can be randomly generated and converted to a string:
2301-
2302-
~~~
2303-
#[deriving(Eq)]
2304-
struct Circle { radius: float }
2305-
2306-
#[deriving(Rand, ToStr)]
2307-
enum ABC { A, B, C }
2308-
~~~
2309-
2310-
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
2311-
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `IterBytes`, `Rand` and
2312-
`ToStr`.
2313-
23142293
# Modules and crates
23152294

23162295
The Rust namespace is arranged in a hierarchy of modules. Each source

branches/try2/src/driver/driver.rs

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

11+
#[no_core];
12+
extern mod core(vers = "0.7-pre");
13+
1114
#[cfg(rustpkg)]
1215
extern mod this(name = "rustpkg", vers = "0.7-pre");
1316

branches/try2/src/libcore/unstable/intrinsics.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ pub extern "rust-intrinsic" {
2020
pub fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int;
2121
pub fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int;
2222

23-
#[cfg(not(stage0))]
24-
pub fn atomic_load(src: &int) -> int;
25-
#[cfg(not(stage0))]
26-
pub fn atomic_load_acq(src: &int) -> int;
27-
28-
#[cfg(not(stage0))]
29-
pub fn atomic_store(dst: &mut int, val: int);
30-
#[cfg(not(stage0))]
31-
pub fn atomic_store_rel(dst: &mut int, val: int);
32-
3323
pub fn atomic_xchg(dst: &mut int, src: int) -> int;
3424
pub fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
3525
pub fn atomic_xchg_rel(dst: &mut int, src: int) -> int;

branches/try2/src/librust/rust.rc

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
#[license = "MIT/ASL2"];
2121
#[crate_type = "lib"];
2222

23-
extern mod rustpkg(vers = "0.7-pre");
24-
extern mod rustdoc(vers = "0.7-pre");
25-
extern mod rusti(vers = "0.7-pre");
26-
extern mod rustc(vers = "0.7-pre");
27-
2823
use core::run;
2924

3025
enum ValidUsage {
@@ -41,13 +36,13 @@ impl ValidUsage {
4136
}
4237

4338
enum Action<'self> {
44-
Call(&'self fn(args: &[~str]) -> ValidUsage),
45-
CallMain(&'static str, &'self fn()),
39+
Exec(&'self str),
40+
Call(&'self fn(args: &[~str]) -> ValidUsage)
4641
}
4742

4843
enum UsageSource<'self> {
49-
UsgStr(&'self str),
50-
UsgCall(&'self fn()),
44+
UsgExec(&'self str),
45+
UsgStr(&'self str)
5146
}
5247

5348
struct Command<'self> {
@@ -60,9 +55,9 @@ struct Command<'self> {
6055
static commands: &'static [Command<'static>] = &[
6156
Command{
6257
cmd: "build",
63-
action: CallMain("rustc", rustc::main),
58+
action: Exec("rustc"),
6459
usage_line: "compile rust source files",
65-
usage_full: UsgCall(rustc_help),
60+
usage_full: UsgExec("rustc --help")
6661
},
6762
Command{
6863
cmd: "run",
@@ -86,21 +81,21 @@ static commands: &'static [Command<'static>] = &[
8681
},
8782
Command{
8883
cmd: "doc",
89-
action: CallMain("rustdoc", rustdoc::main),
84+
action: Exec("rustdoc"),
9085
usage_line: "generate documentation from doc comments",
91-
usage_full: UsgCall(rustdoc::config::usage),
86+
usage_full: UsgExec("rustdoc --help")
9287
},
9388
Command{
9489
cmd: "pkg",
95-
action: CallMain("rustpkg", rustpkg::main),
90+
action: Exec("rustpkg"),
9691
usage_line: "download, build, install rust packages",
97-
usage_full: UsgCall(rustpkg::usage::general),
92+
usage_full: UsgExec("rustpkg --help")
9893
},
9994
Command{
10095
cmd: "sketch",
101-
action: CallMain("rusti", rusti::main),
96+
action: Exec("rusti"),
10297
usage_line: "run a rust interpreter",
103-
usage_full: UsgStr("\nUsage:\trusti"),
98+
usage_full: UsgStr("\nUsage:\trusti")
10499
},
105100
Command{
106101
cmd: "help",
@@ -114,10 +109,6 @@ static commands: &'static [Command<'static>] = &[
114109
}
115110
];
116111

117-
fn rustc_help() {
118-
rustc::usage(copy os::args()[0])
119-
}
120-
121112
fn find_cmd(command_string: &str) -> Option<Command> {
122113
do commands.find |command| {
123114
command.cmd == command_string
@@ -129,14 +120,20 @@ fn cmd_help(args: &[~str]) -> ValidUsage {
129120
match find_cmd(command_string) {
130121
Some(command) => {
131122
match command.action {
132-
CallMain(prog, _) => io::println(fmt!(
123+
Exec(s) => io::println(fmt!(
133124
"The %s command is an alias for the %s program.",
134-
command.cmd, prog)),
125+
command.cmd, s)),
135126
_ => ()
136127
}
137128
match command.usage_full {
138-
UsgStr(msg) => io::println(fmt!("%s\n", msg)),
139-
UsgCall(f) => f(),
129+
UsgStr(msg) => io::println(fmt!("%s\n", msg)),
130+
UsgExec(commandline) => {
131+
let mut words = ~[];
132+
for str::each_word(commandline) |word| { words.push(word.to_owned()) }
133+
let words = words;
134+
let (prog, args) = (words.head(), words.tail());
135+
run::run_program(*prog, args);
136+
}
140137
}
141138
Valid
142139
},
@@ -154,40 +151,50 @@ fn cmd_test(args: &[~str]) -> ValidUsage {
154151
match args {
155152
[filename] => {
156153
let test_exec = Path(filename).filestem().unwrap() + "test~";
157-
invoke("rustc", &[~"--test", filename.to_owned(),
158-
~"-o", test_exec.to_owned()], rustc::main);
159-
run::run_program(~"./" + test_exec, []);
154+
if run::run_program("rustc", [
155+
~"--test",
156+
filename.to_owned(),
157+
~"-o",
158+
test_exec.to_owned()
159+
]) == 0 {
160+
run::run_program(~"./" + test_exec, []);
161+
}
160162
Valid
161163
}
162-
_ => Invalid
164+
_ => Invalid
163165
}
164166
}
165167

166168
fn cmd_run(args: &[~str]) -> ValidUsage {
167169
match args {
168170
[filename, ..prog_args] => {
169171
let exec = Path(filename).filestem().unwrap() + "~";
170-
invoke("rustc", &[filename.to_owned(), ~"-o", exec.to_owned()],
171-
rustc::main);
172-
run::run_program(~"./"+exec, prog_args);
172+
if run::run_program("rustc", [
173+
filename.to_owned(),
174+
~"-o",
175+
exec.to_owned()
176+
]) == 0 {
177+
run::run_program(~"./"+exec, prog_args);
178+
}
173179
Valid
174180
}
175-
_ => Invalid
181+
_ => Invalid
176182
}
177183
}
178184

179-
fn invoke(prog: &str, args: &[~str], f: &fn()) {
180-
let mut osargs = ~[prog.to_owned()];
181-
osargs.push_all_move(args.to_owned());
182-
os::set_args(osargs);
183-
f();
184-
}
185-
186185
fn do_command(command: &Command, args: &[~str]) -> ValidUsage {
187186
match command.action {
188187
Call(f) => f(args),
189-
CallMain(prog, f) => {
190-
invoke(prog, args, f);
188+
Exec(commandline) => {
189+
let mut words = ~[];
190+
for str::each_word(commandline) |word| { words.push(word.to_owned()) }
191+
let words = words;
192+
let (prog, prog_args) = (words.head(), words.tail());
193+
let exitstatus = run::run_program(
194+
*prog,
195+
vec::append(vec::to_owned(prog_args), args)
196+
);
197+
os::set_exit_status(exitstatus);
191198
Valid
192199
}
193200
}
@@ -225,9 +232,11 @@ pub fn main() {
225232
let args = os_args.tail();
226233

227234
if !args.is_empty() {
228-
for find_cmd(*args.head()).each |command| {
229-
let result = do_command(command, args.tail());
230-
if result.is_valid() { return; }
235+
for commands.each |command| {
236+
if command.cmd == *args.head() {
237+
let result = do_command(command, args.tail());
238+
if result.is_valid() { return; }
239+
}
231240
}
232241
}
233242

branches/try2/src/librustc/lib/llvm.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,16 +1339,13 @@ pub mod llvm {
13391339
PointerVal: ValueRef) -> ValueRef;
13401340
#[fast_ffi]
13411341
pub unsafe fn LLVMBuildLoad(B: BuilderRef,
1342-
PointerVal: ValueRef,
1343-
Name: *c_char)
1344-
-> ValueRef;
1345-
1342+
PointerVal: ValueRef,
1343+
Name: *c_char)
1344+
-> ValueRef;
13461345
#[fast_ffi]
13471346
pub unsafe fn LLVMBuildStore(B: BuilderRef,
13481347
Val: ValueRef,
1349-
Ptr: ValueRef)
1350-
-> ValueRef;
1351-
1348+
Ptr: ValueRef) -> ValueRef;
13521349
#[fast_ffi]
13531350
pub unsafe fn LLVMBuildGEP(B: BuilderRef,
13541351
Pointer: ValueRef,
@@ -1564,17 +1561,6 @@ pub mod llvm {
15641561
Name: *c_char) -> ValueRef;
15651562

15661563
/* Atomic Operations */
1567-
pub unsafe fn LLVMBuildAtomicLoad(B: BuilderRef,
1568-
PointerVal: ValueRef,
1569-
Order: AtomicOrdering)
1570-
-> ValueRef;
1571-
1572-
pub unsafe fn LLVMBuildAtomicStore(B: BuilderRef,
1573-
Val: ValueRef,
1574-
Ptr: ValueRef,
1575-
Order: AtomicOrdering)
1576-
-> ValueRef;
1577-
15781564
pub unsafe fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
15791565
LHS: ValueRef,
15801566
CMP: ValueRef,

0 commit comments

Comments
 (0)