]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #82364 - osa1:issue82361, r=estebank
Dylan DPC [Thu, 25 Feb 2021 13:34:04 +0000 (14:34 +0100)]
Rollup merge of #82364 - osa1:issue82361, r=estebank

Improve error msgs when found type is deref of expected

This improves help messages in two cases:

- When expected type is `T` and found type is `&T`, we now look through blocks
  and suggest dereferencing the expression of the block, rather than the whole
  block.

- In the above case, if the expression is an `&`, we not suggest removing the
  `&` instead of adding `*`.

Both of these are demonstrated in the regression test. Before this patch the
first error in the test would be:

    error[E0308]: `if` and `else` have incompatible types
     --> test.rs:8:9
      |
    5 | /     if true {
    6 | |         a
      | |         - expected because of this
    7 | |     } else {
    8 | |         b
      | |         ^ expected `usize`, found `&usize`
    9 | |     };
      | |_____- `if` and `else` have incompatible types
      |
    help: consider dereferencing the borrow
      |
    7 |     } else *{
    8 |         b
    9 |     };
      |

Now:

    error[E0308]: `if` and `else` have incompatible types
     --> test.rs:8:9
      |
    5 | /     if true {
    6 | |         a
      | |         - expected because of this
    7 | |     } else {
    8 | |         b
      | |         ^
      | |         |
      | |         expected `usize`, found `&usize`
      | |         help: consider dereferencing the borrow: `*b`
    9 | |     };
      | |_____- `if` and `else` have incompatible types

The second error:

    error[E0308]: `if` and `else` have incompatible types
      --> test.rs:14:9
       |
    11 | /     if true {
    12 | |         1
       | |         - expected because of this
    13 | |     } else {
    14 | |         &1
       | |         ^^ expected integer, found `&{integer}`
    15 | |     };
       | |_____- `if` and `else` have incompatible types
       |
    help: consider dereferencing the borrow
       |
    13 |     } else *{
    14 |         &1
    15 |     };
       |

now:

    error[E0308]: `if` and `else` have incompatible types
      --> test.rs:14:9
       |
    11 | /     if true {
    12 | |         1
       | |         - expected because of this
    13 | |     } else {
    14 | |         &1
       | |         ^-
       | |         ||
       | |         |help: consider removing the `&`: `1`
       | |         expected integer, found `&{integer}`
    15 | |     };
       | |_____- `if` and `else` have incompatible types

Fixes #82361

---

r? ````@estebank````

3 years agoRollup merge of #82321 - bugadani:ast3, r=varkor
Dylan DPC [Thu, 25 Feb 2021 13:34:03 +0000 (14:34 +0100)]
Rollup merge of #82321 - bugadani:ast3, r=varkor

AST: Remove some unnecessary boxes

3 years agoRollup merge of #82313 - jsha:update-normalize-css, r=GuillaumeGomez
Dylan DPC [Thu, 25 Feb 2021 13:34:02 +0000 (14:34 +0100)]
Rollup merge of #82313 - jsha:update-normalize-css, r=GuillaumeGomez

Update normalize.css to 8.0.1

From From https://github.com/necolas/normalize.css/releases/tag/8.0.1.

The old version was 3.0.0, from 2014. The new version is from 2018.

I noticed when looking at frontend performance for rustdoc that this file was out of date. The URL in the 3.0.0 license header now resolves to an incorrect destination. And generally it seems good to be up-to-date.

Before-and-after images, plus diff, under details. TL;DR: Nothing changes except a slight adjustment to line height.

<details>

