Commit Graph

2936 Commits

Author SHA1 Message Date
Mark Simulacrum
0bb4291295 Rollup merge of #43446 - zackmdavis:rustdoc_sidebar_unions, r=GuillaumeGomez
rustdoc: add unions to whitelist of sidebar types

This resolves #43405.
2017-07-24 09:16:39 -06:00
Zack M. Davis
749dcbaa88 rustdoc: add unions to whitelist of sidebar types
This resolves #43405.
2017-07-23 17:18:58 -07:00
Zack M. Davis
0fdb502710 rustdoc: fix layout of Fields section in documentation for unions
Previously, the union fields would all render on the same line with
hideous spacing; comparison to the analogous section for structs makes
it undoubtable that `display: block` is the true intent.

Concisely and definitively resolves #43404 and its perfidious
malignancy.
2017-07-23 11:37:53 -07:00
Tobias Schottdorf
687ee7fee4 Downgrade ProjectionTy's TraitRef to its substs
Addresses the second part of #42171 by removing the `TraitRef` from
`ProjectionTy`, and directly storing its `Substs`.

Closes #42171.
2017-07-11 10:33:09 -04:00
Guillaume Gomez
12dccbde41 Add spacing between trait functions 2017-07-09 16:47:29 +02:00
Oliver Middleton
1966a6798d rustdoc: Don't run Markdown tests twice
This matches the behaviour for finding tests in Rust files.
2017-07-06 16:47:58 +01:00
bors
4d526e0d14 Auto merge of #40939 - jseyfried:proc_macro_api, r=nrc
proc_macro: implement `TokenTree`, `TokenKind`, hygienic `quote!`, and other API

All new API is gated behind `#![feature(proc_macro)]` and may be used with `#[proc_macro]`, `#[proc_macro_attribute]`, and `#[proc_macro_derive]` procedural macros.

