Commit graph

148588 commits

Author SHA1 Message Date
the8472
7cb4e5180f from review: more robust test
This also checks the contents and not only the capacity in case IntoIter's clone implementation is changed to add capacity at the end. Extra capacity at the beginning would be needed to make InPlaceIterable work.

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
2021-05-19 01:41:12 +02:00
The8472
a44a059c3b add regression test 2021-05-19 01:41:12 +02:00
The8472
60a900ee10 remove InPlaceIterable marker from Peekable due to unsoundness
The unsoundness is not in Peekable per se, it rather is due to the
interaction between Peekable being able to hold an extra item
and vec::IntoIter's clone implementation shortening the allocation.

An alternative solution would be to change IntoIter's clone implementation
to keep enough spare capacity available.
2021-05-19 01:41:09 +02:00
bors
4e3e6db011 Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnr
Implement the new desugaring from `try_trait_v2`

~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix.

`try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277

Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them.  (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits.

r? `@ghost`

~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-18 20:50:01 +00:00
Scott McMurray
e2edee4da0 No matter how trivial the change, tidy always finds a way to complain... 2021-05-18 11:48:00 -07:00
scottmcm
6f7dea74d7
Mention the issue number for the new mir-opt in the FIXMEs
Thanks for the suggestions, lcnr!

Co-authored-by: lcnr <rust@lcnr.de>
2021-05-18 18:29:34 +00:00
bors
491cf5561e Auto merge of #85443 - RalfJung:rollup-d9gd64t, r=RalfJung
Rollup of 7 pull requests

Successful merges:

 - #84462 (rustdoc: use focus for search navigation)
 - #85251 (Make `const_generics_defaults` not an incomplete feature)
 - #85404 (Backport 1.52.1 release notes)
 - #85407 (Improve display for "copy-path" button, making it more discreet)
 - #85423 (Don't require cmake on Windows when LLVM isn't being built)
 - #85428 (Add x.py pre-setup instructions)
 - #85442 (fix typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-18 18:04:47 +00:00
Ralf Jung
7389843115
Rollup merge of #85442 - imjorge:patch-1, r=jonas-schievink
fix typo
2021-05-18 19:35:48 +02:00
Ralf Jung
b86e8f2058
Rollup merge of #85428 - leebradley:add-xpy-presetup-instructions, r=Mark-Simulacrum
Add x.py pre-setup instructions

This change adds pre-setup instructions that outline how x.py requires
python to be setup and how to work around the problem of x.py failing to
locate python, especially now that Ubuntu 20.04's dropped default python
command is causing people to encounter this issue regularly.

See also: #71818
2021-05-18 19:35:47 +02:00
Ralf Jung
aef6848cba
Rollup merge of #85423 - jyn514:cmake, r=Mark-Simulacrum
Don't require cmake on Windows when LLVM isn't being built

Previously, setting `download-ci-llvm = true` when cmake wasn't
installed would give the following error:

```
failed to execute command: "cmake" "--help"
error: The system cannot find the file specified. (os error 2)
```
2021-05-18 19:35:46 +02:00
Ralf Jung
6e05a71bf7
Rollup merge of #85407 - GuillaumeGomez:copy-path-display-improvement, r=jsha
Improve display for "copy-path" button, making it more discreet

As suggested by `@Nemo157` [here](https://github.com/rust-lang/rust/pull/85118#issuecomment-838887670):

![Screenshot from 2021-05-18 11-18-49](https://user-images.githubusercontent.com/3050060/118626882-899ddb00-b7cb-11eb-84c5-ef68dee5e351.png)
![Screenshot from 2021-05-18 11-15-06](https://user-images.githubusercontent.com/3050060/118626880-899ddb00-b7cb-11eb-95c1-2f3bacd22374.png)
![Screenshot from 2021-05-18 11-18-54](https://user-images.githubusercontent.com/3050060/118626885-8a367180-b7cb-11eb-870c-7acdf4259bef.png)
![Screenshot from 2021-05-18 11-15-00](https://user-images.githubusercontent.com/3050060/118626877-89054480-b7cb-11eb-9efc-9a0f153964ce.png)
![Screenshot from 2021-05-18 11-18-58](https://user-images.githubusercontent.com/3050060/118626888-8a367180-b7cb-11eb-91bb-47867cd0f2cc.png)
![Screenshot from 2021-05-18 11-19-00](https://user-images.githubusercontent.com/3050060/118626891-8acf0800-b7cb-11eb-9e3d-d2937b361524.png)

r? `@jsha`
2021-05-18 19:35:45 +02:00
Ralf Jung
27bc2b39c7
Rollup merge of #85404 - pietroalbini:relnotes-1.52.1, r=Mark-Simulacrum
Backport 1.52.1 release notes

This PR backports the 1.52.1 release notes to master, fixing https://github.com/rust-lang/rust/issues/85235.

r? `@Mark-Simulacrum`
`@rustbot` modify-labels: beta-accepted beta-nominated T-release
2021-05-18 19:35:44 +02:00
Ralf Jung
aa10380f3b
Rollup merge of #85251 - BoxyUwU:constparamdefaultsany%, r=lcnr
Make `const_generics_defaults` not an incomplete feature

r? `@lcnr`
2021-05-18 19:35:40 +02:00
Ralf Jung
c9b6bb9279
Rollup merge of #84462 - jsha:focus-search-results2, r=GuillaumeGomez
rustdoc: use focus for search navigation

Rather than keeping track of highlighted element inside the JS, take advantage of `.focus()` and the :focus CSS pseudo-class.

This required wrapping each row of results in one big `<a>` tag (because anchors can be focused, but table rows cannot). That in turn required moving from a table layout to a div layout with float.

This makes it so Ctrl+Enter opens links in new tabs, and using the arrow keys to navigate off the bottom of the page scrolls the rest of the page into view. It also simplifies the keyboard event handling. It eliminates the need for click handlers on the search results, and for tracking mouse movements.

This changes the UI treatment of mouse hovering. A hovered element now gets a light grey background, but does not change the focus. It's possible to have two highlighted search results: one that is focused (via keyboard) and one that is hovered (via mouse). Pressing enter will activate the focused link; clicking will activate the hovered link. This matches up with how Firefox and Chrome handle suggestions in their URL bar, and avoids stray mouse movements changing the focus.

Selecting tabs is now done with left/right arrows while any search result is focused. The visibility of results on each search tab is
controlled with the "active" class, rather than by setting display: none directly. Note that the old code kept track of highlighted search element when tabbing back and forth. The new code doesn't.

Demo at https://hoffman-andrews.com/rust/focus-search-results2/std/?search=fn

Fixes #84384
Fixes #79962
Fixes #79872
2021-05-18 19:35:35 +02:00
Jorge Ferreira
d13745d99b
fix typo 2021-05-18 17:05:40 +01:00
bors
a5560a6a90 Auto merge of #85437 - GuillaumeGomez:rollup-3jcirty, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #84587 (rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`))
 - #85280 (Toggle-wrap items differently than top-doc.)
 - #85338 (Implement more Iterator methods on core::iter::Repeat)
 - #85339 (Report an error if a lang item has the wrong number of generic arguments)
 - #85369 (Suggest borrowing if a trait implementation is found for &/&mut <type>)
 - #85393 (Suppress spurious errors inside `async fn`)
 - #85415 (Clean up remnants of BorrowOfPackedField)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-18 14:48:53 +00:00
