Commit Graph

30317 Commits

Author SHA1 Message Date
bors
4416b32768 auto merge of #14873 : pnkfelix/rust/fsk-dataflow-revisions, r=nikomatsakis
Fix #6298.  Fix  #13767.

This also includes some drive by fixes for some other issues, noted in the commits.

I still need to integrate regression tests for some cases that I noticed were missing from our unit test suite (i.e. things that compiling rustc exposes that should have been exposed when doing `make check-stage1`).  So do not land this yet, until I get the chance to add those tests.

I just wanted to get the review process started soon, since this has been long in the coming.
2014-06-18 16:16:42 +00:00
Felix S. Klock II
4c2a8bbc09 Adapt test case to match current set of emitted warnings. (or lack
thereof.)

PR 14739 injected the new message that this removes from one test
case: borrowck-vec-pattern-loan-from-mut.rs

When reviewing the test case, I was not able to convince myself that
the error message was a legitimate thing to start emitting.  Niko did
not see an obvious reason for it either, so I am going to remove it
and wait for someone (maybe Cameron Zwarich) to explain to me why we
should be emitting it.
2014-06-18 16:44:21 +02:00
Felix S. Klock II
3ddb987f45 Regression tests for flowgraph construction bug on ExprWhile. 2014-06-18 16:42:57 +02:00
Felix S. Klock II
373b0fc569 some extra test cases to cover in the borrow checker. 2014-06-18 16:42:57 +02:00
Felix S. Klock II
95fdbeee48 fix typo in borrowck doc. 2014-06-18 16:42:57 +02:00
Felix S. Klock II
263a433f19 Ensure dataflow of a proc never looks at blocks from closed-over context.
Details: in a program like:
```
type T = proc(int) -> int; /* 4 */

pub fn outer(captured /* pat 16 */: T) -> T {
    (proc(x /* pat 23 */) {
        ((captured /* 29 */).foo((x /* 30 */)) /* 28 */)
    } /* block 27 */ /* 20 */)
} /* block 19 */ /* 12 */
```
the `captured` arg is moved from the outer fn into the inner proc (id=20).

The old dataflow analysis for flowed_move_data_moves, when looking at
the inner proc, would attempt to add a kill bit for `captured` at the
end of its scope; the problem is that it thought the end of the
`captured` arg's scope was the outer fn (id=12), even though at that
point in the analysis, the `captured` arg's scope should now be
restricted to the proc itself (id=20).

This patch fixes handling of upvars so that dataflow of a fn/proc
should never attempts to add a gen or kill bit to any NodeId outside
of the current fn/proc.  It accomplishes this by adding an `LpUpvar`
variant to `borrowck::LoanPath`, so for cases like `captured` above
will carry both their original `var_id`, as before, as well as the
`NodeId` for the closure that is capturing them.

As a drive-by fix to another occurrence of a similar bug that
nikomatsakis pointed out to me earlier, this also fixes
`gather_loans::compute_kill_scope` so that it computes the kill scope
of the `captured` arg to be block 27; that is, the block for the proc
itself (id=20).

(This is an updated version that generalizes the new loan path variant
to cover all upvars, and thus renamed the variant from `LpCopiedUpvar`
to just `LpUpvar`.)
2014-06-18 16:41:53 +02:00
Felix S. Klock II
4d82456f69 middle::cfg code cleanup.
Namely:

 1. Now that cfg mod is used for dataflow, we do not need to turn on
    the `allow(deadcode)` to placate the linter.

 2. remove dead struct defn.
2014-06-18 16:41:52 +02:00
Felix S. Klock II
75340f4176 Revise dataflow to do a cfg-driven walk.
Fix #6298.

This is instead of the prior approach of emulating cfg traversal
privately by traversing AST in same way).

Of special note, this removes a special case handling of `ExprParen`
that was actually injecting a bug (since it was acting like an
expression like `(*func)()` was consuming `*func` *twice*: once from
`(*func)` and again from `*func`).  nikomatsakis was the first one to
point out that it might suffice to simply have the outer `ExprParen`
do the consumption of the contents (alone).

(This version has been updated to incorporate feedback from Niko's
review of PR 14873.)
2014-06-18 16:38:23 +02:00
Felix S. Klock II
fef63e2f23 NodeIndex should derive Show. 2014-06-18 16:36:25 +02:00
Felix S. Klock II
be9c2d1381 Bug fixes for flowgraph construction.
1. After recursively processing an ExprWhile, need to pop loop_scopes
   the same way we do for ExprLoop.

