]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agocore: Move Option::expect to libstd from libcore
Alex Crichton [Wed, 7 May 2014 04:25:36 +0000 (21:25 -0700)]
core: Move Option::expect to libstd from libcore

See #14008 for more details

10 years agocore: Fix an unsigned negation warning
Alex Crichton [Wed, 7 May 2014 04:10:22 +0000 (21:10 -0700)]
core: Fix an unsigned negation warning

10 years agotest: Update with std => core movement
Alex Crichton [Fri, 2 May 2014 02:43:05 +0000 (19:43 -0700)]
test: Update with std => core movement

10 years agocore: Get coretest working
Alex Crichton [Fri, 2 May 2014 01:06:59 +0000 (18:06 -0700)]
core: Get coretest working

This mostly involved frobbing imports between realstd, realcore, and the core
being test. Some of the imports are a little counterintuitive, but it mainly
focuses around libcore's types not implementing Show while libstd's types
implement Show.

10 years agocore: Inherit the cell module
Alex Crichton [Thu, 1 May 2014 18:19:56 +0000 (11:19 -0700)]
core: Inherit the cell module

10 years agocore: Add unwrap()/unwrap_err() methods to Result
Alex Crichton [Thu, 1 May 2014 18:12:16 +0000 (11:12 -0700)]
core: Add unwrap()/unwrap_err() methods to Result

These implementations must live in libstd right now because the fmt module has
not been migrated yet. This will occur in a later PR.

Just to be clear, there are new extension traits, but they are not necessary
once the std::fmt module has migrated to libcore, which is a planned migration
in the future.

10 years agocore: Inherit the result module
Alex Crichton [Thu, 1 May 2014 18:11:28 +0000 (11:11 -0700)]
core: Inherit the result module

The unwrap()/unwrap_err() methods are temporarily removed, and will be added
back in the next commit.

10 years agocore: Remove generics from Option::expect
Alex Crichton [Thu, 1 May 2014 17:51:30 +0000 (10:51 -0700)]
core: Remove generics from Option::expect

The prospects of a generic failure function such as this existing in libcore are
bleak, due to monomorphization not working across the crate boundary, and
allocation into a ~Any is not allowed in libcore.

The argument to expect() is now &str instead of <M: Send + Any>

[breaking-change]

10 years agocore: Add a limited implementation of failure
Alex Crichton [Thu, 1 May 2014 17:47:18 +0000 (10:47 -0700)]
core: Add a limited implementation of failure

This adds an small of failure to libcore, hamstrung by the fact that std::fmt
hasn't been migrated yet. A few asserts were re-worked to not use std::fmt
features, but these asserts can go back to their original form once std::fmt has
migrated.

The current failure implementation is to just have some symbols exposed by
std::rt::unwind that are linked against by libcore. This is an explicit circular
dependency, unfortunately. This will be officially supported in the future
through compiler support with much nicer failure messages. Additionally, there
are two depended-upon symbols today, but in the future there will only be one
(once std::fmt has migrated).

10 years agocore: Bring char/finally test style up to date
Alex Crichton [Thu, 1 May 2014 17:24:21 +0000 (10:24 -0700)]
core: Bring char/finally test style up to date

10 years agocore: Allow some #[deriving] in libcore
Alex Crichton [Thu, 1 May 2014 06:25:35 +0000 (23:25 -0700)]
core: Allow some #[deriving] in libcore

10 years agocore: Implement necessary traits for ~[T]/~str
Alex Crichton [Thu, 1 May 2014 06:19:52 +0000 (23:19 -0700)]
core: Implement necessary traits for ~[T]/~str

Coherence requires that libcore's traits be implemented in libcore for ~[T] and
~str (due to them being language defined types). These implementations cannot
live in libcore forever, but for now, until Heap/Box/Uniq is a lang item, these
implementations must reside inside of libcore. While not perfect
implementations, these shouldn't reside in libcore for too long.

With some form of lang item these implementations can be in a proper crate
because the lang item will not be present in libcore.

10 years agostd: Remove a glob to get std to compile
Alex Crichton [Thu, 1 May 2014 06:16:35 +0000 (23:16 -0700)]
std: Remove a glob to get std to compile

10 years agocore: Inherit possible string functionality
Alex Crichton [Thu, 1 May 2014 06:06:36 +0000 (23:06 -0700)]
core: Inherit possible string functionality

