bors [Wed, 7 May 2014 05:01:43 +0000 (22:01 -0700)]
auto merge of #13754 : alexcrichton/rust/net-experimental, r=brson
The underlying I/O objects implement a good deal of various options here and
there for tuning network sockets and how they perform. Most of this is a relic
of "whatever libuv provides", but these options are genuinely useful.
It is unclear at this time whether these options should be well supported or
not, or whether they have correct names or not. For now, I believe it's better
to expose the functionality than to not, but all new methods are added with
an #[experimental] annotation.
bors [Wed, 7 May 2014 02:46:44 +0000 (19:46 -0700)]
auto merge of #13892 : alexcrichton/rust/mixing-rlib-dylib-deps, r=brson
Currently, rustc requires that a linkage be a product of 100% rlibs or 100%
dylibs. This is to satisfy the requirement that each object appear at most once
in the final output products. This is a bit limiting, and the upcoming libcore
library cannot exist as a dylib, so these rules must change.
The goal of this commit is to enable *some* use cases for mixing rlibs and
dylibs, primarily libcore's use case. It is not targeted at allowing an
exhaustive number of linkage flavors.
There is a new dependency_format module in rustc which calculates what format
each upstream library should be linked as in each output type of the current
unit of compilation. The module itself contains many gory details about what's
going on here.
bors [Tue, 6 May 2014 22:06:52 +0000 (15:06 -0700)]
auto merge of #13960 : brandonw/rust/master, r=alexcrichton
Update the example to make the usage of `pub mod foo;` much more
apparent, as well as using an example where setting the visibility of
the module is actually necessary.
bors [Tue, 6 May 2014 19:41:55 +0000 (12:41 -0700)]
auto merge of #13897 : aturon/rust/issue-6085, r=bjz
The `std::bitflags::bitflags!` macro did not provide support for
adding attributes to the generates structure, due to limitations in
the parser for macros. This patch works around the parser limitations
by requiring a `flags` keyword in the `bitflags!` invocations:
The intent of `std::bitflags` is to allow building type-safe wrappers
around C-style flags APIs. But in addition to construction these flags
from the Rust side, we need a way to convert them from the C
side. This patch adds a `from_bits` function, which is unsafe since
the bits in question may not represent a valid combination of flags.
Finally, this patch changes `std::io::FilePermissions` from an exposed
`u32` representation to a typesafe representation (that only allows valid
flag combinations) using the `std::bitflags`.
Update the example to make the usage of `pub mod foo;` much more
apparent, as well as using an example where setting the visibility of
the module is actually necessary.
bors [Tue, 6 May 2014 05:46:35 +0000 (22:46 -0700)]
auto merge of #13939 : richo/rust/docs/composability, r=thestinger
While there are various references to the work compositionality on the web, I can't find any reference to it being an actual word. My understanding is that composability is what's actually meant here anyway.
bors [Tue, 6 May 2014 01:31:33 +0000 (18:31 -0700)]
auto merge of #13940 : edwardw/rust/refutable-match, r=pcwalton
By carefully distinguishing falling back to the default arm from moving
on to the next pattern, this patch adjusts the codegen logic for range
and guarded arms of pattern matching expression. It is a more
appropriate way of fixing #12582 and #13027 without causing regressions
such as #13867.
bors [Mon, 5 May 2014 23:51:30 +0000 (16:51 -0700)]
auto merge of #13934 : huonw/rust/transmute-mut, r=alexcrichton
Turning a `&T` into an `&mut T` is undefined behaviour, and needs to be
done very very carefully. Providing a convenience function for exactly
this task is a bad idea, just tempting people into doing the wrong
thing.
(The right thing is to use types like `Cell`, `RefCell` or `Unsafe`.)
bors [Mon, 5 May 2014 22:26:31 +0000 (15:26 -0700)]
auto merge of #13912 : seanmonstar/rust/logrecord, r=alexcrichton
The logging macros now create a LogRecord, and pass that to the Logger. This will allow custom loggers to change the formatting, and possible filter on more properties of the log record.
DefaultLogger's formatting was taken from Python's default formatting:
`LEVEL:from: message`
Also included: fmt::Arguments now implement Show, so they can be used to
extend format strings.
Aaron Turon [Fri, 2 May 2014 17:56:26 +0000 (10:56 -0700)]
Change std::io::FilePermission to a typesafe representation
This patch changes `std::io::FilePermissions` from an exposed `u32`
representation to a typesafe representation (that only allows valid
flag combinations) using the `std::bitflags`, thus ensuring a greater
degree of safety on the Rust side.
Despite the change to the type, most code should continue to work
as-is, sincde the new type provides bit operations in the style of C
flags. To get at the underlying integer representation, use the `bits`
method; to (unsafely) convert to `FilePermissions`, use
`FilePermissions::from_bits`.
Aaron Turon [Fri, 2 May 2014 17:41:07 +0000 (10:41 -0700)]
Add (unsafe) coercion from bits to std::bitflags
The intent of `std::bitflags` is to allow building type-safe wrappers
around C-style flags APIs. But in addition to construction these flags
from the Rust side, we need a way to convert them from the C
side. This patch adds a `from_bits` function, which is unsafe since
the bits in question may not represent a valid combination of flags.
Aaron Turon [Fri, 2 May 2014 16:41:34 +0000 (09:41 -0700)]
Allow attributes in std::bitflags::bitflags!
The `std::bitflags::bitflags!` macro did not provide support for
adding attributes to the generated structure or flags, due to
limitations in the parser for macros. This patch works around the
parser limitations by requiring a `flags` keyword in the overall
`bitflags!` invocation, and a `static` keyword for each flag:
bors [Mon, 5 May 2014 17:06:39 +0000 (10:06 -0700)]
auto merge of #13271 : stepancheg/rust/align, r=pcwalton
This patch fixes issue #13186.
When generating constant expression for enum, it is possible that
alignment of expression may be not equal to alignment of type. In that
case space after last struct field must be padded to match size of value
and size of struct. This commit adds that padding.
See detailed explanation in src/test/run-pass/trans-tag-static-padding.rs
bors [Mon, 5 May 2014 15:41:39 +0000 (08:41 -0700)]
auto merge of #13935 : thestinger/rust/noalias, r=pcwalton
This was removed because these could alias with `&const T` or `@mut T`
and those are now gone from the language. There are still aliasing
issues within local scopes, but this is correct for function parameters.
This also removes the no-op `noalias` marker on proc (not a pointer) and
leaves out the mention of #6750 because real type-based alias analysis
is not within the scope of best effort usage of the `noalias` attribute.
bors [Mon, 5 May 2014 12:36:37 +0000 (05:36 -0700)]
auto merge of #13749 : pnkfelix/rust/add-libgraphviz-crate, r=alexcrichton
Add a `graphviz` crate for making .dot files to layout and render graphs.
(This is a precursor to other work to render control-flow graphs from within rustc itself; but this crate should be independently usable, since it abstracts over the client's graph-representation and labeling method.)
Edward Wang [Sun, 4 May 2014 22:16:16 +0000 (06:16 +0800)]
Adjust codegen logic for range and guarded arms
By carefully distinguishing falling back to the default arm from moving
on to the next pattern, this patch adjusts the codegen logic for range
and guarded arms of pattern matching expression. It is a more
appropriate way of fixing #12582 and #13027 without causing regressions
such as #13867.
bors [Mon, 5 May 2014 08:41:39 +0000 (01:41 -0700)]
auto merge of #13936 : Armavica/rust/lint_check-range, r=kballard
Some cases were not correctly handled by this lint, for instance `let a = 42u8; a < 0` and `let a = 42u8; a > 255`.
It led to the discovery of two useless comparisons, which I removed.
Huon Wilson [Sun, 4 May 2014 13:17:37 +0000 (23:17 +1000)]
std: deprecate cast::transmute_mut.
Turning a `&T` into an `&mut T` carries a large risk of undefined
behaviour, and needs to be done very very carefully. Providing a
convenience function for exactly this task is a bad idea, just tempting
people into doing the wrong thing.
The right thing is to use types like `Cell`, `RefCell` or `Unsafe`.
For memory safety, Rust has that guarantee that `&mut` pointers do not
alias with any other pointer, that is, if you have a `&mut T` then that
is the only usable pointer to that `T`. This allows Rust to assume that
writes through a `&mut T` do not affect the values of any other `&` or
`&mut` references. `&` pointers have no guarantees about aliasing or
not, so it's entirely possible for the same pointer to be passed into
both arguments of a function like
fn foo(x: &int, y: &int) { ... }
Converting either of `x` or `y` to a `&mut` pointer and modifying it
would affect the other value: invalid behaviour.
(Similarly, it's undefined behaviour to modify the value of an immutable
local, like `let x = 1;`.)
At a low-level, the *only* safe way to obtain an `&mut` out of a `&` is
using the `Unsafe` type (there are higher level wrappers around it, like
`Cell`, `RefCell`, `Mutex` etc.). The `Unsafe` type is registered with
the compiler so that it can reason a little about these `&` to `&mut`
casts, but it is still up to the user to ensure that the `&mut`s
obtained out of an `Unsafe` never alias.
(Note that *any* conversion from `&` to `&mut` can be invalid, including
a plain `transmute`, or casting `&T` -> `*T` -> `*mut T` -> `&mut T`.)
bors [Mon, 5 May 2014 03:51:43 +0000 (20:51 -0700)]
auto merge of #13924 : gmjosack/rust/master, r=alexcrichton
Most of the links I've removed are for types that don't exist anymore with the exception of `SendReceiver` though I'm not sure how useful it is to link to that without the accompanying `Receiver` and `Sender` and I don't know how useful those links are when they're discussed below and `channel`/`sync_channel` is on the `std::comm` page already linked.
bors [Mon, 5 May 2014 01:36:43 +0000 (18:36 -0700)]
auto merge of #13865 : alexcrichton/rust/issue-13861, r=brson
Previously, windows was using the CREATE_NEW flag which fails if the file
previously existed, which differed from the unix semantics. This alters the
opening to use the OPEN_ALWAYS flag to mirror the unix semantics.
bors [Mon, 5 May 2014 00:11:42 +0000 (17:11 -0700)]
auto merge of #13905 : alexcrichton/rust/issue-13337, r=thestinger
This has long since not been too relevant since the introduction of many crate
type outputs. This commit removes the flag entirely, adjusting all logic to do
the most reasonable thing when building both a library and an executable.
bors [Sun, 4 May 2014 21:21:52 +0000 (14:21 -0700)]
auto merge of #13676 : mdinger/rust/tutorial_doc, r=pnkfelix
Improve tutorial discussion of closures, e.g. with respect to type inference and variable capture.
Fix #13621
---- original description follows
I'd like this pulled to master if possible but if not I'd appreciate comments on what I need to change. I found the closures difficult to understand as they were so I tried to explain it so I would've had an easier time understanding it. I think it's better at least, somewhat.
I don't know that everyone liked the `-> ()` I included but I thought explicit is best to aid understanding. I thought it was much harder to understand than it should have been.
[EDIT] - Clicked too early.
This doesn't `make check` without errors on my Xubuntu on Virtualbox machine. Not sure why. I don't think I changed anything problematic. I'll try `make check` on master tomorrow.
Opened https://github.com/mozilla/rust/issues/13621 regarding this.
Daniel Micay [Sun, 4 May 2014 16:11:20 +0000 (12:11 -0400)]
add back `noalias` to `&mut T` pointer parameters
This was removed because these could alias with `&const T` or `@mut T`
and those are now gone from the language. There are still aliasing
issues within local scopes, but this is correct for function parameters.
This also removes the no-op `noalias` marker on proc (not a pointer) and
leaves out the mention of #6750 because real type-based alias analysis
is not within the scope of best effort usage of the `noalias` attribute.
bors [Sun, 4 May 2014 09:16:50 +0000 (02:16 -0700)]
auto merge of #13391 : smesseim/rust/apache-copyright, r=alexcrichton
The years of copyright and the name of the copyright holder were not
present in the notice.
The Apache license was added to the project in 2012, so 2012 is the
starting year. The copyright holder is the Mozilla Foundation (taken
from the MIT license).
Alex Crichton [Sat, 3 May 2014 03:16:03 +0000 (20:16 -0700)]
rustdoc: Turn the noise down on implemented traits
This commit removes the inherited documentation from type pages. This generally
just clutters up the page when you can click through to the trait itself to get
all the meaty documentation.
Alex Crichton [Sat, 3 May 2014 00:56:35 +0000 (17:56 -0700)]
rustdoc: Migrate from sundown to hoedown
This primary fix brought on by this upgrade is the proper matching of the ```
and ~~~ doc blocks. This also moves hoedown to a git submodule rather than a
bundled repository.
Additionally, hoedown is stricter about code blocks, so this ended up fixing a
lot of invalid code blocks (ending with " ```" instead of "```", or ending with
"~~~~" instead of "~~~").
bors [Sat, 3 May 2014 22:56:51 +0000 (15:56 -0700)]
auto merge of #13906 : alexcrichton/rust/issue-13620, r=luqmana
This ensures that private functions exported through static initializers will
actually end up being public in the object file (so other objects can continue
to reference the function).
bors [Sat, 3 May 2014 19:21:47 +0000 (12:21 -0700)]
auto merge of #13685 : Ryman/rust/issue7575, r=alexcrichton
Closes #7575.
I don't think the change from a contains lookup to an iteration of the HashSet in the resolver should be much of a burden as the set of methods with the same name should be relatively small.
bors [Sat, 3 May 2014 15:06:49 +0000 (08:06 -0700)]
auto merge of #13868 : FlaPer87/rust/opt-in-phase1, r=alexcrichton
This is a first patch towards an opt-in built-in trait world. This patch removes the restriction on built-in traits and allows such traits to be derived.
Alex Crichton [Sat, 3 May 2014 00:19:19 +0000 (17:19 -0700)]
rustdoc: Have no_run imply no_trans
This allows writing code examples which pass all analysis of the compiler, but
don't actually link. A good example is examples that use extern {} blocks.
Alex Crichton [Sat, 3 May 2014 00:16:30 +0000 (17:16 -0700)]
rustdoc: Allow forcing inlining of `pub use`
Rustdoc currently doesn't inline documentation of a `pub use` if the target is
publicly reachable. This changes rustdoc to allow a #[doc(inline)] attribute to
force inlining the documentation, regardless of whether the targe is public or
not.
Alex Crichton [Sat, 3 May 2014 00:08:11 +0000 (17:08 -0700)]
rustdoc: Make static initalizers prettier
Previously, if an initializer took multiple lines or was just large in general,
it was pretty poorly rendered [1] [2]. This alters the logic to just link back
to the source for any multi-line static, with a placeholder of "[definition]".
This should make reading statics a little easier on the eyes. All single-line
statics are still inlined in the documentation.
Alex Crichton [Fri, 2 May 2014 23:39:08 +0000 (16:39 -0700)]
syntax: Fix duplicate attributes on module files
The outer attributes were manually appended when a module file was parsed, but
the attributes were also added higher up the stack of parsing (when the module
finished parsing). This removes the append in parsing the module file.
Alex Crichton [Fri, 2 May 2014 23:03:09 +0000 (16:03 -0700)]
rustdoc: Fix inclusion of the new fonts
These fonts were moved into place by rust's makefiles, but rustdoc is widely
used outside of rustc itself. This moves the fonts into the rustdoc binary,
similarly to the other static assets, and writes them to the output location
whenever rustdoc generates documentation.