Commit Graph

28499 Commits

Author SHA1 Message Date
bors
cba66bc920 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.
2014-05-05 21:21:34 -07:00
bors
a1ca57237b auto merge of #13946 : pnkfelix/rust/fsk-cleanup-proc-comment-in-guide-tasks, r=alexcrichton
Followup to some recent feedback in PR #13676.
2014-05-05 19:56:33 -07:00
bors
acf9d42146 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
2014-05-05 18:31:33 -07:00
bors
bd3fb81e5e 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
2014-05-05 16:51:30 -07:00
bors
7583544fb5 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?
2014-05-05 15:26:31 -07:00
bors
600507d538 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
2014-05-05 13:46:31 -07:00
bors
d943b0fee8 auto merge of #13907 : iliekturtles/rust/tutorial, r=alexcrichton
Some minor clarifications and fixes.
2014-05-05 12:21:36 -07:00
Sean McArthur
ceb29314a7 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]
2014-05-05 11:18:53 -07:00
bors
fd625dda9a 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
2014-05-05 10:06:39 -07:00
bors
2be738ae36 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
2014-05-05 08:41:39 -07:00
Mike Boutin
055cbdeee0 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.
2014-05-05 11:25:16 -04:00
Mike Boutin
e65aea522c doc: Minor example formatting in 11 References 2014-05-05 11:24:00 -04:00
Mike Boutin
81bc32d975 doc: Clarified 4.2 Pattern matching
Combined redundant paragraphs about the match expression and removed a
redundant example.
2014-05-05 11:24:00 -04:00
bors
ecc18f3444 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.)
2014-05-05 05:36:37 -07:00
Felix S. Klock II
67307d4e08 Placate rustdocs testable-by-default code blocks. 2014-05-05 14:31:06 +02:00
Edward Wang
90449abcb3 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
2014-05-05 20:17:59 +08:00
Edward Wang
7adc48527f 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.
2014-05-05 20:16:18 +08:00
Felix S. Klock II
0fb1f3fd38 Cleanup proc comment in guide-tasks.md. 2014-05-05 13:24:54 +02:00
bors
8895f25241 auto merge of #13942 : JamesLaverack/rust/master, r=luqmana
Version changed due to a newer requirement in LLVM.
2014-05-05 03:06:37 -07:00
bors
dcde1ee163 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.
2014-05-05 01:41:39 -07:00
Huon Wilson
edd9bad4ee std::comm: use Unsafe to avoid U.B. & -> &mut transmutes. 2014-05-05 18:20:41 +10:00
Huon Wilson
781ac3e777 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]
2014-05-05 18:20:41 +10:00
bors
abdacecdf8 auto merge of #13930 : alexcrichton/rust/snapshots, r=huonw
cc @pcwalton and @flaper87, this has box expressions and opt-in builtin kinds.
2014-05-04 23:16:40 -07:00
Alex Crichton
877f09bf96 Register new snapshots 2014-05-04 22:35:21 -07:00
bors
3179cd50ae 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.
2014-05-04 20:51:43 -07:00
Kevin Ballard
91e61ad967 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.
2014-05-04 20:16:13 -07:00
James Laverack
72f478f0e8 Update minimum g++ version in documentation
Version changed due to a newer requirement in LLVM.
2014-05-05 03:03:00 +01:00
bors
1b5bbbf877 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
2014-05-04 18:36:43 -07:00
bors
b0977b1e0f 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
2014-05-04 17:11:42 -07:00
bors
002f791189 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.
2014-05-04 15:46:42 -07:00
bors
028159ead4 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.
2014-05-04 14:21:52 -07:00
bors
59569397fb 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.
2014-05-04 12:06:50 -07:00
Virgile Andreani
169a57ee8d Remove two useless comparisons
according to the updated type_limits lint.
2014-05-04 20:48:16 +02:00
Virgile Andreani
0e8e0b2ede Add missing cases to the type_limits lint
and exhaustive testing for the `u8` type.
2014-05-04 20:42:45 +02:00
bors
d8e5d2712c 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.
2014-05-04 10:41:48 -07:00
Daniel Micay
f62c753b8f 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.

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
2014-05-04 12:41:14 -04:00
bors
922c420fcd auto merge of #13916 : TeXitoi/rust/shootout-mandelbrot-rewrite, r=pcwalton
- removed warning
- improved performances
- parallelization
2014-05-04 08:26:47 -07:00
bors
1c9b77643c auto merge of #13915 : nick29581/rust/rslt, r=luqmana 2014-05-04 07:01:48 -07:00
bors
9c1761d0ab auto merge of #13908 : pcwalton/rust/box-pattern, r=alexcrichton
r? @alexcrichton
2014-05-04 05:36:49 -07:00
bors
de99da3fa5 auto merge of #13898 : nikomatsakis/rust/type-bounds-b, r=acrichto
This is needed to bootstrap fix for #5723.
2014-05-04 03:41:50 -07:00
bors
0f9a74fea4 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).
2014-05-04 02:16:50 -07:00
bors
1f25c8b78d auto merge of #13895 : adrientetar/rust/js-escape, r=alexcrichton
See #13884 for the details. Closes #13884.

r? @alexcrichton
2014-05-04 00:51:50 -07:00
Niko Matsakis
92b741aad4 Skip pretty printing for the regions bound test 2014-05-03 22:05:21 -04:00
Gary M. Josack
9246682b06 Remove/Update dead links on Tasks guide. 2014-05-03 18:39:52 -07:00
bors
afed55b99b 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).

Closes #13620
2014-05-03 15:56:51 -07:00
Ali Smesseim
90ba013bde Change the licence holder to The Rust Project Developers
The copyright of this project belongs to The Rust Project Developers,
who are mentioned in AUTHORS.txt.
2014-05-03 23:59:24 +02:00
Guillaume Pinot
2acab61377 shootout-spectralnorm tweaks
- 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.
2014-05-03 23:20:13 +02:00
Phil Ruffwind
7e53af35b1 Recommend autoload instead of require
Lazy loading with autoload will result in faster startup time for Emacs
users and is generally the recommended approach for major modes.
2014-05-03 16:36:54 -04:00
Kevin Butler
74392246ff Remove comment about semicolons for inner attributes from docs and adjust comments. 2014-05-03 21:24:06 +01:00
bors
4f1b0b5199 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.
2014-05-03 12:21:47 -07:00