Commit graph

125831 commits

Author SHA1 Message Date
Yuki Okushi
47a03d9815
Rollup merge of #75859 - jrheard:patch-2, r=jonas-schievink
doc: Fix typo in std::process::Child documentation

Nearly done reading stdlib docs, found another small typo, here's a PR!

r? @steveklabnik
2020-08-24 11:48:55 +09:00
Yuki Okushi
7209b9cc49
Rollup merge of #75856 - matthiaskrgr:more_clippy, r=Dylan-DPC
more tool clippy fixes

r? @Dylan-DPC
2020-08-24 11:48:53 +09:00
Yuki Okushi
648ad7c57e
Rollup merge of #75851 - camelid:patch-2, r=jyn514
Switch to intra-doc links in `core::array`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:52 +09:00
Yuki Okushi
282d258cd1
Rollup merge of #75847 - camelid:patch-1, r=dtolnay
Switch to intra-doc links in `std::collections`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:50 +09:00
Yuki Okushi
d6de9616a1
Rollup merge of #75844 - ehuss:publish-toolstate-httperror, r=Mark-Simulacrum
publish-toolstate: show more context on HTTP error

The default display for HTTPError in Python does not include the request body. For GitHub API, the body includes more details about the error (like rate limiting). This could help diagnosing errors like this: https://github.com/rust-lang/rust/pull/75815#issuecomment-678798158
2020-08-24 11:48:49 +09:00
Yuki Okushi
25a677ccef
Rollup merge of #75831 - lzutao:https, r=Dylan-DPC
doc: Prefer https link for wikipedia URLs

A tiny changes.
2020-08-24 11:48:47 +09:00
Yuki Okushi
427e969c43
Rollup merge of #75826 - ayushmishra2005:misleading_documentation_for_derived_Ord_PartialOrd, r=KodrAus
Corrected Misleading documentation for derived Ord/PartialOrd implementation

Corrected Misleading documentation for derived Ord/PartialOrd implementation

Fixes #75620
2020-08-24 11:48:46 +09:00
Yuki Okushi
b8e456f2db
Rollup merge of #75825 - jrheard:patch-1, r=steveklabnik
Fix typo in documentation of i32 wrapping_abs()

Hi!

I was reading through the std library docs and noticed that this section flowed a bit oddly; comparing it against https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_div and https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_neg , I noticed that those two pieces of documentation used a semicolon here.

This is my first time submitting a PR to this repo. Am I doing this right? Are tiny typo-fix PRs like this worth submitting, or are they not a good use of time?

Thank you!
2020-08-24 11:48:44 +09:00
Yuki Okushi
640b36f97a
Rollup merge of #75821 - camelid:intra-doc-links-for-std-macros, r=jyn514
Switch to intra-doc links in `std::macros`

Part of #75080.

---

* Switch to intra-doc links in `std::macros`
* Fix typo in module docs
* Link to `std::io::stderr` instead of `std::io::Stderr` to match the
  link text
* Link to `std::io::stdout`

---

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:42 +09:00
Yuki Okushi
50bdcc2f2e
Rollup merge of #75819 - LeSeulArtichaut:core-intra-docs-2, r=jyn514
Use intra-doc-links in `core::{char, macros, fmt}`

Helps with #75080.
r? @jyn514
2020-08-24 11:48:41 +09:00
JR Heard
bc47f70f88
doc: Fix typo in std::process::Child documentation 2020-08-23 16:38:23 -07:00
bors
8fdce9bbb9 Auto merge of #74489 - jyn514:assoc-items, r=manishearth,petrochenkov
Fix intra-doc links for associated items

@Manishearth and I found that links of the following sort are broken:
```rust
$ cat str_from.rs
/// [`String::from`]
pub fn foo() {}
$ rustdoc str_from.rs
warning: `[String::from]` cannot be resolved, ignoring it.
 --> str_from.rs:4:6
  |
4 | /// [`String::from`]
  |      ^^^^^^^^^^^^^^ cannot be resolved, ignoring
```
It turns out this is because the current implementation only looks at inherent impls (`impl Bar {}`) and traits _for the item being documented_. Note that this is not the same as the item being _linked_ to. So this code would work:

```rust
pub trait T1 {
    fn method();
}

pub struct S;
impl T1 for S {
    /// [S::method] on method
    fn method() {}
}
```

but putting the documentation on `trait T1` would not.

~~I realized that writing it up that my fix is only partially correct: It removes the inherent impls code when it should instead remove the `trait_item` code.~~ Fixed.

Additionally, I discovered while writing this there is some ambiguity: you could have multiple methods with the same name, but for different traits:

```rust
pub trait T1 {
    fn method();
}

pub trait T2 {
    fn method();
}

/// See [S::method]
pub struct S;
```

