Commit Graph

22472 Commits

Author SHA1 Message Date
Grigoriy
eb519b952d Fix example in std::Option 2013-09-21 02:00:20 +04:00
bors
b7bbc2eea2 auto merge of #9327 : larsbergstrom/rust/tutorial_installation_tweak, r=catamorphism
I've had multiple people whom I pointed at the Rust tutorial ask me where to download the snapshot compiler, so I made the text more explicit.
2013-09-20 09:56:09 -07:00
bors
f4479727a6 auto merge of #9337 : steveklabnik/rust/rustpkg_usage, r=catamorphism
When I took out the ability to make a new project by name, I forgot to
update the usage to reflect the changes.
2013-09-20 08:31:12 -07:00
bors
89cc8529cc auto merge of #9332 : eugals/rust/master, r=alexcrichton
It is intended to optimize/beautify the code generated in a few trivial trait operations.
Let's take the following code as an example:
```
trait Stuff {
    fn bar(&self);
}

fn callBar(s: &Stuff) {
    s.bar();
}

struct Foo;

impl Stuff for Foo {
    fn bar(&self) {
    }
}

pub fn main() {
    let o = Foo;
    callBar(&o as &Stuff);
}
```

At present it is translated into something like:
```
define void @_ZN7callBar_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }*, { %tydesc*, i8* }*) #4 {
"function top level":
  %__trait_callee = alloca { %tydesc*, i8* }
  %__auto_borrow_obj = alloca { %tydesc*, i8* }
  %2 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
  %3 = load %tydesc** %2
  %4 = getelementptr inbounds { %tydesc*, i8* }* %__auto_borrow_obj, i32 0, i32 0
  store %tydesc* %3, %tydesc** %4
  %5 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
  %6 = load i8** %5
  %7 = getelementptr inbounds { %tydesc*, i8* }* %__auto_borrow_obj, i32 0, i32 1
  store i8* %6, i8** %7
  %8 = bitcast { %tydesc*, i8* }* %__auto_borrow_obj to i8*
  %9 = bitcast { %tydesc*, i8* }* %__trait_callee to i8*
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %9, i8* %8, i32 8, i32 4, i1 false)
  %10 = getelementptr inbounds { %tydesc*, i8* }* %__trait_callee, i32 0, i32 1
  %11 = load i8** %10
  %12 = bitcast i8* %11 to { i32, %tydesc*, i8*, i8*, i8 }*
  %13 = getelementptr inbounds { %tydesc*, i8* }* %__trait_callee, i32 0, i32 0
  %14 = bitcast %tydesc** %13 to [1 x i8*]**
  %15 = load [1 x i8*]** %14
  %16 = getelementptr inbounds [1 x i8*]* %15, i32 0, i32 1
  %17 = load i8** %16
  %18 = bitcast i8* %17 to void ({ i32, %tydesc*, i8*, i8*, i8 }*)*
  call void %18({ i32, %tydesc*, i8*, i8*, i8 }* %12)
  ret void
}

...

define void @_ZN4main_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }*) #4 {
"function top level":
  %o = alloca %struct.Foo
  %1 = alloca { %tydesc*, i8* }
  %__auto_borrow_obj = alloca { %tydesc*, i8* }
  %2 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
  %3 = bitcast i8** %2 to %struct.Foo**
  store %struct.Foo* %o, %struct.Foo** %3
  %4 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
  %5 = bitcast %tydesc** %4 to { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }**
  store { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }* @vtable1081, { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }** %5
  %6 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
  %7 = load %tydesc** %6
  %8 = getelementptr inbounds { %tydesc*, i8* }* %__auto_borrow_obj, i32 0, i32 0
  store %tydesc* %7, %tydesc** %8
  %9 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
  %10 = load i8** %9
  %11 = getelementptr inbounds { %tydesc*, i8* }* %__auto_borrow_obj, i32 0, i32 1
  store i8* %10, i8** %11
  call void @_ZN7callBar_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }* undef, { %tydesc*, i8* }* %__auto_borrow_obj)
  ret void
}
```

