Commit Graph

37625 Commits

Author SHA1 Message Date
Brian Anderson
63fcbcf3ce Merge remote-tracking branch 'rust-lang/master'
Conflicts:
	mk/tests.mk
	src/liballoc/arc.rs
	src/liballoc/boxed.rs
	src/liballoc/rc.rs
	src/libcollections/bit.rs
	src/libcollections/btree/map.rs
	src/libcollections/btree/set.rs
	src/libcollections/dlist.rs
	src/libcollections/ring_buf.rs
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcollections/string.rs
	src/libcollections/vec.rs
	src/libcollections/vec_map.rs
	src/libcore/any.rs
	src/libcore/array.rs
	src/libcore/borrow.rs
	src/libcore/error.rs
	src/libcore/fmt/mod.rs
	src/libcore/iter.rs
	src/libcore/marker.rs
	src/libcore/ops.rs
	src/libcore/result.rs
	src/libcore/slice.rs
	src/libcore/str/mod.rs
	src/libregex/lib.rs
	src/libregex/re.rs
	src/librustc/lint/builtin.rs
	src/libstd/collections/hash/map.rs
	src/libstd/collections/hash/set.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/mutex.rs
	src/libstd/sync/poison.rs
	src/libstd/sync/rwlock.rs
	src/libsyntax/feature_gate.rs
	src/libsyntax/test.rs
2015-01-25 01:20:55 -08:00
bors
9bac0179df Auto merge of #20373 - huonw:self-call-lint, r=luqmana
E.g. `fn foo() { foo() }`, or, more subtlely

    impl Foo for Box<Foo+'static> {
        fn bar(&self) {
            self.bar();
        }
    }

The compiler will warn and point out the points where recursion occurs,
if it determines that the function cannot return without calling itself.

Closes #17899.

---

This is highly non-perfect, in particular, my wording above is quite precise, and I have some unresolved questions: This currently will warn about

```rust
fn foo() {
    if bar { loop {} }

    foo()
}
```

even though `foo` may never be called (i.e. our apparent "unconditional" recursion is actually conditional). I don't know if we should handle this case, and ones like it with `panic!()` instead of `loop` (or anything else that "returns" `!`).

However, strictly speaking, it seems to me that changing the above to not warn will require changing

```rust
fn foo() {
    while bar {}
    foo()
}
```

to also not warn since it could be that the `while` is an infinite loop and doesn't ever hit the `foo`.

I'm inclined to think we let these cases warn since true edge cases like the first one seem rare, and if they do occur they seem like they would usually be typos in the function call. (I could imagine someone accidentally having code like `fn foo() { assert!(bar()); foo() /* meant to be boo() */ }` which won't warn if the `loop` case is "fixed".)