2. Proposed fix for flowgraph handling of ExprInlineAsm: we need to
   represent the flow into the subexpressions of an `asm!` block.
2014-06-18 16:36:25 +02:00
bors
78cb2f5bc0 auto merge of #14984 : thestinger/rust/libc, r=alexcrichton 2014-06-18 14:26:42 +00:00
bors
34e3232705 auto merge of #14990 : tomjakubowski/rust/emacs-fix-attribute-highlight, r=pnkfelix
This addresses the font lock regression introduced by the earlier pull
request #14818 - attributes are no longer be highligted inside of comments
and strings.

Also add some font lock test infrastructure and some tests for attribute
font locking and fix some minor nits.
2014-06-18 12:36:42 +00:00
bors
fe931c00cc auto merge of #15000 : alexcrichton/rust/fix-rustdoc-tests, r=huonw
Commits have the descriptions.
2014-06-18 10:46:41 +00:00
bors
af622a491a auto merge of #14994 : nick29581/rust/comments, r=bstrie
Plus a few other misc style things.
2014-06-18 08:56:43 +00:00
Alex Crichton
e710653a3b std: Remove dual export of Show
Closes #14996
2014-06-18 01:13:53 -07:00
Alex Crichton
72c08a4f8f rustdoc: Don't inject extern crate std.
No need to duplicate the compiler's work!

Closes #14999
2014-06-18 01:07:59 -07:00
Alex Crichton
19260b043b rustdoc: Fix testing indented code blocks
The collapse/unindent passes were run in the wrong order, generating different
markdown for indented tests.
2014-06-18 01:07:02 -07:00
Daniel Micay
bb0a42745f fix signatures of mmap-related functions from libc 2014-06-18 01:27:42 -04:00
bors
410d70b5af auto merge of #14992 : nathantypanski/rust/collect-docs, r=huonw
This updates the documentation for result::collect() and
option::collect() to use the new-style syntax for owned pointers and
vectors.

closes #14991
2014-06-18 05:26:38 +00:00
Brian Anderson
77657baf2c Mark all crates except std as experimental 2014-06-17 22:13:36 -07:00
Luqman Aden
4eb5d7baf9 librustc: Don't overwrite vtables when coercing to trait object. 2014-06-17 23:47:17 -04:00
Nathan Typanski
feceb1276e change ~[] -> Vec for collect()
This updates the documentation for result::collect() and
option::collect() to use the new-style syntax for vectors, instead of
the old ~[].

Also updates the code blocks for these docs so they will be tested
automatically.

closes #14991
2014-06-17 23:45:34 -04:00
Nick Cameron
f2dd4f3c06 Wrap debuginfo.rs at 80 columns.
Plus a few other misc style things.
2014-06-18 15:07:26 +12:00
bors
d6736a1440 auto merge of #14880 : SimonSapin/rust/byte-literals, r=alexcrichton
See #14646 (tracking issue) and rust-lang/rfcs#69.

