Commit Graph

1287 Commits

Author SHA1 Message Date
Niko Matsakis
f45c0ef51e Implement "perfect forwarding" for HR impls (#19730). 2014-12-19 03:29:31 -05:00
Niko Matsakis
1205fd88df Centralize on using Binder to introduce new binding levels, rather than having FnSig carry an implicit binding level. This means that we be more typesafe in general, since things that instantiate bound regions can drop the Binder to reflect that. 2014-12-19 03:29:30 -05:00
Niko Matsakis
3cf0fbeee9 Create distinct types for a PolyTraitRef (with bindings) and a normal TraitRef. 2014-12-19 03:29:30 -05:00
Alexis Beingessner
67d3823fc3 enumset fallout 2014-12-18 16:20:32 -05:00
Patrick Walton
ddb2466f6a librustc: Always parse macro!()/macro![] as expressions if not
followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]
2014-12-18 12:09:07 -05:00
bors
41f5907fa6 auto merge of #19777 : nikomatsakis/rust/warn-on-shadowing, r=acrichto
per rfc 459
cc https://github.com/rust-lang/rust/issues/19390

One question is: should we start by warning, and only switch to hard error later? I think we discussed something like this in the meeting. 

r? @alexcrichton
2014-12-16 08:42:40 +00:00
bors
0669a432a2 auto merge of #19448 : japaric/rust/binops-by-value, r=nikomatsakis
- The following operator traits now take their arguments by value: `Add`, `Sub`, `Mul`, `Div`, `Rem`, `BitAnd`, `BitOr`, `BitXor`, `Shl`, `Shr`. This breaks all existing implementations of these traits.

- The binary operation `a OP b` now "desugars" to `OpTrait::op_method(a, b)` and consumes both arguments.

- `String` and `Vec` addition have been changed to reuse the LHS owned value, and to avoid internal cloning. Only the following asymmetric operations are available: `String + &str` and `Vec<T> + &[T]`, which are now a short-hand for the "append" operation.

[breaking-change]

---

This passes `make check` locally. I haven't touch the unary operators in this PR, but converting them to by value should be very similar to this PR. I can work on them after this gets the thumbs up.

@nikomatsakis r? the compiler changes
@aturon r? the library changes. I think the only controversial bit is the semantic change of the `Vec`/`String` `Add` implementation.
cc #19148
2014-12-15 22:11:44 +00:00
Niko Matsakis
1718cd6ee0 Remove all shadowed lifetimes. 2014-12-15 10:23:48 -05:00
Brian Anderson
3673486c6d rollup merge of #19774: tomjakubowski/rustdoc-consts-statics
Build `clean::ConstantItem` values in the `inline` module and
pretty-print the AST for inlined const items.

