Commit Graph

34853 Commits

Author SHA1 Message Date
Niko Matsakis
096a28607f librustc: Make Copy opt-in.
This change makes the compiler no longer infer whether types (structures
and enumerations) implement the `Copy` trait (and thus are implicitly
copyable). Rather, you must implement `Copy` yourself via `impl Copy for
MyType {}`.

A new warning has been added, `missing_copy_implementations`, to warn
you if a non-generic public type has been added that could have
implemented `Copy` but didn't.

For convenience, you may *temporarily* opt out of this behavior by using
`#![feature(opt_out_copy)]`. Note though that this feature gate will never be
accepted and will be removed by the time that 1.0 is released, so you should
transition your code away from using it.

This breaks code like:

    #[deriving(Show)]
    struct Point2D {
        x: int,
        y: int,
    }

    fn main() {
        let mypoint = Point2D {
            x: 1,
            y: 1,
        };
        let otherpoint = mypoint;
        println!("{}{}", mypoint, otherpoint);
    }

Change this code to:

    #[deriving(Show)]
    struct Point2D {
        x: int,
        y: int,
    }

    impl Copy for Point2D {}

    fn main() {
        let mypoint = Point2D {
            x: 1,
            y: 1,
        };
        let otherpoint = mypoint;
        println!("{}{}", mypoint, otherpoint);
    }

This is the backwards-incompatible part of #13231.

Part of RFC #3.

[breaking-change]
2014-12-08 13:47:44 -05:00
bors
c7a9b49d1b auto merge of #19560 : sfackler/rust/should-fail-reason, r=alexcrichton
The test harness will make sure that the panic message contains the
specified string. This is useful to help make `#[should_fail]` tests a
bit less brittle by decreasing the chance that the test isn't
"accidentally" passing due to a panic occurring earlier than expected.
The behavior is in some ways similar to JUnit's `expected` feature:
`@Test(expected=NullPointerException.class)`.

Without the message assertion, this test would pass even though it's not
actually reaching the intended part of the code:
```rust
#[test]
#[should_fail(message = "out of bounds")]
fn test_oob_array_access() {
    let idx: uint = from_str("13o").unwrap(); // oops, this will panic
    [1i32, 2, 3][idx];
}
```
2014-12-08 12:12:23 +00:00
bors
cf0b4e0682 auto merge of #19506 : eddyb/rust/fmt-polish, r=alexcrichton 2014-12-08 09:02:33 +00:00
Eduard Burtescu
15ca63081b test: adjust pretty/issue-4264 for formatting changes. 2014-12-08 09:14:21 +02:00
Eduard Burtescu
fe4fdcc0f6 core: make the public fmt API completely safe. 2014-12-08 09:14:21 +02:00
Eduard Burtescu
c75e8d46c2 core: remove the dead function fmt::argumentstr. 2014-12-08 09:14:21 +02:00
bors
1e69dfa261 auto merge of #19555 : jbranchaud/rust/add-doctests-for-key-values-of-btreemap, r=Gankro 2014-12-08 05:52:28 +00:00
bors
83a44c7fa6 auto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichton
Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns:

- `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")`
- `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")`
- `vec.as_mut_slice().sort()` -> `vec.sort()`
- `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)`

---

Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation.

This is rebased on top of #19167

cc @alexcrichton @aturon
2014-12-08 02:32:31 +00:00
bors
8bca470c5a auto merge of #19561 : csouth3/rust/treeset-bitops, r=Gankro
Implement the `BitOr`, `BitAnd`, `BitXor`, and `Sub` traits from `std::ops` for TreeSet.  The behavior of these operator overloads is consistent with [RFC 235](https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#combinations).

r? @Gankro
2014-12-08 00:12:30 +00:00
Steven Fackler
a20926a51a Mention expected in testing docs 2014-12-07 16:04:56 -08:00
bors
77cd5cc54e auto merge of #19548 : luqmana/rust/mfb, r=nikomatsakis
Fixes #19367.
2014-12-07 19:02:18 +00:00
bors
558f8d8e3e auto merge of #19539 : cmr/rust/18959, r=nikomatsakis
Closes #18959

Technically, this causes code that once compiled to no longer compile, but
that code probably never ran.

[breaking-change]

------------

Not quite sure the error message is good enough, I feel like it ought to tell you "because it inherits from non-object-safe trait Foo", so I've opened up a follow-up issue #19538
2014-12-07 16:12:22 +00:00
Jorge Aparicio
1fea900de7 Fix syntax error on android tests 2014-12-07 08:49:17 -05:00
bors
a243e8820a auto merge of #19522 : mukilan/rust/import-conflicts-item, r=cmr
Fixes #19498
2014-12-07 13:42:18 +00:00
bors
1e835cc7e3 auto merge of #19488 : jbranchaud/rust/add-btree-set-doctests, r=alexcrichton
There is already a test for `union` in the test namespace, but this commit adds a doctest that will appear in the rustdocs.

Someone on IRC said, *Write doctests!*, so here I am.

I am not sure this is the best way to demonstrate the behavior of the union function, so I am open to suggestions for improving this. If I am on the right track I'd be glad to include similar doctests for `intersection`, `difference`, etc.
2014-12-07 07:12:16 +00:00
Jorge Aparicio
2ed42bfbd1 libtime: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
66f52f4c9b libtest: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
00c7786690 libterm: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
93e99b55f8 libsyntax: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
c2da923fc9 libstd: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
ba01ea3730 libserialize: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
71d8d578c6 librustc_back: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
8379d72293 libgetopts: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
98ae63753b libcollections: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
976660f3f7 libtest: remove unnecessary as_mut_slice() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
6132a90788 libstd: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
5172981207 librustdoc: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
a0a354ff22 librustc_trans: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
d64fd22c71 librustc: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
5a24058889 libcollections: remove unnecessary as_mut_slice() calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
a0621f8eba libtest: remove unnecessary as_slice() calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
53b479c195 libterm: remove unnecessary as_slice() calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
39f44c0c20 libsyntax: remove unnecessary as_slice() calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
60338d91c4 libstd: remove unnecessary as_slice() calls 2014-12-06 23:53:00 -05:00
bors
f7d18b92f8 auto merge of #19407 : frewsxcv/rust/rm-reexports, r=cmr
In regards to:

https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729

This commit:

* Changes the #deriving code so that it generates code that utilizes fewer
  reexports (in particur Option::\*, Result::\*, and Ordering::\*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized
2014-12-07 04:12:20 +00:00
Mukilan Thiyagarajan
4b75a5d8da Add compile-fail tests for #19498 2014-12-07 07:37:15 +05:30
Jorge Aparicio
09f7713dd4 libserialize: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
e6bd217ce8 librustdoc: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
8bb5ef9df5 librustc_trans: remove unnecessary as_slice calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
7d8eabb226 librustc_back: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
00f3c3f7a7 librustc: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
ae555a99a6 libregex_macros: remove unnecessary as_slice calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
89e6a81ef9 libregex: remove unnecessary as_slice calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
0ea31348d9 liblog: remove unnecessary as_slice calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
c0ef959b31 libgraphviz: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
6efc87945b libgetops: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
a7960136ac libfmt_macros: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
0f54f32a9c libflate: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
5257a5b284 libcoretest: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
0ac3b166df liballoc: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00