Commit Graph

22420 Commits

Author SHA1 Message Date
bors
137b31e2fe auto merge of #8908 : tikue/rust/master, r=anasazi
SyncChan blocks after sending a message until the SyncPort acknowledges receipt of the message.
2013-09-12 07:26:04 -07:00
bors
3c17903c36 auto merge of #9131 : Dretch/rust/glob-range-patterns, r=alexcrichton
This feature was overlooked in the original pull request (#8914).

r? @alexcrichton
2013-09-12 06:06:04 -07:00
bors
0a2d3c5a6f auto merge of #9096 : huonw/rust/linenoise, r=brson
- Wrap calls into linenoise in a mutex so that the functions don't have to be `unsafe` any more (fixes #3921)
- Stop leaking every line that linenoise reads.
- Handle the situation of `rl::complete(some_function); do spawn { rl::read(""); }` which would crash (`fail!` that turned into an abort, possibly due to failing with the lock locked) when the user attempted to tab-complete anything.
- Add a test for the various functions; it has to be run by hand to verify anything works, but it won't bitrot.
2013-09-12 04:36:06 -07:00
bors
4825db44c8 auto merge of #9012 : alexcrichton/rust/format-args, r=huonw
The purpose of this macro is to further reduce the number of allocations which
occur when dealing with formatting strings. This macro will perform all of the
static analysis necessary to validate that a format string is safe, and then it
will wrap up the "format string" into an opaque struct which can then be passed
around.

Two safe functions are added (write/format) which take this opaque argument
structure, unwrap it, and then call the unsafe version of write/format (in an
unsafe block). Other than these two functions, it is not intended for anyone to
ever look inside this opaque struct.

The macro looks a bit odd, but mostly because of rvalue lifetimes this is the
only way for it to be safe that I know of.

Example use-cases of this are:

* third-party libraries can use the default formatting syntax without any
  forced allocations
* the fail!() macro can avoid allocating the format string
* the logging macros can avoid allocation any strings

I plan on transitioning the standard logging/failing to using these macros soon. This is currently blocking on inner statics being usable in cross-crate situations (still tracking down bugs there), but this will hopefully be coming soon!

Additionally, I'd rather settle on a name now than later, so if anyone has a better suggestion other than `format_args`, I'm not attached to the name at all :)
2013-09-12 03:21:08 -07:00
bors
68125359cd auto merge of #9138 : alexcrichton/rust/dynamic-lib-not-threadsafe, r=thestinger
The library isn't thread-safe, cc #9137
2013-09-12 01:16:08 -07:00
Alex Crichton
a018a5c343 Parse underscores in identifiers for format!
Closes #9119
2013-09-12 01:07:10 -07:00
Alex Crichton
68a9137eac Rewrite fileinput tests to use std::rt::io
These tests are being very flaky on the bots, and the reason is that files are
being created and then when attempted to get read they actually don't exist. I'm
not entirely sure why this is happening, but I also don't fully trust the
std::io implemention using @-boxes to close/flush/write files at the right time.

This moves the tests to using std::rt::io which is hopefully more robust and
something that we can actually reason about. Sadly, due to #8810, these tests
fail on windows, so they're all ignored on windows right now.
2013-09-12 01:04:39 -07:00
Alex Crichton
9a5f95a82c Implement a format_args!() macro
The purpose of this macro is to further reduce the number of allocations which
occur when dealing with formatting strings. This macro will perform all of the
static analysis necessary to validate that a format string is safe, and then it
will wrap up the "format string" into an opaque struct which can then be passed
around.

Two safe functions are added (write/format) which take this opaque argument
structure, unwrap it, and then call the unsafe version of write/format (in an
unsafe block). Other than these two functions, it is not intended for anyone to
ever look inside this opaque struct.

The macro looks a bit odd, but mostly because of rvalue lifetimes this is the
only way for it to be safe that I know of.

Example use-cases of this are:

* third-party libraries can use the default formatting syntax without any
  forced allocations