Doc strings are still missing from inlined constants (see #19773).

Partially address #18156, #19722, #19185

Fix #15821

r? @alexcrichton
2014-12-15 06:45:34 -08:00
Brian Anderson
6c4a2bc55f rollup merge of #19710: steveklabnik/gh15449
Fixes #15499.
2014-12-15 06:44:20 -08:00
Niko Matsakis
22f777ba2e Parse unsafe impl but don't do anything particularly interesting with the results. 2014-12-14 11:11:55 -05:00
Niko Matsakis
5686a91914 Parse unsafe trait but do not do anything with it beyond parsing and integrating into rustdoc etc. 2014-12-14 11:11:55 -05:00
Niko Matsakis
092d04a40a Rename FnStyle trait to Unsafety. 2014-12-14 11:11:55 -05:00
Niko Matsakis
5c3d398919 Mostly rote conversion of proc() to move|| (and occasionally Thunk::new) 2014-12-14 04:21:56 -05:00
Niko Matsakis
d8e51ea0e2 Patch rustdoc to include missing types, make the match exhaustive
to prevent such oversights in the future.
2014-12-14 04:21:56 -05:00
Jorge Aparicio
fb1d4f1b13 librustdoc: convert Counts binops to by value 2014-12-13 20:15:39 -05:00
Jorge Aparicio
e792338318 librustdoc: use tuple indexing 2014-12-13 20:04:41 -05:00
Jorge Aparicio
888f24969f librustdoc: use unboxed closures 2014-12-13 17:03:48 -05:00
Jorge Aparicio
4d4915aa28 librustdoc: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
ca001e1bd0 librustdoc: fix fallout 2014-12-13 17:03:44 -05:00
Tom Jakubowski
25223c8ef8 rustdoc: Properly inline const items
Build `clean::ConstantItem` values in the `inline` module and
pretty-print the AST for inlined const items.

Doc strings are still missing from inlined constants (see #19773).

Partially address #18156, #19722, #19185

Fix #15821
2014-12-12 05:37:08 -08:00
Nick Cameron
ce4318ad86 Reviewer comments 2014-12-12 19:29:17 +13:00
Alex Crichton
52edb2ecc9 Register new snapshots 2014-12-11 11:30:38 -08:00
Steve Klabnik
6780031540 Fix inappropriate ## headings
Fixes #15499.
2014-12-10 13:54:56 -05:00
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
Jorge Aparicio
5172981207 librustdoc: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
e6bd217ce8 librustdoc: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Steven Fackler
616af6eb83 Allow message specification for should_fail
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-06 15:13:48 -08:00
Corey Richardson
4e492cbaf8 rollup merge of #19515: lifthrasiir/rustdoc-wrong-dedup
Fixes #17332.
2014-12-05 10:07:44 -08:00
Corey Richardson
f3a85cf822 rollup merge of #19513: lifthrasiir/rustdoc-fat-redirect
We heavily rely on queries and fragments in the URL structure, so it is desired to preserve them even in the redirects. The generated redirect pages try to preserve them with scripts, which take precedence over the original `Refresh` metadata. Non-scripting browsers would continue to work (with no queries and fragments).

(This in turn solves a number of semi-broken links to the source code, which are actually linked to redirect pages.)
2014-12-05 10:07:42 -08:00
Corey Richardson
a8c1812f36 rollup merge of #19503: lifthrasiir/xenophobic-rustdoc
This series of commits deals with broken links to the source code. It also refactors some repetitive codes from Rustdoc. The most important commit, 1cb1f00d40, describes the rationale; this will fix a half of #16289. Other commits are reasonably independent to each other and can be made into indiviudal PRs at the request.

### Notes on the broken source links

As of bda97e8557 (I've used this to check the PR works as intended), there are 281 (!) such broken links. They can be further classified as follows:

* 178 links to incorrect item types. This is the first half of #16289, and this PR fixes all of them.
* 89 links to redirect pages. They are not technically "broken" but still doesn't give a source code. I have a fix for this in mind, which would make a redirect page slightly *fat*.
* 14 links to incorrect `DefId` in the `gotosrc` parameter. This is #15309, and affects many `liballoc` reexports in `libstd` but *nothing else* (curiously). I'm yet to track this down; might be a metadata bug (not sure).
* 0 links to the crate reexported as a different name. This is the second half of #16289, and seems not hard to fix but I'm running out of time.

Prevalence of this kind of bugs calls for a full link verifier integrated into the testing process. :S
2014-12-05 10:07:38 -08:00
Corey Richardson
ea8bb5d18d rollup merge of #19453: pshc/rustdoc-check-a-href
Fixes the JS error in #18354 at least. I don't know if there's a more underlying issue that needs addressing.
2014-12-05 10:06:58 -08:00
Corey Richardson
7f8f4abc55 rollup merge of #19422: scialex/fix-fmt-macro-doc
these are missing standard #![doc(...)]. add them
2014-12-05 10:06:55 -08:00
Niko Matsakis
61edb0ccb7 Separate the driver into its own crate that uses trans, typeck. 2014-12-04 10:04:52 -05:00
Niko Matsakis
e135fa5b49 Remove dependencies on driver from trans et al. by moving various
structs out from driver and into other places.
2014-12-04 10:04:51 -05:00
Kang Seonghoon
a12b83996e rustdoc: Do not deduplicate items when their parents differ.
Fixes #17332.
2014-12-04 13:52:23 +09:00
Kang Seonghoon
4b271f3f64 rustdoc: Preserve query/fragment in redirects whenever possible.
We heavily rely on queries and fragments in the URL structure, so
it is desired to preserve them even in the redirects. The generated
redirect pages try to preserve them with scripts, which take
precedence over the original `Refresh` metadata. Non-scripting
browsers would continue to work (with no queries and fragments).
2014-12-04 12:48:16 +09:00
Alexander Light
e621116b86 make fmt_macros and rustdoc have standard doc attributes 2014-12-03 12:49:59 -05:00
Kang Seonghoon
1068855925 rustdoc: Avoid rendering foreign items to the sidebar.
Otherwise the generated documentation is 30% larger. The sidebar
renders an entry for each item to all items, so large modules have
O(n^2) items rendered in the sidebars. Not a correct solution, but
at least it works.
2014-12-04 01:00:01 +09:00
Kang Seonghoon
1cb1f00d40 rustdoc: Removed Foreign{Function,Static} item types.
They are just (unsafe) functions and static items to most users
and even compilers! The metadata doesn't distinguish them, so Rustdoc
ended up producing broken links (generated `ffi.*.html`, links to
`fn.*.html`). It would be best to avoid this pitfall at all.
2014-12-04 01:00:01 +09:00
Kang Seonghoon
a3bb8585e8 rustdoc: Refactored various uses of ItemType.
In particular, ItemType variants are no longer reexported. Since
we already do namespace them via `item_type` mod, it's fine.
2014-12-04 00:59:52 +09:00
Kang Seonghoon
131d4ed018 rustdoc: Fixed a missing rendering of ForeignStaticItems. 2014-12-04 00:58:09 +09:00
Jorge Aparicio
09707d70a4 Fix fallout 2014-12-03 10:41:48 -05:00
Paul Collier
e407472f90 rustdoc: Check for href when prepending rootPath
Fixes #18354.
2014-12-01 20:53:32 -08:00
bors
21ba1d5e58 auto merge of #19405 : jfager/rust/de-match-pyramid, r=bstrie
No semantic changes, no enabling `if let` where it wasn't already enabled.
2014-12-01 21:56:53 +00:00
Kang Seonghoon
08fb9aa2d2 rustdoc: Use relative paths in source renders.
Before: doc/src/collections/home/lifthrasiir/git/rust/src/libcollections/vec.rs.html
After: doc/src/collections/vec.rs.html

If the source code is in the parent dirs relative to the crate root,
`..` is replaced with `up` as expected. Any other error like non-UTF-8
paths or drive-relative paths falls back to the absolute path.

There might be a way to improve on false negatives, but this alone
should be enough for fixing #18370.
2014-12-01 20:53:11 +09:00
jfager
232ffa039d Replace some verbose match statements with their if let equivalent.
No semantic changes, no enabling `if let` where it wasn't already enabled.
2014-11-29 16:41:21 -05:00
bors
3dd5443ebd auto merge of #19349 : tomjakubowski/rust/rustdoc-struct-variant-vis, r=sfackler
Teach rustdoc that struct variant fields have inherited visibility.

Fix #19048
2014-11-27 21:46:24 +00:00
bors
66601647cd auto merge of #19343 : sfackler/rust/less-special-attrs, r=alexcrichton
Descriptions and licenses are handled by Cargo now, so there's no reason
to keep these attributes around.
2014-11-27 06:41:17 +00:00