If you apply my patch, it would become way shorter and cleaner:
```
define void @_ZN7callBar_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }*, { %tydesc*, i8* }*) #4 {
"function top level":
  %2 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
  %3 = load i8** %2
  %4 = bitcast i8* %3 to { i32, %tydesc*, i8*, i8*, i8 }*
  %5 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
  %6 = bitcast %tydesc** %5 to [1 x i8*]**
  %7 = load [1 x i8*]** %6
  %8 = getelementptr inbounds [1 x i8*]* %7, i32 0, i32 1
  %9 = load i8** %8
  %10 = bitcast i8* %9 to void ({ i32, %tydesc*, i8*, i8*, i8 }*)*
  call void %10({ i32, %tydesc*, i8*, i8*, i8 }* %4)
  ret void
}

...

define void @_ZN4main_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }*) #4 {
"function top level":
  %o = alloca %struct.Foo
  %1 = alloca { %tydesc*, i8* }
  %2 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 1
  %3 = bitcast i8** %2 to %struct.Foo**
  store %struct.Foo* %o, %struct.Foo** %3
  %4 = getelementptr inbounds { %tydesc*, i8* }* %1, i32 0, i32 0
  %5 = bitcast %tydesc** %4 to { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }**
  store { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }* @vtable1081, { %tydesc*, void ({ i32, %tydesc*, i8*, i8*, i8 }*)* }** %5
  call void @_ZN7callBar_UUID.0E({ i32, %tydesc*, i8*, i8*, i8 }* undef, { %tydesc*, i8* }* %1)
  ret void
}
```

Although this change doesn't increase the compilation speed much (I mentioned only about 1-2% boost on "rustc -O -Z time-passes syntax.rs"), but I still think it's a good thing to do as it greatly simplifies/clarifies LL generated in some cases which would definitely help in the future code generation investigations.

I don't provide any new test cases in this patch as it is merely an optimization.

Sorry guys, I somehow messed my previous PR and I don't see any better way to fix as to recreate it here.
2013-09-20 07:06:13 -07:00
bors
44997a127b auto merge of #9326 : NiccosSystem/rust/master, r=bstrie 2013-09-20 04:56:09 -07:00
bors
176051c6f8 auto merge of #9322 : catamorphism/rust/rustpkg-discovered-outputs, r=brson
r? @brson as per #9112

Closes #9112
2013-09-20 03:26:10 -07:00
bors
ccb80ab4f7 auto merge of #9321 : chris-morgan/rust/lowercase-nan-methods, r=brson
This is for consistency in naming conventions.

- ``std::num::Float::NaN()`` is changed to ``nan()``;
- ``std::num::Float.is_NaN()`` is changed to ``is_nan()``; and
- ``std::num::strconv::NumStrConv::NaN()`` is changed to ``nan()``.

