143472 Commits

Author SHA1 Message Date
Yuki Okushi
5fc898782c
Rollup merge of - 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.
2021-05-11 09:28:03 +09:00
bors
d4d129d566 Auto merge of - FabianWolff:struct-rec, r=davidtwco
Fix stack overflow when checking for structural recursion

This pull request aims to fix  and fix . 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.
2021-05-11 00:00:53 +00:00
LingMan
41779f60ec
Fix typo in variable name
All other sibling functions call this variable "slot", so "slote" was most likely a typo.
2021-05-11 01:17:08 +02:00
Andy Wang
37dbe868c9
Split span_to_string into span_to_diagnostic/embeddable_string 2021-05-11 00:04:12 +01:00
LeSeulArtichaut
804ab9f78e Remove an invalid #[doc(inline)] 2021-05-11 00:03:44 +02:00
Aaron Hill
a4c0793551 Show nicer error when an 'unstable fingerprints' error occurs 2021-05-10 17:43:51 -04:00
bors
79e50bf779 Auto merge of - 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`.
2021-05-10 21:32:13 +00:00
bors
6fd7a6dc0f Auto merge of - GuillaumeGomez:rollup-8u4h34g, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

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

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-10 18:28:24 +00:00
Guillaume Gomez
6ec1de7d4f
Rollup merge of - nagisa:target-search-rustlib, r=Mark-Simulacrum
Adjust target search algorithm for rustlib path

With this the concerns expressed in  should be addressed.

r? `@Mark-Simulacrum`
2021-05-10 20:05:27 +02:00
Guillaume Gomez
3962541dcb
Rollup merge of - 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`
2021-05-10 20:05:26 +02:00
Guillaume Gomez
c7e7de4021
Rollup merge of - 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`
2021-05-10 20:05:25 +02:00
Guillaume Gomez
205a0d3a27
Rollup merge of - jyn514:primitive, r=GuillaumeGomez
rustdoc: Implement `is_primitive` in terms of `primitive_type()`

Previously, they disagreed about what types were primitives.

r? `@GuillaumeGomez`
2021-05-10 20:05:24 +02:00
LeSeulArtichaut
6e8d0dbe11 Add documentation 2021-05-10 18:38:09 +02:00
Simonas Kazlauskas
b7c5599d22 Adjust target search algorithm for rustlib path
With this the concerns expressed in  should be addressed.
2021-05-10 19:15:19 +03:00
Fabian Wolff
98728c2b35 Implement changes suggested by tmiasko and davidtwco 2021-05-10 17:47:50 +02:00
bors
266f452118 Auto merge of - Dylan-DPC:rollup-q26gbx3, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

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

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-10 15:08:08 +00:00
Guillaume Gomez
7450f70ae2 Use an SVG image for clipboard instead of unicode character 2021-05-10 16:26:16 +02:00
Dylan DPC
e76340191e
Rollup merge of - lnicola:rust-analyzer-2021-05-10, r=jonas-schievink
⬆️ rust-analyzer
2021-05-10 16:15:06 +02:00
Dylan DPC
c5e612ce6b
Rollup merge of - 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.
2021-05-10 16:15:05 +02:00
Dylan DPC
ae8a438034
Rollup merge of - 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`
2021-05-10 16:15:03 +02:00
Dylan DPC
7107c89970
Rollup merge of - 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 ,

r? `@oli-obk`
2021-05-10 16:15:02 +02:00
Dylan DPC
37c603864e
Rollup merge of - 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 
2021-05-10 16:15:01 +02:00
Dylan DPC
0740015d59
Rollup merge of - FabianWolff:issue-84592, r=jackh726
Fix suggestions for missing return type lifetime specifiers