This moves as much allocation as possible from teh std::str module into
core::str. This includes essentially all non-allocating functionality, mostly
iterators and slicing and such.

This primarily splits the Str trait into only having the as_slice() method,
adding a new StrAllocating trait to std::str which contains the relevant new
allocation methods. This is a breaking change if any of the methods of "trait
Str" were overriden. The old functionality can be restored by implementing both
the Str and StrAllocating traits.

[breaking-change]

10 years agocore: Inherit necessary unicode functionality
Alex Crichton [Thu, 1 May 2014 06:02:55 +0000 (23:02 -0700)]
core: Inherit necessary unicode functionality

The unicode module remains private, but the normalization iterators require an
allocation, so some functionality needs to remain in libstd

10 years agocore: Inherit non-allocating slice functionality
Alex Crichton [Thu, 1 May 2014 05:54:25 +0000 (22:54 -0700)]
core: Inherit non-allocating slice functionality

This commit adds a new trait, MutableVectorAllocating, which represents
functions on vectors which can allocate.

This is another extension trait to slices which should be removed once a lang
item exists for the ~ allocation.

10 years agocore: Inherit the specific numeric modules
Alex Crichton [Thu, 1 May 2014 05:23:26 +0000 (22:23 -0700)]
core: Inherit the specific numeric modules

This implements all traits inside of core::num for all the primitive types,
removing all the functionality from libstd. The std modules reexport all of the
necessary items from the core modules.

10 years agocore: Inherit what's possible from the num module
Alex Crichton [Thu, 1 May 2014 05:14:22 +0000 (22:14 -0700)]
core: Inherit what's possible from the num module

This strips out all string-related functionality from the num module. The
inherited functionality is all that will be implemented in libcore (for now).
Primarily, libcore will not implement the Float trait or any string-related
functionality.

It may be possible to migrate string parsing functionality into libcore in the
future, but for now it will remain in libstd.

All functionality in core::num is reexported in std::num.

10 years agocore: Inhert ~/@/& cmp traits, remove old modules
Alex Crichton [Thu, 1 May 2014 05:00:31 +0000 (22:00 -0700)]
core: Inhert ~/@/& cmp traits, remove old modules

This commit removes the std::{managed, reference} modules. The modules serve
essentially no purpose, and the only free function removed was `managed::ptr_eq`
which can be achieved by comparing references.

[breaking-change]

10 years agocore: Inherit the cmp module
Alex Crichton [Thu, 1 May 2014 04:55:14 +0000 (21:55 -0700)]
core: Inherit the cmp module

This removes the TotalOrd and TotalEq implementation macros, they will be added
later to the numeric modules (where the other comparison implementations live).

10 years agocore: Inherit the iter module
Alex Crichton [Thu, 1 May 2014 04:41:03 +0000 (21:41 -0700)]
core: Inherit the iter module

10 years agocore: Inherit the option module
Alex Crichton [Thu, 1 May 2014 04:35:56 +0000 (21:35 -0700)]
core: Inherit the option module

10 years agocore: Inherit the bool module
Alex Crichton [Thu, 1 May 2014 04:11:17 +0000 (21:11 -0700)]
core: Inherit the bool module

10 years agocore: Inherit the tuple module
Alex Crichton [Thu, 1 May 2014 04:02:13 +0000 (21:02 -0700)]
core: Inherit the tuple module

10 years agocore: Bring clone tests up to date in style
Alex Crichton [Thu, 1 May 2014 03:56:40 +0000 (20:56 -0700)]
core: Bring clone tests up to date in style

10 years agocore: Inherit the clone module
Alex Crichton [Thu, 1 May 2014 03:55:38 +0000 (20:55 -0700)]
core: Inherit the clone module

10 years agocore: Inherit the unit module
Alex Crichton [Thu, 1 May 2014 03:50:56 +0000 (20:50 -0700)]
core: Inherit the unit module

10 years agocore: Inherit the default module
Alex Crichton [Thu, 1 May 2014 03:46:51 +0000 (20:46 -0700)]
core: Inherit the default module

10 years agocore: Inherit the raw module
Alex Crichton [Thu, 1 May 2014 03:38:31 +0000 (20:38 -0700)]
core: Inherit the raw module

