summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2017-08-17doc tests: use the filename from the source file for doc test programs, ↵Nick Cameron-25/+29
rather than a dummy name
2017-07-11Downgrade ProjectionTy's TraitRef to its substsTobias Schottdorf-5/+5
Addresses the second part of #42171 by removing the `TraitRef` from `ProjectionTy`, and directly storing its `Substs`. Closes #42171.
2017-07-09Add spacing between trait functionsGuillaume Gomez-2/+14
2017-07-06rustdoc: Don't run Markdown tests twiceOliver Middleton-2/+6
This matches the behaviour for finding tests in Rust files.
2017-07-05Auto merge of #40939 - jseyfried:proc_macro_api, r=nrcbors-1/+1
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](https://github.com/rust-lang/rust/pull/40939/commits/20a90485c040df87a667e9b6ee38e4d8a7d7fc5d) and [declarative macros 2.0](https://github.com/rust-lang/rust/pull/40847). r? @nrc
2017-07-05Merge remote-tracking branch 'origin/master' into proc_macro_apiAlex Crichton-58/+66
2017-07-05Auto merge of #42972 - GuillaumeGomez:fix-toggles-rustdoc, r=QuietMisdreavusbors-21/+28
Toggle wrappers are now generated correctly Fixes #42674.
2017-07-02report the total number of errors on compilation failureAriel Ben-Yehuda-24/+14
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-06-29Toggle wrappers are now generated correctlyGuillaume Gomez-21/+28
2017-06-29Change some terminology around keywords and reserved identifierspetrochenkov-1/+1
2017-06-29Rollup merge of #42219 - pwoolcoc:add-allow-fail-to-libtest, r=GuillaumeGomezAriel Ben-Yehuda-19/+29
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-27rustc: move the PolyFnSig out of TyFnDef.Eduard-Mihai Burtescu-13/+17
2017-06-26Auto merge of #42885 - ollie27:rustdoc_empty_glob_path, r=GuillaumeGomezbors-1/+5
rustdoc: Don't ICE on `use *;` Fixes #42875
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-1/+1
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-24rustdoc: Don't ICE on `use *;`Oliver Middleton-1/+5
2017-06-24Shorten some lines so this can pass the tidy checksPaul Woolcock-15/+19
2017-06-24add `allow_fail` test attributePaul Woolcock-19/+25
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-23rustdoc: Fix a few issues with associated constsOliver Middleton-43/+29
* 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-23Removed as many "```ignore" as possible.kennytm-1/+1
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-22Rollup merge of #42806 - ollie27:rustbuild_compiler_docs, r=alexcrichtonMark Simulacrum-2/+11
rustbuild: Fix compiler docs yet again Add support for `-Z force-unstable-if-unmarked` to rustdoc. r? @alexcrichton
2017-06-21rustbuild: Fix compiler docs yet againOliver Middleton-2/+11
Add support for `-Z force-unstable-if-unmarked` to rustdoc.
2017-06-20Switch to the crates.io `getopts` crateAlex Crichton-78/+133
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-19Bump version and stage0 compilerAlex Crichton-4/+0
2017-06-13On-demand is_const_fnTaylor Cramer-2/+2
2017-06-13Auto merge of #42608 - ollie27:rustdoc_variant_reexport, r=QuietMisdreavusbors-18/+14
rustdoc: Fix missing enum variant reexports Fixes #35488
2017-06-12rustdoc: Fix missing enum variant reexportsOliver Middleton-18/+14
2017-06-12Rollup merge of #42594 - ollie27:rustdoc_assoc_type_links, r=steveklabnikCorey Farwell-23/+19
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-12Rollup merge of #42592 - ollie27:rustdoc_empty_modules, r=steveklabnikCorey Farwell-28/+9
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-12Auto merge of #42572 - ollie27:rustdoc_create_dir_all, r=GuillaumeGomezbors-20/+5
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-11rustdoc: Stop stripping empty modulesOliver Middleton-28/+9
There is no good reason to strip empty modules with no documentation and doing so causes subtle problems.
2017-06-11rustdoc: Link directly to associated typesOliver Middleton-23/+19
Rather than just linking to the trait. Also simplifies the logic used to decide whether to render the full QPath.
2017-06-09Rollup merge of #42307 - clarcharr:js-license, r=frewsxcvCorey Farwell-9/+11
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-09rustdoc: Use `create_dir_all` to create output directoryOliver Middleton-20/+5
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-09Auto merge of #42507 - ibabushkin:external-span-trans, r=eddybbors-3/+3
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-09Document direct implementations on type aliases.Michael Killough-2/+23
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-07Make rustdoc.js use license comments.Clar Charr-9/+11
2017-06-07Fix translation of external spans.Inokentiy Babushkin-3/+3
2017-06-06Auto merge of #42394 - ollie27:rustdoc_deref_box, r=QuietMisdreavusbors-7/+13
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-02rustdoc: Hide `self: Box<Self>` in list of deref methodsOliver Middleton-7/+13
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-02Rollup merge of #42360 - ollie27:rustdoc_vector_rename, r=GuillaumeGomezMark Simulacrum-22/+12
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-02Rollup merge of #42225 - brson:vs2017, r=alexcrichtonMark Simulacrum-1/+1
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-01Support VS 2017Brian Anderson-1/+1
Fixes #38584
2017-06-01rustdoc: Rename `Vector` and `FixedVector` to `Slice` and `Array`Oliver Middleton-22/+12
Also store the array length as a usize rather than a String. This is just a minor refactor.
2017-06-01Rollup merge of #42297 - tschottdorf:proj-ty, r=nikomatsakisCorey Farwell-1/+1
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-05-31rustdoc: Cleanup associated const value renderingOliver Middleton-156/+56
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-31Upgrade ProjectionTy's Name to a DefIdTobias Schottdorf-1/+1
Part of #42171, in preparation for downgrading the contained `TraitRef` to only its `substs`.
2017-05-30Fix signature by adding parens when neededGuillaume Gomez-14/+23
2017-05-28fix RUST_LOG ICE caused by printing a default impl's DefIdAriel Ben-Yehuda-1/+1
2017-05-25Auto merge of #40847 - jseyfried:decl_macro, r=nrcbors-4/+3
Initial implementation of declarative macros 2.0 Implement declarative macros 2.0 (rust-lang/rfcs#1584) behind `#![feature(decl_macro)]`. Differences from `macro_rules!` include: - new syntax: `macro m(..) { .. }` instead of `macro_rules! m { (..) => { .. } }` - declarative macros are items: ```rust // crate A: pub mod foo { m!(); // use before definition; declaration order is irrelevant pub macro m() {} // `pub`, `pub(super)`, etc. work } fn main() { foo::m!(); // named like other items { use foo::m as n; n!(); } // imported like other items } pub use foo::m; // re-exported like other items // crate B: extern crate A; // no need for `#[macro_use]` A::foo::m!(); A::m!(); ``` - Racket-like hygiene for items, imports, methods, fields, type parameters, privacy, etc. - Intuitively, names in a macro definition are resolved in the macro definition's scope, not the scope in which the macro is used. - This [explaination](http://beautifulracket.com/explainer/hygiene.html) of hygiene for Racket applies here (except for the "Breaking Hygiene" section). I wrote a similar [explanation](https://github.com/jseyfried/rfcs/blob/hygiene/text/0000-hygiene.md) for Rust. - Generally speaking, if `fn f() { <body> }` resolves, `pub macro m() { <body> } ... m!()` also resolves, even if `m!()` is in a separate crate. - `::foo::bar` in a `macro` behaves like `$crate::foo::bar` in a `macro_rules!`, except it can access everything visible from the `macro` (thus more permissive). - See [`src/test/{run-pass, compile-fail}/hygiene`](https://github.com/rust-lang/rust/pull/40847/commits/afe7d89858fd72b983e24727d6f4058293153c19) for examples. Small example: ```rust mod foo { fn f() { println!("hello world"); } pub macro m() { f(); } } fn main() { foo::m!(); } ``` Limitations: - This does not address planned changes to matchers (`expr`,`ty`, etc.), c.f. #26361. - Lints (including stability and deprecation) and `unsafe` are not hygienic. - adding hygiene here will be mostly or entirely backwards compatible - Nested macro definitions (a `macro` inside another `macro`) don't always work correctly when invoked from external crates. - pending improvements in how we encode macro definitions in crate metadata - There is no way to "escape" hygiene without using a procedural macro. r? @nrc
2017-05-25Fix merge conflicts.Jeffrey Seyfried-1/+1