This pull request aims to fix . 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:
e5f83d24ae/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 :
```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.
2021-05-10 16:15:00 +02:00
Fabian Wolff
2448c7698e More minor fixes suggested by @jackh726 2021-05-10 15:02:15 +02:00
Ian Jackson
7ae852e349 io::Seek: Set tracking issue
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 13:55:31 +01:00
Ian Jackson
3113b6bd69
Fix typo in doc
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-10 13:50:56 +01:00
Ralf Jung
1f17fc23b6 update perf version used for PGO 2021-05-10 14:39:28 +02:00
bors
544d124b81 Auto merge of - 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.)
2021-05-10 12:26:46 +00:00
Guillaume Gomez
4e3fb6858a Add test for source code clickable line number 2021-05-10 14:12:00 +02:00
Guillaume Gomez
09150f8193 Fix line number not being clickable on source pages 2021-05-10 14:11:42 +02:00
Laurențiu Nicola
debf987421 ⬆️ rust-analyzer 2021-05-10 15:11:01 +03:00
Ian Jackson
c3ca148ac0 io::Seek: Provide rewind()
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 13:03:49 +01:00
Ian Jackson
74e0e45f3c io::Seek: Mention that seeking can fail due to buffer flush fail
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 12:57:19 +01:00
Vadim Petrochenkov
273e0a2a05 rustc_session: Use Iterator::find instead of manual search 2021-05-10 14:52:31 +03:00
Vadim Petrochenkov
9d18d4df0e rustc_session: Move more option building code from the options! macro 2021-05-10 14:41:45 +03:00
shirshak55
0778e8dcb8 change k to key and v to v in std::env mod 2021-05-10 19:31:09 +08:00
Deadbeef
5068cbc901
Document Rc::from 2021-05-10 18:46:13 +08:00
bors
1b30245ea1 Auto merge of - camsteffen:duplicate-lint, r=davidtwco
Fix duplicate unknown lint errors

Fixes 
2021-05-10 09:45:28 +00:00
bjorn3
537e814d9c Add link to historic note 2021-05-10 10:49:45 +02:00
Guillaume Gomez
08519959c7 Update documentation for SharedContext::maybe_collapsed_doc_value 2021-05-10 10:49:44 +02:00
bjorn3
487427fbe6 Better error messages 2021-05-10 09:49:42 +02:00
bjorn3
b65a92fdd8 Remove wasmparser 2021-05-10 09:46:02 +02:00
bors
2fb1dee14b Auto merge of - hi-rustin:rustin-patch-typo, r=jonas-schievink
Fix typo
2021-05-10 07:15:23 +00:00
bors
00f2bf40d6 Auto merge of - GuillaumeGomez:end-toggle-migration, r=jsha
Migrate top doc and non-exhaustive toggles to details tag

Fixes .

r? `@jsha`
2021-05-10 04:05:55 +00:00
hamidreza kalbasi
8f5585ac00 remove big match 2021-05-10 05:53:42 +04:30
bors
d29289c509 Auto merge of - crlf0710:codegen_nonlocal_main_wrapper, r=nagisa
Add primary marker on codegen unit and generate main wrapper on primary codegen.

This is the codegen part of changes extracted from .

This add a marker called `primary` on each codegen units, where exactly one codegen unit will be `primary = true` at a time. This specific codegen unit will take charge of generating `main` wrapper when `main` is imported from a foreign crate after the implementation of RFC 1260.

cc 

I'm not sure who should i ask for review for codegen changes, so feel free to reassign.
r? `@nagisa`
2021-05-10 00:42:31 +00:00
hamidreza kalbasi
48f5f01e8b move logic to a function 2021-05-10 03:31:31 +04:30
Guillaume Gomez
3837c1ce33 Update rustdoc test 2021-05-10 00:09:57 +02:00
Guillaume Gomez
4edcf61479 End toggle migration 2021-05-10 00:09:57 +02:00
bors
c55c26cb36 Auto merge of - xobs:impl-16351-nightly, r=nagisa
Add default search path to `Target::search()`

The function `Target::search()` accepts a target triple and returns a `Target` struct defining the requested target.

There is a `// FIXME 16351: add a sane default search path?` comment that indicates it is desirable to include some sort of default. This was raised in https://github.com/rust-lang/rust/issues/16351 which was closed without any resolution.

https://github.com/rust-lang/rust/pull/31117 was proposed, however that has platform-specific logic that is unsuitable for systems without `/etc/`.

This patch implements the suggestion raised in https://github.com/rust-lang/rust/issues/16351#issuecomment-180878193 where a `target.json` file may be placed in `$(rustc --print sysroot)/lib/rustlib/<target-triple>/target.json`. This allows shipping a toolchain distribution as a single file that gets extracted to the sysroot.
2021-05-09 22:01:26 +00:00