]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jsha
Guillaume Gomez [Wed, 12 May 2021 15:19:29 +0000 (17:19 +0200)]
Rollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jsha

Fix border radius for doc code blocks in rustdoc

In #85148, I made an invalid change on the border radius of the doc code blocks (look in the top left and bottom left corners of the code blocks).

Before this fix:

![Screenshot from 2021-05-11 11-14-59](https://user-images.githubusercontent.com/3050060/117791459-a4f86b80-b24a-11eb-8ac3-facc719c799a.png)

After this fix:

![Screenshot from 2021-05-11 11-05-29](https://user-images.githubusercontent.com/3050060/117791482-a9bd1f80-b24a-11eb-8c38-a01989595f5c.png)

r? `@jsha`

3 years agoRollup merge of #85141 - GuillaumeGomez:maybe_collapsed_doc_value-doc, r=jsha
Guillaume Gomez [Wed, 12 May 2021 15:19:28 +0000 (17:19 +0200)]
Rollup merge of #85141 - GuillaumeGomez:maybe_collapsed_doc_value-doc, r=jsha

Update documentation for SharedContext::maybe_collapsed_doc_value

Fixes #85120.

The `doc-collapse` was removed, however, the main crate is always "collapsed", meaning that this function is still needed. I updated the documentation instead to avoid misleading readers.

r? `@jsha`

3 years agoRollup merge of #85117 - jsha:bubble-bubble-toil-and-trouble, r=GuillaumeGomez
Guillaume Gomez [Wed, 12 May 2021 15:19:27 +0000 (17:19 +0200)]
Rollup merge of #85117 - jsha:bubble-bubble-toil-and-trouble, r=GuillaumeGomez

Move global click handlers to per-element ones.

In rustdoc's main.js, we had an onclick handler for the whole document that would dispatch to handlers for various elements. This change attaches the handlers to the elements that trigger them, instead. This simplifies the code and avoids reimplementing the browser's bubbling functionality.

As part of this change, change from a class to an id for help button.

Move the handlers and associated code for highlighting source lines into source-script.js (and factor out a shared regex).

Demo at https://hoffman-andrews.com/rust/bubble-bubble-toil-and-trouble/std/string/struct.String.html

Note: this conflicts with / depends on #85074. Once that's merged I'll rebase this and resolve conflicts.

Part of #83332. Thanks to `@Manishearth` for the [suggestion to not reimplement bubbling](https://github.com/rust-lang/rust/issues/83332#issuecomment-803497509).

r? `@GuillaumeGomez`

3 years agoRollup merge of #84793 - estebank:parse-struct-field-default, r=davidtwco
Guillaume Gomez [Wed, 12 May 2021 15:19:25 +0000 (17:19 +0200)]
Rollup merge of #84793 - estebank:parse-struct-field-default, r=davidtwco

Recover from invalid `struct` item syntax

Parse unsupported "default field const values":

```rust
struct S {
    field: Type = const_val,
}
```

Recover from small `:` typo and provide suggestion:

```rust
struct S {
    field; Type,
    field2= Type,
}
```

3 years agoAuto merge of #83813 - cbeuw:remap-std, r=michaelwoerister
bors [Wed, 12 May 2021 11:05:56 +0000 (11:05 +0000)]
Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister

Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths

This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped.

`RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path.

`RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure.

When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host".

`rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`.

cc `@eddyb` who implemented `/rustc/...` path devirtualisation

3 years agoAuto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot
bors [Wed, 12 May 2021 08:38:03 +0000 (08:38 +0000)]
Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot

rustc_driver cleanup

Best reviewed one commit at a time.

3 years agoAuto merge of #84278 - Aaron1011:feature/new-proc-macro-meta-span, r=estebank
bors [Wed, 12 May 2021 05:59:28 +0000 (05:59 +0000)]
Auto merge of #84278 - Aaron1011:feature/new-proc-macro-meta-span, r=estebank

Implement span quoting for proc-macros

This PR implements span quoting, allowing proc-macros to produce spans
pointing *into their own crate*. This is used by the unstable
`proc_macro::quote!` macro, allowing us to get error messages like this:

```
error[E0412]: cannot find type `MissingType` in this scope
  --> $DIR/auxiliary/span-from-proc-macro.rs:37:20
   |
LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
   | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]`
...
LL |             field: MissingType
   |                    ^^^^^^^^^^^ not found in this scope
   |
  ::: $DIR/span-from-proc-macro.rs:8:1
   |
LL | #[error_from_attribute]
   | ----------------------- in this macro invocation
```

Here, `MissingType` occurs inside the implementation of the proc-macro
`#[error_from_attribute]`. Previosuly, this would always result in a
span pointing at `#[error_from_attribute]`

This will make many proc-macro-related error message much more useful -
when a proc-macro generates code containing an error, users will get an
error message pointing directly at that code (within the macro
definition), instead of always getting a span pointing at the macro
invocation site.

This is implemented as follows:
* When a proc-macro crate is being *compiled*, it causes the `quote!`
  macro to get run. This saves all of the sapns in the input to `quote!`
  into the metadata of *the proc-macro-crate* (which we are currently
  compiling). The `quote!` macro then expands to a call to
  `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an
opaque identifier for the span in the crate metadata.
* When the same proc-macro crate is *run* (e.g. it is loaded from disk
  and invoked by some consumer crate), the call to
`proc_macro::Span::recover_proc_macro_span` causes us to load the span
from the proc-macro crate's metadata. The proc-macro then produces a
`TokenStream` containing a `Span` pointing into the proc-macro crate
itself.

The recursive nature of 'quote!' can be difficult to understand at
first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows
the output of the `quote!` macro, which should make this eaier to
understand.

This PR also supports custom quoting spans in custom quote macros (e.g.
the `quote` crate). All span quoting goes through the
`proc_macro::quote_span` method, which can be called by a custom quote
macro to perform span quoting. An example of this usage is provided in
`src/test/ui/proc-macro/auxiliary/custom-quote.rs`

Custom quoting currently has a few limitations:

In order to quote a span, we need to generate a call to
`proc_macro::Span::recover_proc_macro_span`. However, proc-macros
support renaming the `proc_macro` crate, so we can't simply hardcode
this path. Previously, the `quote_span` method used the path
`crate::Span` - however, this only works when it is called by the
builtin `quote!` macro in the same crate. To support being called from
arbitrary crates, we need access to the name of the `proc_macro` crate
to generate a path. This PR adds an additional argument to `quote_span`
to specify the name of the `proc_macro` crate. Howver, this feels kind
of hacky, and we may want to change this before stabilizing anything
quote-related.

Additionally, using `quote_span` currently requires enabling the
`proc_macro_internals` feature. The builtin `quote!` macro
has an `#[allow_internal_unstable]` attribute, but this won't work for
custom quote implementations. This will likely require some additional
tricks to apply `allow_internal_unstable` to the span of
`proc_macro::Span::recover_proc_macro_span`.

3 years agoUpdate stderr
Aaron Hill [Sun, 9 May 2021 01:33:04 +0000 (21:33 -0400)]
Update stderr

The spans generated by `quote!` are (intentionally) no longer all the
same, so I removed that check entirely.

3 years agoImplement span quoting for proc-macros
Aaron Hill [Sun, 2 Aug 2020 23:52:16 +0000 (19:52 -0400)]
Implement span quoting for proc-macros

This PR implements span quoting, allowing proc-macros to produce spans
pointing *into their own crate*. This is used by the unstable
`proc_macro::quote!` macro, allowing us to get error messages like this:

```
error[E0412]: cannot find type `MissingType` in this scope
  --> $DIR/auxiliary/span-from-proc-macro.rs:37:20
   |
LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
   | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]`
...
LL |             field: MissingType
   |                    ^^^^^^^^^^^ not found in this scope
   |
  ::: $DIR/span-from-proc-macro.rs:8:1
   |
LL | #[error_from_attribute]
   | ----------------------- in this macro invocation
```

Here, `MissingType` occurs inside the implementation of the proc-macro
`#[error_from_attribute]`. Previosuly, this would always result in a
span pointing at `#[error_from_attribute]`

This will make many proc-macro-related error message much more useful -
when a proc-macro generates code containing an error, users will get an
error message pointing directly at that code (within the macro
definition), instead of always getting a span pointing at the macro
invocation site.

This is implemented as follows:
* When a proc-macro crate is being *compiled*, it causes the `quote!`
  macro to get run. This saves all of the sapns in the input to `quote!`
  into the metadata of *the proc-macro-crate* (which we are currently
  compiling). The `quote!` macro then expands to a call to
  `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an
opaque identifier for the span in the crate metadata.
* When the same proc-macro crate is *run* (e.g. it is loaded from disk
  and invoked by some consumer crate), the call to
`proc_macro::Span::recover_proc_macro_span` causes us to load the span
from the proc-macro crate's metadata. The proc-macro then produces a
`TokenStream` containing a `Span` pointing into the proc-macro crate
itself.

The recursive nature of 'quote!' can be difficult to understand at
first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows
the output of the `quote!` macro, which should make this eaier to
understand.

This PR also supports custom quoting spans in custom quote macros (e.g.
the `quote` crate). All span quoting goes through the
`proc_macro::quote_span` method, which can be called by a custom quote
macro to perform span quoting. An example of this usage is provided in
`src/test/ui/proc-macro/auxiliary/custom-quote.rs`

Custom quoting currently has a few limitations:

In order to quote a span, we need to generate a call to
`proc_macro::Span::recover_proc_macro_span`. However, proc-macros
support renaming the `proc_macro` crate, so we can't simply hardcode
this path. Previously, the `quote_span` method used the path
`crate::Span` - however, this only works when it is called by the
builtin `quote!` macro in the same crate. To support being called from
arbitrary crates, we need access to the name of the `proc_macro` crate
to generate a path. This PR adds an additional argument to `quote_span`
to specify the name of the `proc_macro` crate. Howver, this feels kind
of hacky, and we may want to change this before stabilizing anything
quote-related.

Additionally, using `quote_span` currently requires enabling the
`proc_macro_internals` feature. The builtin `quote!` macro
has an `#[allow_internal_unstable]` attribute, but this won't work for
custom quote implementations. This will likely require some additional
tricks to apply `allow_internal_unstable` to the span of
`proc_macro::Span::recover_proc_macro_span`.

3 years agoAuto merge of #85206 - ehuss:update-cargo, r=ehuss
bors [Wed, 12 May 2021 03:32:53 +0000 (03:32 +0000)]
Auto merge of #85206 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in e51522ab3db23b0d8f1de54eb1f0113924896331..070e459c2d8b79c5b2ac5218064e7603329c92ae
2021-05-07 21:29:52 +0000 to 2021-05-11 18:12:23 +0000
- Fix rustdoc warnings (rust-lang/cargo#9468)
- Improve performance of git status check in `cargo package`. (rust-lang/cargo#9478)
- Link to the new rustc tests chapter. (rust-lang/cargo#9477)
- Bump index cache version to deal with semver metadata version mismatch. (rust-lang/cargo#9476)
- Fix Url::into_string deprecation warning (rust-lang/cargo#9475)
- Fix rust-lang/cargo#4482 and rust-lang/cargo#9449: set Fossil ignore and clean settings locally (rust-lang/cargo#9469)
- Improve two error messages (rust-lang/cargo#9472)
- Fix `cargo install` with a semver metadata version. (rust-lang/cargo#9467)

3 years agoRecover from invalid `struct` item syntax
Esteban Küber [Sat, 1 May 2021 19:58:15 +0000 (12:58 -0700)]
Recover from invalid `struct` item syntax

Parse unsupported "default field const values":

```rust
struct S {
    field: Type = const_val,
}
```

Recover from small `:` typo and provide suggestion:

```rust
struct S {
    field; Type,
    field2= Type,
}
```

3 years agoAuto merge of #85192 - klensy:bump-deps, r=Mark-Simulacrum
bors [Wed, 12 May 2021 01:09:33 +0000 (01:09 +0000)]
Auto merge of #85192 - klensy:bump-deps, r=Mark-Simulacrum

updated deps

filetime v0.2.12 -> v0.2.14
https://github.com/alexcrichton/filetime/compare/0.2.12...0.2.14

socket2 v0.3.16 -> v0.3.19
https://github.com/rust-lang/socket2/commits/v0.3.x

tar v0.4.29 -> v0.4.33
https://github.com/alexcrichton/tar-rs/compare/0.4.29...0.4.33

this drops dependency on redox_syscall 0.1.*

---
measureme v9.1.0 -> v9.1.1
https://github.com/rust-lang/measureme/compare/9.1.0...9.1.1

this drops dependency on memmap v0.7.0

---
version_check v0.9.1 -> v0.9.3
https://github.com/SergioBenitez/version_check/compare/v0.9.1...v0.9.3
fixes version parse

3 years agoUpdate cargo
Eric Huss [Wed, 12 May 2021 00:39:51 +0000 (17:39 -0700)]
Update cargo

3 years agoAuto merge of #85199 - JohnTitor:rollup-gz5m06c, r=JohnTitor
bors [Tue, 11 May 2021 22:39:48 +0000 (22:39 +0000)]
Auto merge of #85199 - JohnTitor:rollup-gz5m06c, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #83501 (rustdoc: Add unstable CLI option to show basic type layout information)
 - #85018 (shrinking the deprecated method span)
 - #85124 (rustdoc: remove explicit boolean comparisons.)
 - #85136 (Change param name (k to key and v to value) in std::env module)
 - #85162 (Fix typo in variable name)
 - #85187 (Use .name_str() to format primitive types in error messages)
 - #85191 (Improve rustdoc gui tester)
 - #85196 (Revert "Auto merge of #84797 - richkadel:cover-unreachable-statements…)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #85196 - richkadel:reverts-cover-unreachable-statements, r=tmandry
Yuki Okushi [Tue, 11 May 2021 22:18:06 +0000 (07:18 +0900)]
Rollup merge of #85196 - richkadel:reverts-cover-unreachable-statements, r=tmandry

Revert "Auto merge of #84797 - richkadel:cover-unreachable-statements…

This reverts commit e5f83d24aee866a14753a7cedbb4e301dfe5bef5, reversing
changes made to ac888e8675182c703c2cd097957878faf88dad94.

See https://github.com/rust-lang/rust/pull/84797#issuecomment-839068132

r? `@tmandry`

3 years agoRollup merge of #85191 - GuillaumeGomez:improve-rustdoc-gui-tester, r=Mark-Simulacrum
Yuki Okushi [Tue, 11 May 2021 22:18:05 +0000 (07:18 +0900)]
Rollup merge of #85191 - GuillaumeGomez:improve-rustdoc-gui-tester, r=Mark-Simulacrum

Improve rustdoc gui tester

I cherry-picked the commit from https://github.com/rust-lang/rust/pull/84834 (and modified it a bit). I also used this opportunity to update it to last version (forgot to update GUI test in https://github.com/rust-lang/rust/pull/85074, really can't wait to make https://github.com/rust-lang/rust/pull/84586 finally work).

cc `@Mark-Simulacrum` for the changes in bootstrap.

r? `@jsha`

3 years agoRollup merge of #85187 - FabianWolff:issue-84976, r=jackh726
Yuki Okushi [Tue, 11 May 2021 22:18:04 +0000 (07:18 +0900)]
Rollup merge of #85187 - FabianWolff:issue-84976, r=jackh726

Use .name_str() to format primitive types in error messages

This pull request fixes #84976. The problem described there is caused by this code
https://github.com/rust-lang/rust/blob/506e75cbf8cb5305e49a41326307004ca3976029/compiler/rustc_middle/src/ty/error.rs#L161-L166
using `Debug` formatting (`{:?}`), while the proper solution is to call `name_str()` of `ty::IntTy`, `ty::UintTy` and `ty::FloatTy`, respectively.

3 years agoRollup merge of #85162 - LingMan:patch-1, r=varkor
Yuki Okushi [Tue, 11 May 2021 22:18:03 +0000 (07:18 +0900)]
Rollup merge of #85162 - LingMan:patch-1, r=varkor

Fix typo in variable name

All other sibling functions call this variable "slot", so "slote" was most likely a typo.

3 years agoRollup merge of #85136 - shirshak55:master, r=dtolnay
Yuki Okushi [Tue, 11 May 2021 22:18:02 +0000 (07:18 +0900)]
Rollup merge of #85136 - shirshak55:master, r=dtolnay

Change param name (k to key and v to value) in std::env module

1. When I was reading code the ide displayed `k` and `v`, so I
thought it would be better to show key and value?

2. I noticed var method already uses `key` instead of `k` so it
is more consistent to use `key` instead of `k`?

Thanks

3 years agoRollup merge of #85124 - jsha:trust-the-bool, r=GuillaumeGomez
Yuki Okushi [Tue, 11 May 2021 22:18:01 +0000 (07:18 +0900)]
Rollup merge of #85124 - jsha:trust-the-bool, r=GuillaumeGomez

rustdoc: remove explicit boolean comparisons.

For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`.

In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler.

An example of a style guide recommending this: https://airbnb.io/javascript/#comparison--shortcuts

r? `@GuillaumeGomez`

3 years agoRollup merge of #85018 - hi-rustin:rustin-patch-84637, r=estebank
Yuki Okushi [Tue, 11 May 2021 22:18:00 +0000 (07:18 +0900)]
Rollup merge of #85018 - hi-rustin:rustin-patch-84637, r=estebank

shrinking the deprecated method span

close https://github.com/rust-lang/rust/issues/84637

3 years agoRollup merge of #83501 - camelid:rustdoc-layout, r=jyn514,GuillaumeGomez
Yuki Okushi [Tue, 11 May 2021 22:17:59 +0000 (07:17 +0900)]
Rollup merge of #83501 - camelid:rustdoc-layout, r=jyn514,GuillaumeGomez

rustdoc: Add unstable CLI option to show basic type layout information

Closes #75988.

Right now it just shows the size.

3 years agoMove global click handlers to per-element ones.
Jacob Hoffman-Andrews [Sun, 9 May 2021 18:21:38 +0000 (11:21 -0700)]
Move global click handlers to per-element ones.

In rustdoc's main.js, we had an onclick handler for the whole document
that would dispatch to handlers for various elements. This change
attaches the handlers to the elements that trigger them, instead.
This simplfies the code and avoids reimplementing the browser's bubbling
functionality.

As part of this change, change from a class to an id for help button.

Move the handlers and associated code for highlighting source lines into
source-script.js (and factor out a shared regex).

3 years agoAdd explanatory comment to the issue-84976.rs test case
Fabian Wolff [Tue, 11 May 2021 19:51:58 +0000 (21:51 +0200)]
Add explanatory comment to the issue-84976.rs test case

3 years agoRevert "Auto merge of #84797 - richkadel:cover-unreachable-statements, r=tmandry"
Rich Kadel [Tue, 11 May 2021 19:47:08 +0000 (12:47 -0700)]
Revert "Auto merge of #84797 - richkadel:cover-unreachable-statements, r=tmandry"

This reverts commit e5f83d24aee866a14753a7cedbb4e301dfe5bef5, reversing
changes made to ac888e8675182c703c2cd097957878faf88dad94.

3 years agoAuto merge of #84904 - ssomers:btree_drop_kv_in_place, r=Mark-Simulacrum
bors [Tue, 11 May 2021 19:36:54 +0000 (19:36 +0000)]
Auto merge of #84904 - ssomers:btree_drop_kv_in_place, r=Mark-Simulacrum

BTree: no longer copy keys and values before dropping them

When dropping BTreeMap or BTreeSet instances, keys-value pairs are up to now each copied and then dropped, at least according to source code. This is because the code for dropping and for iterators is shared.

This PR postpones the treatment of doomed key-value pairs from the intermediate functions `deallocating_next`(`_back`) to the last minute, so the we can drop the keys and values in place. According to the library/alloc benchmarks, this does make a difference, (and a positive difference with an `#[inline]` on `drop_key_val`). It does not change anything for #81444 though.

r? `@Mark-Simulacrum`

3 years agofix tidy
klensy [Tue, 11 May 2021 19:25:10 +0000 (22:25 +0300)]
fix tidy

3 years agoMake rustdoc-gui test suite able to run with different sub directories
Guillaume Gomez [Tue, 11 May 2021 19:14:40 +0000 (21:14 +0200)]
Make rustdoc-gui test suite able to run with different sub directories

3 years agoupdated deps
klensy [Tue, 11 May 2021 19:03:59 +0000 (22:03 +0300)]
updated deps

3 years agoUpdate toggle-docs GUI test to last version
Guillaume Gomez [Tue, 11 May 2021 18:56:07 +0000 (20:56 +0200)]
Update toggle-docs GUI test to last version

3 years agoMove rustdoc-gui rust libraries into their own folder and prepare the field for more...
Guillaume Gomez [Sun, 2 May 2021 14:50:14 +0000 (16:50 +0200)]
Move rustdoc-gui rust libraries into their own folder and prepare the field for more libraries

3 years agorustdoc: remove explicit boolean comparisons.
Jacob Hoffman-Andrews [Sun, 9 May 2021 20:49:22 +0000 (13:49 -0700)]
rustdoc: remove explicit boolean comparisons.

For boolean variables it's shorter and more readable to check the value
directly, or negate it with `!`.

In a couple of cases I reordered an if/else pair because it made the
initial `if` statement simpler.

Removed unused isType parameter from two functions.

3 years agoDisable layout docs for type aliases for now
Camelid [Sun, 9 May 2021 20:18:28 +0000 (13:18 -0700)]
Disable layout docs for type aliases for now

There are issues with computing layout for type aliases; see #85103.
Once the issues are fixed, we should re-enable layout docs for them.

3 years agoEnable `--show-type-layout` for the rustdoc API docs
Camelid [Sun, 9 May 2021 20:15:33 +0000 (13:15 -0700)]
Enable `--show-type-layout` for the rustdoc API docs

3 years agoAdd note to docs when layout cannot be computed
Camelid [Wed, 28 Apr 2021 00:11:58 +0000 (17:11 -0700)]
Add note to docs when layout cannot be computed

This should prevent confusion about why generic types don't have layout
docs.

3 years agoAdd test case for zero-sized types
Camelid [Tue, 27 Apr 2021 17:38:12 +0000 (10:38 -0700)]
Add test case for zero-sized types

3 years agoMake test more specific
Camelid [Fri, 23 Apr 2021 21:10:51 +0000 (14:10 -0700)]
Make test more specific

3 years agoApply suggestions from code review
Camelid [Fri, 23 Apr 2021 21:01:00 +0000 (14:01 -0700)]
Apply suggestions from code review

Co-authored-by: Ivan Tham <pickfire@riseup.net>
3 years agoAdd `tcx` local variable
Camelid [Wed, 14 Apr 2021 01:33:25 +0000 (18:33 -0700)]
Add `tcx` local variable

3 years agoFix a few small things
Camelid [Tue, 13 Apr 2021 03:13:19 +0000 (20:13 -0700)]
Fix a few small things

3 years agoEnable `--show-type-layout` for the rustc API docs
Camelid [Tue, 13 Apr 2021 02:43:55 +0000 (19:43 -0700)]
Enable `--show-type-layout` for the rustc API docs

3 years agoOnly show type layout info if `--show-type-layout` is passed
Camelid [Tue, 13 Apr 2021 02:42:26 +0000 (19:42 -0700)]
Only show type layout info if `--show-type-layout` is passed

3 years agoShow memory layout for type aliases
Camelid [Tue, 13 Apr 2021 02:23:49 +0000 (19:23 -0700)]
Show memory layout for type aliases

At first you might think "why not just click through to the aliased
type?", but if a type alias instantiates all of the generic parameters
of the aliased type, then it can show layout info even though the
aliased type cannot (because we can't compute the layout of a generic
type). So I think it's still useful to show layout info for type
aliases.

3 years agoAdd test for memory layout information
Camelid [Tue, 13 Apr 2021 02:06:15 +0000 (19:06 -0700)]
Add test for memory layout information

3 years agoInclude a warning in the layout docs that layout is unstable
Camelid [Thu, 8 Apr 2021 23:04:21 +0000 (16:04 -0700)]
Include a warning in the layout docs that layout is unstable

3 years agoRemove FIXME
Camelid [Thu, 8 Apr 2021 03:55:37 +0000 (20:55 -0700)]
Remove FIXME

Layout errors can occur with valid code, e.g. generic types.

3 years agorustdoc: Show basic type layout information
Camelid [Mon, 22 Mar 2021 02:21:45 +0000 (19:21 -0700)]
rustdoc: Show basic type layout information

Right now it just shows the size.

3 years agoAuto merge of #82272 - b-naber:gat_diag, r=estebank,jackh726
bors [Tue, 11 May 2021 16:49:08 +0000 (16:49 +0000)]
Auto merge of #82272 - b-naber:gat_diag, r=estebank,jackh726

Improve diagnostics for GATs

Fixes https://github.com/rust-lang/rust/issues/81801
Fixes https://github.com/rust-lang/rust/issues/81961
Fixes https://github.com/rust-lang/rust/issues/81862

r? `@estebank`

3 years agoUse .name_str() to format primitive types in error messages
Fabian Wolff [Tue, 11 May 2021 16:12:36 +0000 (18:12 +0200)]
Use .name_str() to format primitive types in error messages

3 years agoAuto merge of #85023 - RalfJung:array-to-raw-elem, r=Mark-Simulacrum
bors [Tue, 11 May 2021 14:08:06 +0000 (14:08 +0000)]
Auto merge of #85023 - RalfJung:array-to-raw-elem, r=Mark-Simulacrum

array-to-raw-elem cast: test that Retag covers entire array

Make sure that we `Retag` *before* doing the `ArrayToPointer` cast.

3 years agoimprove diagnosts for GATs
b-naber [Thu, 18 Feb 2021 20:01:44 +0000 (21:01 +0100)]
improve diagnosts for GATs

3 years agoAuto merge of #85109 - RalfJung:remove-const_fn, r=oli-obk
bors [Tue, 11 May 2021 10:25:14 +0000 (10:25 +0000)]
Auto merge of #85109 - RalfJung:remove-const_fn, r=oli-obk

remove const_fn feature gate

Fixes https://github.com/rust-lang/rust/issues/84510
r? `@oli-obk`

3 years agoFix border radius for doc code blocks in rustdoc
Guillaume Gomez [Tue, 11 May 2021 09:16:14 +0000 (11:16 +0200)]
Fix border radius for doc code blocks in rustdoc

3 years agofix clippy test
Ralf Jung [Mon, 10 May 2021 22:40:25 +0000 (00:40 +0200)]
fix clippy test

3 years agoAuto merge of #85100 - HKalbasi:issue-68049-fix, r=Aaron1011
bors [Tue, 11 May 2021 07:44:16 +0000 (07:44 +0000)]
Auto merge of #85100 - HKalbasi:issue-68049-fix, r=Aaron1011

Fix invalid suggestion of changing impl trait signature

Fix #68049

3 years agoAuto merge of #80300 - LeSeulArtichaut:80275-doc-inline, r=Manishearth
bors [Tue, 11 May 2021 05:03:18 +0000 (05:03 +0000)]
Auto merge of #80300 - LeSeulArtichaut:80275-doc-inline, r=Manishearth

Emit errors/warns on some wrong uses of rustdoc attributes

This PR adds a few diagnostics:
- error if conflicting `#[doc(inline)]`/`#[doc(no_inline)]` are found
- introduce the `invalid_doc_attributes` lint (warn-by-default) which triggers:
  - if a crate-level attribute is used on a non-`crate` item
  - if `#[doc(inline)]`/`#[doc(no_inline)]` is used on a non-`use` item

The code could probably be improved but I wanted to get feedback first. Also, some of those changes could be considered breaking changes, so I don't know what the procedure would be? ~~And finally, for the warnings, they are currently hard warnings, maybe it would be better to introduce a lint?~~ (EDIT: introduced the `invalid_doc_attributes` lint)

Closes #80275.
r? `@jyn514`

3 years agoFix CI problems
hamidreza kalbasi [Tue, 11 May 2021 04:20:43 +0000 (08:50 +0430)]
Fix CI problems

3 years agoAuto merge of #85165 - JohnTitor:rollup-ew1ls7x, r=JohnTitor
bors [Tue, 11 May 2021 02:41:38 +0000 (02:41 +0000)]
Auto merge of #85165 - JohnTitor:rollup-ew1ls7x, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #84777 (Apply `--cfg parallel_compiler` when documenting)
 - #84783 (Allow formatting specific subdirectories)
 - #84998 (Show nicer error when an 'unstable fingerprints' error occurs)
 - #85002 (RELEASES.md: Use broken_intra_doc_links as an example, not nightly lint)
 - #85051 (Allow checking miri and RLS with `x.py check src/tools/{miri,rls}`)
 - #85114 (Remove outdated FIXME for download-rustc)
 - #85143 (Document Rc::from)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #85143 - fee1-dead:master, r=Mark-Simulacrum
Yuki Okushi [Tue, 11 May 2021 00:28:09 +0000 (09:28 +0900)]
Rollup merge of #85143 - fee1-dead:master, r=Mark-Simulacrum

Document Rc::from

3 years agoRollup merge of #85114 - jyn514:download-fixme, r=Mark-Simulacrum
Yuki Okushi [Tue, 11 May 2021 00:28:08 +0000 (09:28 +0900)]
Rollup merge of #85114 - jyn514:download-fixme, r=Mark-Simulacrum

Remove outdated FIXME for download-rustc

https://github.com/rust-lang/rust/pull/82739 has been merged.

3 years agoRollup merge of #85051 - jyn514:check-miri, r=Mark-Simulacrum
Yuki Okushi [Tue, 11 May 2021 00:28:07 +0000 (09:28 +0900)]
Rollup merge of #85051 - jyn514:check-miri, r=Mark-Simulacrum

Allow checking miri and RLS with `x.py check src/tools/{miri,rls}`

Helps with https://github.com/rust-lang/rust/issues/80639.

`@Xanewok` would you find this useful for RLS too?

3 years agoRollup merge of #85002 - jyn514:releases, r=Mark-Simulacrum
Yuki Okushi [Tue, 11 May 2021 00:28:06 +0000 (09:28 +0900)]
Rollup merge of #85002 - jyn514:releases, r=Mark-Simulacrum

RELEASES.md: Use broken_intra_doc_links as an example, not nightly lint

`non_autolinks` has since been renamed and also was unstable at the time
this was written.

3 years agoRollup merge of #84998 - Aaron1011:pretty-unstable-fingerprint, r=Mark-Simulacrum
Yuki Okushi [Tue, 11 May 2021 00:28:04 +0000 (09:28 +0900)]
Rollup merge of #84998 - Aaron1011:pretty-unstable-fingerprint, r=Mark-Simulacrum

Show nicer error when an 'unstable fingerprints' error occurs

An example of the error produced by this PR:

```
error: internal compiler error: encountered incremental compilation error with evaluate_obligation(9f2ad55260c30262-c36667639674ad83)
  |
  = help: This is a known issue with the compiler. Run `cargo clean -p syn` or `cargo clean` to allow your project to compile
  = note: Please follow the instructions below to create a bug report with the provided information

thread 'rustc' panicked at 'Found unstable fingerprints for evaluate_obligation(9f2ad55260c30262-c36667639674ad83): Ok(EvaluatedToOk)', /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:595:9
stack backtrace:
   0: rust_begin_unwind
             at /home/aaron/repos/rust/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /home/aaron/repos/rust/library/std/src/panicking.rs:435:5
   2: rustc_query_system::query::plumbing::incremental_verify_ich
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:595:9
   3: rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:557:9
   4: rustc_query_system::query::plumbing::try_execute_query::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:473:21
   5: core::option::Option<T>::map
             at /home/aaron/repos/rust/library/core/src/option.rs:487:29
   6: rustc_query_system::query::plumbing::try_execute_query::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:471:13
   7: stacker::maybe_grow
             at /home/aaron/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9
   8: rustc_data_structures::stack::ensure_sufficient_stack
             at /home/aaron/repos/rust/compiler/rustc_data_structures/src/stack.rs:16:5
   9: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_impl/src/plumbing.rs:169:17
  10: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:50
  11: rustc_middle::ty::context::tls::set_tlv
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1720:9
  12: rustc_middle::ty::context::tls::enter_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:9
  13: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_impl/src/plumbing.rs:168:13
  14: rustc_middle::ty::context::tls::with_related_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1780:13
  15: rustc_middle::ty::context::tls::with_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1764:40
  16: rustc_middle::ty::context::tls::with_context_opt
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1753:22
  17: rustc_middle::ty::context::tls::with_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1764:9
  18: rustc_middle::ty::context::tls::with_related_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1777:9
  19: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query
             at /home/aaron/repos/rust/compiler/rustc_query_impl/src/plumbing.rs:157:9
  20: rustc_query_system::query::plumbing::try_execute_query
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:469:22
  21: rustc_query_system::query::plumbing::get_query_impl
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:674:5
  22: rustc_query_system::query::plumbing::get_query
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:785:9
  23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::evaluate_obligation
             at /home/aaron/repos/rust/compiler/rustc_query_impl/src/plumbing.rs:603:17
  24: rustc_middle::ty::query::TyCtxtAt::evaluate_obligation
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/mod.rs:204:17
  25: rustc_middle::ty::query::<impl rustc_middle::ty::context::TyCtxt>::evaluate_obligation
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/mod.rs:185:17
  26: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
             at /home/aaron/repos/rust/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs:72:9
  27: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
             at /home/aaron/repos/rust/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs:82:15
  28: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::predicate_must_hold_modulo_regions
             at /home/aaron/repos/rust/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs:58:9
  29: rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions
             at /home/aaron/repos/rust/compiler/rustc_trait_selection/src/traits/mod.rs:146:18
  30: rustc_ty_utils::common_traits::is_item_raw::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_ty_utils/src/common_traits.rs:33:9
  31: rustc_infer::infer::InferCtxtBuilder::enter
             at /home/aaron/repos/rust/compiler/rustc_infer/src/infer/mod.rs:582:9
  32: rustc_ty_utils::common_traits::is_item_raw
             at /home/aaron/repos/rust/compiler/rustc_ty_utils/src/common_traits.rs:32:5
  33: rustc_query_system::query::config::QueryVtable<CTX,K,V>::compute
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/config.rs:44:9
  34: rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:544:67
  35: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:77:46
  36: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:50
  37: rustc_middle::ty::context::tls::set_tlv
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1720:9
  38: rustc_middle::ty::context::tls::enter_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:9
  39: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:77:13
  40: rustc_middle::ty::context::tls::with_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1764:40
  41: rustc_middle::ty::context::tls::with_context_opt
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1753:22
  42: rustc_middle::ty::context::tls::with_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1764:9
  43: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:74:9
  44: rustc_query_system::dep_graph::graph::DepGraph<K>::with_ignore
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/dep_graph/graph.rs:167:9
  45: rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:544:22
  46: rustc_query_system::query::plumbing::try_execute_query::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:473:21
  47: core::option::Option<T>::map
             at /home/aaron/repos/rust/library/core/src/option.rs:487:29
  48: rustc_query_system::query::plumbing::try_execute_query::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:471:13
  49: stacker::maybe_grow
             at /home/aaron/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9
  50: rustc_data_structures::stack::ensure_sufficient_stack
             at /home/aaron/repos/rust/compiler/rustc_data_structures/src/stack.rs:16:5
  51: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_impl/src/plumbing.rs:169:17
  52: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:50
  53: rustc_middle::ty::context::tls::set_tlv
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1720:9
  54: rustc_middle::ty::context::tls::enter_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:9
  55: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_impl/src/plumbing.rs:168:13
  56: rustc_middle::ty::context::tls::with_related_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1780:13
  57: rustc_middle::ty::context::tls::with_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1764:40
  58: rustc_middle::ty::context::tls::with_context_opt
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1753:22
  59: rustc_middle::ty::context::tls::with_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1764:9
  60: rustc_middle::ty::context::tls::with_related_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1777:9
  61: <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::start_query
             at /home/aaron/repos/rust/compiler/rustc_query_impl/src/plumbing.rs:157:9
  62: rustc_query_system::query::plumbing::try_execute_query
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:469:22
  63: rustc_query_system::query::plumbing::get_query_impl
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:674:5
  64: rustc_query_system::query::plumbing::get_query
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:785:9
  65: rustc_middle::ty::query::TyCtxtAt::is_unpin_raw
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/mod.rs:204:17
  66: rustc_middle::ty::util::<impl rustc_middle::ty::TyS>::is_unpin
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/util.rs:727:38
  67: rustc_middle::ty::layout::<impl rustc_target::abi::TyAndLayoutMethods<C> for &rustc_middle::ty::TyS>::pointee_info_at
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/layout.rs:2341:32
  68: rustc_target::abi::TyAndLayout<Ty>::pointee_info_at
             at /home/aaron/repos/rust/compiler/rustc_target/src/abi/mod.rs:1164:9
  69: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/layout.rs:2781:36
  70: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/layout.rs:2840:17
  71: rustc_target::abi::call::ArgAbi<Ty>::new
             at /home/aaron/repos/rust/compiler/rustc_target/src/abi/call/mod.rs:457:53
  72: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/layout.rs:2838:27
  73: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/layout.rs:2870:32
  74: core::iter::adapters::map::map_fold::{{closure}}
             at /home/aaron/repos/rust/library/core/src/iter/adapters/map.rs:82:28
  75: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold::enumerate::{{closure}}
             at /home/aaron/repos/rust/library/core/src/iter/adapters/enumerate.rs:104:27
  76: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /home/aaron/repos/rust/library/core/src/ops/function.rs:269:13
  77: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /home/aaron/repos/rust/library/core/src/ops/function.rs:269:13
  78: core::iter::adapters::map::map_fold::{{closure}}
             at /home/aaron/repos/rust/library/core/src/iter/adapters/map.rs:82:21
  79: core::iter::traits::iterator::Iterator::fold
             at /home/aaron/repos/rust/library/core/src/iter/traits/iterator.rs:2146:21
  80: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/aaron/repos/rust/library/core/src/iter/adapters/map.rs:122:9
  81: <core::iter::adapters::cloned::Cloned<I> as core::iter::traits::iterator::Iterator>::fold
             at /home/aaron/repos/rust/library/core/src/iter/adapters/cloned.rs:58:9
  82: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold
             at /home/aaron/repos/rust/library/core/src/iter/adapters/chain.rs:119:19
  83: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold
             at /home/aaron/repos/rust/library/core/src/iter/adapters/chain.rs:119:19
  84: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold
             at /home/aaron/repos/rust/library/core/src/iter/adapters/enumerate.rs:110:9
  85: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/aaron/repos/rust/library/core/src/iter/adapters/map.rs:122:9
  86: core::iter::traits::iterator::Iterator::for_each
             at /home/aaron/repos/rust/library/core/src/iter/traits/iterator.rs:776:9
  87: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
             at /home/aaron/repos/rust/library/alloc/src/vec/spec_extend.rs:40:17
  88: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
             at /home/aaron/repos/rust/library/alloc/src/vec/spec_from_iter_nested.rs:56:9
  89: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
             at /home/aaron/repos/rust/library/alloc/src/vec/spec_from_iter.rs:36:9
  90: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /home/aaron/repos/rust/library/alloc/src/vec/mod.rs:2448:9
  91: core::iter::traits::iterator::Iterator::collect
             at /home/aaron/repos/rust/library/core/src/iter/traits/iterator.rs:1788:9
  92: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/layout.rs:2864:19
  93: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::of_instance
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/layout.rs:2670:9
  94: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn
             at /home/aaron/repos/rust/compiler/rustc_codegen_llvm/src/mono_item.rs:57:22
  95: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::predefine
             at /home/aaron/repos/rust/compiler/rustc_codegen_ssa/src/mono_item.rs:76:17
  96: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
             at /home/aaron/repos/rust/compiler/rustc_codegen_llvm/src/base.rs:122:17
  97: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/dep_graph/graph.rs:235:62
  98: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:77:46
  99: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:50
 100: rustc_middle::ty::context::tls::set_tlv
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1720:9
 101: rustc_middle::ty::context::tls::enter_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:9
 102: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:77:13
 103: rustc_middle::ty::context::tls::with_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1764:40
 104: rustc_middle::ty::context::tls::with_context_opt
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1753:22
 105: rustc_middle::ty::context::tls::with_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1764:9
 106: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:74:9
 107: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/dep_graph/graph.rs:235:26
 108: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/dep_graph/graph.rs:205:9
 109: rustc_codegen_llvm::base::compile_codegen_unit
             at /home/aaron/repos/rust/compiler/rustc_codegen_llvm/src/base.rs:103:9
 110: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::compile_codegen_unit
             at /home/aaron/repos/rust/compiler/rustc_codegen_llvm/src/lib.rs:109:9
 111: rustc_codegen_ssa::base::codegen_crate
             at /home/aaron/repos/rust/compiler/rustc_codegen_ssa/src/base.rs:655:38
 112: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
             at /home/aaron/repos/rust/compiler/rustc_codegen_llvm/src/lib.rs:270:18
 113: rustc_interface::passes::start_codegen::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/passes.rs:1021:9
 114: rustc_data_structures::profiling::VerboseTimingGuard::run
             at /home/aaron/repos/rust/compiler/rustc_data_structures/src/profiling.rs:573:9
 115: rustc_session::utils::<impl rustc_session::session::Session>::time
             at /home/aaron/repos/rust/compiler/rustc_session/src/utils.rs:16:9
 116: rustc_interface::passes::start_codegen
             at /home/aaron/repos/rust/compiler/rustc_interface/src/passes.rs:1020:19
 117: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:296:20
 118: rustc_interface::passes::QueryContext::enter::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/passes.rs:755:42
 119: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:50
 120: rustc_middle::ty::context::tls::set_tlv
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1720:9
 121: rustc_middle::ty::context::tls::enter_context
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1736:9
 122: rustc_interface::passes::QueryContext::enter
             at /home/aaron/repos/rust/compiler/rustc_interface/src/passes.rs:755:9
 123: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:287:13
 124: rustc_interface::queries::Query<T>::compute
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:40:28
 125: rustc_interface::queries::Queries::ongoing_codegen
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:285:9
 126: rustc_driver::run_compiler::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_driver/src/lib.rs:442:13
 127: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:428:19
 128: rustc_driver::run_compiler::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_driver/src/lib.rs:337:22
 129: rustc_interface::interface::create_compiler_and_run::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/interface.rs:208:13
 130: rustc_span::with_source_map
             at /home/aaron/repos/rust/compiler/rustc_span/src/lib.rs:788:5
 131: rustc_interface::interface::create_compiler_and_run
             at /home/aaron/repos/rust/compiler/rustc_interface/src/interface.rs:202:5
 132: rustc_interface::interface::run_compiler::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/interface.rs:224:12
 133: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/util.rs:155:13
 134: scoped_tls::ScopedKey<T>::set
             at /home/aaron/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
 135: rustc_span::with_session_globals
             at /home/aaron/repos/rust/compiler/rustc_span/src/lib.rs:105:5
 136: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/util.rs:153:9
 137: rustc_interface::util::scoped_thread::{{closure}}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/util.rs:128:24
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `quote::Tokens: std::marker::Unpin`
#1 [is_unpin_raw] computing whether `quote::Tokens` is `Unpin`
end of query stack
error: aborting due to previous error

error: could not compile `syn`

To learn more, run the command again with --verbose.
```

I've left in the panic and ICE following the pretty error, so that we still have all of the debug information available in a bug report.

This message can be reproduced by cloning the repository `https://github.com/Aaron1011/syn-crash`, and running the following shell script (with a `rustup override` set in the directory):

```
set -xe
cargo clean -p syn
cargo clean --release -p syn

git checkout minimize
cargo build --release -j 1

git checkout minimize-change
cargo build --release -j 1
```

r? ``@Mark-Simulacrum``

3 years agoRollup merge of #84783 - jyn514:fmt-one, r=Mark-Simulacrum
Yuki Okushi [Tue, 11 May 2021 00:28:04 +0000 (09:28 +0900)]
Rollup merge of #84783 - jyn514:fmt-one, r=Mark-Simulacrum

Allow formatting specific subdirectories

Fixes https://github.com/rust-lang/rust/issues/71094.

3 years agoRollup merge of #84777 - jyn514:rustdoc-parallel, r=Mark-Simulacrum
Yuki Okushi [Tue, 11 May 2021 00:28:03 +0000 (09:28 +0900)]
Rollup merge of #84777 - jyn514:rustdoc-parallel, r=Mark-Simulacrum

Apply `--cfg parallel_compiler` when documenting

This also reverts commit 9823c2cc700fea541bf2670fcee93af662b63022 working around the bug.

Fixes https://github.com/rust-lang/rust/issues/82301.

3 years agoAuto merge of #85012 - FabianWolff:struct-rec, r=davidtwco
bors [Tue, 11 May 2021 00:00:53 +0000 (00:00 +0000)]
Auto merge of #85012 - FabianWolff:struct-rec, r=davidtwco

Fix stack overflow when checking for structural recursion

This pull request aims to fix #74224 and fix #84611. The current logic for detecting ADTs with structural recursion is flawed because it only looks at the root type, and then for exact matches. What I mean by this is that for examples such as:
```rust
struct A<T> {
    x: T,
    y: A<A<T>>,
}

struct B {
    z: A<usize>
}

fn main() {}
```
When checking `A`, the compiler correctly determines that it has an infinite size (because the "root" type is `A`, and `A` occurs, albeit with different type arguments, as a nested type in `A`).

However, when checking `B`, it also recurses into `A`, but now `B` is the root type, and it only checks for _exact_ matches of `A`, but since `A` never precisely contains itself (only `A<A<T>>`, `A<A<A<T>>>`, etc.), an endless recursion ensues until the stack overflows.

In this PR, I have attempted to fix this behavior by implementing a two-phase checking: When checking `B`, my code first checks `A` _separately_ and stops if `A` already turns out to be infinite. If not (such as for `Option<T>`), the second phase checks whether the root type (`B`) is ever nested inside itself, e.g.:
```rust
struct Foo { x: Option<Option<Foo>> }
```

Special care needs to be taken for mutually recursive types, e.g.:
```rust
struct A<T> {
    z: T,
    x: B<T>,
}

struct B<T> {
    y: A<T>
}
```
Here, both `A` and `B` both _are_ `SelfRecursive` and _contain_ a recursive type. The current behavior, which I have maintained, is to treat both `A` and `B` as `SelfRecursive`, and accordingly report errors for both.

3 years agoFix typo in variable name
LingMan [Mon, 10 May 2021 23:17:08 +0000 (01:17 +0200)]
Fix typo in variable name

All other sibling functions call this variable "slot", so "slote" was most likely a typo.

3 years agoSplit span_to_string into span_to_diagnostic/embeddable_string
Andy Wang [Mon, 3 May 2021 00:14:25 +0000 (01:14 +0100)]
Split span_to_string into span_to_diagnostic/embeddable_string

3 years agoRemove an invalid `#[doc(inline)]`
LeSeulArtichaut [Mon, 10 May 2021 22:03:44 +0000 (00:03 +0200)]
Remove an invalid `#[doc(inline)]`

3 years agoShow nicer error when an 'unstable fingerprints' error occurs
Aaron Hill [Thu, 6 May 2021 17:44:17 +0000 (13:44 -0400)]
Show nicer error when an 'unstable fingerprints' error occurs

3 years agoAuto merge of #84677 - CDirkx:pal, r=Mark-Simulacrum
bors [Mon, 10 May 2021 21:32:13 +0000 (21:32 +0000)]
Auto merge of #84677 - CDirkx:pal, r=Mark-Simulacrum

Fix `tidy` platform-specific code check

I noticed new platform-specific code was introduced outside of `std::sys` ([example](https://github.com/rust-lang/rust/blob/master/library/std/src/thread/available_concurrency.rs)), which should have been checked against by `tidy`. Apparently there are 2 problems with the current check implementation:

- It ignores everything after encountering "mod tests", which is often at the very top of a file.
- There was a bug where when checking the byte immediately before a found string, the first byte of the file was checked instead.

I fixed the bug and made excluding tests a bit more robust by instead adding the following rules:
- Files with a path containing either `tests` or `benches` are excluded.
- A `cfg(...)` containing `test` is excluded.

(Tests are excluded because almost all tests have something like `#[cfg(not(target_os = "emscripten"))]` somewhere.)

The fixed check found some more cases of platform-specific code; for now I have explicitly excluded them and added a FIXME stating that the platform-specific code must be moved to `sys`.

3 years agoAuto merge of #85156 - GuillaumeGomez:rollup-8u4h34g, r=GuillaumeGomez
bors [Mon, 10 May 2021 18:28:24 +0000 (18:28 +0000)]
Auto merge of #85156 - GuillaumeGomez:rollup-8u4h34g, r=GuillaumeGomez

Rollup of 4 pull requests

Successful merges:

 - #84465 (rustdoc: Implement `is_primitive` in terms of `primitive_type()`)
 - #85118 (Use an SVG image for clipboard instead of unicode character)
 - #85148 (Fix source code line number display and make it clickable again)
 - #85152 (Adjust target search algorithm for rustlib path)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #85152 - nagisa:target-search-rustlib, r=Mark-Simulacrum
Guillaume Gomez [Mon, 10 May 2021 18:05:27 +0000 (20:05 +0200)]
Rollup merge of #85152 - nagisa:target-search-rustlib, r=Mark-Simulacrum

Adjust target search algorithm for rustlib path

With this the concerns expressed in #83800 should be addressed.

r? `@Mark-Simulacrum`

3 years agoRollup merge of #85148 - GuillaumeGomez:source-code-line-number, r=jsha
Guillaume Gomez [Mon, 10 May 2021 18:05:26 +0000 (20:05 +0200)]
Rollup merge of #85148 - GuillaumeGomez:source-code-line-number, r=jsha

Fix source code line number display and make it clickable again

Fixes https://github.com/rust-lang/rust/issues/85119.

I used the same logic we're using for other codeblocks: putting the line number `<span>`s into the `example-wrap` directly and then add `display: inline-flex` on `example-wrap`.

r? `@jsha`

3 years agoRollup merge of #85118 - GuillaumeGomez:clipboard-svg, r=Nemo157
Guillaume Gomez [Mon, 10 May 2021 18:05:25 +0000 (20:05 +0200)]
Rollup merge of #85118 - GuillaumeGomez:clipboard-svg, r=Nemo157

Use an SVG image for clipboard instead of unicode character

Linked to https://github.com/rust-lang/docs.rs/pull/1394.

cc `@jsha`
r? `@Nemo157`

3 years agoRollup merge of #84465 - jyn514:primitive, r=GuillaumeGomez
Guillaume Gomez [Mon, 10 May 2021 18:05:24 +0000 (20:05 +0200)]
Rollup merge of #84465 - jyn514:primitive, r=GuillaumeGomez

rustdoc: Implement `is_primitive` in terms of `primitive_type()`

Previously, they disagreed about what types were primitives.

r? `@GuillaumeGomez`

3 years agoAdd documentation
LeSeulArtichaut [Mon, 10 May 2021 16:38:09 +0000 (18:38 +0200)]
Add documentation

3 years agoAdjust target search algorithm for rustlib path
Simonas Kazlauskas [Mon, 10 May 2021 16:15:19 +0000 (19:15 +0300)]
Adjust target search algorithm for rustlib path

With this the concerns expressed in #83800 should be addressed.

3 years agoImplement changes suggested by tmiasko and davidtwco
Fabian Wolff [Mon, 10 May 2021 15:47:50 +0000 (17:47 +0200)]
Implement changes suggested by tmiasko and davidtwco

3 years agoAuto merge of #85150 - Dylan-DPC:rollup-q26gbx3, r=Dylan-DPC
bors [Mon, 10 May 2021 15:08:08 +0000 (15:08 +0000)]
Auto merge of #85150 - Dylan-DPC:rollup-q26gbx3, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #85050 (Fix suggestions for missing return type lifetime specifiers)
 - #85075 (Improve "panic message is not a string literal" warning)
 - #85096 (Make unchecked_{add,sub,mul} inherent methods unstably const)
 - #85112 (ensure failing promoteds in const/static bodies are handled correctly)
 - #85146 (Provide io::Seek::rewind)
 - #85147 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoUse an SVG image for clipboard instead of unicode character
Guillaume Gomez [Sun, 9 May 2021 18:41:24 +0000 (20:41 +0200)]
Use an SVG image for clipboard instead of unicode character

3 years agoRollup merge of #85147 - lnicola:rust-analyzer-2021-05-10, r=jonas-schievink
Dylan DPC [Mon, 10 May 2021 14:15:06 +0000 (16:15 +0200)]
Rollup merge of #85147 - lnicola:rust-analyzer-2021-05-10, r=jonas-schievink

:arrow_up: rust-analyzer

3 years agoRollup merge of #85146 - ijackson:seek-rewind, r=m-ou-se
Dylan DPC [Mon, 10 May 2021 14:15:05 +0000 (16:15 +0200)]
Rollup merge of #85146 - ijackson:seek-rewind, r=m-ou-se

Provide io::Seek::rewind

Using `Seek::seek` is slightly clumsy because of the need to write (or import) `std::io::SeekFrom` to get at `SeekStart`.  C already has `rewind` (although with broken error handling); we should have it too.

I'm motivated to do this because I've just found myself copy-pasting my 5-line extension trait between projects.

That the example ends up using `OpenOptions` makes this look like a niche use case, but it is very common to rewind temporary files.  `tempfile` isn't available for use in this example or it would have looked shorter and more natural.

If this gets a positive reception I will open a tracking issue and update the feature gate.

3 years agoRollup merge of #85112 - RalfJung:promoted-errors, r=oli-obk
Dylan DPC [Mon, 10 May 2021 14:15:03 +0000 (16:15 +0200)]
Rollup merge of #85112 - RalfJung:promoted-errors, r=oli-obk

ensure failing promoteds in const/static bodies are handled correctly

`const`/`static` bodies are the one case where we still promote code that might fail to evaluate. Ensure that this is handled correctly; in particular, it must not fail compilation.

`src/test/ui/consts/const-eval/erroneous-const.rs` ensures that when a non-promoted fails to evaluate, we *do* show an error.

r? `@oli-obk`

3 years agoRollup merge of #85096 - clarfonthey:const_unchecked, r=oli-obk
Dylan DPC [Mon, 10 May 2021 14:15:02 +0000 (16:15 +0200)]
Rollup merge of #85096 - clarfonthey:const_unchecked, r=oli-obk

Make unchecked_{add,sub,mul} inherent methods unstably const

The intrinsics are marked as being stably const (even though they're not stable by nature of being intrinsics), but the currently-unstable inherent versions are not marked as const. This fixes this inconsistency. Split out of #85017,

r? `@oli-obk`

3 years agoRollup merge of #85075 - ptrojahn:panic_warning, r=jackh726
Dylan DPC [Mon, 10 May 2021 14:15:01 +0000 (16:15 +0200)]
Rollup merge of #85075 - ptrojahn:panic_warning, r=jackh726

Improve "panic message is not a string literal" warning

This warning always referenced panic! even in case of an
assert. Related to #84656

3 years agoRollup merge of #85050 - FabianWolff:issue-84592, r=jackh726
Dylan DPC [Mon, 10 May 2021 14:15:00 +0000 (16:15 +0200)]
Rollup merge of #85050 - FabianWolff:issue-84592, r=jackh726

Fix suggestions for missing return type lifetime specifiers

This pull request aims to fix #84592. The issue is that the current code seems to assume that there is only a single relevant span pointing to the missing lifetime, and only looks at the first one:
https://github.com/rust-lang/rust/blob/e5f83d24aee866a14753a7cedbb4e301dfe5bef5/compiler/rustc_resolve/src/late/lifetimes.rs#L2959

This is incorrect, though, and leads to incorrect error messages and invalid suggestions. For instance, the example from #84592:
```rust
struct TwoLifetimes<'x, 'y> {
    x: &'x (),
    y: &'y (),
}

fn two_lifetimes_needed(a: &(), b: &()) -> TwoLifetimes<'_, '_> {
    TwoLifetimes { x: &(), y: &() }
}
```
currently leads to:
```
error[E0106]: missing lifetime specifiers
 --> src/main.rs:6:57
  |
6 | fn two_lifetimes_needed(a: &(), b: &()) -> TwoLifetimes<'_, '_> {
  |                            ---     ---                  ^^ expected 2 lifetime parameters
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b`
help: consider introducing a named lifetime parameter
  |
6 | fn two_lifetimes_needed<'a>(a: &'a (), b: &'a ()) -> TwoLifetimes<'_<'a, 'a>, '_> {
  |                        ^^^^    ^^^^^^     ^^^^^^                  ^^^^^^^^^^
```
There are two problems:
- The error message is wrong. There is only _one_ lifetime parameter expected at the location pointed to by the error message (and another one at a separate location).
- The suggestion is incorrect and will not lead to correct code.

With the changes in this PR, I get the following output:
```
error[E0106]: missing lifetime specifiers
 --> p.rs:6:57
  |
6 | fn two_lifetimes_needed(a: &(), b: &()) -> TwoLifetimes<'_, '_> {
  |                            ---     ---                  ^^  ^^ expected named lifetime parameter
  |                                                         |
  |                                                         expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b`
help: consider introducing a named lifetime parameter
  |
6 | fn two_lifetimes_needed<'a>(a: &'a (), b: &'a ()) -> TwoLifetimes<'a, 'a> {
  |                        ^^^^    ^^^^^^     ^^^^^^                  ^^  ^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0106`.
```
Mainly, I changed `add_missing_lifetime_specifiers_label()` to receive a _vector_ of spans (and counts) instead of just one, and adjusted its body accordingly.

3 years agoMore minor fixes suggested by @jackh726
Fabian Wolff [Mon, 10 May 2021 12:59:54 +0000 (14:59 +0200)]
More minor fixes suggested by @jackh726

3 years agoio::Seek::rewind: Set tracking issue
Ian Jackson [Mon, 10 May 2021 12:55:13 +0000 (13:55 +0100)]
io::Seek::rewind: Set tracking issue

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoFix typo in doc
Ian Jackson [Mon, 10 May 2021 12:50:56 +0000 (13:50 +0100)]
Fix typo in doc

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
3 years agoupdate perf version used for PGO
Ralf Jung [Mon, 10 May 2021 12:39:28 +0000 (14:39 +0200)]
update perf version used for PGO

3 years agoAuto merge of #85079 - petrochenkov:sessclean, r=davidtwco
bors [Mon, 10 May 2021 12:26:46 +0000 (12:26 +0000)]
Auto merge of #85079 - petrochenkov:sessclean, r=davidtwco

rustc_session: Move more option building code from the `options!` macro

The moved code doesn't need to be generated by a macro, it can use a regular (generic) function and type aliases instead.

(The refactoring is salvaged from a branch with different now abandoned work.)

3 years agoAdd test for source code clickable line number
Guillaume Gomez [Mon, 10 May 2021 12:12:00 +0000 (14:12 +0200)]
Add test for source code clickable line number

3 years agoFix line number not being clickable on source pages
Guillaume Gomez [Mon, 10 May 2021 09:39:53 +0000 (11:39 +0200)]
Fix line number not being clickable on source pages

3 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 10 May 2021 12:11:01 +0000 (15:11 +0300)]
:arrow_up: rust-analyzer

3 years agoio::Seek: Provide rewind()
Ian Jackson [Mon, 10 May 2021 11:58:03 +0000 (12:58 +0100)]
io::Seek: Provide rewind()

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoio::Seek: Mention that seeking can fail due to buffer flush fail
Ian Jackson [Mon, 10 May 2021 11:56:35 +0000 (12:56 +0100)]
io::Seek: Mention that seeking can fail due to buffer flush fail

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agorustc_session: Use `Iterator::find` instead of manual search
Vadim Petrochenkov [Mon, 10 May 2021 11:52:31 +0000 (14:52 +0300)]
rustc_session: Use `Iterator::find` instead of manual search

3 years agorustc_session: Move more option building code from the `options!` macro
Vadim Petrochenkov [Fri, 7 May 2021 12:18:19 +0000 (15:18 +0300)]
rustc_session: Move more option building code from the `options!` macro

3 years agochange k to key and v to v in std::env mod
shirshak55 [Mon, 10 May 2021 11:31:09 +0000 (19:31 +0800)]
change k to key and v to v in std::env mod