![with-normalize-8 0 1](https://user-images.githubusercontent.com/220205/108581849-bd5c8800-72e4-11eb-9150-78c8d67ca37a.png)

![with-normalize-3 0 0](https://user-images.githubusercontent.com/220205/108581848-bcc3f180-72e4-11eb-8b45-0cd1415a51e5.png)

![diff](https://user-images.githubusercontent.com/220205/108581890-dfeea100-72e4-11eb-93c5-6284492f54a9.png)

</details>

3 years agoRollup merge of #82220 - henryboisdequin:fixes-80853, r=varkor
Dylan DPC [Thu, 25 Feb 2021 13:34:00 +0000 (14:34 +0100)]
Rollup merge of #82220 - henryboisdequin:fixes-80853, r=varkor

fix the false 'defined here' messages

Closes #80853.

Take this code:

```rust
struct S;

fn repro_ref(thing: S) {
    thing();
}
```

Previously, the error message would be this:

```
error[E0618]: expected function, found `S`
 --> src/lib.rs:4:5
  |
3 | fn repro_ref(thing: S) {
  |              ----- `S` defined here
4 |     thing();
  |     ^^^^^--
  |     |
  |     call expression requires function

error: aborting due to previous error
```

This is incorrect as `S` is not defined in the function arguments, `thing` is defined there. With this change, the following is emitted:

```
error[E0618]: expected function, found `S`
  --> $DIR/80853.rs:4:5
   |
LL | fn repro_ref(thing: S) {
   |              ----- is of type `S`
LL |     thing();
   |     ^^^^^--
   |     |
   |     call expression requires function
   |
   = note: local variable `S` is not a function

error: aborting due to previous error
```

As you can see, this error message points out that `thing` is of type `S` and later in a note, that `S` is not a function. This change does seem like a downside for some error messages. Take this example:

```
LL | struct Empty2;
   | -------------- is of type `Empty2`
```

As you can see, the error message shows that the definition of `Empty2` is of type `Empty2`. Although this isn't wrong, it would be more helpful if it would say something like this (which was there previously):

```
LL | struct Empty2;
   | -------------- `Empty2` defined here
```

If there is a better way of doing this, where the `Empty2` example would stay the same as without this change, please inform me.

**Update: This is now fixed**

CC `@camelid`

3 years agoRollup merge of #82214 - est31:no_to_string, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:59 +0000 (14:33 +0100)]
Rollup merge of #82214 - est31:no_to_string, r=oli-obk

Remove redundant to_string calls

3 years agoRollup merge of #82213 - est31:slices_for_vecs, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:58 +0000 (14:33 +0100)]
Rollup merge of #82213 - est31:slices_for_vecs, r=jyn514

Slices for vecs

3 years agoRollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebank
Dylan DPC [Thu, 25 Feb 2021 13:33:57 +0000 (14:33 +0100)]
Rollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebank

Do not consider using a semicolon inside of a different-crate macro

Fixes #81943

3 years agoRollup merge of #82087 - estebank:abolish-ice, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:56 +0000 (14:33 +0100)]
Rollup merge of #82087 - estebank:abolish-ice, r=oli-obk

Fix ICE caused by suggestion with no code substitutions

Change suggestion logic to filter and checking _before_ creating
specific resolution suggestion.

Assert earlier that suggestions contain code substitions to make it
easier in the future to debug invalid uses. If we find this becomes too
noisy in the wild, we can always make the emitter resilient to these
cases and remove the assertions.

Fix #78651.

3 years agoRollup merge of #82078 - lopopolo:char-u8-const-fn, r=m-ou-se
Dylan DPC [Thu, 25 Feb 2021 13:33:55 +0000 (14:33 +0100)]
Rollup merge of #82078 - lopopolo:char-u8-const-fn, r=m-ou-se

Make char and u8 methods const

char methods `len_utf8`, `len_utf16`, `to_ascii_lowercase`, `eq_ignore_ascii_case` can be made const.

`u8` methods `to_ascii_lowercase`, `to_ascii_uppercase` are required to be const as well.

`u8::eq_ignore_ascii_case` was additionally made const.

Rebase of https://github.com/rust-lang/rust/pull/79549 originally authored by ``@YenForYang.`` Changes from that PR:

- Squashed all commits from #79549.
- rebased to latest upstream master.
- Removed const attributes for `char::escape_unicode` and `char::escape_default`.
- Updated `since` attributes for `const` stabilization to 1.52.0.

cc ``@m-ou-se.``

3 years agoRollup merge of #81713 - estebank:unstable-assoc-item-lint, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:53 +0000 (14:33 +0100)]
Rollup merge of #81713 - estebank:unstable-assoc-item-lint, r=oli-obk

Account for associated consts in the "unstable assoc item name colission" lint

Fix #81663.

3 years agoRollup merge of #81575 - camelid:rustdoc-wrongnamespace-cleanup, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:52 +0000 (14:33 +0100)]
Rollup merge of #81575 - camelid:rustdoc-wrongnamespace-cleanup, r=jyn514

rustdoc: Name fields of `ResolutionFailure::WrongNamespace`

It makes it clearer that the `Namespace` is the one requested by the
disambiguator, rather than the actual namespace of the item. It said
that in the docs before, but now you can tell in the code so it reduces
the potential for confusion.

3 years agoRollup merge of #81167 - usbalbin:const_write, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:51 +0000 (14:33 +0100)]
Rollup merge of #81167 - usbalbin:const_write, r=oli-obk

Make ptr::write const

~~The code in this PR as of right now is not much more than an experiment.~~

~~This should, if I am not mistaken, in theory compile and pass the tests once the bootstraping compiler is updated. Thus the PR is blocked on that which should happen some time after the February the 9th. Also we might want to wait for #79989 to avoid regressing performance due to using `mem::forget` over `intrinsics::forget`~~.

3 years agoRollup merge of #80553 - derekdreery:arc_error, r=m-ou-se
Dylan DPC [Thu, 25 Feb 2021 13:33:50 +0000 (14:33 +0100)]
Rollup merge of #80553 - derekdreery:arc_error, r=m-ou-se

Add an impl of Error on `Arc<impl Error>`.

`Display` already exists so this should be a non-controversial change (famous last words).

Would have to be insta-stable.

3 years agoRollup merge of #80534 - LeSeulArtichaut:doc-include, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:47 +0000 (14:33 +0100)]
Rollup merge of #80534 - LeSeulArtichaut:doc-include, r=jyn514

Use #[doc = include_str!()] in std

cc https://github.com/rust-lang/rust/issues/78835#issuecomment-742531894
r? `````@jyn514`````

3 years agoRollup merge of #75807 - jyn514:num-intra-link, r=poliorcetics
Dylan DPC [Thu, 25 Feb 2021 13:33:44 +0000 (14:33 +0100)]
Rollup merge of #75807 - jyn514:num-intra-link, r=poliorcetics

Convert core/num/mod.rs to intra-doc links

Helps with #75080.
This can't convert the associated constants `MAX` and `MIN` until #74489 is merged.

r? `@poliorcetics`

3 years agoadd helpful error notes and fix the false 'defined here' messages
Henry Boisdequin [Wed, 17 Feb 2021 14:50:59 +0000 (20:20 +0530)]
add helpful error notes and fix the false 'defined here' messages

3 years agoAuto merge of #82338 - RalfJung:interp-error-allocs, r=oli-obk
bors [Thu, 25 Feb 2021 08:27:09 +0000 (08:27 +0000)]
Auto merge of #82338 - RalfJung:interp-error-allocs, r=oli-obk

all InterpError allocate now, so adjust alloc-error-check

Cc https://github.com/rust-lang/rust/pull/82116#discussion_r578310770
r? `@oli-obk`

3 years agoAuto merge of #82162 - cuviper:flat-fold, r=Mark-Simulacrum
bors [Thu, 25 Feb 2021 00:36:05 +0000 (00:36 +0000)]
Auto merge of #82162 - cuviper:flat-fold, r=Mark-Simulacrum

Expand FlattenCompat folds

The former `chain`+`chain`+`fold` implementation looked nice from a
functional-programming perspective, but it introduced unnecessary layers
of abstraction on every `flat_map`/`flatten` fold. It's straightforward
to just fold each part in turn, and this makes it look like a simplified
version of the existing `try_fold` implementation.

For the `iter::bench_flat_map*` benchmarks, I get a large improvement in
`bench_flat_map_chain_sum`, from 1,598,473 ns/iter to 499,889 ns/iter,
and the rest are unchanged.

3 years agoAccount for associated consts in the "unstable assoc item name colission" lint
Esteban Küber [Wed, 3 Feb 2021 16:38:05 +0000 (08:38 -0800)]
Account for associated consts in the "unstable assoc item name colission" lint

Fix #81663.

3 years agoAuto merge of #82159 - BoxyUwU:uwu, r=varkor
bors [Wed, 24 Feb 2021 21:54:52 +0000 (21:54 +0000)]
Auto merge of #82159 - BoxyUwU:uwu, r=varkor

Use correct param_env in conservative_is_privately_uninhabited

cc `@lcnr`
r? `@varkor` since this is your FIXME that was removed ^^

3 years agoAuto merge of #80914 - GuillaumeGomez:remove-is_spotlight, r=jyn514
bors [Wed, 24 Feb 2021 14:46:18 +0000 (14:46 +0000)]
Auto merge of #80914 - GuillaumeGomez:remove-is_spotlight, r=jyn514

Remove is_spotlight field from `Trait`

Small PR, only the last commit is relevant here. The rest is coming from #80883 because I need the `TyCtxt` stored inside `Cache`.

The point is to make ItemKind looks as close as possible to the compiler type so that it makes the switch simpler (which is why I make all these "small" PRs).

r? `@jyn514`

3 years agoAuto merge of #80475 - simonvandel:fix-77355, r=oli-obk
bors [Wed, 24 Feb 2021 07:23:54 +0000 (07:23 +0000)]
Auto merge of #80475 - simonvandel:fix-77355, r=oli-obk

New mir-opt pass to simplify gotos with const values (reopening #77486)

Reopening PR #77486

Fixes #77355

This pass optimizes the following sequence
```rust
bb2: {
    _2 = const true;
    goto -> bb3;
}

bb3: {
    switchInt(_2) -> [false: bb4, otherwise: bb5];
}
```
into
```rust
bb2: {
    _2 = const true;
    goto -> bb5;
}
```

3 years agorustdoc: Name fields of `ResolutionFailure::WrongNamespace`
Camelid [Sat, 30 Jan 2021 23:47:53 +0000 (15:47 -0800)]
rustdoc: Name fields of `ResolutionFailure::WrongNamespace`

It makes it clearer that the `Namespace` is the one requested by the
disambiguator, rather than the actual namespace of the item. It said
that in the docs before, but now you can tell in the code so it reduces
the potential for confusion.

3 years agoAuto merge of #80891 - cjgillot:noq, r=Mark-Simulacrum
bors [Wed, 24 Feb 2021 03:29:00 +0000 (03:29 +0000)]
Auto merge of #80891 - cjgillot:noq, r=Mark-Simulacrum

Make the `Query` enum a simple struct.

A lot of code in `rustc_query_system` is generic over it, only to encode an exceptional error case: query cycles.
The delayed computations are now done at cycle detection.

3 years agoyeet
Ellen [Tue, 23 Feb 2021 23:35:48 +0000 (23:35 +0000)]
yeet

3 years agoImprove code readability
Guillaume Gomez [Tue, 23 Feb 2021 21:13:48 +0000 (22:13 +0100)]
Improve code readability

3 years ago* Fix some typo
Guillaume Gomez [Sun, 14 Feb 2021 13:47:55 +0000 (14:47 +0100)]
* Fix some typo
* Improve documentation
* Add a test to ensure that spotlighted traits from dependencies are taken into account as expected

3 years agoPut clean::Trait extra information into a new struct to make it more coherent
Guillaume Gomez [Fri, 12 Feb 2021 13:33:32 +0000 (14:33 +0100)]
Put clean::Trait extra information into a new struct to make it more coherent

3 years agoUse a qualified path to make it more clear where `list_contains_name` function comes...
Guillaume Gomez [Fri, 12 Feb 2021 12:55:34 +0000 (13:55 +0100)]
Use a qualified path to make it more clear where `list_contains_name` function comes from

3 years agoRemove is_spotlight field from `Trait`
Guillaume Gomez [Thu, 28 Jan 2021 16:05:22 +0000 (17:05 +0100)]
Remove is_spotlight field from `Trait`

3 years agoDo not consider using a semicolon inside of a different-crate macro
Michael Howell [Sun, 14 Feb 2021 07:51:38 +0000 (00:51 -0700)]
Do not consider using a semicolon inside of a different-crate macro

Fixes #81943

3 years agoAuto merge of #82443 - Dylan-DPC:rollup-yni7uio, r=Dylan-DPC
bors [Tue, 23 Feb 2021 17:24:33 +0000 (17:24 +0000)]
Auto merge of #82443 - Dylan-DPC:rollup-yni7uio, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #81629 (Point out implicit deref coercions in borrow)
 - #82113 (Improve non_fmt_panic lint.)
 - #82258 (Implement -Z hir-stats for nested foreign items)
 - #82296 (Support `pub` on `macro_rules`)
 - #82297 (Consider auto derefs before warning about write only fields)
 - #82305 (Remove many RefCells from DocContext)
 - #82308 (Lower condition of `if` expression before it's "then" block)
 - #82311 (Jsondocck improvements)
 - #82362 (Fix mir-cfg dumps)
 - #82391 (disable atomic_max/min tests in Miri)

Failed merges:

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

3 years agoConstify ptr::write and the write[_unaligned] methods on *mut T
Albin Hedman [Mon, 18 Jan 2021 21:59:56 +0000 (22:59 +0100)]
Constify ptr::write and the write[_unaligned] methods on *mut T

Constify intrinsics::forget

3 years agoMake ascii_change_case_unchecked const
Ryan Lopopolo [Tue, 23 Feb 2021 15:20:13 +0000 (07:20 -0800)]
Make ascii_change_case_unchecked const

Rebases and makes changes required by the recent merge of #81837.

3 years agoUpdate since attributes for new const_ascii_methods_on_intrinsics to 1.52.0
Ryan Lopopolo [Sat, 13 Feb 2021 23:17:44 +0000 (15:17 -0800)]
Update since attributes for new const_ascii_methods_on_intrinsics to 1.52.0

3 years agoRemove const from iterator fns
Ryan Lopopolo [Sat, 13 Feb 2021 23:16:48 +0000 (15:16 -0800)]
Remove const from iterator fns

3 years agoMake char methods const
YenForYang [Mon, 30 Nov 2020 02:16:31 +0000 (20:16 -0600)]
Make char methods const

`escape_unicode`, `escape_default`, `len_utf8`, `len_utf16`, to_ascii_lowercase`, `eq_ignore_ascii_case`

`u8` methods `to_ascii_lowercase`, `to_ascii_uppercase` also must be made const

u8 methods made const

Update methods.rs

Update mod.rs

Update methods.rs

Fix `since` in rustc_const_stable to next stable

Fix `since` in rustc_const_stable to next stable

Update methods.rs

Update mod.rs

3 years agoRollup merge of #82391 - RalfJung:miri-atomic-minmax, r=dtolnay
Dylan DPC [Tue, 23 Feb 2021 15:10:30 +0000 (16:10 +0100)]
Rollup merge of #82391 - RalfJung:miri-atomic-minmax, r=dtolnay

disable atomic_max/min tests in Miri

Disable some tests that currently [fail in Miri](https://travis-ci.com/github/RalfJung/miri-test-libstd/builds/217788631).

3 years agoRollup merge of #82362 - osa1:issue81918, r=oli-obk
Dylan DPC [Tue, 23 Feb 2021 15:10:29 +0000 (16:10 +0100)]
Rollup merge of #82362 - osa1:issue81918, r=oli-obk

Fix mir-cfg dumps

Fixes #81918
Fixes #82326 (duplicate)
Fixes #82325

---

r? ``@oli-obk``

3 years agoRollup merge of #82311 - aDotInTheVoid:jsondocck-improvements, r=jyn514
Dylan DPC [Tue, 23 Feb 2021 15:10:28 +0000 (16:10 +0100)]
Rollup merge of #82311 - aDotInTheVoid:jsondocck-improvements, r=jyn514

Jsondocck improvements

Adds 2 new commands, ```@is``` and ```@set`.``

```@is``` works like ```@has`,`` except instead of checking if any value matches, it checks that there is exactly one value, and it matches. This allows more precise testing.

```@set``` gets a value, and saves it to be used later. This makes it possible to check that an item appears in the correct module.

Once this lands, the rest of the test suite can be upgraded to use these.

cc ``@CraftSpider``

 ``@rustbot`` modify labels: +T-rustdoc +A-rustdoc-json +A-testsuite

3 years agoRollup merge of #82308 - estebank:issue-82290, r=lcnr
Dylan DPC [Tue, 23 Feb 2021 15:10:27 +0000 (16:10 +0100)]
Rollup merge of #82308 - estebank:issue-82290, r=lcnr

Lower condition of `if` expression before it's "then" block

Fix #82290, fix #82250.

3 years agoRollup merge of #82305 - camelid:no-more-refcell, r=jyn514
Dylan DPC [Tue, 23 Feb 2021 15:10:26 +0000 (16:10 +0100)]
Rollup merge of #82305 - camelid:no-more-refcell, r=jyn514

Remove many RefCells from DocContext

I left some of them so this change doesn't balloon in size and because
removing the RefCell in `DocContext.resolver` would require compiler
changes.

Thanks to `@jyn514` for making this a lot easier with #82020!

r? `@jyn514`

3 years agoRollup merge of #82297 - tmiasko:write-only, r=oli-obk
Dylan DPC [Tue, 23 Feb 2021 15:10:25 +0000 (16:10 +0100)]
Rollup merge of #82297 - tmiasko:write-only, r=oli-obk

Consider auto derefs before warning about write only fields

Changes from #81473 extended the dead code lint with an ability to detect
fields that are written to but never read from. The implementation skips
over fields on the left hand side of an assignment, without marking them
as live.

A field access might involve an automatic dereference and de-facto read
the field. Conservatively mark expressions with deref adjustments as
live to avoid generating false positive warnings.

Closes #81626.

3 years agoRollup merge of #82296 - spastorino:pubrules, r=nikomatsakis
Dylan DPC [Tue, 23 Feb 2021 15:10:23 +0000 (16:10 +0100)]
Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakis

Support `pub` on `macro_rules`

This rebases and updates `since` version of #78166 from ``@petrochenkov``

r? ``@nikomatsakis``

3 years agoRollup merge of #82258 - tmiasko:foreign-hir-stats, r=davidtwco
Dylan DPC [Tue, 23 Feb 2021 15:10:22 +0000 (16:10 +0100)]
Rollup merge of #82258 - tmiasko:foreign-hir-stats, r=davidtwco

Implement -Z hir-stats for nested foreign items

An attempt to compute HIR stats for crates with nested foreign items results in an ICE.

```rust
fn main() {
    extern "C" { fn f(); }
}
```

```
thread 'rustc' panicked at 'visit_nested_xxx must be manually implemented in this visitor'
```

Provide required implementation of visitor method.

3 years agoRollup merge of #82113 - m-ou-se:panic-format-lint, r=estebank
Dylan DPC [Tue, 23 Feb 2021 15:10:21 +0000 (16:10 +0100)]
Rollup merge of #82113 - m-ou-se:panic-format-lint, r=estebank

Improve non_fmt_panic lint.

This change:
- fixes the span used by this lint in the case the panic argument is a single macro expansion (e.g. `panic!(a!())`);
- adds a suggestion for `panic!(format!(..))` to remove `format!()` instead of adding `"{}", ` or using `panic_any` like it does now; and
- fixes the incorrect suggestion to replace `panic![123]` by `panic_any(123]`.

Fixes #82109.
Fixes #82110.
Fixes #82111.

Example output:
```
warning: panic message is not a string literal
 --> src/main.rs:8:12
  |
8 |     panic!(format!("error: {}", "oh no"));
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(non_fmt_panic)]` on by default
  = note: this is no longer accepted in Rust 2021
  = note: the panic!() macro supports formatting, so there's no need for the format!() macro here
help: remove the `format!(..)` macro call
  |
8 |     panic!("error: {}", "oh no");
  |           --                  --

```

r? `@estebank`

3 years agoRollup merge of #81629 - 1000teslas:issue-81365-fix, r=Aaron1011
Dylan DPC [Tue, 23 Feb 2021 15:10:20 +0000 (16:10 +0100)]
Rollup merge of #81629 - 1000teslas:issue-81365-fix, r=Aaron1011

Point out implicit deref coercions in borrow

Fixes #81365

`@Aaron1011` I'm not sure why my code shows the note even in an implicit `Deref` call. See the output for `issue-81365-8.rs`.

3 years agoUse #[doc = include_str!()] in std
LeSeulArtichaut [Wed, 30 Dec 2020 22:33:38 +0000 (23:33 +0100)]
Use #[doc = include_str!()] in std

3 years agoAuto merge of #82127 - tgnottingham:tune-ahead-of-time-codegen, r=varkor
bors [Tue, 23 Feb 2021 14:38:45 +0000 (14:38 +0000)]
Auto merge of #82127 - tgnottingham:tune-ahead-of-time-codegen, r=varkor

rustc_codegen_ssa: tune codegen according to available concurrency

This change tunes ahead-of-time codegening according to the amount of
concurrency available, rather than according to the number of CPUs on
the system. This can lower memory usage by reducing the number of
compiled LLVM modules in memory at once, particularly across several
rustc instances.

Previously, each rustc instance would assume that it should codegen
ahead of time to meet the demand of number-of-CPUs workers. But often, a
rustc instance doesn't have nearly that much concurrency available to
it, because the concurrency availability is split, via the jobserver,
across all active rustc instances spawned by the driving cargo process,
and is further limited by the `-j` flag argument. Therefore, each rustc
might have had several times the number of LLVM modules in memory than
it really needed to meet demand. If the modules were large, the effect
on memory usage would be noticeable.

With this change, the required amount of ahead-of-time codegen scales up
with the actual number of workers running within a rustc instance. Note
that the number of workers running can be less than the actual
concurrency available to a rustc instance. However, if more concurrency
is actually available, workers are spun up quickly as job tokens are
acquired, and the ahead-of-time codegen scales up quickly as well.

3 years agoFix link
Joshua Nelson [Thu, 31 Dec 2020 01:38:58 +0000 (20:38 -0500)]
Fix link

3 years agoConvert core/num/mod.rs to intra-doc links
Joshua Nelson [Sat, 22 Aug 2020 15:00:40 +0000 (11:00 -0400)]
Convert core/num/mod.rs to intra-doc links

3 years agoAuto merge of #82102 - nagisa:nagisa/fix-dwo-name, r=davidtwco
bors [Tue, 23 Feb 2021 10:02:16 +0000 (10:02 +0000)]
Auto merge of #82102 - nagisa:nagisa/fix-dwo-name, r=davidtwco

Set path of the compile unit to the source directory

As part of the effort to implement split dwarf debug info, we ended up
setting the compile unit location to the output directory rather than
the source directory. Furthermore, it seems like we failed to remap the
prefixes for this as well!

The desired behaviour is to instead set the `DW_AT_GNU_dwo_name` to a
path relative to compiler's working directory. This still allows
debuggers to find the split dwarf files, while not changing the
behaviour of the code that is compiling with regular debug info, and not
changing the compiler's behaviour with regards to reproducibility.

Fixes #82074

cc `@alexcrichton` `@davidtwco`

3 years agoImprove error msgs when found type is deref of expected
Ömer Sinan Ağacan [Sun, 21 Feb 2021 10:29:43 +0000 (13:29 +0300)]
Improve error msgs when found type is deref of expected

This improves help messages in two cases:

- When expected type is `T` and found type is `&T`, we now look through blocks
  and suggest dereferencing the expression of the block, rather than the whole
  block.

- In the above case, if the expression is an `&`, we not suggest removing the
  `&` instead of adding `*`.

Both of these are demonstrated in the regression test. Before this patch the
first error in the test would be:

    error[E0308]: `if` and `else` have incompatible types
     --> test.rs:8:9
      |
    5 | /     if true {
    6 | |         a
      | |         - expected because of this
    7 | |     } else {
    8 | |         b
      | |         ^ expected `usize`, found `&usize`
    9 | |     };
      | |_____- `if` and `else` have incompatible types
      |
    help: consider dereferencing the borrow
      |
    7 |     } else *{
    8 |         b
    9 |     };
      |

Now:

    error[E0308]: `if` and `else` have incompatible types
     --> test.rs:8:9
      |
    5 | /     if true {
    6 | |         a
      | |         - expected because of this
    7 | |     } else {
    8 | |         b
      | |         ^
      | |         |
      | |         expected `usize`, found `&usize`
      | |         help: consider dereferencing the borrow: `*b`
    9 | |     };
      | |_____- `if` and `else` have incompatible types

The second error:

    error[E0308]: `if` and `else` have incompatible types
      --> test.rs:14:9
       |
    11 | /     if true {
    12 | |         1
       | |         - expected because of this
    13 | |     } else {
    14 | |         &1
       | |         ^^ expected integer, found `&{integer}`
    15 | |     };
       | |_____- `if` and `else` have incompatible types
       |
    help: consider dereferencing the borrow
       |
    13 |     } else *{
    14 |         &1
    15 |     };
       |

now:

    error[E0308]: `if` and `else` have incompatible types
      --> test.rs:14:9
       |
    11 | /     if true {
    12 | |         1
       | |         - expected because of this
    13 | |     } else {
    14 | |         &1
       | |         ^-
       | |         ||
       | |         |help: consider removing the `&`: `1`
       | |         expected integer, found `&{integer}`
    15 | |     };
       | |_____- `if` and `else` have incompatible types

Fixes #82361

3 years agoAuto merge of #82076 - jyn514:update-bootstrap, r=Mark-Simulacrum
bors [Tue, 23 Feb 2021 07:19:41 +0000 (07:19 +0000)]
Auto merge of #82076 - jyn514:update-bootstrap, r=Mark-Simulacrum

Update the bootstrap compiler

This updates the bootstrap compiler, notably leaving out a change to enable semicolon in macro expressions lint, because stdarch still depends on the old behavior.

3 years agoAuto merge of #82430 - Dylan-DPC:rollup-nu4kfyc, r=Dylan-DPC
bors [Tue, 23 Feb 2021 04:31:32 +0000 (04:31 +0000)]
Auto merge of #82430 - Dylan-DPC:rollup-nu4kfyc, r=Dylan-DPC

Rollup of 12 pull requests

Successful merges:

 - #79423 (Enable smart punctuation)
 - #81154 (Improve design of `assert_len`)
 - #81235 (Improve suggestion for tuple struct pattern matching errors.)
 - #81769 (Suggest `return`ing tail expressions that match return type)
 - #81837 (Slight perf improvement on char::to_ascii_lowercase)
 - #81969 (Avoid `cfg_if` in `std::os`)
 - #81984 (Make WASI's `hard_link` behavior match other platforms.)
 - #82091 (use PlaceRef abstractions more consistently)
 - #82128 (add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice)
 - #82166 (add s390x-unknown-linux-musl target)
 - #82234 (Remove query parameters when skipping search results)
 - #82255 (Make `treat_err_as_bug` Option<NonZeroUsize>)

Failed merges:

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

3 years agoRollup merge of #82255 - nhwn:nonzero-err-as-bug, r=davidtwco
Dylan DPC [Tue, 23 Feb 2021 01:51:55 +0000 (02:51 +0100)]
Rollup merge of #82255 - nhwn:nonzero-err-as-bug, r=davidtwco

Make `treat_err_as_bug` Option<NonZeroUsize>

`rustc -Z treat-err-as-bug=N` already requires `N` to be nonzero when the argument is parsed, so changing the type from `Option<usize>` to `Option<NonZeroUsize>` is a low-hanging fruit in terms of layout optimization.

3 years agoRollup merge of #82234 - GuillaumeGomez:remove-query-param-on-esc, r=Nemo157
Dylan DPC [Tue, 23 Feb 2021 01:51:54 +0000 (02:51 +0100)]
Rollup merge of #82234 - GuillaumeGomez:remove-query-param-on-esc, r=Nemo157

Remove query parameters when skipping search results

Fixes #81330.

This PR changes the following: when pressing ESC and that no other "action" was performed (understand: no closing the search result, or hiding a menu or something along the line), then we discard the URL query parameters (the `?whatever=dsjfs`). What do you think about this change ```@rust-lang/rustdoc``` ?

EDIT: finally we're simply removing the query parameter when we're skipping the search results.

r? ```@Nemo157```

3 years agoRollup merge of #82166 - kaniini:s390x-musl-target, r=nagisa
Dylan DPC [Tue, 23 Feb 2021 01:51:53 +0000 (02:51 +0100)]
Rollup merge of #82166 - kaniini:s390x-musl-target, r=nagisa

add s390x-unknown-linux-musl target

This is the first step in bringup for Rust on s390x.

The libc and std crates need modifications as well, but getting this upstream makes that work easier.

3 years agoRollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwco
Dylan DPC [Tue, 23 Feb 2021 01:51:51 +0000 (02:51 +0100)]
Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwco

add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice

This is adding diagnostic items to be used by rust-lang/rust-clippy#6730, but my understanding is the clippy-side change does need to be done over there since I am adding a new clippy feature.

Add diagnostic items to the following types:
  OsString (os_string_type)
  PathBuf (path_buf_type)
  Owned (to_owned_trait)

As well as the to_vec method on slice/[T]

3 years agoRollup merge of #82091 - henryboisdequin:use-place-ref-more, r=RalfJung
Dylan DPC [Tue, 23 Feb 2021 01:51:50 +0000 (02:51 +0100)]
Rollup merge of #82091 - henryboisdequin:use-place-ref-more, r=RalfJung

use PlaceRef abstractions more consistently

Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715)
Associated issue: #80647

