Commit graph

139672 commits

Author SHA1 Message Date
Guillaume Gomez
1d26e6b632 Improve code by removing similar function calls and using loops instead for collecting iterators 2021-03-11 22:33:40 +01:00
Guillaume Gomez
2069d3e13b Update doc alias ui tests 2021-03-11 22:33:40 +01:00
Guillaume Gomez
bbbefa3edc Allow doc alias attributes to use both list and value 2021-03-10 10:17:37 +01:00
bors
4b9f5cc4c1 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`
2021-03-09 04:33:43 +00:00
bors
bb3afe1e60 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
2021-03-09 01:47:39 +00:00
bors
eb476b172f 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 354f19cf24, reversing changes made to 0cfba2fd09.

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
2021-03-08 22:53:20 +00:00
Mara Bos
54add8dfca
Rollup merge of #82897 - artagnon:patch-2, r=joshtriplett
[.mailmap] Add entry for Ramkumar Ramachandra
2021-03-08 20:09:08 +01:00
Mara Bos
2d3ba78561
Rollup merge of #82888 - Daggy1234:patch-1, r=joshtriplett
Grammar Fixes

Found typo's in the array rustdoc. Pr'ed a fix!
2021-03-08 20:09:07 +01:00
Mara Bos
3908eec60f
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
2021-03-08 20:09:06 +01:00
Mara Bos
a5035c9995
Rollup merge of #82874 - erikdesjardins:cgtests, r=nagisa
Add codegen tests for some issues closed by LLVM 12

Namely #73031, #75546, and #77812
2021-03-08 20:09:04 +01:00
Mara Bos
a55b192d59
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.
2021-03-08 20:09:03 +01:00
Mara Bos
6a55aa1246
Rollup merge of #82854 - estebank:issue-82827, r=oli-obk
Account for `if (let pat = expr) {}`

Fix #82827.
2021-03-08 20:09:02 +01:00
Mara Bos
0ee2f4c3e0
Rollup merge of #82829 - JohnTitor:handle-neg-val, r=estebank
Handle negative literals in cast overflow warning

Closes #48535
r? `@estebank`
2021-03-08 20:09:01 +01:00
Mara Bos
09b17a1c2d
Rollup merge of #82810 - amaurremi:source-based-coverage-typo, r=ehuss
Typo fix in Unstable book: `cargo cov` -> `cargo profdata`
2021-03-08 20:09:00 +01:00
Mara Bos
5ff52cbdb7
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.
2021-03-08 20:08:59 +01:00
Mara Bos
6e9a94a72b
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`
2021-03-08 20:08:57 +01:00
Mara Bos
3114e2bcf3
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
2021-03-08 20:08:56 +01:00
bors
8f349be278 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
2021-03-08 14:59:20 +00:00
Arnav Jindal
655155caa0
Update library/core/src/array/mod.rs
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2021-03-08 20:28:30 +05:30
Joshua Nelson
bc1fbf55db Move rustdoc UI tests into a subdirectory
This also adds a little leeway to the test limit.
2021-03-08 09:17:04 -05:00
Ramkumar Ramachandra
84bfa388e4
[.mailmap] Add entry for Ramkumar Ramachandra 2021-03-08 13:40:35 +01:00
Dylan DPC
3b0a02a26b
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
2021-03-08 13:13:27 +01:00
Dylan DPC
08475e7873
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.
2021-03-08 13:13:26 +01:00
Dylan DPC
041bc04be4
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.
2021-03-08 13:13:25 +01:00
Dylan DPC
dd7a606804
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.
2021-03-08 13:13:24 +01:00
Dylan DPC
9c310571a8
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
2021-03-08 13:13:23 +01:00
Dylan DPC
7b78d86d6a
Rollup merge of #82642 - sfackler:jemalloc-zone, r=pnkfelix
Fix jemalloc usage on OSX

Closes #82423
2021-03-08 13:13:22 +01:00
Dylan DPC
0681951287
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
2021-03-08 13:13:21 +01:00
Dylan DPC
298c31b04a
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`.
2021-03-08 13:13:20 +01:00
Dylan DPC
4a4e3e667d
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.
2021-03-08 13:13:19 +01:00
Dylan DPC
da74a77622
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.
2021-03-08 13:13:18 +01:00
bors
1d6b0f626a 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`
2021-03-08 11:39:32 +00:00
bors
27885a94c6 Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelix
Test the effect of shrinking the size of Rvalue by 16 bytes

r? `@ghost`
2021-03-08 08:39:24 +00:00
Arnav Jindal
2aa28ad4f0
Grammar Fixes 2021-03-08 11:49:26 +05:30
Michael Howell
69a37a63fa Add documentation for string->Cow conversions
Mostly, it's just to reassure everyone that these functions don't allocate.

Part of #51430
2021-03-07 20:36:43 -07:00
bors
76c500ec6c 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)
2021-03-07 23:45:57 +00:00
Manish Goregaokar
0eeae1abfc diagnostics: Don't mention external crates when hitting import errors on crate imports in 2018 2021-03-07 15:15:19 -08:00
Esteban Küber
aa7ac6e957 Remove notes, increase S/N ratio 2021-03-07 15:03:46 -08:00
Erik Desjardins
938637033c add codegen tests for some issues closed by LLVM 12 2021-03-07 17:56:09 -05:00
Esteban Küber
63fb294a74 Add help for matches for if let in arm guard 2021-03-07 14:44:21 -08:00
Manish Goregaokar
9d5d669b77 diagnostics: Differentiate between edition meanings of ::foo in resolve diagnostics for ::foo::Bar 2021-03-07 14:24:47 -08:00
Manish Goregaokar
ac7f9ccb6f diagnostics: Differentiate between edition meanings of ::foo in resolve diagnostics (for bare ::foo) 2021-03-07 14:21:48 -08:00
Esteban Küber
23bcea4249 Add help suggesting matches to let_chains lint 2021-03-07 14:17:10 -08:00
Esteban Küber
e62a543344 Account for if (let pat = expr) {}
Partially address #82827.
2021-03-07 13:49:36 -08:00
bors
234781afe3 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?
2021-03-07 20:23:23 +00:00
Julian Frimmel
c40ef91f76 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).
2021-03-07 21:08:07 +01:00
Eric Huss
acdca316c3 Revert "use RWlock when accessing os::env #81850"
This reverts commit 354f19cf24, reversing
changes made to 0cfba2fd09.
2021-03-07 11:32:42 -08:00
Joel Höner
ab8995bbca 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
2021-03-07 16:22:53 +01:00
pierwill
6b2eb0e6c6 Edit ructc_ast_lowering docs
Fixes some punctuation and formatting; also makes some small wording changes.
2021-03-06 22:07:38 -08:00
bors
66ec64ccf3 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
2021-03-07 02:36:07 +00:00