]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoBuild StKind::CopyOverlapping
kadmin [Sat, 23 Jan 2021 03:55:41 +0000 (03:55 +0000)]
Build StKind::CopyOverlapping

This replaces where it was previously being constructed in intrinsics, with direct construction
of the Statement.

3 years agoChange CopyNonOverlapping::codegen_ssa
kadmin [Sat, 23 Jan 2021 02:28:08 +0000 (02:28 +0000)]
Change CopyNonOverlapping::codegen_ssa

Fixes copy_non_overlapping codegen_ssa to properly handle pointees,
and use bytes instead of elem count

3 years agoReplace todos with impls
kadmin [Sat, 23 Jan 2021 00:23:13 +0000 (00:23 +0000)]
Replace todos with impls

Changed to various implementations, copying the style of prior function calls in places I was
unsure of.

Also one minor style nit.

3 years agoUpdate cranelift
kadmin [Tue, 29 Dec 2020 02:00:04 +0000 (02:00 +0000)]
Update cranelift

3 years agoUpdate interpret step
kadmin [Sat, 7 Nov 2020 00:49:55 +0000 (00:49 +0000)]
Update interpret step

3 years agoUpdate match branches
kadmin [Mon, 5 Oct 2020 22:53:00 +0000 (22:53 +0000)]
Update match branches

This updates all places where match branches check on StatementKind or UseContext.
This doesn't properly implement them, but adds TODOs where they are, and also adds some best
guesses to what they should be in some cases.

3 years agoUpdate fmt and use of memcpy
kadmin [Mon, 5 Oct 2020 20:13:36 +0000 (20:13 +0000)]
Update fmt and use of memcpy

I'm still not totally sure if this is the right way to implement the memcpy, but that portion
compiles correctly now. Now to fix the compile errors everywhere else :).

3 years agoImpl StatementKind::CopyNonOverlapping
kadmin [Sat, 3 Oct 2020 20:57:47 +0000 (20:57 +0000)]
Impl StatementKind::CopyNonOverlapping

3 years agoAuto merge of #82929 - m-ou-se:rollup-7fwrewh, r=m-ou-se
bors [Tue, 9 Mar 2021 09:43:55 +0000 (09:43 +0000)]
Auto merge of #82929 - m-ou-se:rollup-7fwrewh, r=m-ou-se

Rollup of 8 pull requests

Successful merges:

 - #81127 (Improve sift_down performance in BinaryHeap)
 - #81879 (Added #[repr(transparent)] to core::cmp::Reverse)
 - #82048 (or-patterns: disallow in `let` bindings)
 - #82731 (Bump libc dependency of std to 0.2.88.)
 - #82799 (Add regression test for #75525)
 - #82841 (Change x64 size checks to not apply to x32.)
 - #82883 (Update Cargo)
 - #82887 (Update CONTRIBUTING.md)

Failed merges:

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

3 years agoRollup merge of #82887 - henryboisdequin:improve-contributing-md, r=joshtriplett
Mara Bos [Tue, 9 Mar 2021 09:05:27 +0000 (09:05 +0000)]
Rollup merge of #82887 - henryboisdequin:improve-contributing-md, r=joshtriplett

Update CONTRIBUTING.md

Fixes #77215

As mentioned in #77215, the current CONTRIBUTING.md links to the rustc-dev-guide.
Even though the rustc-dev-guide has lots of useful information for contributors,
one is already confused by reading the first line of the current CONTRIBUTING.md.

> To get started, read the [Getting Started] guide in the [rustc-dev-guide].

This line tells the contributor to go and read the rustc-dev-guide. What is
the rustc-dev-guide? What does rustc even mean? These are some of the
questions that went into my head when reading this line as a first-time
contributor. By explaining what the rustc-dev-guide is and some platforms
to get help, a new contributor understands what the first step is and the process
is much clearer. The `About the [rustc-dev-guide]` section explains what
the rustc-dev-guide is, what rustc is, and the purpose out of reading the
guide. The `Getting help` section points the user to some places where
they can get help, find a mentor, and introduce themselves.

3 years agoRollup merge of #82883 - Aaron1011:update-cargo, r=ehuss
Mara Bos [Tue, 9 Mar 2021 09:05:25 +0000 (09:05 +0000)]
Rollup merge of #82883 - Aaron1011:update-cargo, r=ehuss

Update Cargo

Output of `git log --oneline  c68432f1e..970bc67c3`:

970bc67c3 (HEAD, origin/master, origin/auto-cargo, origin/HEAD) Auto merge of #9243 - wickerwaka:configurable-env-doc, r=ehuss
4d7a29b75 Document the configurable-env usntable option
f7a7a3f91 Auto merge of #9229 - alexcrichton:fix-borrow-mut, r=ehuss
3f2ece7a9 Fix a `BorrowMut` error when stdout is closed
7441e8c23 Auto merge of #8825 - Aaron1011:feature/report-future-incompat, r=ehuss
139ed73f5 Add future-incompat tracking issue number.
9ea350368 Fix some minor formatting issues.
f03d47ce4 Address review comments
6177c6584 Implement future incompatibility report support
c69409658 Auto merge of #9022 - nagisa:nagisa/manifest_path, r=alexcrichton
548300b20 Add the path to the manifest in json output
99e714c05 Auto merge of #9230 - kornelski:nobinaries, r=alexcrichton
61a31bc5f Auto merge of #9236 - kornelski:track-assert, r=Eh2406
3f7f0942c track_caller on custom assert functions
6977dee10 Explain `cargo install` is not for libraries
e4aebf0a0 Auto merge of #9231 - joshtriplett:clear-to-eol-if-color, r=alexcrichton
b219f0eb7 Auto merge of #9181 - jyn514:computer-says-no, r=ehuss
0b1816578 Remove unhelpful link to Cargo book
ea46f5ce3 Use ANSI clear-to-EOL if color is force-enabled
a6394bcc1 Remove unnecessary `config` argument to `Features::add`
3a86ecf2d Fix TODO about nightly features
09677c83c Be less unix-centric in error messages
ecfdced0d Fix test that assumed tests always were run on the stable channel
eba541994 Update comment in build_script_env
a5720117f Make `nightly_features_allowed` a field instead of a function
169b09ce7 Compute `enable_nightly_features` once instead of on each call
8fc86e155 Remove unused thread_locals
4b096beae Fix `masquerade_as_nightly_cargo` in work threads
e56417c8c Suggest RUSTC_BOOTSTRAP=crate instead of RUSTC_BOOTSTRAP=1
418129dae Downgrade error to a warning when `RUSTC_BOOTSTRAP` is set or this is the nightly channel
6c422a2c0 Restrict RUSTC_BOOTSTRAP in build.rs

3 years agoRollup merge of #82841 - hvdijk:x32, r=joshtriplett
Mara Bos [Tue, 9 Mar 2021 09:05:24 +0000 (09:05 +0000)]
Rollup merge of #82841 - hvdijk:x32, r=joshtriplett

Change x64 size checks to not apply to x32.

Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.

3 years agoRollup merge of #82799 - bugadani:codegen-tests, r=nagisa
Mara Bos [Tue, 9 Mar 2021 09:05:23 +0000 (09:05 +0000)]
Rollup merge of #82799 - bugadani:codegen-tests, r=nagisa