10 years agocore: Inherit the any module
Alex Crichton [Thu, 1 May 2014 03:36:58 +0000 (20:36 -0700)]
core: Inherit the any module

10 years agocore: Inherit the finally module
Alex Crichton [Thu, 1 May 2014 03:34:41 +0000 (20:34 -0700)]
core: Inherit the finally module

10 years agocore: Inherit the char module
Alex Crichton [Thu, 1 May 2014 03:33:08 +0000 (20:33 -0700)]
core: Inherit the char module

10 years agocore: Inherit the container module
Alex Crichton [Thu, 1 May 2014 03:27:26 +0000 (20:27 -0700)]
core: Inherit the container module

10 years agocore: Inherit the ty module
Alex Crichton [Thu, 1 May 2014 03:26:12 +0000 (20:26 -0700)]
core: Inherit the ty module

10 years agocore: Inherit the ops module
Alex Crichton [Thu, 1 May 2014 03:24:32 +0000 (20:24 -0700)]
core: Inherit the ops module

10 years agocore: Inherit the kinds module
Alex Crichton [Thu, 1 May 2014 03:22:55 +0000 (20:22 -0700)]
core: Inherit the kinds module

10 years agocore: Inherit the cast module
Alex Crichton [Thu, 1 May 2014 03:20:44 +0000 (20:20 -0700)]
core: Inherit the cast module

10 years agocore: Inherit the ptr module
Alex Crichton [Thu, 1 May 2014 03:17:50 +0000 (20:17 -0700)]
core: Inherit the ptr module

10 years agocore: Inherit the mem module
Alex Crichton [Thu, 1 May 2014 03:13:05 +0000 (20:13 -0700)]
core: Inherit the mem module

10 years agocore: Inherit the intrinsics module
Alex Crichton [Thu, 1 May 2014 03:04:56 +0000 (20:04 -0700)]
core: Inherit the intrinsics module

10 years agomk: Add libcore
Alex Crichton [Thu, 1 May 2014 03:05:14 +0000 (20:05 -0700)]
mk: Add libcore

10 years agoauto merge of #13958 : pcwalton/rust/detilde, r=pcwalton
bors [Wed, 7 May 2014 12:16:48 +0000 (05:16 -0700)]
auto merge of #13958 : pcwalton/rust/detilde, r=pcwalton

for `~str`/`~[]`.

Note that `~self` still remains, since I forgot to add support for
`Box<self>` before the snapshot.

r? @brson or @alexcrichton or whoever

10 years agoauto merge of #13914 : alexcrichton/rust/pile-o-rustdoc-fixes, r=brson
bors [Wed, 7 May 2014 10:21:47 +0000 (03:21 -0700)]
auto merge of #13914 : alexcrichton/rust/pile-o-rustdoc-fixes, r=brson

Lots of assorted things here and there, all the details are in the commits.

Closes #11712

10 years agoauto merge of #13836 : jbcrail/rust/add-bitv-doc, r=alexcrichton
bors [Wed, 7 May 2014 08:56:48 +0000 (01:56 -0700)]
auto merge of #13836 : jbcrail/rust/add-bitv-doc, r=alexcrichton

10 years agolibrustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
Patrick Walton [Tue, 6 May 2014 01:56:44 +0000 (18:56 -0700)]
librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
for `~str`/`~[]`.

Note that `~self` still remains, since I forgot to add support for
`Box<self>` before the snapshot.

How to update your code:

* Instead of `~EXPR`, you should write `box EXPR`.

* Instead of `~TYPE`, you should write `Box<Type>`.

* Instead of `~PATTERN`, you should write `box PATTERN`.

[breaking-change]

10 years agoauto merge of #13754 : alexcrichton/rust/net-experimental, r=brson
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.

10 years agoAdd documentation for Bitv.
Joseph Crail [Tue, 29 Apr 2014 04:54:27 +0000 (00:54 -0400)]
Add documentation for Bitv.

10 years agoauto merge of #13892 : alexcrichton/rust/mixing-rlib-dylib-deps, r=brson
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.

cc #10729

10 years agoauto merge of #13982 : alexcrichton/rust/more-logging, r=nikomatsakis
bors [Tue, 6 May 2014 23:31:39 +0000 (16:31 -0700)]
auto merge of #13982 : alexcrichton/rust/more-logging, r=nikomatsakis