r? ```@RalfJung```

3 years agoRollup merge of #81984 - sunfishcode:wasi-link, r=alexcrichton
Dylan DPC [Tue, 23 Feb 2021 01:51:49 +0000 (02:51 +0100)]
Rollup merge of #81984 - sunfishcode:wasi-link, r=alexcrichton

Make WASI's `hard_link` behavior match other platforms.

Following #78026, `std::fs::hard_link` on most platforms does not follow
symlinks. Change the WASI implementation to also not follow symlinks.

r? ```@alexcrichton```

3 years agoRollup merge of #81969 - jonas-schievink:no-cfg-if, r=Mark-Simulacrum
Dylan DPC [Tue, 23 Feb 2021 01:51:48 +0000 (02:51 +0100)]
Rollup merge of #81969 - jonas-schievink:no-cfg-if, r=Mark-Simulacrum

Avoid `cfg_if` in `std::os`

rust-analyzer cannot currently load the `cfg_if` crate, which means that rust-analyzer is unable to see `std::os::{unix, windows, linux}` here. This works around that by avoiding `cfg_if`; the `#[cfg]` expressions are simple enough to reasonably write by hand.

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6038

3 years agoRollup merge of #81837 - gilescope:to_ascii_speedups, r=dtolnay
Dylan DPC [Tue, 23 Feb 2021 01:51:47 +0000 (02:51 +0100)]
Rollup merge of #81837 - gilescope:to_ascii_speedups, r=dtolnay

