Commit Graph

1053 Commits

Author SHA1 Message Date
Felix S. Klock II 9c14391f93 placate tidy. 2021-05-03 13:51:18 -04:00
Felix S. Klock II 106ac7eefc regression test for issue 82465. 2021-05-03 13:51:18 -04:00
Felix S. Klock II e917d2f1ea beta-targetted revert of PR #80653, to address issue #82465.
adapted from 513756bb55a0dbc6e74d0043afd1727bd3c73aae
2021-05-03 13:51:18 -04:00
bors f24ce9b014 Auto merge of #82838 - Amanieu:rustdoc_asm, r=nagisa
Allow rustdoc to handle asm! of foreign architectures

This allows rustdoc to process code containing `asm!` for architectures other than the current one. Since this never reaches codegen, we just replace target-specific registers and register classes with a dummy one.

Fixes #82869
2021-03-16 10:05:46 +00:00
Oli Scherer 1f7df1956a Replace `type_alias_impl_trait` by `min_type_alias_impl_trait` with no actual changes in behaviour
This makes `type_alias_impl_trait` not actually do anything anymore
2021-03-15 17:32:43 +00:00
Amanieu d'Antras ba00ddc39a Address review comments 2021-03-14 23:21:03 +00:00
Aaron Hill 06546d4b40
Avoid sorting predicates by `DefId`
Fixes issue #82920