This was accidentally left out of the recent logging improvements.

10 years agolog: Use writeln!() instead of write!()
Alex Crichton [Tue, 6 May 2014 16:11:34 +0000 (09:11 -0700)]
log: Use writeln!() instead of write!()

This was accidentally left out of the recent logging improvements.

10 years agoauto merge of #13960 : brandonw/rust/master, r=alexcrichton
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.

10 years agoauto merge of #13897 : aturon/rust/issue-6085, r=bjz
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:

    bitflags!(
        #[deriving(Hash)]
        #[doc="Three flags"]
        flags Flags: u32 {
            FlagA       = 0x00000001,
            FlagB       = 0x00000010,
            FlagC       = 0x00000100
        }
    )

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`.

Closes #6085.

10 years agoauto merge of #13822 : EdorianDark/rust/master, r=cmr
bors [Tue, 6 May 2014 17:16:40 +0000 (10:16 -0700)]
auto merge of #13822 : EdorianDark/rust/master, r=cmr

New attempt to generalize stats, after #12606.
Since #12355 did not get merged, i want go get first get my change done and the try to fix sum.

10 years agoUpdate multiple file use statement example
Brandon Waskiewicz [Tue, 6 May 2014 02:41:10 +0000 (22:41 -0400)]
Update multiple file use statement example

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.

10 years agoauto merge of #13962 : luqmana/rust/al, r=alexcrichton
bors [Tue, 6 May 2014 15:06:45 +0000 (08:06 -0700)]
auto merge of #13962 : luqmana/rust/al, r=alexcrichton

10 years agoauto merge of #13961 : richo/rust/richo-author, r=alexcrichton
bors [Tue, 6 May 2014 08:36:34 +0000 (01:36 -0700)]
auto merge of #13961 : richo/rust/richo-author, r=alexcrichton

Shamelessly adds myself as a contributor.

10 years agoauto merge of #13952 : aaronraimist/rust/patch-1, r=thestinger
bors [Tue, 6 May 2014 07:11:37 +0000 (00:11 -0700)]
auto merge of #13952 : aaronraimist/rust/patch-1, r=thestinger

10 years agoLower armhf target feature to v6.
Luqman Aden [Tue, 6 May 2014 06:05:05 +0000 (02:05 -0400)]
Lower armhf target feature to v6.

10 years agoauto merge of #13939 : richo/rust/docs/composability, r=thestinger
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.

10 years agoauto merge of #13925 : kballard/rust/vim_indent_bracket_fix, r=thestinger
bors [Tue, 6 May 2014 04:21:34 +0000 (21:21 -0700)]
auto merge of #13925 : kballard/rust/vim_indent_bracket_fix, r=thestinger

If an unbalanced [ exists in a string or comment, this should not be
considered when calculating the indent at the top level.

Similarly, when testing for ({/}) to see if we're at the top level to
begin with, strings and comments should be skipped.

10 years agoAdd Richo Healey to contributors
Richo Healey [Tue, 6 May 2014 03:44:47 +0000 (20:44 -0700)]
Add Richo Healey to contributors

10 years agoauto merge of #13946 : pnkfelix/rust/fsk-cleanup-proc-comment-in-guide-tasks, r=alexc...
bors [Tue, 6 May 2014 02:56:33 +0000 (19:56 -0700)]
auto merge of #13946 : pnkfelix/rust/fsk-cleanup-proc-comment-in-guide-tasks, r=alexcrichton

Followup to some recent feedback in PR #13676.

10 years agoauto merge of #13940 : edwardw/rust/refutable-match, r=pcwalton
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.

Closes #13867

10 years agoauto merge of #13934 : huonw/rust/transmute-mut, r=alexcrichton
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`.)

cc https://github.com/mozilla/rust/issues/13933

10 years agoauto merge of #13912 : seanmonstar/rust/logrecord, r=alexcrichton
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.

@alexcrichton r?