Slight perf improvement on char::to_ascii_lowercase

`char::to_ascii_lowercase()` was checking if it was ascii and then if it was in the right range. Instead propose to check once (I think removing a compare and a shift in the process: [godbolt](https://godbolt.org/z/e5Tora) ).

before:
```
        test char::methods::bench_to_ascii_lowercase                    ... bench:      11,196 ns/iter (+/- 632)
        test char::methods::bench_to_ascii_uppercase                    ... bench:      11,656 ns/iter (+/- 671)
```
after:
```
         test char::methods::bench_to_ascii_lowercase                    ... bench:       9,612 ns/iter (+/- 979)
         test char::methods::bench_to_ascii_uppercase                    ... bench:       8,241 ns/iter (+/- 701)
```

(calling u8::to_ascii_lowercase and letting that flip the 5th bit is also an option, but it's more instructions. I'm thinking for things around ascii and char we want to be as efficient as possible.)

3 years agoRollup merge of #81769 - estebank:tail-expr-as-potential-return, r=lcnr
Dylan DPC [Tue, 23 Feb 2021 01:51:46 +0000 (02:51 +0100)]
Rollup merge of #81769 - estebank:tail-expr-as-potential-return, r=lcnr

Suggest `return`ing tail expressions that match return type

Some newcomers are confused by the behavior of tail expressions,
interpreting that "leaving out the `;` makes it the return value".
To help them go in the right direction, suggest using `return` instead
when applicable.

3 years agoRollup merge of #81235 - reese:rw-tuple-diagnostics, r=estebank
Dylan DPC [Tue, 23 Feb 2021 01:51:44 +0000 (02:51 +0100)]
Rollup merge of #81235 - reese:rw-tuple-diagnostics, r=estebank

Improve suggestion for tuple struct pattern matching errors.

Closes #80174

This change allows numbers to be parsed as field names when pattern matching on structs, which allows us to provide better error messages when tuple structs are matched using a struct pattern.

r? ``@estebank``

3 years agoRollup merge of #81154 - dylni:improve-design-of-assert-len, r=KodrAus
Dylan DPC [Tue, 23 Feb 2021 01:51:43 +0000 (02:51 +0100)]
Rollup merge of #81154 - dylni:improve-design-of-assert-len, r=KodrAus

Improve design of `assert_len`

It was discussed in the [tracking issue](https://github.com/rust-lang/rust/issues/76393#issuecomment-761765448) that `assert_len`'s name and usage are confusing. This PR improves them based on a suggestion by ``@scottmcm`` in that issue.

I also improved the documentation to make it clearer when you might want to use this method.

Old example:

```rust
let range = range.assert_len(slice.len());
```

New example:

```rust
let range = range.ensure_subset_of(..slice.len());
```

Fixes #81157

3 years agoRollup merge of #79423 - camelid:smart-punct, r=jyn514
Dylan DPC [Tue, 23 Feb 2021 01:51:42 +0000 (02:51 +0100)]
Rollup merge of #79423 - camelid:smart-punct, r=jyn514

Enable smart punctuation

Closes #76690.

3 years agoAuto merge of #81937 - ssomers:btree_drainy_refactor_9b, r=Mark-Simulacrum
bors [Tue, 23 Feb 2021 00:30:37 +0000 (00:30 +0000)]
Auto merge of #81937 - ssomers:btree_drainy_refactor_9b, r=Mark-Simulacrum

BTree: move more shared iterator code into navigate.rs

The functions in navigate.rs only exist to support iterators, and these look easier on my eyes if there is a shared `struct` with the recurring pair of handles.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #81978 - tmiasko:head-ctor, r=Mark-Simulacrum
bors [Mon, 22 Feb 2021 21:45:50 +0000 (21:45 +0000)]
Auto merge of #81978 - tmiasko:head-ctor, r=Mark-Simulacrum

Inline hot part of PatStack::head_ctor

When building rustc with `-Codegen-units=1` this inline hint ensures
that obtaining already initialized head constructor does not involve
a function call overhead and reduces the instruction count in
match-stress-enum-check full benchmark from 11.9G to 9.8G.

It shouldn't have significant impact on the currently default
configuration where it reflects existing inlining decisions.

3 years agoNew mir-opt pass to simplify gotos with const values
Simon Vandel Sillesen [Sat, 3 Oct 2020 09:18:24 +0000 (11:18 +0200)]
New mir-opt pass to simplify gotos with const values

Fixes #77355

3 years agoAvoid `cfg_if` in `std::os`
Jonas Schievink [Wed, 10 Feb 2021 18:35:35 +0000 (19:35 +0100)]
Avoid `cfg_if` in `std::os`

3 years agoRemove many RefCells from DocContext
Camelid [Fri, 19 Feb 2021 22:27:30 +0000 (14:27 -0800)]
Remove many RefCells from DocContext

I left some of them so this change doesn't balloon in size and because
removing the RefCell in `DocContext.resolver` would require compiler
changes.

Thanks to `@jyn514` for making this a lot easier with #82020!

3 years agoAuto merge of #81362 - ssomers:btree_drainy_refactor_8, r=Mark-Simulacrum
bors [Mon, 22 Feb 2021 17:56:43 +0000 (17:56 +0000)]
Auto merge of #81362 - ssomers:btree_drainy_refactor_8, r=Mark-Simulacrum

BTreeMap: gather and decompose reusable tree fixing functions

This is kind of pushing it as a standalone refactor, probably only useful for #81075 (or similar).
r? `@Mark-Simulacrum`

3 years agoFix mir-cfg dumps
Ömer Sinan Ağacan [Sun, 21 Feb 2021 08:15:37 +0000 (11:15 +0300)]
Fix mir-cfg dumps

Fixes #81918
Fixes #82326 (duplicate)
Fixes #82325

3 years agoAdd impl `Error` for `Arc`
Richard Dodd [Mon, 22 Feb 2021 12:49:42 +0000 (12:49 +0000)]
Add impl `Error` for `Arc`

3 years agoAuto merge of #77551 - simonvandel:extend-simplify-branch-same, r=oli-obk
bors [Mon, 22 Feb 2021 12:14:23 +0000 (12:14 +0000)]
Auto merge of #77551 - simonvandel:extend-simplify-branch-same, r=oli-obk

MIR-OPT: Pass to deduplicate blocks

This pass finds basic blocks that are completely equal,
and replaces all uses with just one of them.

```bash
$ RUSTC_LOG=rustc_mir::transform::deduplicate_blocks ./x.py build --stage 2 | grep "SUCCESS: Replacing: " > log
...
$ cat log | wc -l
23875
```

3 years agoSimplify Error Handling.
Nixon Enraght-Moony [Mon, 22 Feb 2021 10:33:33 +0000 (10:33 +0000)]
Simplify Error Handling.

3 years agoAuto merge of #82393 - JohnTitor:rollup-5c8jryl, r=JohnTitor
bors [Mon, 22 Feb 2021 09:33:31 +0000 (09:33 +0000)]
Auto merge of #82393 - JohnTitor:rollup-5c8jryl, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #82098 (Add internal `collect_into_array[_unchecked]` to remove duplicate code)
 - #82228 (Provide NonZero_c_* integers)
 - #82287 (Make "missing field" error message more natural)
 - #82351 (Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions)
 - #82353 (rustdoc: Remove unnecessary `Cell` around `param_env`)
 - #82367 (remove redundant option/result wrapping of return values)
 - #82372 (improve UnsafeCell docs)
 - #82379 (Fix sizes of repr(C) enums on hexagon)
 - #82382 (rustdoc: Remove `fake_def_ids` RefCell)

Failed merges:

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

3 years agoRollup merge of #82382 - camelid:remove-fake_def_ids-refcell, r=jyn514
Yuki Okushi [Mon, 22 Feb 2021 09:26:14 +0000 (18:26 +0900)]
Rollup merge of #82382 - camelid:remove-fake_def_ids-refcell, r=jyn514

rustdoc: Remove `fake_def_ids` RefCell

3 years agoRollup merge of #82379 - nagisa:nagisa/hexagon-enums, r=estebank
Yuki Okushi [Mon, 22 Feb 2021 09:26:13 +0000 (18:26 +0900)]
Rollup merge of #82379 - nagisa:nagisa/hexagon-enums, r=estebank

Fix sizes of repr(C) enums on hexagon

Enums on hexagon use a smallest size (but at least 1 byte) that fits all
the enumeration values. This is unlike many other ABIs where enums are
at least 32 bits.

Fixes #82100

3 years agoRollup merge of #82372 - RalfJung:unsafe-cell, r=KodrAus
Yuki Okushi [Mon, 22 Feb 2021 09:26:11 +0000 (18:26 +0900)]
Rollup merge of #82372 - RalfJung:unsafe-cell, r=KodrAus

improve UnsafeCell docs

Sometimes [questions like this come up](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/UnsafeCells.20as.20raw.20pointers) because the UnsafeCell docs say "it's the only legal way to obtain aliasable data that is considered mutable". That is not entirely correct, since raw pointers also provide that option. So I propose we focus the docs on the interaction of `UnsafeCell` and *shared references* specifically, which is really where they are needed.

3 years agoRollup merge of #82367 - matthiaskrgr:wraps, r=petrochenkov
Yuki Okushi [Mon, 22 Feb 2021 09:26:10 +0000 (18:26 +0900)]
Rollup merge of #82367 - matthiaskrgr:wraps, r=petrochenkov

remove redundant option/result wrapping of return values

If a function always returns `Ok(something)`, we can return `something` directly and remove the corresponding error handling in the callers.
clippy::unnecessary_wraps

3 years agoRollup merge of #82353 - camelid:no-more-param_env-cell, r=jyn514
Yuki Okushi [Mon, 22 Feb 2021 09:26:09 +0000 (18:26 +0900)]
Rollup merge of #82353 - camelid:no-more-param_env-cell, r=jyn514

rustdoc: Remove unnecessary `Cell` around `param_env`

r? `@jyn514`

3 years agoRollup merge of #82351 - notriddle:docs-meta-description, r=jyn514
Yuki Okushi [Mon, 22 Feb 2021 09:26:08 +0000 (18:26 +0900)]
Rollup merge of #82351 - notriddle:docs-meta-description, r=jyn514

Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions

Partially addresses #82283.

3 years agoRollup merge of #82287 - r00ster91:field_name_and, r=petrochenkov
Yuki Okushi [Mon, 22 Feb 2021 09:26:07 +0000 (18:26 +0900)]
Rollup merge of #82287 - r00ster91:field_name_and, r=petrochenkov

Make "missing field" error message more natural

```rust
struct A {
    x: i32,
    y: i32,
    z: i32,
}

fn main() {
    A { };
}
```
```
error[E0063]: missing fields `x`, `y`, `z` in initializer of `A`
 --> src/main.rs:8:5
  |
8 |     A { };
  |     ^ missing `x`, `y`, `z`
```
This error is now:
```
error[E0063]: missing fields `x`, `y` and `z` in initializer of `A`
 --> src/main.rs:8:5
  |
8 |     A { };
  |     ^ missing `x`, `y` and `z`
```
I thought it looked nicer and more natural this way. Also, if there is >3 fields missing, there is an "and" as well ("missing \`x\`, \`y\`, \`z\` *and* 1 other field"), but for <=3 there is not. As such it improves consistency too.

As for the implementation, originally I ended up with a chunky `push_str` algorithm but then I figured I could just do the formatting manually since it's just 3 field names at maximum. It is comparatively readable.

As a sidenote, one thing I was wondering about is, isn't there more cases where you have a list of things like field names? Maybe this whole thing can at some point later be made into a more general function to be used in multiple areas.

3 years agoRollup merge of #82228 - ijackson:nonzero-cint, r=KodrAus
Yuki Okushi [Mon, 22 Feb 2021 09:26:06 +0000 (18:26 +0900)]
Rollup merge of #82228 - ijackson:nonzero-cint, r=KodrAus

Provide NonZero_c_* integers

I'm pretty sure I am going want this for #73125 and it seems like an
omission that would be in any case good to remedy.

<strike>Because the raw C types are in `std`, not `core`, to achieve this we
must export the relevant macros from `core` so that `std` can use
them.  That's done with a new `num_internals` perma-unstable feature.

The macros need to take more parameters for the module to get the
types from and feature attributes to use.

I have eyeballed the docs output for core, to check that my changes to
these macros have made no difference to the core docs output.</strike>

3 years agoRollup merge of #82098 - LukasKalbertodt:add-collect-into-array, r=dtolnay
Yuki Okushi [Mon, 22 Feb 2021 09:26:04 +0000 (18:26 +0900)]
Rollup merge of #82098 - LukasKalbertodt:add-collect-into-array, r=dtolnay

Add internal `collect_into_array[_unchecked]` to remove duplicate code

Unlike the similar PRs  #69985, #75644 and #79659, this PR only adds private functions and does not propose any new public API. The change is just for the purpose of avoiding duplicate code.

Many array methods already contained the same kind of code and there are still many array related methods to come (e.g. `Iterator::{chunks, map_windows, next_n, ...}`, `[T; N]::{cloned, copied, ...}`, ...) which all basically need this functionality. Writing custom `unsafe` code for each of those doesn't seem like a good idea. I added two functions in this PR (and not just the `unsafe` version) because I already know that I need the `Option`-returning version for `Iterator::map_windows`.

This is closely related to https://github.com/rust-lang/rust/issues/81615. I think that all options listed in that issue can be implemented using the function added in this PR. The only instance where `collect_array_into` might not be general enough is when the caller want to handle incomplete arrays manually. Currently, if `iter` yields fewer than `N` items, `None` is returned and the already yielded items are dropped. But as this is just a private function, it can be made more general in future PRs.

And while this was not the goal, this seems to lead to better assembly for `array::map`: https://rust.godbolt.org/z/75qKTa (CC ``@JulianKnodt)``

Let me know what you think :)

CC ``@matklad`` ``@bstrie``

3 years agodisable atomic_max/min tests in Miri
Ralf Jung [Mon, 22 Feb 2021 08:41:20 +0000 (09:41 +0100)]
disable atomic_max/min tests in Miri

3 years agoExtract deref coercion explanation into method
1000teslas [Mon, 22 Feb 2021 08:08:44 +0000 (19:08 +1100)]
Extract deref coercion explanation into method

3 years agofix rebase
Esteban Küber [Mon, 22 Feb 2021 00:54:42 +0000 (16:54 -0800)]
fix rebase

3 years agoAuto merge of #79979 - GuillaumeGomez:rustdoc-gui-tests, r=Mark-Simulacrum
bors [Mon, 22 Feb 2021 06:47:59 +0000 (06:47 +0000)]
Auto merge of #79979 - GuillaumeGomez:rustdoc-gui-tests, r=Mark-Simulacrum

Rustdoc gui tests

This is a reopening of #70533.

For this first version, there will be no screenshot comparison. Also, a big change compared to the previous version: the tests are now hosted in the rust repository directly. Since there is no image, it's pretty lightweight to say the least.

So now, only remains the nodejs script to run the tests and the tests themselves. Just one thing is missing: where should I put the documentation for these tests? I'm not sure where would be the best place for that. The doc will contain important information like the documentation of the framework used and how to install it (`npm install browser-ui-test`, but still needs to be put somewhere so no one is lost).

We'd also need to install the package when running the CI too. For now, it runs as long as we have nodejs installed, but I think we don't it to run in all nodejs targets?

cc `@jyn514`

r? `@Mark-Simulacrum`

3 years agoAuto merge of #81732 - m-ou-se:inherit-overflow-checks, r=Mark-Simulacrum
bors [Mon, 22 Feb 2021 04:07:05 +0000 (04:07 +0000)]
Auto merge of #81732 - m-ou-se:inherit-overflow-checks, r=Mark-Simulacrum

Use `#[rustc_inherit_overflow_checks]` instead of Add::add etc.

See https://github.com/rust-lang/rust/issues/81721

3 years agorustdoc: Remove `fake_def_ids` RefCell
Camelid [Mon, 22 Feb 2021 01:52:23 +0000 (17:52 -0800)]
rustdoc: Remove `fake_def_ids` RefCell

3 years agotidy
Esteban Küber [Fri, 5 Feb 2021 19:34:55 +0000 (11:34 -0800)]
tidy

3 years agoDo not suggest `;` if expression is side effect free
Esteban Küber [Fri, 5 Feb 2021 01:36:06 +0000 (17:36 -0800)]
Do not suggest `;` if expression is side effect free

When a tail expression isn't unit, we previously always suggested adding
a trailing `;` to turn it into a statement. This suggestion isn't
appropriate for any expression that doesn't have side-effects, as the
user will have likely wanted to call something else or do something with
the resulting value, instead of just discarding it.

3 years agoreword `;` suggestions to have consistent wording
Esteban Küber [Thu, 4 Feb 2021 21:59:23 +0000 (13:59 -0800)]
reword `;` suggestions to have consistent wording

3 years agoSuggest `return`ing tail expressions that match return type
Esteban Küber [Thu, 4 Feb 2021 20:22:01 +0000 (12:22 -0800)]
Suggest `return`ing tail expressions that match return type

Some newcomers are confused by the behavior of tail expressions,
interpreting that "leaving out the `;` makes it the return value".
To help them go in the right direction, suggest using `return` instead
when applicable.

3 years agoAuto merge of #82295 - jyn514:feature-gate, r=Manishearth
bors [Mon, 22 Feb 2021 00:04:09 +0000 (00:04 +0000)]
Auto merge of #82295 - jyn514:feature-gate, r=Manishearth

[intra-doc links] Don't check feature gates of items re-exported across crates

It should be never break another crate to re-export a public item.

Note that this doesn't check the feature gate at
*all* for other crates:

- Feature-gates aren't currently serialized, so the only way to check
  the gate is with ad-hoc attribute checking.
- Checking the feature gate twice (once when documenting the original
  crate and one when documenting the current crate) seems not great.

This should still catch using the feature most of the time though, since
people tend to document their own crates.

Closes https://github.com/rust-lang/rust/issues/82284.

r? `@Manishearth`

3 years agoFix sizes of repr(C) enums on hexagon
Simonas Kazlauskas [Sun, 21 Feb 2021 22:22:15 +0000 (00:22 +0200)]
Fix sizes of repr(C) enums on hexagon

Enums on hexagon use a smallest size (but at least 1 byte) that fits all
the enumeration values. This is unlike many other ABIs where enums are
at least 32 bits.

3 years agoNew pass to deduplicate blocks
Simon Vandel Sillesen [Sun, 4 Oct 2020 13:52:14 +0000 (15:52 +0200)]
New pass to deduplicate blocks