Fixes #9319.
2013-09-20 02:01:13 -07:00
bors
e5fdc7dee5 auto merge of #9320 : chris-morgan/rust/unreachable-macro-part-two-of-two-containing-the-destruction-of-the-unreachable-function, r=alexcrichton
This is the second of two parts of #8991, now possible as a new snapshot
has been made. (The first part implemented the unreachable!() macro; it
was #8992, 6b7b8f2682.)

``std::util::unreachable()`` is removed summarily; any code which used
it should now use the ``unreachable!()`` macro.

Closes #9312.

Closes #8991.
2013-09-20 00:36:11 -07:00
bors
c7c769d8c2 auto merge of #9315 : thestinger/rust/doc, r=alexcrichton
This also renames the section, as managed vectors cannot be resized
(since it would invalidate the other references).
2013-09-19 23:11:19 -07:00
bors
7f826cb25a auto merge of #9308 : ben0x539/rust/lexer-error-spans, r=alexcrichton
Previously, the lexer calling `rdr.fatal(...)` would report the span of
the last complete token, instead of a span within the erroneous token
(besides one span fixed in 1ac90bb).

This branch adds wrappers around `rdr.fatal(...)` that sets the span
explicilty, so that all fatal errors in `libsyntax/parse/lexer.rs` now
report the offending code more precisely. A number of tests try to
verify that, though the `compile-fail` testing setup can only check that
the spans are on the right lines, and the "unterminated string/block
comment" errors can't have the line marked at all, so that's incomplete.

This closes #9149.

Also, the lexer errors now report the offending code in the error message,
not just via the span, just like other errors do.
2013-09-19 21:46:45 -07:00
bors
407d179f4e auto merge of #9285 : sfackler/rust/future, r=alexcrichton
The `Drop` implementation was used to prevent `Future` from being implicitly copyable. Since `~fn`s are no longer copyable, this is no longer needed. I added a cfail test to make sure that this is actually the case.

I method-ized all of the `Future` creation methods and added a new one, `spawn_with`, which is similar to `task::spawn_with`.

I also got rid of some unused imports in tests.
2013-09-19 19:31:13 -07:00
bors
570431fcac auto merge of #9342 : alexcrichton/rust/ignore-libuv-signal-tests, r=brson
They're causing syscalls to get interrupted, and std::io doesn't correctly
handle EINTR
2013-09-19 15:56:04 -07:00
Steven Fackler
963707f45d Clean up unused imports 2013-09-19 15:19:25 -07:00
Steven Fackler
48d5b4b8e1 Add Future::spawn_with 2013-09-19 15:19:25 -07:00
Steven Fackler
ff85389344 Modernize extra::future API 2013-09-19 15:19:20 -07:00
Alex Crichton
5165ecde66 Ignore io::process tests
They're causing syscalls to get interrupted, and std::io doesn't correctly
handle EINTR
2013-09-19 15:17:29 -07:00
Benjamin Herr
567c567b2d lexer: further slight improvements to lexer errors 2013-09-19 23:08:06 +02:00
Steve Klabnik
806105fea8 Fix usage for rustpkg init
When I took out the ability to make a new project by name, I forgot to
update the usage to reflect the changes.
2013-09-19 12:53:38 -07:00
bors
85c0fb7b8a auto merge of #9295 : alexcrichton/rust/fix-lang-items, r=thestinger
Also add a test to help prevent this from getting out of sync again.
2013-09-19 11:11:01 -07:00
Evgeny Sologubov
fadc6cc4b0 pacified test/run-pass/core-run-destroy on Win7x64 2013-09-19 21:25:27 +04:00
bors
755f6229da auto merge of #9279 : erickt/rust/master, r=alexcrichton
`Some(5).or_{default,zero}` can be easily replaced with `Some(Some(5).unwrap_or_default())`.
2013-09-19 09:55:59 -07:00
Steven Fackler
2df5a13334 Removed future's destructor
It was only there to prevent Future from being copyable, but it's
noncopyable anyways since it contains a ~fn.
2013-09-19 09:06:42 -07:00
Lars Bergstrom
9051a35fc8 Clarify that snapshots are automatically retrieved. 2013-09-19 10:58:26 -05:00
bors
068e04231d auto merge of #9313 : brson/rust/relnotes, r=thestinger 2013-09-19 08:40:59 -07:00
NiccosSystem
5708b91969 Fix broken tutorial link 2013-09-19 17:18:40 +02:00
Benjamin Herr
8009c97a55 lexer: report problematic chars verbatim or as escape sequence
... instead of giving their numeric codepoint, following the lead of
fdaae34. So the error message for, say, '\_' mentions _ instead of 95,
and '\●' now mentions \u25cf.
2013-09-19 16:58:49 +02:00
Benjamin Herr
1019177958 lexer: show correct span on lexical errors
Previously, the lexer calling `rdr.fatal(...)` would report the span of
the last complete token, instead of a span within the erroneous token
(besides one span fixed in 1ac90bb).

This commit adds a wrapper around `rdr.fatal(...)` that sets the span
explicilty, so that all fatal errors in `libsyntax/parse/lexer.rs` now
report the offending code more precisely. A number of tests try to
verify that, though the `compile-fail` testing setup can only check that
the spans are on the right lines, and the "unterminated string/block
comment" errors can't have the line marked at all, so that's incomplete.

Closes #9149.
2013-09-19 16:58:11 +02:00
U-NOV2010\eugals
0c3b6ad6b8 will not copy trait_callee on stack if it's source expr is a plain borrowed ref 2013-09-19 18:34:30 +04:00
U-NOV2010\eugals
dfa3f5fa8d minor Type::opaque_trait code cleanup 2013-09-19 18:34:26 +04:00
U-NOV2010\eugals
2927ab13df optimized trans_to_datum::auto_borrow_obj code generation in case some trivial cases where simple copying can be applied 2013-09-19 18:34:23 +04:00
bors
da29a8e6be auto merge of #9299 : alexcrichton/rust/fmt-trailing-comma, r=huonw
This is more consistent with other parts of the language and it also makes it
easier to use in situations where format string is massive.
2013-09-19 07:06:04 -07:00
Chris Morgan
d9874c0885 Rename the NaN and is_NaN methods to lowercase.
This is for consistency in naming conventions.

- ``std::num::Float::NaN()`` is changed to ``nan()``;
- ``std::num::Float.is_NaN()`` is changed to ``is_nan()``; and
- ``std::num::strconv::NumStrConv::NaN()`` is changed to ``nan()``.

Fixes #9319.
2013-09-19 23:59:51 +10:00
bors
99ec14dbb0 auto merge of #9267 : Kimundi/rust/master, r=huonw 2013-09-19 05:06:00 -07:00
Marvin Löbel
06d1dccf95 Turned extra::getopts functions into methods
Some minor api and doc adjustments
2013-09-19 12:32:18 +02:00
bors
4904bc33cc auto merge of #9292 : blake2-ppc/rust/borrow-ref-eq, r=huonw
std::borrow: Use raw pointer comparison for `ref_eq`

Compare as `*T` in `ref_eq` instead of casting to uint, to match what
std::ptr does.
2013-09-19 03:01:05 -07:00
bors
a7cf7b7b0b auto merge of #9291 : jzelinskie/rust/remove-cond, r=alexcrichton
This is my first contribution, so please point out anything that I may have missed.

I consulted IRC and settled on `match () { ... }` for most of the replacements.
2013-09-19 00:31:05 -07:00
Tim Chevalier
d84a22addf rustpkg: Register correct dependencies for built and installed files
as per #9112

Closes #9112
2013-09-18 22:48:37 -07:00
blake2-ppc
f0630fdc8b doc: Fix the tutorial's link to rustpkg docs 2013-09-19 01:43:10 -04:00
bors
3c0013134c auto merge of #9280 : alexcrichton/rust/less-c++, r=brson
Some of the functions could be converted to rust, but the functions dealing with
signals were moved to rust_builtin.cpp instead (no reason to keep the original
file around for one function).

Closes #2674

Because less C++ is better C++!
2013-09-18 22:15:59 -07:00
Chris Morgan
e2807a4565 Replace unreachable() calls with unreachable!().
This is the second of two parts of #8991, now possible as a new snapshot
has been made. (The first part implemented the unreachable!() macro; it
was #8992, 6b7b8f2682.)

``std::util::unreachable()`` is removed summarily; any code which used
it should now use the ``unreachable!()`` macro.

Closes #9312.

Closes #8991.
2013-09-19 15:04:03 +10:00
Alex Crichton
c3ad785d83 Remove rust_run_program.cpp
Some of the functions could be converted to rust, but the functions dealing with
signals were moved to rust_builtin.cpp instead (no reason to keep the original
file around for one function).

Closes #2674
2013-09-18 20:58:56 -07:00
blake2-ppc
bf0e2a6f57 doc: Update container tutorial with new names of methods and macros
`deque` -> `ringbuf`, mention `extra::dlist`.

fix reference to vector method `bsearch`. Also convert all output
in example code to use `print!`/`println!`
2013-09-18 23:17:07 -04:00
Brian Anderson
3bd0eb9f63 0.8 release notes 2013-09-18 20:16:02 -07:00
Daniel Micay
d12e0305b1 clarify vector stub in the container tutorial
This also renames the section, as managed vectors cannot be resized
(since it would invalidate the other references).
2013-09-18 22:26:48 -04:00
bors
4dacd73651 auto merge of #9260 : alexcrichton/rust/libuv-processes, r=brson
This is a re-landing of #8645, except that the bindings are *not* being used to
power std::run just yet. Instead, this adds the bindings as standalone bindings
inside the rt::io::process module.

I made one major change from before, having to do with how pipes are
created/bound. It's much clearer now when you can read/write to a pipe, as
there's an explicit difference (different types) between an unbound and a bound
pipe. The process configuration now takes unbound pipes (and consumes ownership
of them), and will return corresponding pipe structures back if spawning is
successful (otherwise everything is destroyed normally).
2013-09-18 18:30:56 -07:00
bors
36cc41481c auto merge of #9263 : catamorphism/rust/rustpkg-issue-7879, r=brson
r? @brson Treating a package as the thing that can have other packages depend on it,
and depends on other packages, was wrong if a package has more than one
crate. Now, rustpkg knows about dependencies between crates in the same
package. This solves the problem reported in #7879 where rustpkg wrongly
discovered a circular dependency between thhe package and itself, and
recursed infinitely.

Closes #7879
2013-09-18 16:20:52 -07:00
Tim Chevalier
e199790bac rustpkg: Make crates, not packages, the unit of rustpkg dependencies
Treating a package as the thing that can have other packages depend on it,
and depends on other packages, was wrong if a package has more than one
crate. Now, rustpkg knows about dependencies between crates in the same
package. This solves the problem reported in #7879 where rustpkg wrongly
discovered a circular dependency between thhe package and itself, and
recursed infinitely.

Closes #7879
2013-09-18 15:30:41 -07:00
bors
8f65529627 auto merge of #9284 : thestinger/rust/main, r=luqmana
the real entry point will now pass the user's main function directly to
the scheduler
2013-09-18 15:05:56 -07:00
Alex Crichton
cb7756a81d Implement process bindings to libuv
This is a re-landing of #8645, except that the bindings are *not* being used to
power std::run just yet. Instead, this adds the bindings as standalone bindings
inside the rt::io::process module.

I made one major change from before, having to do with how pipes are
created/bound. It's much clearer now when you can read/write to a pipe, as
there's an explicit difference (different types) between an unbound and a bound
pipe. The process configuration now takes unbound pipes (and consumes ownership
of them), and will return corresponding pipe structures back if spawning is
successful (otherwise everything is destroyed normally).
2013-09-18 13:52:18 -07:00
Alex Crichton
040f1c06bc Allow trailing commas in format!
This is more consistent with other parts of the language and it also makes it
easier to use in situations where format string is massive.
2013-09-18 13:51:07 -07:00