Even if an item does not change between compilation sessions, it may end
up with a different `DefId`, since inserting/deleting an item affects
the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash`
in the incremental compilation system, which is stable in the face of
changes to unrelated items.

In particular, the query system will consider the inputs to a query to
be unchanged if any `DefId`s in the inputs have their `DefPathHash`es
unchanged. Queries are pure functions, so the query result should be
unchanged if the query inputs are unchanged.

Unfortunately, it's possible to inadvertantly make a query result
incorrectly change across compilations, by relying on the specific value
of a `DefId`. Specifically, if the query result is a slice that gets
sorted by `DefId`, the precise order will depend on how the `DefId`s got
assigned in a particular compilation session. If some definitions end up
with different `DefId`s (but the same `DefPathHash`es) in a subsequent
compilation session, we will end up re-computing a *different* value for
the query, even though the query system expects the result to unchanged
due to the unchanged inputs.

It turns out that we have been sorting the predicates computed during
`astconv` by their `DefId`. These predicates make their way into the
`super_predicates_that_define_assoc_type`, which ends up getting used to
compute the vtables of trait objects. This, re-ordering these predicates
between compilation sessions can lead to undefined behavior at runtime -
the query system will re-use code built with a *differently ordered*
vtable, resulting in the wrong method being invoked at runtime.

This PR avoids sorting by `DefId` in `astconv`, fixing the
miscompilation. However, it's possible that other instances of this
issue exist - they could also be easily introduced in the future.

To fully fix this issue, we should
1. Turn on `-Z incremental-verify-ich` by default. This will cause the
   compiler to ICE whenver an 'unchanged' query result changes between
   compilation sessions, instead of causing a miscompilation.
2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it
   difficult to introduce ICEs in the first place.
2021-03-13 13:45:12 -05:00
Mara ec2619ca62
Rollup merge of #80763 - petrochenkov:pubusecrate, r=estebank
resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lint

This lint was deny-by-default since July 2017, crater showed 7 uses on crates.io back then (https://github.com/rust-lang/rust/pull/42894#issuecomment-311921147).

Unfortunately, the construction `pub use foo as bar` where `foo` is `extern crate foo;` was used by an older version `bitflags`, so turning it into an error causes too many regressions.
So, this PR reduces the scope of the lint instead of turning it into a hard error, and only turns some more rarely used components of it into errors.
2021-03-05 10:57:15 +01:00
Yuki Okushi f898aa3f5b
Rollup merge of #80527 - jyn514:rustdoc-lints, r=GuillaumeGomez
Make rustdoc lints a tool lint instead of built-in

- Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` (and similar for other rustdoc lints; I don't expect any others to be used frequently, though).
- Ensure that the old lint names still work and give deprecation errors
- Register lints even when running doctests
- Move lint machinery into a separate file
- Add `declare_rustdoc_lint!` macro

Unblocks https://github.com/rust-lang/rust/pull/80300, https://github.com/rust-lang/rust/pull/79816, https://github.com/rust-lang/rust/pull/80965. Makes the strangeness in https://github.com/rust-lang/rust/pull/77364 more apparent to the end user (note that `missing_docs` is *not* moved to rustdoc in this PR). Closes https://github.com/rust-lang/rust/issues/78786.

## Current status

This is blocked on #82620 (see https://github.com/rust-lang/rust/pull/80527#issuecomment-787401519)
2021-03-04 20:01:01 +09:00
Yuki Okushi 9a827d9f7e
Rollup merge of #81223 - GuillaumeGomez:generate-redirect-map, r=jyn514
[rustdoc] Generate redirect map file

Fixes #81134.

So with this code:

```rust
#![crate_name = "foo"]

pub use private::Quz;
pub use hidden::Bar;

mod private {
    pub struct Quz;
}

#[doc(hidden)]
pub mod hidden {
    pub struct Bar;
}

#[macro_export]
macro_rules! foo {
() => {}
}
```

It generates:

```json
{
  "foo/macro.foo!.html": "foo/macro.foo.html",
  "foo/private/struct.Quz.html": "foo/struct.Quz.html",
  "foo/hidden/struct.Bar.html": "foo/struct.Bar.html"
}
```

Do the pathes look as you expected ````@pietroalbini?````

r? ````@jyn514````
2021-03-03 16:27:38 +09:00
Yuki Okushi 543ef7f13c
Rollup merge of #82593 - sunfishcode:wasi-docs, r=alexcrichton
Teach rustdoc how to display WASI.

As a followup to [this comment] in #82420, this patch teaches rustdoc
how to display WASI.

[this comment]: https://github.com/rust-lang/rust/pull/82420#issuecomment-784523826

r? `@alexcrichton`
2021-03-02 21:23:18 +09:00
Joshua Nelson cc62018e61 Rename rustdoc lints to be a tool lint instead of built-in.
- Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links`
- Ensure that the old lint names still work and give deprecation errors
- Register lints even when running doctests

  Otherwise, all `rustdoc::` lints would be ignored.

- Register all existing lints as removed

  This unfortunately doesn't work with `register_renamed` because tool
  lints have not yet been registered when rustc is running. For similar
  reasons, `check_backwards_compat` doesn't work either. Call
  `register_removed` directly instead.

- Fix fallout

  + Rustdoc lints for compiler/
  + Rustdoc lints for library/

Note that this does *not* suggest `rustdoc::broken_intra_doc_links` for
`rustdoc::intra_doc_link_resolution_failure`, since there was no time
when the latter was valid.
2021-03-01 19:29:15 -05:00
Guillaume Gomez 5a82251e92
Rollup merge of #82598 - GuillaumeGomez:rustdoc-rustc-pass, r=jyn514
Check stability and feature attributes in rustdoc

Fixes #82588.

cc `@Nemo157` `@camelid`
r? `@jyn514`
2021-03-02 00:50:08 +01:00
Dan Gohman e27eba3397 Add a test in src/test/rustdoc/doc-cfg.rs 2021-02-28 14:07:05 -08:00
Guillaume Gomez 5ab4d46e9a Update rustdoc test to make it work with newly added rustc passes 2021-02-28 00:48:43 +01:00
Lucas De Angelis 5835f6defa Move test file, add test of generated link 2021-02-27 01:08:05 +01:00
Lucas De Angelis 5661fe3fa9 Fix intra-doc handling of `Self` in enum
Fixes #82209
2021-02-26 22:09:39 +01:00
Guillaume Gomez 3c59e64abf * Fix some typo
* Improve documentation
* Add a test to ensure that spotlighted traits from dependencies are taken into account as expected
2021-02-23 21:58:17 +01:00
Guillaume Gomez 2b59e7667d Add tests for --generate-redirect-map option 2021-02-23 11:13:35 +01:00
Dylan DPC 1c2a949736
Rollup merge of #79423 - camelid:smart-punct, r=jyn514
Enable smart punctuation

Closes #76690.
2021-02-23 02:51:42 +01:00
Yuki Okushi 1dba8ce8a5
Rollup merge of #82351 - notriddle:docs-meta-description, r=jyn514
Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions

Partially addresses #82283.
2021-02-22 18:26:08 +09:00
Michael Howell 575c75b324
Update src/test/rustdoc/description.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-21 09:31:39 -07:00
Michael Howell a6b85fbc78
Update src/test/rustdoc/description.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-21 09:31:23 -07:00
Michael Howell fd5a710092 Use has for non-regexes 2021-02-20 17:51:41 -07:00
Michael Howell dcf49916e4 Fix formatting for description rustdoc UI tests 2021-02-20 17:50:01 -07:00
Michael Howell 8b3b1c922e Add rustdoc UI tests for new description behaviour 2021-02-20 17:43:13 -07:00
Guillaume Gomez 0c511c9115 Add test for no src links on dummy spans 2021-02-20 19:51:38 +01:00
Guillaume Gomez 46f24c912f Add tests for !Sized trait display 2021-02-19 22:38:07 +01:00
Simon Sapin 21ceebf296 Fix intra-doc link to raw pointer method
CC https://github.com/rust-lang/rust/pull/80181
2021-02-15 14:27:50 +01:00
Yuki Okushi 3560ff39f0
Rollup merge of #82040 - GuillaumeGomez:ensure-src-link, r=CraftSpider
Add test to prevent src link regression

Fixes #80502.

This PR is simply about adding a test to prevent a regression.

cc `@bugadani` `@CraftSpider`
r? `@camelid`
2021-02-13 16:36:49 +09:00
Dylan DPC ab3f4f0bc0
Rollup merge of #79775 - jyn514:doctest, r=GuillaumeGomez
Fix injected errors when running doctests on a crate named after a keyword

Closes https://github.com/rust-lang/rust/issues/79771
2021-02-12 22:53:21 +01:00
Guillaume Gomez 95c984a4a3 Add test to prevent src link regression 2021-02-12 20:27:57 +01:00
Joshua Nelson 02ffe9ef01 Fix injected errors when running doctests on a crate named after a keyword
Unfortunately, this can't currently be tested. The problem is that we
need the file to be compiled first to then be used as dependency, which
cannot be done currently unfortunately in the rustdoc test suites.
Example:

```rust
// name this file "foo.rs"

/// ```
/// let x = foo::foo();
/// ```
pub fn foo() {}
```

If you run `rustdoc --test foo.rs`, you'll get:

```
running 1 test
test foo.rs - foo (line 1) ... FAILED

failures:

---- foo.rs - foo (line 1) stdout ----
error[E0463]: can't find crate for `foo`
 --> foo.rs:0:1
  |
2 | extern crate foo;
  | ^^^^^^^^^^^^^^^^^ can't find crate
```

If a test were possible, it would look something like

 ````rust
 #![crate_name = "mod"]
 #![crate_type = "lib"]
 //! ```
 //! // NOTE: requires that the literal string 'mod' appears in the doctest for
 //! // the bug to appear
 //! assert_eq!(1, 1);
 //! ```
 ````
2021-02-11 17:16:43 -05:00
Vadim Petrochenkov 7b021aacb5 resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lint 2021-02-11 10:15:29 +03:00
LeSeulArtichaut 089ee27dd0 Do not ICE on range patterns in function arguments 2021-02-10 16:41:48 +01:00
LeSeulArtichaut 793e88ad16 Add regression test for #81289 2021-02-10 16:41:09 +01:00
Camelid 0a3452110c Fix `@has` checks "no closing quotation" error
Apparently `"foo\""` has different behavior from `'foo\''` in Python
shlex. See the [discussion on Zulip][z] for more.

[z]: https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.40has.20checks.20.22no.20closing.20quotation.22
2021-02-08 15:49:04 -08:00
bors 921ec4b3fc Auto merge of #81313 - LeSeulArtichaut:revert-32558, r=jyn514
Restore linking to itself in implementors section of trait page

Reverts #32558 as proposed in [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Trait.20implementation.20self-links/near/223773273)
r? `@jyn514` cc `@camelid`
2021-02-08 10:46:10 +00:00
Camelid f1581ed8fc Test that code does not get smart-punctuated 2021-02-07 20:19:01 -08:00
Camelid a0f9d4beec Enable smart punctuation 2021-02-07 19:57:53 -08:00
LeSeulArtichaut 1daddb47d2 Restore linking to itself in implementors section of trait page 2021-02-06 21:05:41 +01:00
Joshua Nelson 9653b601b2 Enable 'task list' markdown extension
- Add documentation about task lists
2021-02-06 00:08:21 -05:00
Camelid cd8dceef86 rustdoc: Render HRTB correctly for bare functions
The angle brackets were not rendered, so code like this:

    some_func: for<'a> fn(val: &'a i32) -> i32