10 years agoChange std::io::FilePermission to a typesafe representation
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`.

Closes #6085.

[breaking-change]

10 years agoAdd (unsafe) coercion from bits to std::bitflags
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.

10 years agoAllow attributes in std::bitflags::bitflags!
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:

    bitflags!(
        #[deriving(Hash)]
        #[doc="Three flags"]
        flags Flags: u32 {
            #[doc="The first flag"]
            static FlagA       = 0x00000001,
            static FlagB       = 0x00000010,
            static FlagC       = 0x00000100
        }
    )

10 years agoauto merge of #13782 : alexcrichton/rust/issue-13775, r=pcwalton
bors [Mon, 5 May 2014 20:46:31 +0000 (13:46 -0700)]
auto merge of #13782 : alexcrichton/rust/issue-13775, r=pcwalton

These often crop up when using default methods that don't actually bind their
argument names.

Closes #13775

10 years agoUpdated CONTRIBUTING.md for 2014
Aaron Raimist [Mon, 5 May 2014 20:46:10 +0000 (15:46 -0500)]
Updated CONTRIBUTING.md for 2014

10 years agoauto merge of #13907 : iliekturtles/rust/tutorial, r=alexcrichton
bors [Mon, 5 May 2014 19:21:36 +0000 (12:21 -0700)]
auto merge of #13907 : iliekturtles/rust/tutorial, r=alexcrichton

Some minor clarifications and fixes.

10 years agolog: Logger receiveis a LogRecord
Sean McArthur [Sat, 3 May 2014 02:32:47 +0000 (19:32 -0700)]
log: Logger receiveis a LogRecord

The logging macros now create a LogRecord, and pass that to the
Logger, instead of passing a `level` and `args`. The new signature is:

    trait Logger {
        fn log(&mut self, record: &LogRecord);
    }

The LogRecord includes additional values that may be useful to custom
loggers, and also allows for further expansion if not values are found
useful.

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.

[breaking-change]

10 years agoauto merge of #13271 : stepancheg/rust/align, r=pcwalton
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

10 years agoauto merge of #13935 : thestinger/rust/noalias, r=pcwalton
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.

Test case:

    pub fn foo(x: &mut &mut u32) {
        **x = 5;
        **x = 5;
    }

Before:

    define void @_ZN3foo20h0ce94c9671b0150bdaa4v0.0E(i32** nocapture readonly) unnamed_addr #0 {
    entry-block:
      %1 = load i32** %0, align 8
      store i32 5, i32* %1, align 4
      %2 = load i32** %0, align 8
      store i32 5, i32* %2, align 4
      ret void
    }

After:

    define void @_ZN3foo20h0ce94c9671b0150bdaa4v0.0E(i32** noalias nocapture readonly) unnamed_addr #0 {
    entry-block:
      %1 = load i32** %0, align 8
      store i32 5, i32* %1, align 4
      ret void
    }

Closes #12436

10 years agodoc: Corrected example in 17.8 Deriving implementations for traits
Mike Boutin [Fri, 2 May 2014 17:39:08 +0000 (13:39 -0400)]
doc: Corrected example in 17.8 Deriving implementations for traits

Corrected example to to use Rand trait referenced in preceding
description and included an example using the Show trait to print ABC.

10 years agodoc: Minor example formatting in 11 References
Mike Boutin [Wed, 30 Apr 2014 00:35:26 +0000 (20:35 -0400)]
doc: Minor example formatting in 11 References

10 years agodoc: Clarified 4.2 Pattern matching
Mike Boutin [Sat, 26 Apr 2014 15:41:23 +0000 (11:41 -0400)]
doc: Clarified 4.2 Pattern matching

Combined redundant paragraphs about the match expression and removed a
redundant example.

10 years agoauto merge of #13749 : pnkfelix/rust/add-libgraphviz-crate, r=alexcrichton
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.)

10 years agoPlacate rustdocs testable-by-default code blocks.
Felix S. Klock II [Mon, 5 May 2014 12:31:06 +0000 (14:31 +0200)]
Placate rustdocs testable-by-default code blocks.

10 years agoAdjust codegen logic for range and guarded arms
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.

Closes #13867

10 years agoReverse #13034
Edward Wang [Sun, 4 May 2014 14:08:45 +0000 (22:08 +0800)]
Reverse #13034

It has been found that #13034 was flawed and caused regression #13867.
This patch reveres the changes made by it except the companion tests.

10 years agoCleanup proc comment in guide-tasks.md.
Felix S. Klock II [Mon, 5 May 2014 11:24:54 +0000 (13:24 +0200)]
Cleanup proc comment in guide-tasks.md.

10 years agoauto merge of #13942 : JamesLaverack/rust/master, r=luqmana
bors [Mon, 5 May 2014 10:06:37 +0000 (03:06 -0700)]
auto merge of #13942 : JamesLaverack/rust/master, r=luqmana

Version changed due to a newer requirement in LLVM.

10 years agoauto merge of #13936 : Armavica/rust/lint_check-range, r=kballard
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.

10 years agostd::comm: use Unsafe to avoid U.B. & -> &mut transmutes.
Huon Wilson [Sun, 4 May 2014 13:35:48 +0000 (23:35 +1000)]
std::comm: use Unsafe to avoid U.B. & -> &mut transmutes.

10 years agostd: deprecate cast::transmute_mut.
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`.)