Add regression test for #75525

3 years agoRollup merge of #82731 - de-vri-es:bump-libc-for-std, r=Mark-Simulacrum
Mara Bos [Tue, 9 Mar 2021 09:05:22 +0000 (09:05 +0000)]
Rollup merge of #82731 - de-vri-es:bump-libc-for-std, r=Mark-Simulacrum

Bump libc dependency of std to 0.2.88.

This PR bumps the `libc` dependency of `std` to 0.2.88. This will fix `TcpListener::accept` for Android on x86 platforms (https://github.com/rust-lang/libc/commit/31a2777d8f72db9eb3c3105f13afa94a47ca90d5).

This will really finally fix https://github.com/rust-lang/rust/issues/82400 for the main branch :)

r? ``@JohnTitor``

3 years agoRollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov
Mara Bos [Tue, 9 Mar 2021 09:05:20 +0000 (09:05 +0000)]
Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov

or-patterns: disallow in `let` bindings

~~Blocked on https://github.com/rust-lang/rust/pull/81869~~

Disallows top-level or-patterns before type ascription. We want to reserve this syntactic space for possible future generalized type ascription.

r? ``@petrochenkov``

3 years agoRollup merge of #81879 - imbrem:make-reverse-repr-transparent, r=m-ou-se
Mara Bos [Tue, 9 Mar 2021 09:05:19 +0000 (09:05 +0000)]
Rollup merge of #81879 - imbrem:make-reverse-repr-transparent, r=m-ou-se

Added #[repr(transparent)] to core::cmp::Reverse

I found casting from an `&T` to an `&Reverse<T>` potentially useful, but found that `Reverse` was not `#[repr(transparent)]`, so after asking about it [on Reddit](https://www.reddit.com/r/rust/comments/le60uv/make_stdcmpreverse_reprtransparent_and_add_a/), I decided to go ahead and make a pull request which simply adds the attribute to the struct.

3 years agoRollup merge of #81127 - hanmertens:binary_heap_sift_down_perf, r=dtolnay
Mara Bos [Tue, 9 Mar 2021 09:05:18 +0000 (09:05 +0000)]
Rollup merge of #81127 - hanmertens:binary_heap_sift_down_perf, r=dtolnay

Improve sift_down performance in BinaryHeap

Replacing `child < end - 1` with `child <= end.saturating_sub(2)` in `BinaryHeap::sift_down_range` (surprisingly) results in a significant speedup of `BinaryHeap::into_sorted_vec`. The same substitution can be done for `BinaryHeap::sift_down_to_bottom`, which causes a slight but probably statistically insignificant speedup for `BinaryHeap::pop`. It's interesting that benchmarks aside from `bench_into_sorted_vec` are barely affected, even those that do use `sift_down_*` methods internally.

| Benchmark                | Before (ns/iter) | After (ns/iter) | Speedup |
|--------------------------|------------------|-----------------|---------|
| bench_find_smallest_1000<sup>1</sup> | 392,617          | 385,200         |    1.02 |
| bench_from_vec<sup>1</sup>           | 506,016          | 504,444         |    1.00 |
| bench_into_sorted_vec<sup>1</sup>    | 476,869          | 384,458         |    1.24 |
| bench_peek_mut_deref_mut<sup>3</sup> | 518,753          | 519,792         |    1.00 |
| bench_pop<sup>2</sup>                | 446,718          | 444,409         |    1.01 |
| bench_push<sup>3</sup>               | 772,481          | 770,208         |    1.00 |

<sup>1</sup>: internally calls `sift_down_range`
<sup>2</sup>: internally calls `sift_down_to_bottom`
<sup>3</sup>: should not be affected

3 years agoAuto merge of #82356 - camelid:render-cleanup, r=GuillaumeGomez
bors [Tue, 9 Mar 2021 04:33:43 +0000 (04:33 +0000)]
Auto merge of #82356 - camelid:render-cleanup, r=GuillaumeGomez

rustdoc: Cleanup `html::render::Context`

- Move most shared fields to `SharedContext` (except for `cache`, which
  isn't mutated anyway)
- Replace a use of `Arc` with `Rc`
- Make a bunch of fields private
- Add static size assertion for `Context`
- Don't share `id_map` and `deref_id_map`

3 years agoMake opening sentence friendlier for new contributors
Henry Boisdequin [Tue, 9 Mar 2021 02:55:41 +0000 (08:25 +0530)]
Make opening sentence friendlier for new contributors

Co-authored-by: Camelid <camelidcamel@gmail.com>
3 years agoUpdate CONTRIBUTING.md
Henry Boisdequin [Mon, 8 Mar 2021 05:56:05 +0000 (11:26 +0530)]
Update CONTRIBUTING.md

Fixes #77215

As mentioned in #77215, the current CONTRIBUTING.md links to the rustc-dev-guide.
Even though the rustc-dev-guide has lots of useful information for contributors,
one is already confused by reading the first line of the current CONTRIBUTING.md.

> To get started, read the [Getting Started] guide in the [rustc-dev-guide].

This line tells the contributor to go and read the rustc-dev-guide. What is
the rustc-dev-guide? What does rustc even mean? These are some of the
questions that went into my head when reading this line as a first time
contributor. By explaining what the rustc-dev-guide is and some platforms
to get help, a new contributor understands what the first step is and the process
is much clearer. The `About the [rustc-dev-guide]` section explains what
the rustc-dev-guide is, what rustc is, and the purpose out of reading the
guide. The `Getting help` section points the user to some places where
they can get help, find a mentor, and introduce themsevles.

3 years agoAuto merge of #82911 - m-ou-se:rollup-rjomgja, r=m-ou-se
bors [Tue, 9 Mar 2021 01:47:39 +0000 (01:47 +0000)]
Auto merge of #82911 - m-ou-se:rollup-rjomgja, r=m-ou-se

Rollup of 11 pull requests

Successful merges:

 - #82711 (Add documentation for string->Cow conversions)
 - #82767 (Update minifier dependency version)
 - #82800 (Move rustdoc UI tests into a subdirectory)
 - #82810 (Typo fix in Unstable book: `cargo cov` -> `cargo profdata`)
 - #82829 (Handle negative literals in cast overflow warning)
 - #82854 (Account for `if (let pat = expr) {}`)
 - #82870 (Add note about the `#[doc(no-inline)]` usage)
 - #82874 (Add codegen tests for some issues closed by LLVM 12)
 - #82881 (diagnostics: Be clear about "crate root" and `::foo` paths in resolve diagnostics)
 - #82888 (Grammar Fixes)
 - #82897 ([.mailmap] Add entry for Ramkumar Ramachandra)

Failed merges:

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

3 years agoAuto merge of #82877 - ehuss:revert-rwlock, r=m-ou-se
bors [Mon, 8 Mar 2021 22:53:20 +0000 (22:53 +0000)]
Auto merge of #82877 - ehuss:revert-rwlock, r=m-ou-se

Revert switch of env locking to rwlock, to fix deadlock in process spawning

This reverts commit 354f19cf2475148994954b6783341620c7445071, reversing changes made to 0cfba2fd090834c909d5ed9deccdee8170da791b.

PR https://github.com/rust-lang/rust/pull/81850 switched the environment lock from a mutex to an rwlock. However, process spawning (when not able to use `posix_spawn`) locks the environment before forking, and unlocks it after forking (in both the parent and the child). With a mutex, this works (although probably not correct even with a mutex). With an rwlock, on at least some targets, unlocking in the child does not work correctly, resulting in a deadlock.

This has manifested as CI hangs on i686 Linux; that target doesn't use `posix_spawn` in the CI environment due to the age of the installed C library (currently glibc 2.23). (Switching to `posix_spawn` would just mask this issue, though, which would still arise in any case that can't use `posix_spawn`.)

Some additional cleanup of environment handling around process spawning may help, but for now, revert the PR and go back to a standard mutex.

Fixes #82221

3 years agoclippy: fix or-pattern in let binding
mark [Mon, 8 Mar 2021 18:41:28 +0000 (12:41 -0600)]
clippy: fix or-pattern in let binding

3 years agoRollup merge of #82897 - artagnon:patch-2, r=joshtriplett
Mara Bos [Mon, 8 Mar 2021 19:09:08 +0000 (20:09 +0100)]
Rollup merge of #82897 - artagnon:patch-2, r=joshtriplett

[.mailmap] Add entry for Ramkumar Ramachandra

3 years agoRollup merge of #82888 - Daggy1234:patch-1, r=joshtriplett
Mara Bos [Mon, 8 Mar 2021 19:09:07 +0000 (20:09 +0100)]
Rollup merge of #82888 - Daggy1234:patch-1, r=joshtriplett

Grammar Fixes

Found typo's in the array rustdoc. Pr'ed a fix!

3 years agoRollup merge of #82881 - Manishearth:crate-root, r=estebank
Mara Bos [Mon, 8 Mar 2021 19:09:06 +0000 (20:09 +0100)]
Rollup merge of #82881 - Manishearth:crate-root, r=estebank

diagnostics: Be clear about "crate root" and `::foo` paths in resolve diagnostics

Various changes to make sure the diagnostics are clear about the differences in `::foo` paths across editions:

 - `::foo` will say "crate root" in 2015 and "list of imported crates" in 2018
 - `crate::` will never reference imported crates in 2018

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

3 years agoRollup merge of #82874 - erikdesjardins:cgtests, r=nagisa
Mara Bos [Mon, 8 Mar 2021 19:09:04 +0000 (20:09 +0100)]
Rollup merge of #82874 - erikdesjardins:cgtests, r=nagisa

Add codegen tests for some issues closed by LLVM 12

Namely #73031, #75546, and #77812

3 years agoRollup merge of #82870 - jfrimmel:improve-docs, r=jyn514
Mara Bos [Mon, 8 Mar 2021 19:09:03 +0000 (20:09 +0100)]
Rollup merge of #82870 - jfrimmel:improve-docs, r=jyn514

Add note about the `#[doc(no-inline)]` usage

This is required to correctly build the documentation (including all submodules, that are only available in certain targets).

See the linked issue and #82861 for reference.

3 years agoRollup merge of #82854 - estebank:issue-82827, r=oli-obk
Mara Bos [Mon, 8 Mar 2021 19:09:02 +0000 (20:09 +0100)]
Rollup merge of #82854 - estebank:issue-82827, r=oli-obk

Account for `if (let pat = expr) {}`

Fix #82827.

3 years agoRollup merge of #82829 - JohnTitor:handle-neg-val, r=estebank
Mara Bos [Mon, 8 Mar 2021 19:09:01 +0000 (20:09 +0100)]
Rollup merge of #82829 - JohnTitor:handle-neg-val, r=estebank

Handle negative literals in cast overflow warning

Closes #48535
r? `@estebank`

3 years agoRollup merge of #82810 - amaurremi:source-based-coverage-typo, r=ehuss
Mara Bos [Mon, 8 Mar 2021 19:09:00 +0000 (20:09 +0100)]
Rollup merge of #82810 - amaurremi:source-based-coverage-typo, r=ehuss

Typo fix in Unstable book: `cargo cov` -> `cargo profdata`

3 years agoRollup merge of #82800 - jyn514:group-rustdoc-tests, r=Mark-Simulacrum
Mara Bos [Mon, 8 Mar 2021 19:08:59 +0000 (20:08 +0100)]
Rollup merge of #82800 - jyn514:group-rustdoc-tests, r=Mark-Simulacrum

Move rustdoc UI tests into a subdirectory

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

3 years agoRollup merge of #82767 - GuillaumeGomez:update-minifier-crate-version, r=jyn514
Mara Bos [Mon, 8 Mar 2021 19:08:57 +0000 (20:08 +0100)]
Rollup merge of #82767 - GuillaumeGomez:update-minifier-crate-version, r=jyn514

Update minifier dependency version

Very small PR simply upgrading the minifier-rs version we use in rustdoc.

Some details might be useful: there were a few bug fixes and a lot of cleanup/code improvements.

r? `@camelid`

3 years agoRollup merge of #82711 - notriddle:string-cow-docs, r=Mark-Simulacrum
Mara Bos [Mon, 8 Mar 2021 19:08:56 +0000 (20:08 +0100)]
Rollup merge of #82711 - notriddle:string-cow-docs, r=Mark-Simulacrum

Add documentation for string->Cow conversions

Mostly, it's just to reassure everyone that these functions don't allocate.

Part of #51430

3 years agoAuto merge of #82896 - Dylan-DPC:rollup-9setmme, r=Dylan-DPC
bors [Mon, 8 Mar 2021 14:59:20 +0000 (14:59 +0000)]
Auto merge of #82896 - Dylan-DPC:rollup-9setmme, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #82047 (bypass auto_da_alloc for metadata files)
 - #82415 (expand: Refactor module loading)
 - #82557 (Add natvis for Result, NonNull, CString, CStr, and Cow)
 - #82613 (Remove Item::kind, use tagged enum. Rename variants to match)
 - #82642 (Fix jemalloc usage on OSX)
 - #82682 (Implement built-in attribute macro `#[cfg_eval]` + some refactoring)
 - #82684 (Disable destination propagation on all mir-opt-levels)
 - #82755 (Refactor confirm_builtin_call, remove partial if)
 - #82857 (Edit ructc_ast_lowering docs)
 - #82862 (Generalize Write impl for Vec<u8> to Vec<u8, A>)

Failed merges:

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

3 years agoUpdate library/core/src/array/mod.rs
Arnav Jindal [Mon, 8 Mar 2021 14:58:30 +0000 (20:28 +0530)]
Update library/core/src/array/mod.rs

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
3 years agoMove rustdoc UI tests into a subdirectory
Joshua Nelson [Fri, 5 Mar 2021 15:04:22 +0000 (10:04 -0500)]
Move rustdoc UI tests into a subdirectory

This also adds a little leeway to the test limit.

3 years ago[.mailmap] Add entry for Ramkumar Ramachandra
Ramkumar Ramachandra [Mon, 8 Mar 2021 12:40:35 +0000 (13:40 +0100)]
[.mailmap] Add entry for Ramkumar Ramachandra

3 years agoRollup merge of #82862 - athre0z:generalize-vec-write-impl, r=TimDiekmann
Dylan DPC [Mon, 8 Mar 2021 12:13:27 +0000 (13:13 +0100)]
Rollup merge of #82862 - athre0z:generalize-vec-write-impl, r=TimDiekmann

Generalize Write impl for Vec<u8> to Vec<u8, A>

As discussed in the [issue tracker for the wg-allocators working group][1], updating this impl for allocator support was most likely just forgotten previously. This PR fixes this.

r? `````@TimDiekmann`````

[1]: https://github.com/rust-lang/wg-allocators/issues/86

3 years agoRollup merge of #82857 - pierwill:edit-ast-lowering-lib, r=Dylan-DPC
Dylan DPC [Mon, 8 Mar 2021 12:13:26 +0000 (13:13 +0100)]
Rollup merge of #82857 - pierwill:edit-ast-lowering-lib, r=Dylan-DPC

Edit ructc_ast_lowering docs

Fixes some punctuation and formatting; also makes some small wording changes.

3 years agoRollup merge of #82755 - osa1:confirm_builtin_call_refactor, r=petrochenkov
Dylan DPC [Mon, 8 Mar 2021 12:13:25 +0000 (13:13 +0100)]
Rollup merge of #82755 - osa1:confirm_builtin_call_refactor, r=petrochenkov

Refactor confirm_builtin_call, remove partial if

Pass callee expr to `confirm_builtin_call`. This removes a partial
pattern match in `confirm_builtin_call` and the `panic` in the `else`
branch. The diff is large because of indentation changes caused by
removing the if-let.

3 years agoRollup merge of #82684 - tmiasko:dest-prop, r=jonas-schievink
Dylan DPC [Mon, 8 Mar 2021 12:13:24 +0000 (13:13 +0100)]
Rollup merge of #82684 - tmiasko:dest-prop, r=jonas-schievink

Disable destination propagation on all mir-opt-levels

The new `// compile-flags: -Zunsound-mir-opts` are inserted without an extra newline to avoid introducing a large mir-opt diff.

3 years agoRollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011
Dylan DPC [Mon, 8 Mar 2021 12:13:23 +0000 (13:13 +0100)]
Rollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011

Implement built-in attribute macro `#[cfg_eval]` + some refactoring

This PR implements a built-in attribute macro `#[cfg_eval]` as it was suggested in https://github.com/rust-lang/rust/pull/79078 to avoid `#[derive()]` without arguments being abused as a way to configure input for other attributes.

The macro is used for eagerly expanding all `#[cfg]` and `#[cfg_attr]` attributes in its input ("fully configuring" the input).
The effect is identical to effect of `#[derive(Foo, Bar)]` which also fully configures its input before passing it to macros `Foo` and `Bar`, but unlike `#[derive]` `#[cfg_eval]` can be applied to any syntax nodes supporting macro attributes, not only certain items.

`cfg_eval` was the first name suggested in https://github.com/rust-lang/rust/pull/79078, but other alternatives are also possible, e.g. `cfg_expand`.

```rust
#[cfg_eval]
#[my_attr] // Receives `struct S {}` as input, the field is configured away by `#[cfg_eval]`
struct S {
    #[cfg(FALSE)]
    field: u8,
}
```

Tracking issue: https://github.com/rust-lang/rust/issues/82679

3 years agoRollup merge of #82642 - sfackler:jemalloc-zone, r=pnkfelix
Dylan DPC [Mon, 8 Mar 2021 12:13:22 +0000 (13:13 +0100)]
Rollup merge of #82642 - sfackler:jemalloc-zone, r=pnkfelix

Fix jemalloc usage on OSX

Closes #82423

3 years agoRollup merge of #82613 - CraftSpider:fix-de, r=aDotInTheVoid
Dylan DPC [Mon, 8 Mar 2021 12:13:21 +0000 (13:13 +0100)]
Rollup merge of #82613 - CraftSpider:fix-de, r=aDotInTheVoid

Remove Item::kind, use tagged enum. Rename variants to match

Fixes #82299, by making the ItemEnum tagged. Doesn't remove ItemKind as it's still used in other places.

r? `````@jyn514`````
`````@rustbot````` label: +A-rustdoc-json +T-rustdoc

3 years agoRollup merge of #82557 - rylev:natvis-improvements, r=varkor
Dylan DPC [Mon, 8 Mar 2021 12:13:20 +0000 (13:13 +0100)]
Rollup merge of #82557 - rylev:natvis-improvements, r=varkor

Add natvis for Result, NonNull, CString, CStr, and Cow

This adds natvis support (used for Windows debugging) to the following types: `Result`, `NonNull`, `CString`, `CStr`, and `Cow`.

3 years agoRollup merge of #82415 - petrochenkov:modin3, r=davidtwco
Dylan DPC [Mon, 8 Mar 2021 12:13:19 +0000 (13:13 +0100)]
Rollup merge of #82415 - petrochenkov:modin3, r=davidtwco

expand: Refactor module loading

This is an accompanying PR to https://github.com/rust-lang/rust/pull/82399, but they can be landed independently.
See individual commits for more details.

Anyone should be able to review this equally well because all people actually familiar with this code left the project.

3 years agoRollup merge of #82047 - the8472:fast-rename, r=davidtwco
Dylan DPC [Mon, 8 Mar 2021 12:13:18 +0000 (13:13 +0100)]
Rollup merge of #82047 - the8472:fast-rename, r=davidtwco

bypass auto_da_alloc for metadata files

This saves about 0.7% when rerunning the UI test suite. I.e. when the metadata files exist and will be overwritten. No improvements expected for a clean build. So it might show up in incr-patched perf results.
```
regular rename:

Benchmark #1: touch src/tools/compiletest/src/main.rs ; RUSTC_WRAPPER="" schedtool -B -e ./x.py test src/test/ui
  Time (mean ± σ):     47.305 s ±  0.170 s    [User: 1631.540 s, System: 412.648 s]
  Range (min … max):   47.125 s … 47.856 s    20 runs

non-durable rename:

Benchmark #1: touch src/tools/compiletest/src/main.rs ; RUSTC_WRAPPER="" schedtool -B -e ./x.py test src/test/ui
  Time (mean ± σ):     46.930 s ±  0.064 s    [User: 1634.344 s, System: 396.038 s]
  Range (min … max):   46.759 s … 47.043 s    20 runs
```

There are more places that trigger auto_da_alloc behavior by overwriting existing files with O_TRUNC, but those are much harder to locate because `O_TRUNC` is set on `open()` but the writeback is triggered on `close()`. The latter is the part which shows up in profiles.

3 years agoAuto merge of #82783 - nikic:llvm-ct-backports, r=nagisa
bors [Mon, 8 Mar 2021 11:39:32 +0000 (11:39 +0000)]
Auto merge of #82783 - nikic:llvm-ct-backports, r=nagisa

Backport some LLVM compile-time improvements

Pick up two LLVM patches that reduce number of alias analysis queries, to see whether that gives any visible improvement.

r? `@ghost`

3 years agoAuto merge of #82727 - oli-obk:shrinkmem, r=pnkfelix
bors [Mon, 8 Mar 2021 08:39:24 +0000 (08:39 +0000)]
Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelix

Test the effect of shrinking the size of Rvalue by 16 bytes

r? `@ghost`

3 years agoGrammar Fixes
Arnav Jindal [Mon, 8 Mar 2021 06:19:26 +0000 (11:49 +0530)]
Grammar Fixes

3 years agoAdd documentation for string->Cow conversions
Michael Howell [Tue, 2 Mar 2021 23:37:50 +0000 (16:37 -0700)]
Add documentation for string->Cow conversions

Mostly, it's just to reassure everyone that these functions don't allocate.

Part of #51430

3 years agoAuto merge of #81635 - michaelwoerister:structured_def_path_hash, r=pnkfelix
bors [Sun, 7 Mar 2021 23:45:57 +0000 (23:45 +0000)]
Auto merge of #81635 - michaelwoerister:structured_def_path_hash, r=pnkfelix

Let a portion of DefPathHash uniquely identify the DefPath's crate.

This allows to directly map from a `DefPathHash` to the crate it originates from, without constructing side tables to do that mapping -- something that is useful for incremental compilation where we deal with `DefPathHash` instead of `DefId` a lot.

It also allows to reliably and cheaply check for `DefPathHash` collisions which allows the compiler to gracefully abort compilation instead of running into a subsequent ICE at some random place in the code.

The following new piece of documentation describes the most interesting aspects of the changes:

```rust
/// A `DefPathHash` is a fixed-size representation of a `DefPath` that is
/// stable across crate and compilation session boundaries. It consists of two
/// separate 64-bit hashes. The first uniquely identifies the crate this
/// `DefPathHash` originates from (see [StableCrateId]), and the second
/// uniquely identifies the corresponding `DefPath` within that crate. Together
/// they form a unique identifier within an entire crate graph.
///
/// There is a very small chance of hash collisions, which would mean that two
/// different `DefPath`s map to the same `DefPathHash`. Proceeding compilation
/// with such a hash collision would very probably lead to an ICE and, in the
/// worst case, to a silent mis-compilation. The compiler therefore actively
/// and exhaustively checks for such hash collisions and aborts compilation if
/// it finds one.
///
/// `DefPathHash` uses 64-bit hashes for both the crate-id part and the
/// crate-internal part, even though it is likely that there are many more
/// `LocalDefId`s in a single crate than there are individual crates in a crate
/// graph. Since we use the same number of bits in both cases, the collision
/// probability for the crate-local part will be quite a bit higher (though
/// still very small).
///
/// This imbalance is not by accident: A hash collision in the
/// crate-local part of a `DefPathHash` will be detected and reported while
/// compiling the crate in question. Such a collision does not depend on
/// outside factors and can be easily fixed by the crate maintainer (e.g. by
/// renaming the item in question or by bumping the crate version in a harmless
/// way).
///
/// A collision between crate-id hashes on the other hand is harder to fix
/// because it depends on the set of crates in the entire crate graph of a
/// compilation session. Again, using the same crate with a different version
/// number would fix the issue with a high probability -- but that might be
/// easier said then done if the crates in questions are dependencies of
/// third-party crates.
///
/// That being said, given a high quality hash function, the collision
/// probabilities in question are very small. For example, for a big crate like
/// `rustc_middle` (with ~50000 `LocalDefId`s as of the time of writing) there
/// is a probability of roughly 1 in 14,750,000,000 of a crate-internal
/// collision occurring. For a big crate graph with 1000 crates in it, there is
/// a probability of 1 in 36,890,000,000,000 of a `StableCrateId` collision.
```

Given the probabilities involved I hope that no one will ever actually see the error messages. Nonetheless, I'd be glad about some feedback on how to improve them. Should we create a GH issue describing the problem and possible solutions to point to? Or a page in the rustc book?

r? `@pnkfelix` (feel free to re-assign)

3 years agoUpdate Cargo
Aaron Hill [Sun, 7 Mar 2021 23:39:19 +0000 (18:39 -0500)]
Update Cargo

Output of `git log --oneline  c68432f1e..970bc67c3`:

970bc67c3 (HEAD, origin/master, origin/auto-cargo, origin/HEAD) Auto merge of #9243 - wickerwaka:configurable-env-doc, r=ehuss
4d7a29b75 Document the configurable-env usntable option
f7a7a3f91 Auto merge of #9229 - alexcrichton:fix-borrow-mut, r=ehuss
3f2ece7a9 Fix a `BorrowMut` error when stdout is closed
7441e8c23 Auto merge of #8825 - Aaron1011:feature/report-future-incompat, r=ehuss
139ed73f5 Add future-incompat tracking issue number.
9ea350368 Fix some minor formatting issues.
f03d47ce4 Address review comments
6177c6584 Implement future incompatibility report support
c69409658 Auto merge of #9022 - nagisa:nagisa/manifest_path, r=alexcrichton
548300b20 Add the path to the manifest in json output
99e714c05 Auto merge of #9230 - kornelski:nobinaries, r=alexcrichton
61a31bc5f Auto merge of #9236 - kornelski:track-assert, r=Eh2406
3f7f0942c track_caller on custom assert functions
6977dee10 Explain `cargo install` is not for libraries
e4aebf0a0 Auto merge of #9231 - joshtriplett:clear-to-eol-if-color, r=alexcrichton
b219f0eb7 Auto merge of #9181 - jyn514:computer-says-no, r=ehuss
0b1816578 Remove unhelpful link to Cargo book
ea46f5ce3 Use ANSI clear-to-EOL if color is force-enabled
a6394bcc1 Remove unnecessary `config` argument to `Features::add`
3a86ecf2d Fix TODO about nightly features
09677c83c Be less unix-centric in error messages
ecfdced0d Fix test that assumed tests always were run on the stable channel
eba541994 Update comment in build_script_env
a5720117f Make `nightly_features_allowed` a field instead of a function
169b09ce7 Compute `enable_nightly_features` once instead of on each call
8fc86e155 Remove unused thread_locals
4b096beae Fix `masquerade_as_nightly_cargo` in work threads
e56417c8c Suggest RUSTC_BOOTSTRAP=crate instead of RUSTC_BOOTSTRAP=1
418129dae Downgrade error to a warning when `RUSTC_BOOTSTRAP` is set or this is the nightly channel
6c422a2c0 Restrict RUSTC_BOOTSTRAP in build.rs

3 years agodiagnostics: Don't mention external crates when hitting import errors on crate import...
Manish Goregaokar [Sun, 7 Mar 2021 22:51:35 +0000 (14:51 -0800)]
diagnostics: Don't mention external crates when hitting import errors on crate imports in 2018

3 years agoRemove notes, increase S/N ratio
Esteban Küber [Sun, 7 Mar 2021 23:03:46 +0000 (15:03 -0800)]
Remove notes, increase S/N ratio

3 years agoadd codegen tests for some issues closed by LLVM 12
Erik Desjardins [Sun, 7 Mar 2021 19:03:35 +0000 (14:03 -0500)]
add codegen tests for some issues closed by LLVM 12

3 years agoAdd help for `matches` for `if let` in arm guard
Esteban Küber [Sun, 7 Mar 2021 22:44:21 +0000 (14:44 -0800)]
Add help for `matches` for `if let` in arm guard

3 years agodiagnostics: Differentiate between edition meanings of ::foo in resolve diagnostics...
Manish Goregaokar [Sun, 7 Mar 2021 22:19:50 +0000 (14:19 -0800)]
diagnostics: Differentiate between edition meanings of ::foo in resolve diagnostics for ::foo::Bar

3 years agodiagnostics: Differentiate between edition meanings of ::foo in resolve diagnostics...
Manish Goregaokar [Sun, 7 Mar 2021 21:53:45 +0000 (13:53 -0800)]
diagnostics: Differentiate between edition meanings of ::foo in resolve diagnostics (for bare `::foo`)

3 years agoAdd help suggesting `matches` to `let_chains` lint
Esteban Küber [Sun, 7 Mar 2021 22:05:52 +0000 (14:05 -0800)]
Add help suggesting `matches` to `let_chains` lint

3 years agoAccount for `if (let pat = expr) {}`
Esteban Küber [Sun, 7 Mar 2021 02:29:41 +0000 (18:29 -0800)]
Account for `if (let pat = expr) {}`

Partially address #82827.

3 years agoAuto merge of #82285 - nhwn:nonzero-debug, r=nagisa
bors [Sun, 7 Mar 2021 20:23:23 +0000 (20:23 +0000)]
Auto merge of #82285 - nhwn:nonzero-debug, r=nagisa

Use u32 over Option<u32> in DebugLoc

~~Changes `Option<u32>` fields in `DebugLoc` to `Option<NonZeroU32>`. Since the respective fields (`line` and `col`) are guaranteed to be 1-based, this layout optimization is a freebie.~~

EDIT: Changes `Option<u32>` fields in `DebugLoc` to `u32`. As `@bugadani` pointed out, an `Option<NonZeroU32>` is probably an unnecessary layer of abstraction since the `None` variant is always used as `UNKNOWN_LINE_NUMBER` (which is just `0`).  Also, `SourceInfo` in `metadata.rs` already uses a `u32` instead of an `Option<u32>` to encode the same information, so I think this change is warranted.

Since `@jyn514` raised some concerns over measuring performance in a similar PR (#82255), does this need a perf run?

3 years agoAdd note about the `#[doc(no-inline)]` usage
Julian Frimmel [Sun, 7 Mar 2021 09:52:35 +0000 (10:52 +0100)]
Add note about the `#[doc(no-inline)]` usage

This is required to correctly build the documentation (including all
submodules, that are only available in certain targets).

3 years agoRevert "use RWlock when accessing os::env #81850"
Eric Huss [Sun, 7 Mar 2021 19:32:42 +0000 (11:32 -0800)]
Revert "use RWlock when accessing os::env #81850"

This reverts commit 354f19cf2475148994954b6783341620c7445071, reversing
changes made to 0cfba2fd090834c909d5ed9deccdee8170da791b.

3 years agoGeneralize Write impl for Vec<u8> to Vec<u8, A>
Joel Höner [Sun, 7 Mar 2021 15:22:53 +0000 (16:22 +0100)]
Generalize Write impl for Vec<u8> to Vec<u8, A>

As discussed in the issue tracker for the wg-allocators working group[1], updating this implementation for allocator support was most likely just forgotten in the original PR.

[1]: https://github.com/rust-lang/wg-allocators/issues/86

3 years agoEdit ructc_ast_lowering docs
pierwill [Sun, 7 Mar 2021 06:07:38 +0000 (22:07 -0800)]
Edit ructc_ast_lowering docs

Fixes some punctuation and formatting; also makes some small wording changes.

3 years agoAuto merge of #82851 - JohnTitor:rollup-me5ko8g, r=JohnTitor
bors [Sun, 7 Mar 2021 02:36:07 +0000 (02:36 +0000)]
Auto merge of #82851 - JohnTitor:rollup-me5ko8g, r=JohnTitor

Rollup of 13 pull requests

Successful merges:

 - #77916 (Change built-in kernel targets to be os = none throughout)
 - #82130 (Make some Option, Result methods unstably const)
 - #82292 (Prevent specialized ZipImpl from calling `__iterator_get_unchecked` twice with the same index)
 - #82402 (Remove RefCell around `module_trait_cache`)
 - #82592 (Improve transmute docs with further clarifications)
 - #82651 (Cleanup rustdoc warnings)
 - #82720 (Fix diagnostic suggests adding type `[type error]`)
 - #82751 (improve offset_from docs)
 - #82793 (Move some tests to more suitable subdirs)
 - #82803 (rustdoc: Add an unstable option to print all unversioned files)
 - #82808 (Sync rustc_codegen_cranelift)
 - #82822 (Fix typo)
 - #82837 (tweak MaybeUninit docs)

Failed merges:

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

3 years agoRollup merge of #82837 - RalfJung:maybe-uninit, r=dtolnay
Yuki Okushi [Sun, 7 Mar 2021 01:41:22 +0000 (10:41 +0900)]
Rollup merge of #82837 - RalfJung:maybe-uninit, r=dtolnay

tweak MaybeUninit docs

Explain what "(no) fixed value" means.

3 years agoRollup merge of #82822 - henryboisdequin:fix-typo-rustc, r=oli-obk
Yuki Okushi [Sun, 7 Mar 2021 01:41:20 +0000 (10:41 +0900)]
Rollup merge of #82822 - henryboisdequin:fix-typo-rustc, r=oli-obk

Fix typo

we need to actually -> we actually need to

````@rustbot```` label +C-cleanup

3 years agoRollup merge of #82808 - bjorn3:sync_cg_clif-2021-03-05, r=bjorn3
Yuki Okushi [Sun, 7 Mar 2021 01:41:19 +0000 (10:41 +0900)]
Rollup merge of #82808 - bjorn3:sync_cg_clif-2021-03-05, r=bjorn3

Sync rustc_codegen_cranelift

The main highlight of this sync is removal of support for the old x86 Cranelift backend. This made it possible to use native atomic instructions rather than hackishly using a global mutex. 128bit integer support has also seen a few bugfixes and performance improvements. And finally I have formatted everything using the same rustfmt config as the rest of this repo.

r? ````@ghost````

````@rustbot```` label +A-codegen +A-cranelift +T-compiler

3 years agoRollup merge of #82803 - jyn514:unversioned-files, r=GuillaumeGomez
Yuki Okushi [Sun, 7 Mar 2021 01:41:18 +0000 (10:41 +0900)]
Rollup merge of #82803 - jyn514:unversioned-files, r=GuillaumeGomez

rustdoc: Add an unstable option to print all unversioned files

This allows sharing those files between different doc invocations
without having to know their names ahead of time.

Helps with https://github.com/rust-lang/docs.rs/issues/1302.
r? ````@GuillaumeGomez```` cc ````@pietroalbini```` ````@Nemo157````

3 years agoRollup merge of #82793 - JohnTitor:move-ui-tests, r=petrochenkov
Yuki Okushi [Sun, 7 Mar 2021 01:41:17 +0000 (10:41 +0900)]
Rollup merge of #82793 - JohnTitor:move-ui-tests, r=petrochenkov

Move some tests to more suitable subdirs

## The results from classifui

(The full results can be found here: https://gist.github.com/JohnTitor/c9e00840990b5e4a8fc562ec3571e427)

- [lint-expr-stmt-attrs-for-early-lints.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/lint-expr-stmt-attrs-for-early-lints.rs) <sup>unknown</sup>: lint (1.566), feature-gates (-0.632), numbers-arithmetic (-0.955)
- [try-block.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/try-block.rs) <sup>unknown</sup>: binding (1.385), try-block (-0.097), lint (-0.932)
- [backtrace-debuginfo.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/backtrace-debuginfo.rs) <sup>unknown</sup>: macros (1.365), cfg (-0.279), drop (-0.291)
- [issues/issue-3521.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-3521.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/3521)</sup>: consts (1.298), enum (-0.872), in-band-lifetimes (-0.978)
- [impl-bounds-checking.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/impl-bounds-checking.rs) <sup>unknown</sup>: traits (1.243), for (-0.999), shadowed (-0.999)
- [issues/issue-17718.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-17718.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/17718)</sup>: binding (1.236), consts (0.315), extern (-0.779)
- [issue-6157.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issue-6157.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/6157)</sup>: regions (1.213), unboxed-closures (-0.285), traits (-0.510)
- [issues/issue-44373.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-44373.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/44373)</sup>: consts (1.187), nll (0.427), borrowck (-0.704)
- [nullable-pointer-ffi-compat.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/nullable-pointer-ffi-compat.rs) <sup>unknown</sup>: regions (1.184), consts (0.650), traits (-0.571)
- [issues/issue-52992.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-52992.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/52992)</sup>: nll (1.132), associated-types (-0.628), parser (-0.893)
- [issues/issue-2330.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-2330.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/2330)</sup>: traits (1.116), directory_ownership (-0.691), compare-method (-0.981)
- [issue-74047.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issue-74047.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/74047)</sup>: async-await (1.109), impl-trait (-0.629), resolve (-0.781)
- [issues/issue-33140.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-33140.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/33140)</sup>: traits (1.063), coherence (-0.832), codemap_tests (-0.944)
- [issues/issue-28576.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-28576.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/28576)</sup>: traits (1.062), associated-types (-0.333), impl-trait (-0.697)
- [issues/issue-7222.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-7222.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/7222)</sup>: binding (1.062), consts (-0.226), numbers-arithmetic (-0.294)
- [tup.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/tup.rs) <sup>unknown</sup>: structs-enums (1.061), threads-sendsync (-0.550), moves (-0.790)
- [issues/issue-15261.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-15261.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/15261)</sup>: consts (1.052), where-clauses (-0.833), macros (-0.862)
- [issues/issue-76179.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-76179.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/76179)</sup>: associated-types (1.048), process (-0.887), rfc-2457 (-0.984)
- [issues/issue-42344.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-42344.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/42344)</sup>: borrowck (1.043), macros (-0.481), specialization (-0.966)
- [issues/issue-18661.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-18661.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/18661)</sup>: unboxed-closures (1.038), mir (-0.648), higher-rank-trait-bounds (-0.688)
- [issues/issue-2633.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-2633.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/2633)</sup>: structs-enums (1.020), functions-closures (-0.722), lint (-0.967)

Some notes:
- If there are related tests (e.g. it's for the same issue), they are moved along with it.
- Moved try-block.rs to the `try-block` dir.
- Moved tup.rs to the `tuple` dir.
- Moved some tests that classified as consts to the `statics` dir, as it seems they have statics actually.
- Skipped backtrace-debuginfo.rs because I think classifui overrates their helper macros.

cc #73494
r? ```@petrochenkov```

3 years agoRollup merge of #82751 - RalfJung:offset_from, r=dtolnay
Yuki Okushi [Sun, 7 Mar 2021 01:41:16 +0000 (10:41 +0900)]
Rollup merge of #82751 - RalfJung:offset_from, r=dtolnay

improve offset_from docs

`@thomcc` pointed out that the current docs leave it kind of unclear how one can satisfy the "no wrapping around `isize` or the address space" requirement of `offset_from`, so make the docs clearer about that.

FWIW, I don't think I entirely agree with that second paragraph about large objects (that I left mostly unchanged here). LLVM, to my knowledge, fundamentally assumes that all allocations fit into an `isize::MAX`. So in that sense creating a larger allocation is simply UB. I would expect a guarantee that Rust heap allocation methods will never return allocations larger than `isize::MAX` (or rather, Rust heap allocation methods should require that the `Layout` is no larger than `isize::MAX`). However, I cannot find any such requirement documented currently. Large allocations are not mentioned at all in the allocator docs, which is quite surprising -- even if we say that such allocations are not insta-UB (which I think is incompatible with LLVM), they are still extremely footgunny since `ptr::offset`/`ptr::add` do not support offsetting by more than `isize::MAX` bytes.

Furthermore, the allocator docs don't even say anything about allocations wrapping around the address space. But that is certainly something allocators must ensure never happens; we cannot expect clients to defend against this.

Cc `@rust-lang/wg-allocators`

3 years agoRollup merge of #82720 - henryboisdequin:fix-79040, r=oli-obk
Yuki Okushi [Sun, 7 Mar 2021 01:41:15 +0000 (10:41 +0900)]
Rollup merge of #82720 - henryboisdequin:fix-79040, r=oli-obk

Fix diagnostic suggests adding type `[type error]`

Fixes #79040

### Unresolved questions:

<del>Why does this change output the diagnostic twice (`src/test/ui/79040.rs`)?</del> Thanks `````@oli-obk`````

3 years agoRollup merge of #82651 - jyn514:rustdoc-warnings, r=GuillaumeGomez
Yuki Okushi [Sun, 7 Mar 2021 01:41:13 +0000 (10:41 +0900)]
Rollup merge of #82651 - jyn514:rustdoc-warnings, r=GuillaumeGomez

Cleanup rustdoc warnings

## Clean up error reporting for deprecated passes

Using `error!` here goes all the way back to the original commit, https://github.com/rust-lang/rust/pull/8540. I don't see any reason to use logging; rustdoc should use diagnostics wherever possible. See https://github.com/rust-lang/rust/pull/81932#issuecomment-785291244 for further context.

- Use spans for deprecated attributes
- Use a proper diagnostic for unknown passes, instead of error logging
- Add tests for unknown passes
- Improve some wording in diagnostics

##  Report that `doc(plugins)` doesn't work using diagnostics instead of `eprintln!`

This also adds a test for the output.

This was added in https://github.com/rust-lang/rust/pull/52194. I don't see any particular reason not to use diagnostics here, I think it was just missed in https://github.com/rust-lang/rust/pull/50541.

3 years agoRollup merge of #82592 - Lonami:patch-1, r=RalfJung
Yuki Okushi [Sun, 7 Mar 2021 01:41:12 +0000 (10:41 +0900)]
Rollup merge of #82592 - Lonami:patch-1, r=RalfJung

Improve transmute docs with further clarifications

Closes #82493.

Please let me know if any of the new wording sounds off, English is not my mother tongue.

3 years agoRollup merge of #82402 - jyn514:module-cache-refcell, r=GuillaumeGomez
Yuki Okushi [Sun, 7 Mar 2021 01:41:11 +0000 (10:41 +0900)]
Rollup merge of #82402 - jyn514:module-cache-refcell, r=GuillaumeGomez

Remove RefCell around `module_trait_cache`

This builds on https://github.com/rust-lang/rust/pull/82018 and should not be merged before.

## Don't require a `DocContext` for `report_diagnostic`

This is needed for the next commit, which needs mutable access to the `cx` from
within the `decorate` closure.

- Change `as_local_hir_id` to an associated function, since it only
  needs a `TyCtxt`
- Change `source_span_for_markdown_range` to only take a `TyCtxt`

##  Remove RefCell around module_trait_cache

This is mostly just changing lots of functions from `&DocContext` to `&mut DocContext`.

3 years agoRollup merge of #82292 - SkiFire13:fix-issue-82291, r=m-ou-se
Yuki Okushi [Sun, 7 Mar 2021 01:41:10 +0000 (10:41 +0900)]
Rollup merge of #82292 - SkiFire13:fix-issue-82291, r=m-ou-se

Prevent specialized ZipImpl from calling `__iterator_get_unchecked` twice with the same index

Fixes #82291

It's open for review, but conflicts with #82289, wait before merging. The conflict involves only the new test, so it should be rather trivial to fix.

3 years agoRollup merge of #82130 - jhpratt:const-option-result, r=RalfJung
Yuki Okushi [Sun, 7 Mar 2021 01:41:09 +0000 (10:41 +0900)]
Rollup merge of #82130 - jhpratt:const-option-result, r=RalfJung

Make some Option, Result methods unstably const

The following methods are now unstably const:

- Option::transpose
- Option::flatten
- Result::flatten

While some methods for could likely be made `const` in the future, nearly all of them require something to be dropped at compile-time, which isn't currently supported. The functions listed above should have a trivial path to stabilization.

3 years agoRollup merge of #77916 - QuiltOS:kernel-code-targets-os-none, r=joshtriplett
Yuki Okushi [Sun, 7 Mar 2021 01:41:04 +0000 (10:41 +0900)]
Rollup merge of #77916 - QuiltOS:kernel-code-targets-os-none, r=joshtriplett

Change built-in kernel targets to be os = none throughout

Whether for Rust's own `target_os`, LLVM's triples, or GNU config's, the
OS-related have fields have been for code running *on* that OS, not code
hat is *part* of the OS.

The difference is huge, as syscall interfaces are nothing like
freestanding interfaces. Kernels are (hypervisors and other more exotic
situations aside) freestanding programs that use the interfaces provided
by the hardware. It's *those* interfaces, the ones external to the
program being built and its software dependencies, that are the content
of the target.

For the Linux Kernel in particular, `target_env: "gnu"` is removed for
the same reason: that `-gnu` refers to glibc or GNU/linux, neither of
which applies to the kernel itself.

Relates to #74247

3 years agorustc_builtin_macros: Share some more logic between `derive` and `cfg_eval`
Vadim Petrochenkov [Sat, 6 Mar 2021 22:11:21 +0000 (01:11 +0300)]
rustc_builtin_macros: Share some more logic between `derive` and `cfg_eval`

3 years agocfg_eval: Configure everything through mutable visitor methods
Vadim Petrochenkov [Sat, 6 Mar 2021 21:18:51 +0000 (00:18 +0300)]
cfg_eval: Configure everything through mutable visitor methods

This is simpler and mirrors what invocation collector does

3 years agoMove full configuration logic from `rustc_expand` to `rustc_builtin_macros`
Vadim Petrochenkov [Sat, 6 Mar 2021 20:37:59 +0000 (23:37 +0300)]
Move full configuration logic from `rustc_expand` to `rustc_builtin_macros`

This logic is applicable to two specific macros and not to the expansion infrastructure in general.

3 years agoAuto merge of #82738 - estebank:tail-expr-check-is-too-slow, r=oli-obk
bors [Sat, 6 Mar 2021 21:02:53 +0000 (21:02 +0000)]
Auto merge of #82738 - estebank:tail-expr-check-is-too-slow, r=oli-obk

Move check only relevant in error case out of critical path

Move the check for potentially forgotten `return` in a tail expression
of arbitrary expressions into the coercion error branch to avoid
computing unncessary coercion checks on successful code.

Follow up to #81458.

3 years agoRevert fmt version, add rustdoc-json-types to bootstrap tests
Rune Tynan [Sat, 6 Mar 2021 20:37:07 +0000 (15:37 -0500)]
Revert fmt version, add rustdoc-json-types to bootstrap tests

3 years agox.py fmt
Rune Tynan [Fri, 5 Mar 2021 00:44:09 +0000 (19:44 -0500)]
x.py fmt

3 years agoMove tests to own file
Rune Tynan [Fri, 5 Mar 2021 00:08:06 +0000 (19:08 -0500)]
Move tests to own file

3 years agoAdd roundtrip testing and bump format version
Rune Tynan [Thu, 4 Mar 2021 23:45:57 +0000 (18:45 -0500)]
Add roundtrip testing and bump format version

3 years agoRemove Item::kind, use tagged enum. Rename variants to match
Rune Tynan [Sun, 28 Feb 2021 00:44:17 +0000 (19:44 -0500)]
Remove Item::kind, use tagged enum. Rename variants to match

3 years agoImplement built-in attribute macro `#[cfg_eval]`
Vadim Petrochenkov [Sat, 6 Mar 2021 18:33:02 +0000 (21:33 +0300)]
Implement built-in attribute macro `#[cfg_eval]`

3 years agoMake some Option, Result methods unstably const
Jacob Pratt [Mon, 15 Feb 2021 03:11:46 +0000 (22:11 -0500)]
Make some Option, Result methods unstably const

The following functions are now unstably const:

- Option::transpose
- Option::flatten
- Result::transpose

3 years agorustc_ast: Replace `AstLike::finalize_tokens` with a getter `tokens_mut`
Vadim Petrochenkov [Sat, 6 Mar 2021 18:06:01 +0000 (21:06 +0300)]
rustc_ast: Replace `AstLike::finalize_tokens` with a getter `tokens_mut`

3 years agoChange x64 size checks to not apply to x32.
Harald van Dijk [Sat, 6 Mar 2021 16:02:48 +0000 (16:02 +0000)]
Change x64 size checks to not apply to x32.

Rust contains various size checks conditional on target_arch = "x86_64",
but these checks were never intended to apply to
x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the
conditions.

3 years agotweak MaybeUninit docs
Ralf Jung [Sat, 6 Mar 2021 15:59:39 +0000 (16:59 +0100)]
tweak MaybeUninit docs

3 years agoImprove transmute docs with further clarifications
Lonami [Sat, 27 Feb 2021 15:16:41 +0000 (16:16 +0100)]
Improve transmute docs with further clarifications

Closes #82493.

3 years agoMove some tests to more suitable subdirs
Yuki Okushi [Fri, 5 Mar 2021 09:34:12 +0000 (18:34 +0900)]
Move some tests to more suitable subdirs

3 years agoHandle negative literals in cast overflow warning
Yuki Okushi [Sat, 6 Mar 2021 08:32:47 +0000 (17:32 +0900)]
Handle negative literals in cast overflow warning

3 years agoUndo addition of boxes
Camelid [Tue, 2 Mar 2021 04:06:49 +0000 (20:06 -0800)]
Undo addition of boxes

I don't think the boxing helped performance, in fact I think it
potentially made it worse. The data was still being copied, but now it
was through a pointer. Thinking about it more, I think boxing might only
help when you're passing a big object around by value all the time,
rather than the slowdown being that you're cloning it.

3 years agoFix typo
Henry Boisdequin [Sat, 6 Mar 2021 03:46:29 +0000 (09:16 +0530)]
Fix typo

we need to actually -> we actually need to

@rustbot label +C-cleanup