about summary refs log tree commit diff
path: root/tests/rustdoc
AgeCommit message (Collapse)AuthorLines
2024-08-10Add regression tests for negative impls not showing their itemsGuillaume Gomez-0/+26
2024-08-05Update rustdoc testsGuillaume Gomez-5/+5
2024-08-03Rollup merge of #127921 - spastorino:stabilize-unsafe-extern-blocks, ↵Matthias Krüger-2/+1
r=compiler-errors Stabilize unsafe extern blocks (RFC 3484) # Stabilization report ## Summary This is a tracking issue for the RFC 3484: Unsafe Extern Blocks We are stabilizing `#![feature(unsafe_extern_blocks)]`, as described in [Unsafe Extern Blocks RFC 3484](https://github.com/rust-lang/rfcs/pull/3484). This feature makes explicit that declaring an extern block is unsafe. Starting in Rust 2024, all extern blocks must be marked as unsafe. In all editions, items within unsafe extern blocks may be marked as safe to use. RFC: https://github.com/rust-lang/rfcs/pull/3484 Tracking issue: #123743 ## What is stabilized ### Summary of stabilization We now need extern blocks to be marked as unsafe and items inside can also have safety modifiers (unsafe or safe), by default items with no modifiers are unsafe to offer easy migration without surprising results. ```rust unsafe extern { // sqrt (from libm) may be called with any `f64` pub safe fn sqrt(x: f64) -> f64; // strlen (from libc) requires a valid pointer, // so we mark it as being an unsafe fn pub unsafe fn strlen(p: *const c_char) -> usize; // this function doesn't say safe or unsafe, so it defaults to unsafe pub fn free(p: *mut core::ffi::c_void); pub safe static IMPORTANT_BYTES: [u8; 256]; pub safe static LINES: SyncUnsafeCell<i32>; } ``` ## Tests The relevant tests are in `tests/ui/rust-2024/unsafe-extern-blocks`. ## History - https://github.com/rust-lang/rust/pull/124482 - https://github.com/rust-lang/rust/pull/124455 - https://github.com/rust-lang/rust/pull/125077 - https://github.com/rust-lang/rust/pull/125522 - https://github.com/rust-lang/rust/issues/126738 - https://github.com/rust-lang/rust/issues/126749 - https://github.com/rust-lang/rust/issues/126755 - https://github.com/rust-lang/rust/pull/126757 - https://github.com/rust-lang/rust/pull/126758 - https://github.com/rust-lang/rust/issues/126756 - https://github.com/rust-lang/rust/pull/126973 - https://github.com/rust-lang/rust/pull/127535 - https://github.com/rust-lang/rustfmt/pull/6204 ## Unresolved questions I am not aware of any unresolved questions.
2024-08-03Rollup merge of #128161 - EtomicBomb:just-compiletest, r=notriddleMatthias Krüger-0/+244
nested aux-build in tests/rustdoc/ tests * Fixes bug that prevented using nested aux-build in `tests/rustdoc/` tests. Before, `fn document` and the auxiliary builder disagreed about where to find the nested aux-build source file (`auxiliary/auxiliary/aux.rs` vs `auxiliary/aux.rs`), preventing them from building. Picked the latter in line with other builders in compiletest. * Adds `//@ doc-flags` header, which forwards flags to rustdoc and not rustc. * Adds `//@ unique-doc-out-dir` header, which sets the --out-dir for the rustdoc invocation to a unique directory: `<root out dir>/docs/<test name>/doc` * Changes working directory of the rustdoc invocation to the root out directory (common among all aux-builds). Prior art: exec_compiled_test in runtest.rs * Adds tests that use nested aux builds and new headers These changes provide useful capabilities for writing rustdoc tests on their own. They are also needed to test the implementation for the [mergable-rustdoc-cross-crate-info](https://github.com/rust-lang/rfcs/pull/3662) RFC. try-job: x86_64-msvc
2024-08-01rustdoc: Add test for `impl_trait_in_accos_type`Alona Enraght-Moony-0/+17
2024-07-29rustdoc: move the wbr after the underscore, instead of beforeMichael Howell-1/+1
2024-07-29rustdoc: word wrap CamelCase in the item list tableMichael Howell-1/+9
This is an alternative to ee6459d6521cf6a4c2e08b6e13ce3c6ce5d55ed0. That is, it fixes the issue that affects the very long type names in https://docs.rs/async-stripe/0.31.0/stripe/index.html#structs. This is, necessarily, a pile of nasty heuristics. We need to balance a few issues: - Sometimes, there's no real word break. For example, `BTreeMap` should be `BTree<wbr>Map`, not `B<wbr>Tree<wbr>Map`. - Sometimes, there's a legit word break, but the name is tiny and the HTML overhead isn't worth it. For example, if we're typesetting `TyCtx`, writing `Ty<wbr>Ctx` would have an HTML overhead of 50%. Line breaking inside it makes no sense.
2024-07-29reformatted rustdoc/cross-crate-info, fixing trailing newline issueEtomicBomb-46/+2
2024-07-29ordering and wrapping cross-crate-info testsEtomicBomb-59/+65
2024-07-29initial implementation of rustdoc nested aux-buildEtomicBomb-0/+282
2024-07-23Stabilize unsafe extern blocks (RFC 3484)Santiago Pastorino-2/+1
2024-07-21Auto merge of #120812 - compiler-errors:impl-sorting, r=lcnrbors-2/+2
Remove unnecessary impl sorting in queries and metadata Removes unnecessary impl sorting because queries already return their keys in HIR definition order: https://github.com/rust-lang/rust/issues/120371#issuecomment-1926422838 r? `@cjgillot` or `@lcnr` -- unless I totally misunderstood what was being asked for here? 😆 fixes #120371
2024-07-21Auto merge of #127722 - BoxyUwU:new_adt_const_params_limitations, ↵bors-1/+1
r=compiler-errors Forbid borrows and unsized types from being used as the type of a const generic under `adt_const_params` Fixes #112219 Fixes #112124 Fixes #112125 ### Motivation Currently the `adt_const_params` feature allows writing `Foo<const N: [u8]>` this is entirely useless as it is not possible to write an expression which evaluates to a type that is not `Sized`. In order to actually use unsized types in const generics they are typically written as `const N: &[u8]` which *is* possible to provide a value of. Unfortunately allowing the types of const parameters to contain references is non trivial (#120961) as it introduces a number of difficult questions about how equality of references in the type system should behave. References in the types of const generics is largely only useful for using unsized types in const generics. This PR introduces a new feature gate `unsized_const_parameters` and moves support for `const N: [u8]` and `const N: &...` from `adt_const_params` into it. The goal here hopefully is to experiment with allowing `const N: [u8]` to work without references and then eventually completely forbid references in const generics. Splitting this out into a new feature gate means that stabilization of `adt_const_params` does not have to resolve #120961 which is the only remaining "big" blocker for the feature. Remaining issues after this are a few ICEs and naming bikeshed for `ConstParamTy`. ### Implementation The implementation is slightly subtle here as we would like to ensure that a stabilization of `adt_const_params` is forwards compatible with any outcome of `unsized_const_parameters`. This is inherently tricky as we do not support unstable trait implementations and we determine whether a type is valid as the type of a const parameter via a trait bound. There are a few constraints here: - We would like to *allow for the possibility* of adding a `Sized` supertrait to `ConstParamTy` in the event that we wind up opting to not support unsized types and instead requiring people to write the 'sized version', e.g. `const N: [u8; M]` instead of `const N: [u8]`. - Crates should be able to enable `unsized_const_parameters` and write trait implementations of `ConstParamTy` for `!Sized` types without downstream crates that only enable `adt_const_params` being able to observe this (required for std to be able to `impl<T> ConstParamTy for [T]` Ultimately the way this is accomplished is via having two traits (sad), `ConstParamTy` and `UnsizedConstParamTy`. Depending on whether `unsized_const_parameters` is enabled or not we change which trait is used to check whether a type is allowed to be a const parameter. Long term (when stabilizing `UnsizedConstParamTy`) it should be possible to completely merge these traits (and derive macros), only having a single `trait ConstParamTy` and `macro ConstParamTy`. Under `adt_const_params` it is now illegal to directly refer to `ConstParamTy` it is only used as an internal impl detail by `derive(ConstParamTy)` and checking const parameters are well formed. This is necessary in order to ensure forwards compatibility with all possible future directions for `feature(unsized_const_parameters)`. Generally the intuition here should be that `ConstParamTy` is the stable trait that everything uses, and `UnsizedConstParamTy` is that plus unstable implementations (well, I suppose `ConstParamTy` isn't stable yet :P).
2024-07-18Make clippy and rustdoc happyMichael Goulet-2/+2
2024-07-17Add cross-crate precise capturing support to rustdocMichael Goulet-0/+20
2024-07-17Split part of `adt_const_params` into `unsized_const_params`Boxy-1/+1
2024-07-13Rollup merge of #127671 - notriddle:notriddle/issue-d, r=Mark-SimulacrumJubilee-60/+32
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 8) Follow up * https://github.com/rust-lang/rust/pull/116214 * https://github.com/rust-lang/rust/pull/116432 * https://github.com/rust-lang/rust/pull/116824 * https://github.com/rust-lang/rust/pull/118105 * https://github.com/rust-lang/rust/pull/119561 * https://github.com/rust-lang/rust/pull/123574 * https://github.com/rust-lang/rust/pull/125382 As always, it's easier to review the commits one at a time. Don't use the Files Changed tab. It's confusing.
2024-07-12Move assertion-free rustdoc ice tests to rustdoc-uiMichael Howell-50/+0
2024-07-12rustdoc: rename `issue-\d+.rs` tests to have meaningful namesMichael Howell-0/+0
2024-07-12Add URL and crate_name to test casesMichael Howell-4/+26
2024-07-12Add rustdoc support for use<> in (local) RPITsMichael Goulet-0/+14
2024-06-30Migrate tests to use `-Znext-solver`Deadbeef-0/+2
2024-06-28finishing touches, move fixed ICEs to ui testsDeadbeef-1/+2
2024-06-24Update `tests/rustdoc` to new test syntaxGuillaume Gomez-4378/+4378
2024-06-22Auto merge of #126761 - GuillaumeGomez:unsafe_extern_blocks, r=spastorinobors-0/+30
rustdoc: Add support for `missing_unsafe_on_extern` feature Follow-up of https://github.com/rust-lang/rust/pull/124482. Not sure if the `safe` keyword is supposed to be displayed or not though? For now I didn't add it in the generated doc, only `unsafe` as usual. cc `@spastorino` r? `@fmease`
2024-06-22Make `effects` an incomplete featureDeadbeef-10/+13
2024-06-20Add regression test for `unsafe_extern_blocks`Guillaume Gomez-0/+30
2024-06-04Update code format and testsSergi-Ferrez-8/+7
2024-06-01Auto merge of #124577 - ↵bors-1/+0
GuillaumeGomez:stabilize-custom_code_classes_in_docs, r=rustdoc Stabilize `custom_code_classes_in_docs` feature Fixes #79483. This feature has been around for quite some time now, I think it's fine to stabilize it now. ## Summary ## What is the feature about? In short, this PR changes two things, both related to codeblocks in doc comments in Rust documentation: * Allow to disable generation of `language-*` CSS classes with the `custom` attribute. * Add your own CSS classes to a code block so that you can use other tools to highlight them. #### The `custom` attribute Let's start with the new `custom` attribute: it will disable the generation of the `language-*` CSS class on the generated HTML code block. For example: ```rust /// ```custom,c /// int main(void) { /// return 0; /// } /// ``` ``` The generated HTML code block will not have `class="language-c"` because the `custom` attribute has been set. The `custom` attribute becomes especially useful with the other thing added by this feature: adding your own CSS classes. #### Adding your own CSS classes The second part of this feature is to allow users to add CSS classes themselves so that they can then add a JS library which will do it (like `highlight.js` or `prism.js`), allowing to support highlighting for other languages than Rust without increasing burden on rustdoc. To disable the automatic `language-*` CSS class generation, you need to use the `custom` attribute as well. This allow users to write the following: ```rust /// Some code block with `{class=language-c}` as the language string. /// /// ```custom,{class=language-c} /// int main(void) { /// return 0; /// } /// ``` fn main() {} ``` This will notably produce the following HTML: ```html <pre class="language-c"> int main(void) { return 0; }</pre> ``` Instead of: ```html <pre class="rust rust-example-rendered"> <span class="ident">int</span> <span class="ident">main</span>(<span class="ident">void</span>) { <span class="kw">return</span> <span class="number">0</span>; } </pre> ``` To be noted, we could have written `{.language-c}` to achieve the same result. `.` and `class=` have the same effect. One last syntax point: content between parens (`(like this)`) is now considered as comment and is not taken into account at all. In addition to this, I added an `unknown` field into `LangString` (the parsed code block "attribute") because of cases like this: ```rust /// ```custom,class:language-c /// main; /// ``` pub fn foo() {} ``` Without this `unknown` field, it would generate in the DOM: `<pre class="language-class:language-c language-c">`, which is quite bad. So instead, it now stores all unknown tags into the `unknown` field and use the first one as "language". So in this case, since there is no unknown tag, it'll simply generate `<pre class="language-c">`. I added tests to cover this. EDIT(camelid): This description is out-of-date. Using `custom,class:language-c` will generate the output `<pre class="language-class:language-c">` as would be expected; it treats `class:language-c` as just the name of a language (similar to the langstring `c` or `js` or what have you) since it does not use the designed class syntax. Finally, I added a parser for the codeblock attributes to make it much easier to maintain. It'll be pretty easy to extend. As to why this syntax for adding attributes was picked: it's [Pandoc's syntax](https://pandoc.org/MANUAL.html#extension-fenced_code_attributes). Even if it seems clunkier in some cases, it's extensible, and most third-party Markdown renderers are smart enough to ignore Pandoc's brace-delimited attributes (from [this comment](https://github.com/rust-lang/rust/pull/110800#issuecomment-1522044456)). r? `@notriddle`
2024-05-27Auto merge of #125599 - camelid:clarify-stability, r=notriddle,GuillaumeGomezbors-0/+6
rustdoc: Clarify const-stability with regard to normal stability Fixes #125511. - Elide const-unstable if also unstable overall - Show "const" for const-unstable if also overall unstable
2024-05-26rustdoc: Show "const" for const-unstable if also overall unstableNoah Lev-1/+1
If a const function is unstable overall (and thus, in all circumstances I know of, also const-unstable), we should show the option to use it as const. You need to enable a feature to use the function at all anyway. If the function is stabilized without also being const-stabilized, then we do not show the const keyword and instead show "const: unstable" in the version info.
2024-05-25rustdoc: Elide const-unstable if also unstable overallNoah Lev-0/+6
It's confusing because if a function is unstable overall, there's no need to highlight the constness is also unstable. Technically, these attributes (overall stability and const-stability) are separate, but in practice, we don't even show the const-unstable's feature flag (it's normally the same as the overall function).
2024-05-21Move tests into appropriate subdirectoriesMichael Howell-12/+4
2024-05-21rustdoc: rename `issue-\d+.rs` tests to have meaningful namesMichael Howell-0/+0
2024-05-21Add URL and crate_name to test casesMichael Howell-12/+40
2024-05-19Add failing test for cross-crate enum in type aliasMichael Goulet-0/+12
2024-05-14rustdoc: Negative impls are not notableMichael Goulet-0/+24
2024-05-13Apply nitsMichael Goulet-0/+1
2024-05-11Always hide private fields in aliased typeUrgau-0/+20
2024-05-07rustdoc: use stability, instead of features, to decide what to showMichael Howell-2/+23
To decide if internal items should be inlined in a doc page, check if the crate is itself internal, rather than if it has the rustc_private feature flag. The standard library uses internal items, but is not itself internal and should not show internal items on its docs pages.
2024-05-01Stabilize `custom_code_classes_in_docs` featureGuillaume Gomez-1/+0
2024-04-28Fix the assertion crash from rustdoc document indent widthsyukang-0/+7
2024-04-19Auto merge of #118441 - GuillaumeGomez:display-stability-version, r=rustdocbors-5/+5
Always display stability version even if it's the same as the containing item Fixes https://github.com/rust-lang/rust/issues/118439. Currently, if the containing item's version is the same as the item's version (like a method), we don't display it on the item. This was something done on purpose as you can see [here](https://github.com/rust-lang/rust/blob/e9b7bf011478aa8c19ac49afc99853a66ba04319/src/librustdoc/html/render/mod.rs#L949-L955). It was implemented in https://github.com/rust-lang/rust/pull/30686. I think we should change this because on pages with a lot of items, if someone arrives (through the search or a link) to an item far below the page, they won't know the stability version unless they scroll to the top, which isn't great. You can see the result [here](https://rustdoc.crud.net/imperio/display-stability-version/std/pin/struct.Pin.html#method.new). r? `@notriddle`
2024-04-16Rollup merge of #123574 - notriddle:notriddle/issue-d, r=fmeaseGuillaume Gomez-96/+65
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 6) Follow up * https://github.com/rust-lang/rust/pull/116214 * https://github.com/rust-lang/rust/pull/116432 * https://github.com/rust-lang/rust/pull/116824 * https://github.com/rust-lang/rust/pull/118105 * https://github.com/rust-lang/rust/pull/119561
2024-04-15rustdoc: move tests into applicable subdirectoriesMichael Howell-0/+0
2024-04-15rustdoc: rename `issue-\d+.rs` tests to have meaningful namesMichael Howell-0/+0
2024-04-15Move ice tests to rustdoc-uiMichael Howell-65/+0
2024-04-15Add URL and crate_name to test casesMichael Howell-16/+50
2024-04-11Rollup merge of #123459 - GuillaumeGomez:fix-123435, r=notriddleMatthias Krüger-0/+14
Correctly handle inlining of doc hidden foreign items Fixes #123435. In case a foreign item has doc(hidden) attribute, we simply merged its attributes with the re-export's, making it being removed once in the `strip_hidden` pass. The solution was to use the same as for local reexported items: merge attributes, but not some of them (like `doc(hidden)`). I originally checked if we could simply update `Item::is_doc_hidden` method to use `self.inline_stmt_id.is_some_and(|def_id| tcx.is_doc_hidden(def_id))` but unfortunately, it added (local) items that shouldn't be inlined. At least it unifies local and foreign items inlining, which I think is the best course of action here. r? `@notriddle`
2024-04-08rustdoc: synthetic auto: filter out clauses from the implementor's ParamEnvLeón Orell Valerian Liehr-0/+14
not just the ones from the elaborated clauses.