(Part of the reason this is unresolved is wanting feedback, part of the reason is I couldn't devise a strategy that worked in all cases.)

---

The name `unconditional_self_calls` is kinda clunky; and this reconstructs the CFG for each function that is linted which may or may not be very expensive, I don't know.
2015-01-25 08:24:47 +00:00
Alex Crichton
0dac568578 syntax: Don't put quotes around filenames in codemap
This ends up propagating all the way out to the output of dep-info which then
makes Cargo think that files are not existent (it thinks the files have quotes
in their name) when they in fact do.
2015-01-24 22:43:11 -08:00
Dzmitry Malyshau
e5632157b1 Associated types support for deriving::generic::TraitDef 2015-01-25 00:54:30 -05:00
bors
43046becce Auto merge of #21558 - alexcrichton:result-debug, r=aturon
This commit relaxes the bound on `Result::unwrap` and `Result::unwrap_err` from
the `Display` trait to the `Debug` trait for generating an error message about
the unwrapping operation.

This commit is a breaking change and any breakage should be mitigated by
ensuring that `Debug` is implemented on the relevant type.

[breaking-change]
2015-01-25 05:50:30 +00:00
bors
70b13a7c7c Auto merge of #21511 - alfie:suffix-cleanup, r=huonw 2015-01-25 00:49:41 +00:00
Alfie John
f67e7470b3 Moving away from deprecated i/u suffixes in libcore 2015-01-25 00:17:41 +00:00
Huon Wilson
ae4e1a190b Tell the compiler to tell us that deriving is dead.
I'm beginning to suspect it's impossible to avoid accidentally writing
`#[deriving]` at least once in every program, and it results in
non-intuitive error messages: "Foo doesn't have any method in scope
`clone`" despite there being a `#[deriv...(Clone)]` attribute!

Also, lots of documentation around the internet uses `#[deriving]` so
providing this guidance is very helpful (lots of people ask in #rust
about this error).

Fixes #21166.
2015-01-25 10:44:56 +11:00
Ariel Ben-Yehuda
e7245252cc Cleanup check_cast. Fixes #21554
This also makes the cast error messages somewhat more uniform.
2015-01-25 01:44:49 +02:00
bors
4e4e8cff16 Auto merge of #21452 - bleibig:bison-grammar, r=nikomatsakis
This adds a new lexer/parser combo for the entire Rust language can be generated with with flex and bison, taken from my project at https://github.com/bleibig/rust-grammar. There is also a testing script that runs the generated parser with all *.rs files in the repository (except for tests in compile-fail or ones that marked as "ignore-test" or "ignore-lexer-test"). If you have flex and bison installed, you can run these tests using the new "check-grammar" make target.

This does not depend on or interact with the existing testing code in the grammar, which only provides and tests a lexer specification.

OS X users should take note that the version of bison that comes with the Xcode toolchain (2.3) is too old to work with this grammar, they need to download and install version 3.0 or later.

The parser builds up an S-expression-based AST, which can be displayed by giving the "-v" argument to parser-lalr (normally it only gives output on error). It is only a rough approximation of what is parsed and doesn't capture every detail and nuance of the program.

Hopefully this should be sufficient for issue #2234, or at least a good starting point.
2015-01-24 22:14:14 +00:00
bors
bb7cc4eb26 Auto merge of #21488 - aturon:os-str, r=alexcrichton
Per [RFC 517](https://github.com/rust-lang/rfcs/pull/575/), this commit introduces platform-native strings. The API is essentially as described in the RFC.

The WTF-8 implementation is adapted from @SimonSapin's [implementation](https://github.com/SimonSapin/rust-wtf8). To make this work, some encodign and decoding functionality in `libcore` is now exported in a "raw" fashion reusable for WTF-8. These exports are *not* reexported in `std`, nor are they stable.
2015-01-24 19:39:52 +00:00
Aaron Turon
c5369ebc7f Add ffi::OsString and OsStr
Per [RFC 517](https://github.com/rust-lang/rfcs/pull/575/), this commit
introduces platform-native strings. The API is essentially as described
in the RFC.

The WTF-8 implementation is adapted from @SimonSapin's
[implementation](https://github.com/SimonSapin/rust-wtf8). To make this
work, some encodign and decoding functionality in `libcore` is now
exported in a "raw" fashion reusable for WTF-8. These exports are *not*
reexported in `std`, nor are they stable.
2015-01-24 10:21:30 -08:00
bors
76fbb35831 Auto merge of #21079 - huonw:chained-cmp-tweaks, r=pnkfelix
First commit is mindless groundwork for the second one, to make the spans (arguably) nicer.

### before

```
require-parens-for-chained-comparison.rs:14:20: 14:22 error: Chained comparison operators require parentheses
require-parens-for-chained-comparison.rs:14     false == false == false;
                                                               ^~
require-parens-for-chained-comparison.rs:17:16: 17:17 error: Chained comparison operators require parentheses
require-parens-for-chained-comparison.rs:17     false == 0 < 2;
                                                           ^
require-parens-for-chained-comparison.rs:20:8: 20:9 error: Chained comparison operators require parentheses
require-parens-for-chained-comparison.rs:20     f<X>();
                                                   ^
require-parens-for-chained-comparison.rs:20:8: 20:9 help: Use ::< instead of < if you meant to specify type arguments.
require-parens-for-chained-comparison.rs:20     f<X>();
                                                   ^
```

### after

```
require-parens-for-chained-comparison.rs:14:11: 14:22 error: chained comparison operators require parentheses
require-parens-for-chained-comparison.rs:14     false == false == false;
                                                      ^~~~~~~~~~~
require-parens-for-chained-comparison.rs:17:11: 17:17 error: chained comparison operators require parentheses
require-parens-for-chained-comparison.rs:17     false == 0 < 2;
                                                      ^~~~~~
require-parens-for-chained-comparison.rs:20:6: 20:9 error: chained comparison operators require parentheses
require-parens-for-chained-comparison.rs:20     f<X>();
                                                 ^~~
require-parens-for-chained-comparison.rs:20:6: 20:9 help: use `::<...>` instead of `<...>` if you meant to specify type arguments
require-parens-for-chained-comparison.rs:20     f<X>();
                                                 ^~~
```
2015-01-24 17:07:43 +00:00
Flavio Percoco
577c4643dd don't run pretty-rpass for tests using #![main] 2015-01-24 15:10:37 +01:00
Michael Woerister
75ad1161dd debuginfo: Improve DWARF representation of unsized vecs and strings. 2015-01-24 15:02:38 +01:00
Michael Woerister
612ded78e3 debuginfo: Extend option-like-enum test case to contain nested discriminants. 2015-01-24 15:02:38 +01:00
Pyfisch
0736ad3c2a Spellfix for Debug trait
Spellfix for `Debug` trait documentation. Change "most all types should implement this" to "all types should implement this". Same fix for deprecated `Show` trait.
2015-01-24 14:54:43 +01:00
Huon Wilson
ec790d6fcc Tweak chained comparison errors.
Lower case and give a more precise span: from operator to operator, not
just the last one.
2015-01-25 00:35:06 +11:00
Huon Wilson
2e888d0341 Add the span of the operator itself to ast::BinOp. 2015-01-25 00:33:50 +11:00
Huon Wilson
0684c8ebf9 Fix infinite recursion in the compiler.
This was detected by the unconditional_recursion lint.
2015-01-25 00:21:03 +11:00
Huon Wilson
fbef241709 Add a lint to detect unconditional recursion.
E.g. `fn foo() { foo() }`, or, more subtlely

    impl Foo for Box<Foo+'static> {
        fn bar(&self) {
            self.bar();
        }
    }

The compiler will warn and point out the points where recursion occurs,
if it determines that the function cannot return without calling itself.

Closes #17899.
2015-01-25 00:21:03 +11:00
bors
0430a43d63 Auto merge of #21542 - vadimcn:fix-exported-macro-paths, r=alexcrichton
... so that `super::foo` gets serialized as `super:: foo`, rather than `super :: foo`.
2015-01-24 13:04:39 +00:00
Daniel Griffen
ec88426ea8 Implement winsize() for unix. 2015-01-24 04:25:17 -06:00
Flavio Percoco Premoli
8d40f0f3b5 Rollup merge of #21579 - brson:beta, r=alexcrichton 2015-01-24 10:42:42 +01:00
Flavio Percoco Premoli
38cb4c128e Rollup merge of #21573 - japaric:gh19660, r=huonw
closes #19660
2015-01-24 10:42:42 +01:00
Flavio Percoco Premoli
df2ab66044 Rollup merge of #21560 - steveklabnik:remove_discuss_link, r=sanxiyn
We've had some new people post questions to Discuss, so this should be removed for now. http://discuss.rust-lang.org/t/did-you-mean-to-point-to-discuss-rust-lang-org-as-a-user-forum/1381
2015-01-24 10:42:42 +01:00
Flavio Percoco Premoli
a1f15414f6 Rollup merge of #21550 - FlaPer87:fix-compiletest, r=huonw 2015-01-24 10:42:41 +01:00
Flavio Percoco Premoli
8a2eee6095 Rollup merge of #21541 - steveklabnik:gh13179, r=huonw
Fixes #13179
2015-01-24 10:42:41 +01:00
Flavio Percoco Premoli
60c9e12fb7 Rollup merge of #21540 - steveklabnik:gh13082, r=brson
Fixes #13082

r? @brson
2015-01-24 10:42:41 +01:00
Flavio Percoco Premoli
41e2d71589 Rollup merge of #21539 - iKevinY:pythonic, r=alexcrichton
Also makes `errorck.py` and `tidy.py` compatible with Python 3.
2015-01-24 10:42:41 +01:00
Flavio Percoco Premoli
dc32dfaccf Rollup merge of #21535 - steveklabnik:gh19759, r=alexcrichton
Fixes #19759 

I'm not going to bother to do more than this, as it'll end up getting re-done as part of the reference work, but at least it's correct now.
2015-01-24 10:42:40 +01:00
Flavio Percoco Premoli
fd6fb165bd Rollup merge of #21532 - steveklabnik:gh21531, r=alexcrichton
Fixes #21531
2015-01-24 10:42:40 +01:00
Flavio Percoco Premoli
82299c07de Rollup merge of #21504 - blackbeam:has_test_signature_fix, r=alexcrichton
Fix for `error: functions used as tests must have signature fn() -> ()` and `error: functions used as benches must have signature `fn(&mut Bencher) -> ()` in case of explicit return type declaration.
2015-01-24 10:42:40 +01:00
Flavio Percoco Premoli
65d14d2661 Rollup merge of #21498 - quantheory:master, r=alexcrichton
While trying to experiment with changes for some other issues, I noticed that the test for #15149 was failing because I have `/tmp` mounted as `noexec` on my Linux box, and that test tries to run out of a temporary directory. This may not be the most common case, but it's not rare by any means, because executing from a world-writable directory is a security problem. (For this reason, some kernel options/mods such as grsecurity also can prevent this on Linux.) I instead copy the executable to a directory created in the build tree, following the example of the `process-spawn-with-unicode-params` test.

After I made that change, I noticed that I'd made a mistake, but the test was still passing, because the "parent" process was not actually checking the status of the "child" process, meaning that the assertion in the child could never cause the overall test to fail. (I don't know if this has always been the case, or if it has something to do with either Windows or a change in the semantics of `spawn`.) So I fixed the test so that it would fail correctly, then fixed my original mistake so that it would pass again.

The one big problem with this is that I haven't set up any machines of my own so that I can build on Windows, which is the platform this test was targeted at in the first place! That might take a while to address on my end. So I need someone else to check this on Windows.
2015-01-24 10:42:40 +01:00
Flavio Percoco Premoli
6a9ee09a99 Rollup merge of #21445 - P1start:no-implemented, r=nikomatsakis 2015-01-24 10:42:40 +01:00
Flavio Percoco Premoli
d19f28b2f2 Rollup merge of #21108 - steveklabnik:gh16969, r=alexcrichton
Fixes #16969
2015-01-24 10:42:39 +01:00
bors
796d00948a Auto merge of #21537 - tbu-:pr_coretest_fmt, r=alexcrichton
r? @alexcrichton 

Part of #20792 that wasn't done in your commit.
2015-01-24 07:45:55 +00:00
Brian Anderson
b44ee371b8 grandfathered -> rust1 2015-01-23 21:48:20 -08:00
Brian Anderson
b7fe2c54b7 Fix bugs in featureck.py 2015-01-23 21:43:38 -08:00
Brian Anderson
2595780e26 Fix beta naming 2015-01-23 21:13:35 -08:00
bors
e5c1f166a8 Auto merge of #21458 - alexcrichton:remove-some-code, r=brson
The base64 support can be trivially removed (there are no in-tree users) and the regex support is a whopping 4k lines of code to maintain for a few non-critical uses in-tree. This commit migrates all current users in-tree away from regexes to custom matching code.

The most critical application affected by this migration is that the testing framework no longer considers filter arguments as regexes, but rather just a substring matching. It is expected that more featureful testing frameworks can evolve outside of the in-tree libtest version over time which can properly depend on libregex from crates.io.

[breaking-change]
2015-01-24 05:12:15 +00:00
Alex Crichton
6c29708bf9 regex: Remove in-tree version
The regex library was largely used for non-critical aspects of the compiler and
various external tooling. The library at this point is duplicated with its
out-of-tree counterpart and as such imposes a bit of a maintenance overhead as
well as compile time hit for the compiler itself.

The last major user of the regex library is the libtest library, using regexes
for filters when running tests. This removal means that the filtering has gone
back to substring matching rather than using regexes.
2015-01-23 21:04:10 -08:00
Alex Crichton
494896f2dd serialize: Remove base64 support
This is not used in-tree and is available out-of-tree
2015-01-23 21:03:54 -08:00
Vadim Chugunov
f09c680b4c Fix tidy. 2015-01-23 18:32:00 -08:00
Huon Wilson
000dc07f71 Store a method-from-trait's impl in some cases when it is known.
This allows one to look at an `ExprMethodCall` `foo.bar()` where `bar`
is a method in some trait and (sometimes) extract the `impl` that `bar`
is defined in, e.g.

    trait Foo {
        fn bar(&self);
    }

    impl Foo for uint { // <A>
        fn bar(&self) {}
    }

    fn main() {
        1u.bar(); // impl_def_id == Some(<A>)
    }

This definitely doesn't handle all cases, but is correct when it is
known, meaning it should only be used for certain linting/heuristic
purposes; no safety analysis.
2015-01-24 13:01:21 +11:00
Jorge Aparicio
12d7be9a28 make walk_ty walk over a trait projections
closes #21363
2015-01-23 20:13:32 -05:00
Jorge Aparicio
6f7c0b16d3 add test for issue 19660
closes #19660
2015-01-23 19:35:10 -05:00
Brian Anderson
9758c488a9 Deprecated attributes don't take 'feature' names and are paired with stable/unstable
Conflicts:
	src/libcore/atomic.rs
	src/libcore/finally.rs
	src/test/auxiliary/inherited_stability.rs
	src/test/auxiliary/lint_stability.rs
2015-01-23 15:50:03 -08:00
Alex Crichton
08246520c0 std: Relax Result::unwrap() to Debug
This commit relaxes the bound on `Result::unwrap` and `Result::unwrap_err` from
the `Display` trait to the `Debug` trait for generating an error message about
the unwrapping operation.

This commit is a breaking change and any breakage should be mitigated by
ensuring that `Debug` is implemented on the relevant type.

[breaking-change]
2015-01-23 14:11:34 -08:00
Brian Anderson
cd6d9eab5d Set unstable feature names appropriately
* `core` - for the core crate
* `hash` - hashing
* `io` - io
* `path` - path
* `alloc` - alloc crate
* `rand` - rand crate
* `collections` - collections crate
* `std_misc` - other parts of std
* `test` - test crate
* `rustc_private` - everything else
2015-01-23 13:28:40 -08:00