would be rendered as:

    some_func: fn'a(val: &'a i32) -> i32

However, rendering with angle brackets is still invalid syntax:

    some_func: fn<'a>(val: &'a i32) -> i32

so now it renders correctly as:

    some_func: for<'a> fn(val: &'a i32) -> i32

-----

However, note that this code:

    some_trait: dyn for<'a> Trait<'a>

will still render as:

    some_trait: dyn Trait<'a>

which is not invalid syntax, but is still unclear. Unfortunately I think
it's hard to fix that case because there isn't enough information in the
`rustdoc::clean::Type` that this code operates on. Perhaps that case can
be fixed in a later PR.
2021-01-27 19:55:46 -08:00
Jonas Schievink ee4461a996
Rollup merge of #81302 - LeSeulArtichaut:80777-trait-render, r=jyn514
Fix rendering of stabilization version for trait implementors

Rustdoc compares an item's stabilization version with its parent's to not render it if they are the same. Here, the implementor was compared with itself, resulting in the stabilization version never getting shown.

This probably needs a test.

Fixes #80777.
r? `@jyn514`
2021-01-24 22:10:04 +01:00
LeSeulArtichaut 20a460e1cf Fix rendering of stabilization version for trait implementors 2021-01-23 22:02:06 +01:00
Camelid 93e51b185a rustdoc: Fix visibility of trait and impl items 2021-01-22 18:30:30 -08:00
bors 339e19697a Auto merge of #80958 - bstrie:deptbdnums, r=KodrAus
Deprecate-in-future the constants superceded by RFC 2700