[breaking-change]

10 years agoauto merge of #13930 : alexcrichton/rust/snapshots, r=huonw
bors [Mon, 5 May 2014 06:16:40 +0000 (23:16 -0700)]
auto merge of #13930 : alexcrichton/rust/snapshots, r=huonw

cc @pcwalton and @flaper87, this has box expressions and opt-in builtin kinds.

10 years agoRegister new snapshots
Alex Crichton [Sun, 4 May 2014 08:16:16 +0000 (01:16 -0700)]
Register new snapshots

10 years agoauto merge of #13924 : gmjosack/rust/master, r=alexcrichton
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.

10 years agovim: Fix indentation at global scope after non-semantic ([{/)]}
Kevin Ballard [Sun, 4 May 2014 00:00:32 +0000 (17:00 -0700)]
vim: Fix indentation at global scope after non-semantic ([{/)]}

If an unbalanced [ exists in a string or comment, this should not be
considered when calculating the indent at the top level.

Similarly, when testing for ({/}) to see if we're at the top level to
begin with, strings and comments should be skipped.

10 years agoUpdate minimum g++ version in documentation
James Laverack [Mon, 5 May 2014 02:03:00 +0000 (03:03 +0100)]
Update minimum g++ version in documentation

Version changed due to a newer requirement in LLVM.

10 years agoauto merge of #13865 : alexcrichton/rust/issue-13861, r=brson
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.

Closes #13861

10 years agoauto merge of #13905 : alexcrichton/rust/issue-13337, r=thestinger
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.

Closes #13337

10 years agoauto merge of #13923 : Rufflewind/rust/patch-2, r=thestinger
bors [Sun, 4 May 2014 22:46:42 +0000 (15:46 -0700)]
auto merge of #13923 : Rufflewind/rust/patch-2, r=thestinger

Lazy loading with autoload will result in faster startup time for Emacs
users and is generally the recommended approach for major modes.

10 years agoauto merge of #13676 : mdinger/rust/tutorial_doc, r=pnkfelix
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.

10 years agodocs: change compositionality to composability
Richo Healey [Sun, 4 May 2014 21:16:08 +0000 (14:16 -0700)]
docs: change compositionality to composability

10 years agoauto merge of #13921 : TeXitoi/rust/shootout-spectralnorm-tweaks, r=alexcrichton
bors [Sun, 4 May 2014 19:06:50 +0000 (12:06 -0700)]
auto merge of #13921 : TeXitoi/rust/shootout-spectralnorm-tweaks, r=alexcrichton

- using libgreen to optimize CPU usage
- less tasks to limit wasted resources

Here, on a one core 2 threads CPU, new version is ~1.2 faster.  May
be better with more core.

10 years agoRemove two useless comparisons
Virgile Andreani [Sun, 4 May 2014 18:48:16 +0000 (20:48 +0200)]
Remove two useless comparisons

according to the updated type_limits lint.

10 years agoAdd missing cases to the type_limits lint
Virgile Andreani [Sun, 4 May 2014 18:42:45 +0000 (20:42 +0200)]
Add missing cases to the type_limits lint

and exhaustive testing for the `u8` type.

10 years agoauto merge of #13920 : Ryman/rust/inner_attr_doc, r=alexcrichton
bors [Sun, 4 May 2014 17:41:48 +0000 (10:41 -0700)]
auto merge of #13920 : Ryman/rust/inner_attr_doc, r=alexcrichton

Also updated the comment for `parse_inner_attrs_and_next` and removed extra whitespace on line endings.