More specifically, this PR adds the following in `proc_macro`:
```rust
// `TokenStream` constructors:
impl TokenStream { fn empty() -> TokenStream { ... } }
impl From<TokenTree> for TokenStream { ... }
impl From<TokenKind> for TokenStream { ... }
impl<T: Into<TokenStream>> FromIterator<T> for TokenStream { ... }
macro quote($($t:tt)*) { ... } // A hygienic `TokenStream` quoter

// `TokenStream` destructuring:
impl TokenStream { fn is_empty(&self) -> bool { ... } }
impl IntoIterator for TokenStream { type Item = TokenTree; ... }

struct TokenTree { span: Span, kind: TokenKind }
impl From<TokenKind> for TokenTree { ... }
impl Display for TokenTree { ... }

struct Span { ... } // a region of source code along with expansion/hygiene information
impl Default for Span { ... } // a span from the current procedural macro definition
impl Span { fn call_site() -> Span { ... } } // the call site of the current expansion
fn quote_span(span: Span) -> TokenStream;

enum TokenKind {
    Group(Delimiter, TokenStream), // A delimited sequence, e.g. `( ... )`
    Term(Term), // a unicode identifier, lifetime ('a), or underscore
    Op(char, Spacing), // a punctuation character (`+`, `,`, `$`, etc.).
    Literal(Literal), // a literal character (`'a'`), string (`"hello"`), or number (`2.3`)
}

enum Delimiter {
    Parenthesis, // `( ... )`
    Brace, // `[ ... ]`
    Bracket, // `{ ... }`
    None, // an implicit delimiter, e.g. `$var`, where $var is  `...`.
}

struct Term { ... } // An interned string
impl Term {
    fn intern(string: &str) -> Symbol { ... }
    fn as_str(&self) -> &str { ... }
}

enum Spacing {
    Alone, // not immediately followed by another `Op`, e.g. `+` in `+ =`.
    Joint, // immediately followed by another `Op`, e.g. `+` in `+=`
}

struct Literal { ... }
impl Display for Literal { ... }
impl Literal {
    fn integer(n: i128) -> Literal { .. } // unsuffixed integer literal
    fn float(n: f64) -> Literal { .. } // unsuffixed floating point literal
    fn u8(n: u8) -> Literal { ... } // similarly: i8, u16, i16, u32, i32, u64, i64, f32, f64
    fn string(string: &str) -> Literal { ... }
    fn character(ch: char) -> Literal { ... }
    fn byte_string(bytes: &[u8]) -> Literal { ... }
}
```
For details on `quote!` hygiene, see [this example](20a90485c0) and [declarative macros 2.0](https://github.com/rust-lang/rust/pull/40847).

r? @nrc
2017-07-05 21:16:34 +00:00
Alex Crichton
fd95db25b3 Merge remote-tracking branch 'origin/master' into proc_macro_api 2017-07-05 08:42:13 -07:00
bors
3610a70ce4 Auto merge of #42972 - GuillaumeGomez:fix-toggles-rustdoc, r=QuietMisdreavus
Toggle wrappers are now generated correctly

Fixes #42674.
2017-07-05 13:56:32 +00:00
Ariel Ben-Yehuda
fb7ab9e43d report the total number of errors on compilation failure
Prior to this PR, when we aborted because a "critical pass" failed, we
displayed the number of errors from that critical pass. While that's the
number of errors that caused compilation to abort in *that place*,
that's not what people really want to know. Instead, always report the
total number of errors, and don't bother to track the number of errors
from the last pass that failed.

This changes the compiler driver API to handle errors more smoothly,
and therefore is a compiler-api-[breaking-change].

Fixes #42793.
2017-07-02 16:16:44 +03:00
Guillaume Gomez
7327cf7be5 Toggle wrappers are now generated correctly 2017-06-29 22:10:24 +02:00
petrochenkov
b33fd6d759 Change some terminology around keywords and reserved identifiers 2017-06-29 15:19:53 +03:00
Ariel Ben-Yehuda
bea4e60327 Rollup merge of #42219 - pwoolcoc:add-allow-fail-to-libtest, r=GuillaumeGomez
add `allow_fail` test attribute

This change allows the user to add an `#[allow_fail]` attribute to
tests that will cause the test to compile & run, but if the test fails
it will not cause the entire test run to fail. The test output will
show the failure, but in yellow instead of red, and also indicate that
it was an allowed failure.

Here is an example of the output: http://imgur.com/a/wt7ga
2017-06-29 08:40:01 +00:00
Eduard-Mihai Burtescu
33ecf72e8e rustc: move the PolyFnSig out of TyFnDef. 2017-06-27 16:39:52 +03:00
bors
859c3236e5 Auto merge of #42885 - ollie27:rustdoc_empty_glob_path, r=GuillaumeGomez
rustdoc: Don't ICE on `use *;`

Fixes #42875
2017-06-26 11:06:13 +00:00
Jeffrey Seyfried
d4488b7df9 Simplify hygiene::Mark application, and
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-26 02:05:45 +00:00
Oliver Middleton
927625912a rustdoc: Don't ICE on use *; 2017-06-24 18:16:39 +01:00
Paul Woolcock
76d605255b Shorten some lines so this can pass the tidy checks 2017-06-24 06:42:29 -04:00
Paul Woolcock
60dd83ea85 add allow_fail test attribute
This change allows the user to add an `#[allow_fail]` attribute to
tests that will cause the test to compile & run, but if the test fails
it will not cause the entire test run to fail. The test output will
show the failure, but in yellow instead of red, and also indicate that
it was an allowed failure.
2017-06-24 06:42:29 -04:00
Oliver Middleton
4488f9bc0f rustdoc: Fix a few issues with associated consts
* Make sure private consts are stripped.
* Don't show a code block for the value if there is none.
* Make sure default values are shown in impls.
* Make sure docs from the trait are used if the impl has no docs.
2017-06-23 18:39:27 +01:00
kennytm
4711982314
Removed as many "```ignore" as possible.
Replaced by adding extra imports, adding hidden code (`# ...`), modifying
examples to be runnable (sorry Homura), specifying non-Rust code, and
converting to should_panic, no_run, or compile_fail.

Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-23 15:31:53 +08:00
Mark Simulacrum
7f693e2cb9 Rollup merge of #42806 - ollie27:rustbuild_compiler_docs, r=alexcrichton
rustbuild: Fix compiler docs yet again

Add support for `-Z force-unstable-if-unmarked` to rustdoc.

r? @alexcrichton
2017-06-22 06:30:12 -06:00
Oliver Middleton
ae1dc2a6f9 rustbuild: Fix compiler docs yet again
Add support for `-Z force-unstable-if-unmarked` to rustdoc.
2017-06-21 17:59:10 +01:00
Alex Crichton
5c3d0e6de3 Switch to the crates.io getopts crate
This commit deletes the in-tree `getopts` crate in favor of the crates.io-based
`getopts` crate. The main difference here is with a new builder-style API, but
otherwise everything else remains relatively standard.
2017-06-20 12:43:12 -07:00
Alex Crichton
be7ebdd512 Bump version and stage0 compiler 2017-06-19 22:25:05 -07:00
Taylor Cramer
9f710530a7 On-demand is_const_fn 2017-06-13 23:10:59 -07:00
bors
9adf969cd8 Auto merge of #42608 - ollie27:rustdoc_variant_reexport, r=QuietMisdreavus
rustdoc: Fix missing enum variant reexports

Fixes #35488
2017-06-13 08:54:23 +00:00
Oliver Middleton
68ccba81ae rustdoc: Fix missing enum variant reexports 2017-06-12 22:42:20 +01:00
Corey Farwell
3023cc49c8 Rollup merge of #42594 - ollie27:rustdoc_assoc_type_links, r=steveklabnik
rustdoc: Link directly to associated types

Rather than just linking to the trait.

Also simplifies the logic used to decide whether to render the full
QPath.
2017-06-12 12:39:49 -04:00
Corey Farwell
87426195ec Rollup merge of #42592 - ollie27:rustdoc_empty_modules, r=steveklabnik
rustdoc: Stop stripping empty modules

There is no good reason to strip empty modules with no documentation and
doing so causes subtle problems.

Fixes #42590
2017-06-12 12:39:48 -04:00
bors
0a5218b506 Auto merge of #42572 - ollie27:rustdoc_create_dir_all, r=GuillaumeGomez
rustdoc: Use `create_dir_all` to create output directory

Currently rustdoc will fail if passed `-o foo/doc` if the `foo`
directory doesn't exist.

Also remove unneeded `mkdir` as `create_dir_all` can now handle
concurrent invocations since #39799.
2017-06-12 08:49:51 +00:00
Oliver Middleton
7298dabdb3 rustdoc: Stop stripping empty modules
There is no good reason to strip empty modules with no documentation and
doing so causes subtle problems.
2017-06-11 18:26:01 +01:00
Oliver Middleton
429dc51bfe rustdoc: Link directly to associated types
Rather than just linking to the trait.

Also simplifies the logic used to decide whether to render the full
QPath.
2017-06-11 18:20:48 +01:00
Corey Farwell
9163f338f9 Rollup merge of #42307 - clarcharr:js-license, r=frewsxcv
Make rustdoc.js use license comments.

This will ensure that JS minifiers and the like will preserve the license statement even after minimisation.
2017-06-09 18:29:25 -04:00
Oliver Middleton
577c059d50 rustdoc: Use create_dir_all to create output directory
Currently rustdoc will fail if passed `-o foo/doc` if the `foo`
directory doesn't exist.

Also remove unneeded `mkdir` as `create_dir_all` can now handle
concurrent invocations.
2017-06-09 23:03:08 +01:00
bors
5fe923d434 Auto merge of #42507 - ibabushkin:external-span-trans, r=eddyb
Fix translation of external spans

Previously, I noticed that spans from external crates don't generate any output. This limitation is problematic if analysis is performed on one or more external crates, as is the case with [rust-semverver](https://github.com/ibabushkin/rust-semverver). This change should address this behaviour, with the potential drawback that a minor performance hit is to be expected, as spans from potentially large crates have to be translated now.
2017-06-09 12:49:49 +00:00
Michael Killough
2da350168d Document direct implementations on type aliases.
This improves #32077, but is not a complete fix. For a type alias `type
NewType = AliasedType`, it will include any `impl NewType` and `impl
Trait for NewType` blocks in the documentation for `NewType`.

A complete fix would include the implementations from the aliased type
in the type alias' documentation, so that users have a complete
picture of methods that are available on the alias. However, to do this
properly would require a fix for #14072, as the alias may affect the
type parameters of the type alias, making the documentation difficult to
understand. (That is, for `type Result = std::result::Result<(), ()>` we
would ideally show documentation for `impl Result<(), ()>`, rather than
generic documentation for `impl<T, E> Result<T, E>`).

I think this improvement is worthwhile, as it exposes implementations
which are not currently documented by rustdoc. The documentation for the
implementations on the aliased type are still accessible by clicking
through to the docs for that type. (Although perhaps it's now less
obvious to the user that they should click-through to get there).
2017-06-09 10:57:08 +09:00
Clar Charr
dd23fda9bd Make rustdoc.js use license comments. 2017-06-07 22:44:53 -04:00
Inokentiy Babushkin
9a054f2002
Fix translation of external spans. 2017-06-07 16:31:05 +02:00
bors
17f493fffc Auto merge of #42394 - ollie27:rustdoc_deref_box, r=QuietMisdreavus
rustdoc: Hide `self: Box<Self>` in list of deref methods

These methods can never be called through deref so there is no point including them. For example you can't call [`into_boxed_bytes`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.into_boxed_bytes) or [`into_string`](https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.into_string) on `String`.
2017-06-06 06:18:17 +00:00
Oliver Middleton
88c791bf69 rustdoc: Hide self: Box<Self> in list of deref methods
These methods can never be called through deref so there is no point
including them. For example you can't call `into_boxed_bytes` or
`into_string` on `String`.
2017-06-02 22:37:11 +01:00
Mark Simulacrum
7a2d4b30b6 Rollup merge of #42360 - ollie27:rustdoc_vector_rename, r=GuillaumeGomez
rustdoc: Rename `Vector` and `FixedVector` to `Slice` and `Array`

Also store the array length as a usize rather than a String.

This is just a minor refactor.
2017-06-02 09:10:47 -06:00
Mark Simulacrum
551dd7c7a2 Rollup merge of #42225 - brson:vs2017, r=alexcrichton
Support VS 2017

Fixes #38584

This replaces all the MSVC linker logic with that from the 'gcc' crate. The code looks the same, but there could be regressions.

I've only tested this with x86_64.

r? @alexcrichton
cc @vadimcn @retep998
2017-06-02 09:10:42 -06:00
Brian Anderson
da100fe0bb Support VS 2017
Fixes #38584
2017-06-01 20:41:38 +00:00
Oliver Middleton
a74338d60e rustdoc: Rename Vector and FixedVector to Slice and Array
Also store the array length as a usize rather than a String.

This is just a minor refactor.
2017-06-01 13:36:36 +01:00
Corey Farwell
b03ed42c36 Rollup merge of #42297 - tschottdorf:proj-ty, r=nikomatsakis
Upgrade ProjectionTy's Name to a DefId

Part of #42171, in preparation for downgrading the contained `TraitRef` to
only its `substs`.

Some inline questions in the diff. Look for `FIXME(tschottdorf)`. These comments
should be addressed before merging.
2017-06-01 00:09:22 -04:00
Oliver Middleton
86ea93e83c rustdoc: Cleanup associated const value rendering
Rather than (ab)using Debug for outputting the type in plain text use the
alternate format parameter which already does exactly that. This fixes
type parameters for example which would output raw HTML.

Also cleans up adding parens around references to trait objects.
2017-05-31 20:05:28 +01:00
Tobias Schottdorf
e5e664fb07 Upgrade ProjectionTy's Name to a DefId
Part of #42171, in preparation for downgrading the contained `TraitRef` to
only its `substs`.
2017-05-31 12:35:13 -04:00
Guillaume Gomez
171d285756 Fix signature by adding parens when needed 2017-05-30 23:04:03 +02:00
Ariel Ben-Yehuda
55767702ec fix RUST_LOG ICE caused by printing a default impl's DefId 2017-05-28 10:43:25 +03:00