]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoImplementation of build.print_step_rusage.
Felix S. Klock II [Fri, 19 Feb 2021 18:27:39 +0000 (13:27 -0500)]
Implementation of build.print_step_rusage.

On non-unix platforms, does not try to call `getrusage` (and does not attempt to
implement its own shim; that could be follow-on work, though its probably best
to not invest too much effort there, versus using separate dedicated tooling).

On unix platforms, calls libc::rusage and attempts to emit the subset of fields
that are supported on Linux and Mac OS X. Omits groups of related stats which
appear to be unsupported on the platform (due to them all remaining zero).

Adjusts output to compensate for Mac using bytes instead of kb (a well known
discrepancy on Mac OS X). However, so far I observe a lot of strange values
(orders of magnitude wrong) reported on Mac OS X in some cases, so I would not
trust this in that context currently.

3 years agoCreated experimental build.print_step_rusage setting
Felix S. Klock II [Fri, 19 Feb 2021 18:25:26 +0000 (13:25 -0500)]
Created experimental build.print_step_rusage setting

Intended to piggy-back on output from existing build.print_step_timings setting.

3 years agoAuto merge of #82265 - GuillaumeGomez:cleanup-attrs-twice, r=jyn514
bors [Thu, 25 Feb 2021 12:33:21 +0000 (12:33 +0000)]
Auto merge of #82265 - GuillaumeGomez:cleanup-attrs-twice, r=jyn514

Prevent to compute Item attributes twice

I came across this case when working on another part of rustdoc. Not a game changer but a nice little improvement.

cc `@camelid`

r? `@jyn514`

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 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 agoMake DocContext &mut for clean
Guillaume Gomez [Wed, 24 Feb 2021 09:16:33 +0000 (10:16 +0100)]
Make DocContext &mut for clean

3 years agoPrevent to compute Item attributes twice
Guillaume Gomez [Thu, 18 Feb 2021 16:29:44 +0000 (17:29 +0100)]
Prevent to compute Item attributes twice

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 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 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 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 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 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 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 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

3 years agoMake MatchBranchSimplification clean up after itself
Simon Vandel Sillesen [Sun, 4 Oct 2020 16:12:20 +0000 (18:12 +0200)]
Make MatchBranchSimplification clean up after itself

3 years agoDrive-by formatting of comment
Simon Vandel Sillesen [Sun, 4 Oct 2020 08:26:29 +0000 (10:26 +0200)]
Drive-by formatting of comment

3 years agoExtract string_to_value to its own function
Nixon Enraght-Moony [Sun, 21 Feb 2021 20:10:57 +0000 (20:10 +0000)]
Extract string_to_value to its own function

3 years agoApply suggestions from code review
Nixon Enraght-Moony [Sun, 21 Feb 2021 19:45:32 +0000 (19:45 +0000)]
Apply suggestions from code review

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoremove redundant wrapping of return types of allow_internal_unstable() and rustc_allo...
Matthias Krüger [Sun, 21 Feb 2021 17:11:27 +0000 (18:11 +0100)]
remove redundant wrapping of return types of allow_internal_unstable() and rustc_allow_const_fn_unstable()

3 years agoUpdate src/test/rustdoc/description.rs
Michael Howell [Sun, 21 Feb 2021 16:31:39 +0000 (09:31 -0700)]
Update src/test/rustdoc/description.rs

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoUpdate src/test/rustdoc/description.rs
Michael Howell [Sun, 21 Feb 2021 16:31:23 +0000 (09:31 -0700)]
Update src/test/rustdoc/description.rs

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoimprove UnsafeCell docs
Ralf Jung [Sun, 21 Feb 2021 16:24:19 +0000 (17:24 +0100)]
improve UnsafeCell docs

3 years agoUpdate CI scripts
Guillaume Gomez [Sun, 21 Feb 2021 13:27:22 +0000 (14:27 +0100)]
Update CI scripts

3 years agoAdd rustdoc gui tests
Guillaume Gomez [Sun, 21 Feb 2021 13:25:12 +0000 (14:25 +0100)]
Add rustdoc gui tests

3 years agoIgnore nodejs/npm files
Guillaume Gomez [Sun, 21 Feb 2021 13:21:38 +0000 (14:21 +0100)]
Ignore nodejs/npm files

3 years agoAdd new rustdoc-gui test suite
Guillaume Gomez [Sun, 21 Feb 2021 13:21:04 +0000 (14:21 +0100)]
Add new rustdoc-gui test suite

3 years agorustc_mir: remove redundant wrapping of return type in numeric_intrinsic()
Matthias Krüger [Sun, 21 Feb 2021 12:44:16 +0000 (13:44 +0100)]
rustc_mir: remove redundant wrapping of return type in numeric_intrinsic()