* the fail!() macro can avoid allocating the format string
* the logging macros can avoid allocation any strings
2013-09-12 00:36:54 -07:00
Huon Wilson
a9184975da Add linenoise lock helpers to rustrt.def.in. 2013-09-12 17:07:24 +10:00
Alex Crichton
645b83d712 Flag the dynamic_lib tests as ignored
The library isn't thread-safe, cc #9137
2013-09-11 23:22:52 -07:00
bors
03ca1befb3 auto merge of #9114 : sfackler/rust/flush-fix, r=brson 2013-09-11 23:11:04 -07:00
Daniel Micay
b7435cf447 implement raw pointer comparisons in librustc
This is mostly for consistency, as you can now compare raw pointers in
constant expressions or without the standard library.

It also reduces the number of `ptrtoint` instructions in the IR, making
tracking down culprits of what's usually an anti-pattern easier.
2013-09-12 01:58:39 -04:00
John Clements
de5b9b9a0b added run-pass test from issue #9110 2013-09-11 22:18:45 -07:00
John Clements
e9832d44df ident->name cleanup 2013-09-11 22:18:45 -07:00
John Clements
f576ed0c76 fix for bug #9110 2013-09-11 22:18:45 -07:00
John Clements
b9a8b3700b more helpful error message for ident comparison failure 2013-09-11 22:18:45 -07:00
Luqman Aden
cbe79bbbd3 librust: Remove unnecessary workaround. Closes #7617 2013-09-12 00:25:08 -04:00
bors
62166611e7 auto merge of #9061 : jakub-/rust/pretty-print-empty-impl, r=huonw 2013-09-11 19:16:00 -07:00
Tim Kuehn
a835995488 Rendezvous stream for synchronous channel messaging 2013-09-11 22:03:54 -04:00
Jakub
de799722dc Fix the empty-impl tests
Use an existing type so that it compiles.
2013-09-11 23:58:30 +00:00
bors
91ab8a3f52 auto merge of #9014 : dcrewi/rust/convert-between-bigints, r=anasazi 2013-09-11 16:46:00 -07:00
Gareth Smith
ef08b2339d Support character range patterns (e.g. [0-9], [a-z]), like other globs do. 2013-09-11 23:46:33 +01:00
bors
7f0d261ae2 auto merge of #9064 : SiegeLord/rust/external_struct_variants, r=luqmana
Fixes issues #5557 and #8746.

This patch adds an additional family for struct-like variants, and encodes some struct-like aspects of such variants that can then be properly decoded by resolve.

Note that I am not 100% sure how this fix works, but it fixes the issue without breaking any of the tests on my machine.
2013-09-11 14:56:00 -07:00
bors
c8f69dd2a4 auto merge of #9038 : singingboyo/rust/with-mem-writer, r=anasazi
This is in many ways a replacement for the current std::io::with_str_writer.
2013-09-11 12:16:01 -07:00
SiegeLord
0766c89b42 xfail-fast the new test for windows compatibility 2013-09-11 14:51:27 -04:00
SiegeLord
2b9d19d5b5 Fix whitespace in tests 2013-09-11 14:49:10 -04:00
SiegeLord
ba5c6c3b04 Replace dashes in the filenames of the new tests with underscores to avoid issues with Windows 2013-09-11 14:49:10 -04:00
SiegeLord
55206d5a3f Add a test for cross-crate struct variants 2013-09-11 14:49:10 -04:00
SiegeLord
7ae4fd75c4 Rename encode_struct_field_names to encode_struct_fields to reflect what it actually does 2013-09-11 14:49:09 -04:00
SiegeLord
8c5402fd36 Properly encode/decode structural variants. 2013-09-11 14:49:09 -04:00
bors
f711650b8d auto merge of #8999 : anasazi/rust/multi-threaded-io-tests, r=brson
Resolves #8685
2013-09-11 10:21:02 -07:00
Florian Hahn
b0e13e0d0e Add HashSet::with_capacity_and_keys() function
This function can be use to create HashSets before the tls is
initialized.
2013-09-11 16:57:15 +02:00
bors
49eb7bd271 auto merge of #9039 : singingboyo/rust/update-for-expr-docs, r=thestinger
The old documentation for for loops/expressions has been quite wrong since the change to iterators.  This updates the docs to make them relevant to how for loops work now, if not very in-depth.  There may be a need for updates giving more depth on how they work, such as detailing what method calls they make, but I don't know enough about the implementation to include that.
2013-09-11 07:46:04 -07:00
bors
67ed30cd5e auto merge of #9097 : michaelwoerister/rust/namespaces, r=jdm
Who would have thought that namespaces are such a can of worms `:P` This is mostly because of some GDB idiosyncrasies (does not use namespace information but linkage-name attributes for displaying items contained in namespaces, also cannot handle functions lexically nested within functions), monomorphization, and information about external items only available from metadata.