Rustdoc should give an ambiguity error here, but since there is currently no way to disambiguate the traits (https://github.com/rust-lang/rust/issues/74563) it does not (https://github.com/rust-lang/rust/pull/74489#issuecomment-673878404).

There is a _third_ ambiguity that pops up: What if the trait is generic and is implemented multiple times with different generic parameters? In this case, my fix does not do very well: it thinks there is only one trait instantiated and links to that trait:

```
/// [`String::from`] -- this resolves to https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from
pub fn foo() {}
```

However, every `From` implementation has a method called `from`! So the browser picks a random one. This is not the desired behavior, but it's not clear how to avoid it.

To be consistent with the rest of intra-doc links, this only resolves associated items from traits that are in scope. This required changes to rustc_resolve to work cross-crate; the relevant commits are prefixed with `resolve: `. As a bonus, considering only traits in scope is slightly faster. To avoid re-calculating the traits over and over, rustdoc uses a cache to store the traits in scope for a given module.
2020-08-23 23:10:33 +00:00
Matthias Krüger
a72500145b unstable-book-gen: fix clippy::single_char_pattern and clippy::iter_skip_next 2020-08-24 00:47:38 +02:00
Matthias Krüger
ba6b4274b5 unicode_table_generator: fix clippy::writeln_empty_string, clippy::useless_format, clippy:::for_kv_map 2020-08-24 00:43:50 +02:00
Matthias Krüger
ebac0e4727 tidy: remove redundant variable from check_if_error_code_is_test_in_explanation 2020-08-24 00:15:40 +02:00
LeSeulArtichaut
d36e3e23a8 Use intra-doc-links in core::{char, macros, fmt} 2020-08-24 00:13:23 +02:00
Matthias Krüger
d97c4703eb linkcheckr: fix clippy::redundant_static_lifetimes and clippy::single_char_pattern 2020-08-23 23:53:53 +02:00
Matthias Krüger
7c6362a19c expand-yaml-anchors: fix clippy::match_ref_pats and clippy::redundant_closure 2020-08-23 23:53:53 +02:00
Joshua Nelson
d77eff21b9 resolve: Add comments to traits_in_scope 2020-08-23 17:47:59 -04:00
Camelid
04e8237c6d
Switch to intra-doc links in core::array 2020-08-23 14:42:21 -07:00
bors
5180f3da5f Auto merge of #75656 - tirr-c:match-suggest-semi, r=estebank
Provide better spans for the match arm without tail expression

Resolves #75418.

Applied the same logic in the `if`-`else` type mismatch case.

r? @estebank
2020-08-23 21:18:06 +00:00
Camelid
e9928d8926
Switch to intra-doc links in std::collections 2020-08-23 13:51:01 -07:00
bors
0ec94594dd Auto merge of #72449 - ecstatic-morse:const-float-bitcast, r=RalfJung
Const floating point bitcasts and classification

Makes the `f32` and `f64` methods described in #72447 and #72505 unstably const.

r? @RalfJung
2020-08-23 19:14:55 +00:00
Eric Huss
2e6f2e8855 publish-toolstate: show more context on HTTP error 2020-08-23 11:29:27 -07:00
ecstatic-morse
130766c466
Fix compile-flags directive
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-08-23 10:45:26 -07:00
bors
d02a209eb9 Auto merge of #75028 - MrModder:master, r=steveklabnik
Document that slice refers to any pointer type to a sequence

I was recently confused about the way slices are represented in memory. The necessary information was not available in the std-docs directly, but was a mix of different material from the reference and book.

This PR should clear up the definition of slices a bit more in the documentation. Especially the fact that the term slice refers to the pointer/reference type, e.g. `&[T]`, and not `[T]`.
It also documents that slice pointers are twice the size of pointers to `Sized` types, as this concept may be unfamiliar to users coming from other languages that do not have the concept of "fat pointers" (especially C/C++).

I've documented why this was important to me and my findings in [this blog post](https://codecrash.me/understanding-rust-slices).

r? @lcnr
2020-08-23 16:59:10 +00:00
bors
9d606d939a Auto merge of #74238 - RalfJung:offset_from, r=oli-obk
stabilize ptr_offset_from

This stabilizes ptr::offset_from, and closes https://github.com/rust-lang/rust/issues/41079. It also removes the deprecated `wrapping_offset_from`. This function was deprecated 19 days ago and was never stable; given an FCP of 10 days and some waiting time until FCP starts, that leaves at least a month between deprecation and removal which I think is fine for a nightly-only API.

Regarding the open questions in https://github.com/rust-lang/rust/issues/41079:
* Should offset_from abort instead of panic on ZSTs? -- As far as I know, there is no precedent for such aborts. We could, however, declare this UB. Given that the size is always known statically and the check thus rather cheap, UB seems excessive.
* Should there be more methods like this with different restrictions (to allow nuw/nsw, perhaps) or that return usize (like how isize-taking offset is more conveniently done with usize-taking add these days)? -- No reason to block stabilization on that, we can always add such methods later.

Also nominating the lang team because this exposes an intrinsic.

The stabilized method is best described [by its doc-comment](56d4b2d69a/src/libcore/ptr/const_ptr.rs (L227)). The documentation forgot to mention the requirement that both pointers must "have the same provenance", aka "be derived from pointers to the same allocation", which I am adding in this PR. This is a precondition that [Miri already implements](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a3b9d0a07a01321f5202cd99e9613480) and that, should LLVM ever obtain a `psub` operation to subtract pointers, will likely be required for that operation (following the semantics in [this paper](https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf)).
2020-08-23 14:50:15 +00:00
Ralf Jung
4129e0757a bump stable version
Co-authored-by: Josh Stone <cuviper@gmail.com>
2020-08-23 16:12:39 +02:00
Ralf Jung
eb27828bf1 remove an unused feature flag 2020-08-23 16:12:39 +02:00
Leon Matthes
cf76256b83 Revert changed paragraph about slice definition.
This reverts part of commit e6c83dd57b.
As requested by @steveklabnik .
2020-08-23 16:02:22 +02:00
bors
b88434ee0f Auto merge of #75816 - LeSeulArtichaut:core-intra-docs, r=jyn514
Use intra-doc-links in `core::{raw, ffi, pin}`

Helps with #75080.
r? @jyn514
2020-08-23 12:40:01 +00:00
Ayush Kumar Mishra
18f47d81da Misleading documentation for derived Ord/PartialOrd implementation for enums #75620 2020-08-23 15:56:01 +05:30
bors
2342cc3333 Auto merge of #75789 - matthiaskrgr:clippy_compiletest, r=Dylan-DPC
compiletest: fix a couple clippy lint findings
2020-08-23 10:25:53 +00:00
Lzu Tao
2c995d29f7 Prefer https link for wikipedia URLs 2020-08-23 10:02:42 +00:00
bors
d5ba3efed1 Auto merge of #75465 - Aaron1011:feature/short-fn-def-span, r=estebank
Use smaller def span for functions

Currently, the def span of a function encompasses the entire function
signature and body. However, this is usually unnecessarily verbose - when we are
pointing at an entire function in a diagnostic, we almost always want to
point at the signature. The actual contents of the body tends to be
irrelevant to the diagnostic we are emitting, and just takes up
additional screen space.

This commit changes the `def_span` of all function items (freestanding
functions, `impl`-block methods, and `trait`-block methods) to be the
span of the signature. For example, the function

```rust
pub fn foo<T>(val: T) -> T { val }
```

now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T`
(everything before the opening curly brace).

Trait methods without a body have a `def_span` which includes the
trailing semicolon. For example:

```rust
trait Foo {
    fn bar();
}
```

the function definition `Foo::bar` has a `def_span` of `fn bar();`

This makes our diagnostic output much shorter, and emphasizes
information that is relevant to whatever diagnostic we are reporting.

We continue to use the full span (including the body) in a few of
places:

* MIR building uses the full span when building source scopes.
* 'Outlives suggestions' use the full span to sort the diagnostics being
  emitted.
* The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]`
attribute points the entire scope body.

All of these cases work only with local items, so we don't need to
add anything extra to crate metadata.
2020-08-23 08:14:17 +00:00
bors
d5abc8d3b2 Auto merge of #75813 - petrochenkov:feature/incr-def-path-table, r=Aaron1011
Lazy decoding of DefPathTable from crate metadata (non-incremental case)

The is the half of https://github.com/rust-lang/rust/pull/74967 that doesn't touch incremental-related structures.
We are still decoding def path hashes eagerly if we are in incremental mode.

The incremental part of https://github.com/rust-lang/rust/pull/74967 feels hacky, but I'm not qualified enough to suggest improvements. I'll reassign it so someone else once this PR lands.
@Aaron1011, I wasn't asking you to do this split because I wasn't sure that it's feasible (or simple to do).

r? @Aaron1011
2020-08-23 05:56:47 +00:00
JR Heard
69d3334adf
Fix typo in documentation of i32 wrapping_abs() 2020-08-22 22:21:03 -07:00
bors
7ce71c362b Auto merge of #73526 - cuviper:rust-llvm11, r=nikic
Upgrade to LLVM 11 (rc2)

This builds on #73525 to try actually moving rust-lang/llvm-project to LLVM 11.
2020-08-23 04:02:41 +00:00
Camelid
637659be6a Add missing links 2020-08-22 20:23:50 -07:00
bors
e482c86b9d Auto merge of #73084 - Aaron1011:feature/new-recursive-expand, r=petrochenkov
Re-land PR #72388:  Recursively expand `TokenKind::Interpolated` in `probably_equal_for_proc_macro`

PR #72388 allowed us to preserve the original `TokenStream` in more cases during proc-macro expansion, but had to be reverted due to a large number of regressions (See #72545 and #72622). These regressions fell into two categories

1. Missing handling for `Group`s with `Delimiter::None`, which are inserted during `macro_rules!` expansion (but are lost during stringification and re-parsing). A large number of these regressions were due to `syn` and `proc-macro-hack`, but several crates needed changes to their own proc-macro code.
2. Legitimate hygiene issues that were previously being masked by stringification. Some of these were relatively benign (e.g. [a compiliation error](https://github.com/paritytech/parity-scale-codec/pull/210) caused by misusing `quote_spanned!`). However, two crates had intentionally written unhygenic `macro_rules!` macros, which were able to access identifiers that were not passed as arguments (see https://github.com/rust-lang/rust/issues/72622#issuecomment-636402573).

All but one of the Crater regressions have now been fixed upstream (see https://hackmd.io/ItrXWRaSSquVwoJATPx3PQ?both). The remaining crate (which has a PR pending at https://github.com/sammhicks/face-generator/pull/1) is not on `crates.io`, and is a Yew application that seems unlikely to have any reverse dependencies.

As @petrochenkov mentioned in https://github.com/rust-lang/rust/issues/72545#issuecomment-638632434, not re-landing PR #72388 allows more crates to write unhygenic `macro_rules!` macros, which will eventually stop compiling. Since there is only one Crater regression remaining, since additional crates could write unhygenic `macro_rules!` macros in the time it takes that PR to be merged.
2020-08-23 01:44:36 +00:00
Camelid
becf5ec4ea Add missing intra-doc link 2020-08-22 17:41:40 -07:00
Camelid
5d32786b4f Switch to intra-doc links in std::macros
Also:
* Fix typo in module docs
* Link to `std::io::stderr` instead of `std::io::Stderr` to match the
  link text
* Link to `std::io::stdout`
2020-08-22 15:44:00 -07:00
Aaron Hill
e3cd43eb00
Use smaller def span for functions
Currently, the def span of a funtion encompasses the entire function
signature and body. However, this is usually unnecessarily verbose - when we are
pointing at an entire function in a diagnostic, we almost always want to
point at the signature. The actual contents of the body tends to be
irrelevant to the diagnostic we are emitting, and just takes up
additional screen space.

This commit changes the `def_span` of all function items (freestanding
functions, `impl`-block methods, and `trait`-block methods) to be the
span of the signature. For example, the function

```rust
pub fn foo<T>(val: T) -> T { val }
```

now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T`
(everything before the opening curly brace).

Trait methods without a body have a `def_span` which includes the
trailing semicolon. For example:

```rust
trait Foo {
    fn bar();
}```

the function definition `Foo::bar` has a `def_span` of `fn bar();`

This makes our diagnostic output much shorter, and emphasizes
information that is relevant to whatever diagnostic we are reporting.

We continue to use the full span (including the body) in a few of
places:

* MIR building uses the full span when building source scopes.
* 'Outlives suggestions' use the full span to sort the diagnostics being
  emitted.
* The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]`
attribute points the entire scope body.
* The 'unconditional recursion' lint uses the full span to show
  additional context for the recursive call.

All of these cases work only with local items, so we don't need to
add anything extra to crate metadata.
2020-08-22 18:41:49 -04:00
Aaron Hill
0fcad9cd29
Add backwards-compat hack for certain '$name' tokens
See issue #74616
2020-08-22 17:31:47 -04:00
Aaron Hill
cd24aee8e6
Recursively expand TokenKind::Interpolated (take 2)
Fixes #68430

This is a re-attempt of PR #72388, which was previously reverted due to
a large number of breakages. All of the known breakages should now be
patched upstream.
2020-08-22 17:18:26 -04:00
Josh Stone
b450c0c86c Write coverage filenames in Version3 format 2020-08-22 13:44:54 -07:00
Josh Stone
fb05be00df Match scalar-pair-bool more flexibly for LLVM 11
LLVM 11 started using `phi` and `select` for `fn pair_i32_bool`, which
is still valid, but harder to match than the simple instructions we were
getting before. We'll just check that the unpacked args are directly
referenced in any way, and call it good.
2020-08-22 13:44:54 -07:00
Josh Stone
5c87749a27 Apply suggestions from code review
Flatten the INC definition to one line.

Co-authored-by: lzutao <taolzu@gmail.com>
2020-08-22 13:44:54 -07:00
Josh Stone
a210a29303 Expand RISCV pseudo-instructions to match LLVM 11 2020-08-22 13:44:54 -07:00
Josh Stone
636ca7a412 Upgrade to LLVM 11 (rc2) 2020-08-22 13:44:54 -07:00