3 years agorustc_codegen_ssa: remove unneeded wrapping of return type of execute_copy_from_cache...
Matthias Krüger [Sun, 21 Feb 2021 12:40:39 +0000 (13:40 +0100)]
rustc_codegen_ssa: remove unneeded wrapping of return type of execute_copy_from_cache_work_item (always returns Ok(..))

3 years agoremove redundant return value Ok(()) of clear_relocations()
Matthias Krüger [Sun, 21 Feb 2021 12:25:28 +0000 (13:25 +0100)]
remove redundant return value Ok(()) of clear_relocations()

3 years agoparser: remove unneccessary wrapping of return value in parse_extern()
Matthias Krüger [Sun, 21 Feb 2021 12:06:00 +0000 (13:06 +0100)]
parser: remove unneccessary wrapping of return value in parse_extern()

3 years agoAuto merge of #82359 - JohnTitor:rollup-6puemik, r=JohnTitor
bors [Sun, 21 Feb 2021 12:23:45 +0000 (12:23 +0000)]
Auto merge of #82359 - JohnTitor:rollup-6puemik, r=JohnTitor

Rollup of 11 pull requests

Successful merges:

 - #81300 (BTree: share panicky test code & test panic during clear, clone)
 - #81706 (Document BinaryHeap unsafe functions)
 - #81833 (parallelize x.py test tidy)
 - #81966 (Add new `rustc` target for Arm64 machines that can target the iphonesimulator)
 - #82154 (Update RELEASES.md 1.50 to include methods stabilized in #79342)
 - #82177 (Do not delete bootstrap.exe on Windows during clean)
 - #82181 (Add check for ES5 in CI)
 - #82229 (Add [A-diagnostics] bug report template)
 - #82233 (try-back-block-type test: Use TryFromSliceError for From test)
 - #82302 (Remove unsafe impl Send for CompletedTest & TestResult)
 - #82349 (test: Print test name only once on timeout)

Failed merges:

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

3 years agoremove unneccessary wrapping of return value in mk_await_expr()
Matthias Krüger [Sun, 21 Feb 2021 12:01:01 +0000 (13:01 +0100)]
remove unneccessary wrapping of return value in mk_await_expr()

3 years agorustc_parse: remove unneccessary wrapping of return value in fn mk_range() which...
Matthias Krüger [Sun, 21 Feb 2021 11:54:49 +0000 (12:54 +0100)]
rustc_parse: remove unneccessary wrapping of return value in fn mk_range() which would always return Ok(..)

3 years agoremove unneccessary wrapping of return value of allow_unstable(), it would always...
Matthias Krüger [Sun, 21 Feb 2021 11:52:51 +0000 (12:52 +0100)]
remove unneccessary wrapping of return value of allow_unstable(), it would always return Some(thing)

3 years agoSimplify hashing.
Camille GILLOT [Tue, 9 Feb 2021 17:53:38 +0000 (18:53 +0100)]
Simplify hashing.

3 years agoupdate tracking issue for raw_os_nonzero
Ashley Mannix [Sun, 21 Feb 2021 09:43:42 +0000 (19:43 +1000)]
update tracking issue for raw_os_nonzero

3 years agoAuto merge of #82340 - kennytm:fix-82254, r=Mark-Simulacrum
bors [Sun, 21 Feb 2021 09:42:50 +0000 (09:42 +0000)]
Auto merge of #82340 - kennytm:fix-82254, r=Mark-Simulacrum

Fix some Python2→3 error in publish_toolstate.py

Fix #82254.

The error is primarily due to `data = json.dumps(…)` producing a `str` instead of a `bytes`, which are different types on Python 3. But then `urllib.request.urlopen(…, data)` cannot accept `data` as a `str`, thus the error.

This PR added `.encode()` call after `json.dumps()` to ensure we are sending `bytes`. Additionally, we added type annotation to ensure things can statically type-check with `mypy` on both Python 2 and 3.

3 years agoRollup merge of #82349 - tmiasko:pretty-test-timeout, r=Mark-Simulacrum
Yuki Okushi [Sun, 21 Feb 2021 06:26:50 +0000 (15:26 +0900)]
Rollup merge of #82349 - tmiasko:pretty-test-timeout, r=Mark-Simulacrum

test: Print test name only once on timeout

Pretty formatter when using multiple test threads displays test name twice on
timeout event. This implicitly suggest that those are two different events,
while in fact they are always printed together.

Print test name only once.

Before:

```
running 3 tests
test src/lib.rs - c (line 16) ... ok
test src/lib.rs - a (line 3) ... ok
test src/lib.rs - b (line 9) ... test src/lib.rs - b (line 9) has been running for over 60 seconds
test src/lib.rs - b (line 9) ... ok
```

After:

```
running 3 tests
test src/lib.rs - c (line 16) ... ok
test src/lib.rs - a (line 3) ... ok
test src/lib.rs - b (line 9) has been running for over 60 seconds
test src/lib.rs - b (line 9) ... ok
```