This pull request tries to tackle the problem anyway:
* The `DW_AT_linkage_name` for functions is generated just to make GDB display a proper namespace-enabled function name. To this end, a pseudo-mangled name is generated, not corresponding to the real linkage name. This approach shows some success and could be extended to make GDB also show proper parameter types.
* As GDB won't accept subprogram DIEs nested within other subprogram DIEs, the `debuginfo` module now generates a *companion namespace* for each functions (iff needed). A function `fn abc()` will get a companion namespace with name `abc()`, which contains all items (modules, types, functions) declared within the functions scope. The real, proper solution, in my opinion, would be to faithfully reflect the program's lexical structure within DWARF (which allows arbitrary nesting of DIEs, afaik), but I am not sure LLVM's source level debugging implementation would like that and I am pretty sure GDB won't support this in the foreseeable future.
* Monomorphization leads to functions and companion namespaces like `somelib::some_func<int, float>()::some_other_function<bool, bool, bool>()`, which I think is the desired behaviour. There is some design space here, however. Maybe you people prefer `somelib::some_func()::some_other_function<bool, bool, bool>()` or `somelib::some_func()::some_other_function::<int, float, bool, bool, bool>()`.

The solution will work for now but there are a few things on my 'far future wish list':
* A real specification somewhere, what language constructs are mapped to what DWARF structures.
* Proper tests that directly compare the generated DWARF information to the expected results (possibly using something like [pyelftools](https://github.com/eliben/pyelftools) or llvm-dwarfdump)
* A unified implementation for crate-local and crate-external items (which would possibly involve beefing up `ast_map::path` and metadata a bit)

Any comments are welcome!

Closes #1541
Closes #1542 (there might be other issues with function name prettiness, but this specific issue should be fixed)
Closes #7715 (source locations for structs and enums are now read correctly from the AST)
2013-09-11 06:26:05 -07:00
Huon Wilson
491ce71453 Add a test for extra::rl.
This test has to be run by a human, to check inputs etc. Fortunately, it
won't bitrot (syntactically, or type-check-ly; it might bitrot
semantically), as it is designed so that the test runner compiles it with
`--cfg robot_mode`, which is used to disable the actual running of code.
2013-09-11 22:20:33 +10:00
Huon Wilson
4ed5fcb122 extra: improvements & bug fixes to rl.
- Removes a layer of indirection in the storage of the completion
  callback.
- Handles user tab completion in a task in which `complete` hasn't been
  properly. Previously, if `complete` was called in one task, and `read`
  called in another, attempting to get completions would crash. This
  makes the completion handlers non-ambiguously task-local only.
- Fix a mismatch in return values between the Rust code and linenoise.
2013-09-11 22:20:33 +10:00
Huon Wilson
fe03d827a4 extra: stop rl from leaking each line that is read. 2013-09-11 22:20:33 +10:00
Huon Wilson
21ce41d42d extra: use a mutex to wrap linenoise calls and make them threadsafe.
Fixes #3921.
2013-09-11 22:20:33 +10:00
Michael Woerister
eb32ec13f1 debuginfo: Renamed NamespaceTree to NamespaceTreeNode. 2013-09-11 14:19:56 +02:00
bors
d14bd0879d auto merge of #9107 : catamorphism/rust/rustpkg-command-line-flags, r=brson
r? @brson rustpkg now accepts most of rustc's command-line arguments and passes
them along to rustc when building or installing.

A few rarely-used arguments aren't implemented yet.

rustpkg doesn't support flags that don't make sense with rustpkg
(for example, --bin and --lib, which get inferred from crate file names).

Closes #8522
2013-09-11 05:16:04 -07:00
bors
5bb8aefed6 auto merge of #9007 : dcrewi/rust/random-bigints, r=huonw 2013-09-11 03:11:05 -07:00
bors
f8cbf41064 auto merge of #9093 : pnkfelix/rust/fsk-remove-oldvisit, r=alexcrichton 2013-09-11 01:46:07 -07:00
bors
ef6a97ddbe auto merge of #9013 : alexcrichton/rust/generated-unsafe-blocks, r=sanxiyn
This way syntax extensions can generate unsafe blocks without worrying about them generating unnecessary unsafe warnings. Perhaps a special keyword could be added to be used in macros, but I don't think that's the best solution.

Currently if you use `format!` and friends in an `unsafe` block you're guaranteed to get some unused-unsafe warnings which is unfortunate. We normally do want these warnings, but I'm ok ignoring them in the case of compiler-generated unsafe blocks. I tried to do this in the least intrusive way possible, but others may have better ideas about how to do this.
2013-09-11 00:36:07 -07:00
Alex Crichton
11e9c48353 Flag unsafe blocks from format! as compiler-generated 2013-09-11 00:13:41 -07:00
Alex Crichton
19a6fabad8 Implement the notion of a "generated unsafe block"
This way syntax extensions can generate unsafe blocks without worrying about
them generating unnecessary unsafe warnings. Perhaps a special keyword could be
added to be used in macros, but I don't think that's the best solution.
2013-09-11 00:13:22 -07:00
Steven Fackler
412ab49557 Don't fail in TcpStream.flush 2013-09-10 21:43:47 -07:00
bors
ba9fa89bfb auto merge of #9091 : sfackler/rust/buffered, r=alexcrichton
The default buffer size is the same as the one in Java's BufferedWriter.

We may want BufferedWriter to have a Drop impl that flushes, but that
isn't possible right now due to #4252/#4430. This would be a bit
awkward due to the possibility of the inner flush failing. For what it's
worth, Java's BufferedReader doesn't have a flushing finalizer, but that
may just be because Java's finalizer support is awful.

The current implementation of BufferedStream is weird in my opinion, but
it's what the discussion in #8953 settled on.

I wrote a custom copy function since vec::copy_from doesn't optimize as
well as I would like.

Closes #8953
2013-09-10 21:36:06 -07:00
Steven Fackler
71f0305cf1 Buffered I/O wrappers
The default buffer size is the same as the one in Java's BufferedWriter.

We may want BufferedWriter to have a Drop impl that flushes, but that
isn't possible right now due to #4252/#4430. This would be a bit
awkward due to the possibility of the inner flush failing. For what it's
worth, Java's BufferedReader doesn't have a flushing finalizer, but that
may just be because Java's finalizer support is awful.

Closes #8953
2013-09-10 21:26:28 -07:00
bors
8cf60de758 auto merge of #9111 : thestinger/rust/tycat, r=cmr
The line marked as being for `bot` was actually for `tycat_struct`, and
can be replaced with `tycat_other`.
2013-09-10 19:41:14 -07:00
Daniel Micay
118d374832 remove redundant tycat line from the binop table
The line marked as being for `bot` was actually for `tycat_struct`, and
can be replaced with `tycat_other`.
2013-09-10 22:36:26 -04:00