Guillaume Gomez
f4a0d97def
Rollup merge of #85415 - LeSeulArtichaut:no-packed-borrow-unsafeck, r=RalfJung
Clean up remnants of BorrowOfPackedField

cc #82525 which removed `BorrowOfPackedField` from unsafety-checking
r? `@RalfJung`
2021-05-18 14:08:57 +02:00
Guillaume Gomez
5f544bcf70
Rollup merge of #85393 - Aaron1011:async-type-err, r=varkor
Suppress spurious errors inside `async fn`

Fixes #73741
2021-05-18 14:08:56 +02:00
Guillaume Gomez
fad04ff60e
Rollup merge of #85369 - FabianWolff:issue-84973, r=jackh726
Suggest borrowing if a trait implementation is found for &/&mut <type>

This pull request fixes #84973 by suggesting to borrow if a trait is not implemented for some type `T`, but it is for `&T` or `&mut T`. For instance:
```rust
trait Ti {}
impl<T> Ti for &T {}
fn foo<T: Ti>(_: T) {}

trait Tm {}
impl<T> Tm for &mut T {}
fn bar<T: Tm>(_: T) {}

fn main() {
    let a: i32 = 5;
    foo(a);

    let b: Box<i32> = Box::new(42);
    bar(b);
}
```
gives, on current nightly:
```
error[E0277]: the trait bound `i32: Ti` is not satisfied
  --> t2.rs:11:9
   |
3  | fn foo<T: Ti>(_: T) {}
   |           -- required by this bound in `foo`
...
11 |     foo(a);
   |         ^ the trait `Ti` is not implemented for `i32`

error[E0277]: the trait bound `Box<i32>: Tm` is not satisfied
  --> t2.rs:14:9
   |
7  | fn bar<T: Tm>(_: T) {}
   |           -- required by this bound in `bar`
...
14 |     bar(b);
   |         ^ the trait `Tm` is not implemented for `Box<i32>`

error: aborting due to 2 previous errors
```
whereas with my changes, I get:
```
error[E0277]: the trait bound `i32: Ti` is not satisfied
  --> t2.rs:11:9
   |
3  | fn foo<T: Ti>(_: T) {}
   |           -- required by this bound in `foo`
...
11 |     foo(a);
   |         ^
   |         |
   |         expected an implementor of trait `Ti`
   |         help: consider borrowing here: `&a`

error[E0277]: the trait bound `Box<i32>: Tm` is not satisfied
  --> t2.rs:14:9
   |
7  | fn bar<T: Tm>(_: T) {}
   |           -- required by this bound in `bar`
...
14 |     bar(b);
   |         ^
   |         |
   |         expected an implementor of trait `Tm`
   |         help: consider borrowing mutably here: `&mut b`

error: aborting due to 2 previous errors
```
In my implementation, I have added a "blacklist" to make these suggestions flexible. In particular, suggesting to borrow can interfere with other suggestions, such as to add another trait bound to a generic argument. I have tried to configure this blacklist to cause the least amount of test case failures, i.e. to model the current behavior as closely as possible (I only had to change one existing test case, and this change was quite clearly an improvement).
2021-05-18 14:08:55 +02:00
Guillaume Gomez
1bfd987f69
Rollup merge of #85339 - FabianWolff:issue-83893, r=varkor
Report an error if a lang item has the wrong number of generic arguments