This does not close the tracking issue, as the `bytes!()` macro still needs to be removed. It will be later, after a snapshot is made with the changes in this PR, so that the new syntax can be used when bootstrapping the compiler.
2014-06-18 02:06:37 +00:00
Kevin Butler
3791a85087 rustc: reduce redundant resolve errors. 2014-06-18 01:19:22 +01:00
bors
5c81a186e9 auto merge of #14869 : nick29581/rust/tstore, r=nmatsakis
Use ty_rptr/ty_uniq(ty_trait) rather than TraitStore to represent trait types.
Also addresses (but doesn't close) #12470.
Part of the work towards DST (#12938).
2014-06-18 00:16:37 +00:00
Tom Jakubowski
23a7d24dd7 emacs: Remove outdated references to ~ in tests 2014-06-17 16:42:42 -07:00
Tom Jakubowski
77b874b68d emacs: Add shebang to test script 2014-06-17 16:39:40 -07:00
Tom Jakubowski
9175326272 emacs: Don't overwrite font lock for attributes
This addresses the font lock regression introduced by the earlier pull
request #14818 - attributes are no longer be highligted inside of comments
and strings.

Also add some font lock test infrastructure and some tests for attribute
font locking.
2014-06-17 16:38:19 -07:00
Simon Sapin
3744d82851 Fix expected error message in a test.
The change is a result of the char/string parsing refactor.
2014-06-18 00:47:20 +02:00
bors
1bb42e557c auto merge of #14956 : nathantypanski/rust/master, r=alexcrichton
Closes #14329

Recent-ish uses of `find_linkage_metas` from my `git grep` output are [here](https://gist.github.com/nathantypanski/b9d2d453718a22765f5c), for those interested who wish to tread through the history.
2014-06-17 22:31:41 +00:00
Nick Cameron
8e7213f65b Remove TraitStore from ty_trait
Use ty_rptr/ty_uniq(ty_trait) rather than TraitStore to represent trait types.
Also addresses (but doesn't close) #12470.
Part of the work towards DST (#12938).

[breaking-change] lifetime parameters in `&mut trait` are now invariant. They used to be contravariant.
2014-06-18 10:30:33 +12:00
Simon Sapin
8de2618182 Fix some violations of stronger guarantees for mutable borrows.
See 159e27aebb
2014-06-18 00:15:24 +02:00
Simon Sapin
612bbaf7a0 Refactor backslash-escape parsing to share similar code.
Move into a new syntax::parse::lexer::StringReader method the code
that was almost duplicated for parsing backslash-escapes in
byte, byte string, char, and string literals.
2014-06-17 23:49:53 +02:00
Simon Sapin
3a52a8a8b8 Document the byte, byte string, and raw byte string literals. 2014-06-17 23:43:18 +02:00
Simon Sapin
b8a4c1415b Add br##"xx"## raw byte string literals. 2014-06-17 23:43:18 +02:00
Simon Sapin
d7e01b5809 Add a b"xx" byte string literal of type &'static [u8]. 2014-06-17 23:43:18 +02:00
Simon Sapin
bccdba0296 Add a b'x' byte literal of type u8. 2014-06-17 23:41:03 +02:00
Kevin Butler
207bfee214 rustc: Add self/super hint for extern crate resolve errors. 2014-06-17 22:08:56 +01:00
bors
ed3308098c auto merge of #14977 : pcwalton/rust/address-insignificant-reform, r=brson
`#[inline(never)]` is used.

Closes #8958.

This can break some code that relied on the addresses of statics
being distinct; add `#[inline(never)]` to the affected statics.

[breaking-change]

r? @brson
2014-06-17 20:41:38 +00:00
bors
2fd618e77a auto merge of #14976 : luqmana/rust/focwtc, r=pcwalton
Fixes #14959.
2014-06-17 18:56:35 +00:00
Patrick Walton
cad760b770 librustc: Make addresses of immutable statics insignificant unless
`#[inline(never)]` is used.

Closes #8958.

This can break some code that relied on the addresses of statics
being distinct; add `#[inline(never)]` to the affected statics.

[breaking-change]
2014-06-17 11:44:00 -07:00
Luqman Aden
8827395a3a librustc: Check regions for overloaded calls. 2014-06-17 14:27:37 -04:00
bors
db298145c7 auto merge of #14957 : alexcrichton/rust/rustdoc-fixups, r=huonw
Fixing some of rustdoc's rendering to use newer syntaxes rather than older
syntaxes.
2014-06-17 16:26:33 +00:00
Alex Crichton
7b42e3851c rustdoc: Remove outdated syntax
Fixing some of rustdoc's rendering to use newer syntaxes rather than older
syntaxes.
2014-06-17 08:23:15 -07:00
bors
acc944a35c auto merge of #14970 : nkoep/rust/patch-1, r=huonw
Compiling a crate with `rustc --crate-type=lib` produces an rlib file, not a shared object. The latter is only produced for `--crate-type=dylib`.
2014-06-17 13:36:35 +00:00
Niklas Koep
7fec86b5e2 tutorial.md: tiny correction for --crate-type=lib
Compiling a crate with `rustc --crate-type=lib` produces an rlib file, not a shared object. The latter is only produced for `--crate-type=dylib`.
2014-06-17 15:28:59 +02:00
bors
feb294ca11 auto merge of #14818 : tomjakubowski/rust/emacs-attributes-key-value, r=pnkfelix
This addresses two problems noted in #14347: the highlight of `#foo]` as an attribute, and the non-highlight of `#[foo = "bar"]`.
2014-06-17 08:16:27 +00:00
bors
9f8d2205f0 auto merge of #14945 : alexcrichton/rust/issue-14940, r=brson
This just takes a similar approach to reading stdin on windows by artificially
limiting the size of the buffers going in and out.

Closes #14940
2014-06-17 06:31:28 +00:00
Alex Crichton
d400563e17 std: Chunk writing to stdout on windows
This just takes a similar approach to reading stdin on windows by artificially
limiting the size of the buffers going in and out.

Closes #14940
2014-06-16 22:12:15 -07:00