Successor to #78335, re-opened after addressing the issues tracked in #68490.

This PR makes use of the new ability to explicitly annotate an item as triggering the deprecated-in-future lint (via `rustc_deprecated(since="TBD"`, see #78381). We might call this *soft deprecation*; unlike with deprecation, users will *not* receive warnings when compiling code that uses these items *unless* they opt-in via `#[warn(deprecated_in_future)]`. Like deprecation, soft deprecation causes documentation to formally acknowledge that an item is marked for eventual deprecation (at a non-specific point in the future).

With this new ability, we can sidestep all debate about when or on what timeframe something ought to be deprecated; as long as we can agree that something ought to be deprecated, we can receive much of the benefits of deprecation with none of the drawbacks. For these items specifically, the libs team has already agreed that they should be deprecated (see https://github.com/rust-lang/rust/issues/68490#issuecomment-747022696).
2021-01-21 09:14:37 +00:00
bstrie 6f3df00610 Deprecate-in-future the constants superceded by RFC 2700 2021-01-20 20:08:11 -05:00
Joshua Nelson 1f6f750ade Remove flaky test
See https://github.com/rust-lang/rust/pull/81197 for what's going on
here; this is a temporary stopgap until someone has time to review the
proper fix.
2021-01-20 19:18:23 -05:00
Joshua Nelson fc53594756 Feature-gate `pointer` and `reference` in intra-doc links
- Only feature gate associated items
- Add docs to unstable book
2021-01-17 15:27:35 -05:00