This pull request fixes #83893. The issue is that the lang item code currently checks whether the lang item has the correct item kind (e.g. a `#[lang="add"]` has to be a trait), but not whether the item has the correct number of generic arguments.

This can lead to an "index out of bounds" ICE when the compiler tries to create more substitutions than there are suitable types available (if the lang item was declared with too many generic arguments).

For instance, here is a reduced ("reduced" in the sense that it does not trigger additional errors) version of the example given in #83893:
```rust
#![feature(lang_items,no_core)]
#![no_core]
#![crate_type="lib"]

#[lang = "sized"]
trait MySized {}

#[lang = "add"]
trait MyAdd<'a, T> {}

fn ice() {
    let r = 5;
    let a = 6;
    r + a
}
```
On current nightly, this immediately causes an ICE without any warnings or errors emitted. With the changes in this PR, however, I get no ICE and two errors:
```
error[E0718]: `add` language item must be applied to a trait with 1 generic argument
 --> pr-ex.rs:8:1
  |
8 | #[lang = "add"]
  | ^^^^^^^^^^^^^^^
9 | trait MyAdd<'a, T> {}
  |            ------- this trait has 2 generic arguments, not 1

error[E0369]: cannot add `{integer}` to `{integer}`
  --> pr-ex.rs:14:7
   |
14 |     r + a
   |     - ^ - {integer}
   |     |
   |     {integer}

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0369, E0718.
For more information about an error, try `rustc --explain E0369`.
```
2021-05-18 14:08:51 +02:00
Guillaume Gomez
a181806b8c
Rollup merge of #85338 - lopopolo:core-iter-repeat-gh-81292, r=joshtriplett
Implement more Iterator methods on core::iter::Repeat

`core::iter::Repeat` always returns the same element, which means we can
do better than implementing most `Iterator` methods in terms of
`Iterator::next`.

Fixes #81292.

#81292 raises the question of whether these changes violate the contract of `core::iter::Repeat`, but as far as I can tell `core::iter::repeat` doesn't make any guarantees around how it calls `Clone::clone`.
2021-05-18 14:08:46 +02:00
Guillaume Gomez
d151ed8699
Rollup merge of #85280 - jsha:move-trait-toggles, r=GuillaumeGomez
Toggle-wrap items differently than top-doc.

This makes sure things like trait methods get wrapped at the
`<h3><code>` level rather than at the `.docblock` level. Also it ensures
that only the actual top documentation gets the `.top-doc` class.

Fixes #85167

Before:

![image](https://user-images.githubusercontent.com/220205/117743384-98790200-b1bb-11eb-8804-588530842514.png)

https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read

After:

![image](https://user-images.githubusercontent.com/220205/118410882-98a75080-b646-11eb-949d-ca688bab6923.png)
2021-05-18 14:08:42 +02:00
Guillaume Gomez
07d11cf95c
Rollup merge of #84587 - jyn514:rustdoc-lint-block, r=CraftSpider
rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`)

Fixes https://github.com/rust-lang/rust/issues/79792. This already went through FCP in https://github.com/rust-lang/rust/pull/79816, so it only needs final review.

This is mostly a rebase of https://github.com/rust-lang/rust/pull/79816 - thank you ``@poliorcetics`` for doing most of the work!
2021-05-18 14:08:41 +02:00
bors
70b9d1e102 Auto merge of #85313 - jackh726:region_eq, r=nikomatsakis
Unify Regions with RegionVids in UnificationTable

A few test output changes; might be able to revert those but figured I would open this for perf and comments.

r? `@nikomatsakis`
2021-05-18 12:07:56 +00:00
Guillaume Gomez
5d004c1e20 Improve display for "copy-path" button, making it more discrete 2021-05-18 11:16:07 +02:00
bors
25a277f03d Auto merge of #82973 - ijackson:exitstatuserror, r=yaahc
Provide ExitStatusError

Closes #73125

In MR #81452 "Add #[must_use] to [...] process::ExitStatus" we concluded that the existing arrangements in are too awkward so adding that `#[must_use]` is blocked on improving the ergonomics.

I wrote a mini-RFC-style discusion of the approach in https://github.com/rust-lang/rust/issues/73125#issuecomment-771092741
2021-05-18 08:01:32 +00:00
Lee Bradley
4c12a5dc6c Add x.py pre-setup instructions
This change adds pre-setup instructions that outline how x.py requires
python to be setup and how to work around the problem of x.py failing to
locate python, especially now that Ubuntu 20.04's dropped default python
command is causing people to encounter this issue regularly.

See also: #71818
2021-05-18 01:01:28 -05:00
Joshua Nelson
587c50452f Fix rebase conflicts 2021-05-17 23:33:04 -04:00
Joshua Nelson
28c9c04325 Don't require cmake on Windows when LLVM isn't being built
Previously, setting `download-ci-llvm = true` when cmake wasn't
installed would give the following error:

```
failed to execute command: "cmake" "--help"
error: The system cannot find the file specified. (os error 2)
```
2021-05-17 22:08:20 -04:00
Joshua Nelson
18f6922d8c Address review comments
- Simplify boolean expression
- Give an example of invalid syntax
- Remove explanation of why code block is text
2021-05-17 21:31:05 -04:00
Joshua Nelson
b885d81a4a Rename INVALID_RUST_CODEBLOCK{,S} 2021-05-17 21:31:04 -04:00
Joshua Nelson
4120f7561c Add back missing help for ignore blocks
This also gives a better error message when a span is missing.
2021-05-17 21:31:03 -04:00
Alexis Bourget
b574c67b93 New rustdoc lint to respect -Dwarnings correctly
This adds a new lint to `rustc` that is used in rustdoc when a code
block is empty or cannot be parsed as valid Rust code.

Previously this was unconditionally a warning. As such some
documentation comments were (unknowingly) abusing this to pass despite
the `-Dwarnings` used when compiling `rustc`, this should not be the
case anymore.
2021-05-17 21:31:01 -04:00
bors
5f10d310f4 Auto merge of #85402 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/85397
2021-05-18 00:32:19 +00:00
Ralf Jung
a05dd06cc0 update Miri 2021-05-18 00:48:05 +02:00
Fabian Wolff
572bb13ae5 Implement jackh726's suggestions 2021-05-17 23:13:04 +02:00
bors
3e99439f4d Auto merge of #85414 - RalfJung:rollup-ueqcik4, r=RalfJung
Rollup of 8 pull requests

Successful merges:

 - #85087 (`eval_fn_call`: check the ABI of `body.source`)
 - #85302 (Expand WASI abbreviation in docs)
 - #85355 (More tests for issue-85255)
 - #85367 (Fix invalid input:disabled CSS selector)
 - #85374 (mark internal inplace_iteration traits as hidden)
 - #85408 (remove size field from Allocation)
 - #85409 (Simplify `cfg(any(unix, target_os="redox"))` in example to just `cfg(unix)`)
 - #85412 (remove some functions that were only used by Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-17 19:15:21 +00:00
LeSeulArtichaut
62044b2fab Remove remnants of BorrowOfPackedField 2021-05-17 19:32:58 +02:00
Ralf Jung
a28be5cbe8
Rollup merge of #85412 - RalfJung:c_str, r=oli-obk
remove some functions that were only used by Miri

and Miri does not need them any more with https://github.com/rust-lang/miri/pull/1805.

r? ``@oli-obk``
2021-05-17 18:52:17 +02:00
Ralf Jung
360db9c384
Rollup merge of #85409 - CDirkx:cfg_redox, r=nagisa
Simplify `cfg(any(unix, target_os="redox"))` in example to just `cfg(unix)`

Update example for `OsString` that handled `redox` seperately from `unix`: Redox has been completely integrated under `target_family="unix"`, so `cfg(unix)` implies `target_os="redox"`

35dbef2350/compiler/rustc_target/src/spec/redox_base.rs (L26)
2021-05-17 18:52:13 +02:00
Ralf Jung
af1ac55cbf
Rollup merge of #85408 - RalfJung:alloc-size, r=oli-obk
remove size field from Allocation

This is a part of https://github.com/rust-lang/rust/pull/85376 that can be easily split out.
r? ``@oli-obk``
2021-05-17 18:52:11 +02:00
Ralf Jung
fbb0d70c2c
Rollup merge of #85374 - the8472:hide-internal-traits, r=SimonSapin
mark internal inplace_iteration traits as hidden

resolves #85373

r? ``@SimonSapin``
2021-05-17 18:52:10 +02:00
Ralf Jung
266e7afe13
Rollup merge of #85367 - GuillaumeGomez:fix-css-rule, r=jsha
Fix invalid input:disabled CSS selector

For some reason, we used "search-focus" instead of "search-input"...

r? ``@jsha``
2021-05-17 18:52:09 +02:00
Ralf Jung
8f9d1107b5
Rollup merge of #85355 - hi-rustin:rustin-patch-issue-85255, r=varkor
More tests for issue-85255

Add more test for `pub(crate)`.

r? ``@varkor``
2021-05-17 18:52:08 +02:00
Ralf Jung
8a1403af1e
Rollup merge of #85302 - r00ster91:patch-7, r=joshtriplett
Expand WASI abbreviation in docs

I was pretty sure this was related to something for WebAssembly but wasn't 100% sure so I checked but even on these top-level docs I couldn't find the abbreviation expanded. I'm normally used to Rust docs being detailed and explanatory and writing abbreviations like this out in full at least once so I thought it was worth the change. Feel free to close this if it's too much.
2021-05-17 18:52:04 +02:00
Ralf Jung
b93753ee21
Rollup merge of #85087 - hyd-dev:lots-of-abis, r=RalfJung
`eval_fn_call`: check the ABI of `body.source`

And stop checking `instance_ty.fn_sig(*self.tcx).abi()`, if the function is not an intrinsic.
Addresses https://github.com/rust-lang/miri/pull/1776#discussion_r615381169.
No idea how to test this without Miri...
2021-05-17 18:51:59 +02:00
bors
fa72878a61 Auto merge of #85352 - Xanewok:update-rls, r=Xanewok
Update RLS

Contains https://github.com/rust-lang/rls/pull/1736. With #82208 merged, this should now close https://github.com/rust-lang/rust/issues/85225. Tested locally with `./x.py test src/tools/rls` and seems to be working as expected.

I noticed the rustfmt merge didn't trigger toolstate upgrade (because we pruned most but not all of the related machinery?), so I'd rather get this rubber-stamped by someone more knowledgeable with infra/the merged changes in case I missed something and need to include something else here to unbreak the RLS toolstate.

r? `@Mark-Simulacrum`
2021-05-17 16:34:11 +00:00
hyd-dev
97bc0eefe7
Add a comment for check_abi() 2021-05-17 20:54:31 +08:00
Ralf Jung
cb5533cff2 remove some functions that were only used by Miri 2021-05-17 14:43:16 +02:00
bors
9964284fed Auto merge of #84571 - jedel1043:issue-49804-impl, r=petrochenkov
Parse unnamed fields of struct and union type

Added the `unnamed_fields` feature gate.

This is a prototype of [RFC 2102](https://github.com/rust-lang/rust/issues/49804), so any suggestions are greatly appreciated.

r? `@petrochenkov`
2021-05-17 12:15:26 +00:00