Commit graph

160853 commits

Author SHA1 Message Date
Matthias Krüger
fb87e7ceed
Rollup merge of #92360 - jackh726:param-heuristics-1, r=davidtwco
Some cleanups around check_argument_types

Split out in ways from my rebase/continuation of #71827

Commits are mostly self-explanatory and these changes should be fairly straightforward
2022-01-06 12:01:02 +01:00
Matthias Krüger
4d0b567efb
Rollup merge of #92349 - avitex:fix-rustdoc-private-doc-tests, r=GuillaumeGomez
Fix rustdoc::private_doc_tests lint for public re-exported items

Closes #72081

This involves changing the lint to check the access level is exported, rather than public.
The [exported access level](e91ad5fc62/compiler/rustc_middle/src/middle/privacy.rs (L24)) accounts for public items and items accessible to other crates with the help of `pub use` re-exports.
The pattern of re-exporting public items from a private module is usage seen in a number of popular crates.
2022-01-06 12:01:01 +01:00
Matthias Krüger
2647ce2165
Rollup merge of #92288 - yescallop:patch-1, r=m-ou-se
Fix a pair of mistyped test cases in `std::net::ip`

These two test cases are not consistent with their comments, which I believe is unintended.
2022-01-06 12:01:00 +01:00
Matthias Krüger
50d5e38800
Rollup merge of #92058 - jsha:run-on-hover, r=GuillaumeGomez
Make Run button visible on hover

This slightly reduces the noisiness of doc pages, making them easier to read.

Demo: https://rustdoc.crud.net/jsha/run-on-hover/std/string/struct.String.html

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.22Run.22.20button.20visible.20on.20hover).

Part of #59845
2022-01-06 12:00:59 +01:00
David Wood
7ecdc89436 Revert "bootstrap: copy llvm-dwp to sysroot"
This reverts commit 241160de72.
2022-01-06 09:32:42 +00:00
David Wood
2dc1a8a779 cg: use thorin instead of llvm-dwp
`thorin` is a Rust implementation of a DWARF packaging utility that
supports reading DWARF objects from archive files (i.e. rlibs) and
therefore is better suited for integration into rustc.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-01-06 09:32:42 +00:00
David Wood
08ed338f56 sess/cg: re-introduce split dwarf kind
In #79570, `-Z split-dwarf-kind={none,single,split}` was replaced by `-C
split-debuginfo={off,packed,unpacked}`. `-C split-debuginfo`'s packed
and unpacked aren't exact parallels to single and split, respectively.

On Unix, `-C split-debuginfo=packed` will put debuginfo into object
files and package debuginfo into a DWARF package file (`.dwp`) and
`-C split-debuginfo=unpacked` will put debuginfo into dwarf object files
and won't package it.

In the initial implementation of Split DWARF, split mode wrote sections
which did not require relocation into a DWARF object (`.dwo`) file which
was ignored by the linker and then packaged those DWARF objects into
DWARF packages (`.dwp`). In single mode, sections which did not require
relocation were written into object files but ignored by the linker and
were not packaged. However, both split and single modes could be
packaged or not, the primary difference in behaviour was where the
debuginfo sections that did not require link-time relocation were
written (in a DWARF object or the object file).

This commit re-introduces a `-Z split-dwarf-kind` flag, which can be
used to pick between split and single modes when `-C split-debuginfo` is
used to enable Split DWARF (either packed or unpacked).

Signed-off-by: David Wood <david.wood@huawei.com>
2022-01-06 09:32:42 +00:00
Vadim Petrochenkov
1b88007af0 rustc_metadata: Split fn get_implementations_for_trait into two functions 2022-01-06 15:13:22 +08:00
Vadim Petrochenkov
4e8855bdc9 rustc_metadata: Make opt_item_ident in decoder faster and stricter
By avoiding formatting and allocations in the no-ident case, and by making the span mandatory if the ident exists.

Use the optimized `opt_item_ident` to cleanup `fn each_child_of_item`
2022-01-06 14:57:17 +08:00
asquared31415
dd364ed226 add some missing must use to float ops 2022-01-06 00:20:58 -05:00
Vadim Petrochenkov
4c6120c386 rustc_metadata: Make attribute decoding slightly faster and stricter
Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions
2022-01-06 12:13:41 +08:00
Vadim Petrochenkov
636fd495c8 rustc_middle: Add a method for getting a SimplifiedType definition/ID
Import `SimplifiedType` more
2022-01-06 12:04:16 +08:00
inquisitivecrystal
42de973099 Add regression test 2022-01-05 15:22:22 -08:00
inquisitivecrystal
486585242e Do not resolve blocks in foreign functions 2022-01-05 15:22:22 -08:00
Guillaume Gomez
3b70c6e4bd Simplify :target CSS selector 2022-01-05 21:28:19 +01:00
Augie Fackler
34a6b6c423 RustWrapper: simplify removing attributes
Avoids some extra conversions. Spotted by nikic during review.
2022-01-05 13:51:59 -05:00
Chris Denton
014f22abaf
Break the loop
A missing break statement lead to an infinite loop in bootstrap.py.
2022-01-05 17:59:13 +00:00
Jacob Hoffman-Andrews
8abb4bb698 Move crate drop-down to search results page
This reduces clutter on doc pages.
2022-01-05 12:57:25 -05:00
Jacob Hoffman-Andrews
f3fe91278c Switch to es6 for eslint
Also update Node to v16.9.0, es-check to 6.1.1, and eslint to 8.6.0.
2022-01-05 11:44:29 -05:00
Guillaume Gomez
a0085f249a Add test for [src] font-size in headers 2022-01-05 17:35:06 +01:00
Guillaume Gomez
270d09dca9 Fix font size for [src] links in headers 2022-01-05 17:35:04 +01:00
Aaron Hill
4ca275add0
Address review comments 2022-01-05 10:30:49 -05:00
bors
f1ce0e6a00 Auto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92092 (Drop guards in slice sorting derive src pointers from &mut T, which is invalidated by interior mutation in comparison)
 - #92388 (Fix a minor mistake in `String::try_reserve_exact` examples)
 - #92442 (Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`)
 - #92483 (Stabilize `result_cloned` and `result_copied`)
 - #92574 (Add RISC-V detection macro and more architecture instructions)
 - #92575 (ast: Always keep a `NodeId` in `ast::Crate`)
 - #92583 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-05 15:28:36 +00:00
Aaron Hill
560c90f5df
Adjust assert_default_hashing_controls 2022-01-05 10:13:29 -05:00
Aaron Hill
5580e5e1dd
Ensure that Fingerprint caching respects hashing configuration
Fixes #92266

In some `HashStable` impls, we use a cache to avoid re-computing
the same `Fingerprint` from the same structure (e.g. an `AdtDef`).
However, the `StableHashingContext` used can be configured to
perform hashing in different ways (e.g. skipping `Span`s). This
configuration information is not included in the cache key,
which will cause an incorrect `Fingerprint` to be used if
we hash the same structure with different `StableHashingContext`
settings.

To fix this, the configuration settings of `StableHashingContext`
are split out into a separate `HashingControls` struct. This
struct is used as part of the cache key, ensuring that our caches
always produce the correct result for the given settings.

With this in place, we now turn off `Span` hashing during the
entire process of computing the hash included in legacy symbols.
This current has no effect, but will matter when a future PR
starts hashing more `Span`s that we currently skip.
2022-01-05 10:13:28 -05:00
Jacob Hoffman-Andrews
6409f0d558 Make Run button visible on hover
This slightly reduces the noisiness of doc pages, making them easier to
read.
2022-01-05 10:07:22 -05:00
Matthias Krüger
439a1254b9
Rollup merge of #92583 - lnicola:rust-analyzer-2022-01-05, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2022-01-05 15:05:50 +01:00
Matthias Krüger
5f03ae3507
Rollup merge of #92575 - petrochenkov:cratenodeid, r=Aaron1011
ast: Always keep a `NodeId` in `ast::Crate`

This makes it more uniform with other expanded nodes.
It makes generic code in https://github.com/rust-lang/rust/pull/92573 simpler in particular.

This is another follow-up to https://github.com/rust-lang/rust/pull/91313.
r? `@Aaron1011`
2022-01-05 15:05:49 +01:00
Matthias Krüger
c570fcb0c4
Rollup merge of #92574 - luojia65:riscv-kernel-dev-rust, r=Amanieu
Add RISC-V detection macro and more architecture instructions

This pull request includes:

- Update `stdarch` dependency to include ratified RISC-V supervisor and hypervisor instruction intrinsics which is useful in Rust kernel development
- Add macro `is_riscv_feature_detected!`
- Modify impl of `core::hint::spin_loop` to comply with latest version of `core::arch`

After this update, users may now develop RISC-V kernels and user applications more freely.

r? `@Amanieu`
2022-01-05 15:05:48 +01:00
Matthias Krüger
051d591edf
Rollup merge of #92483 - ksqsf:master, r=dtolnay
Stabilize `result_cloned` and `result_copied`

Tracking issue: #63168

The FCP is now completed.
2022-01-05 15:05:47 +01:00
Matthias Krüger
bf9546c127
Rollup merge of #92442 - pierwill:localdefid-doc-ord, r=Aaron1011
Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`

Suggested in https://github.com/rust-lang/rust/pull/92233#discussion_r776123222.

This also fixes some formatting in the doc comment.

r? `@cjgillot`
2022-01-05 15:05:46 +01:00
Matthias Krüger
84e48a41d3
Rollup merge of #92388 - SpriteOvO:master, r=Mark-Simulacrum
Fix a minor mistake in `String::try_reserve_exact` examples

The examples of `String::try_reserve_exact` didn't actually use `try_reserve_exact`, which was probably a minor mistake, and this PR fixed it.
2022-01-05 15:05:45 +01:00
Matthias Krüger
56d11a446b
Rollup merge of #92092 - saethlin:fix-sort-guards-sb, r=danielhenrymantilla
Drop guards in slice sorting derive src pointers from &mut T, which is invalidated by interior mutation in comparison

I tried to run https://github.com/rust-lang/miri-test-libstd on `alloc` with `-Zmiri-track-raw-pointers`, and got a failure on the test `slice::panic_safe`. The test failure has nothing to do with panic safety, it's from how the test tests for panic safety.

I minimized the test failure into this very silly program:
```rust
use std::cell::Cell;
use std::cmp::Ordering;

#[derive(Clone)]
struct Evil(Cell<usize>);

fn main() {
    let mut input = vec![Evil(Cell::new(0)); 3];

    // Hits the bug pattern via CopyOnDrop in core
    input.sort_unstable_by(|a, _b| {
        a.0.set(0);
        Ordering::Less
    });

    // Hits the bug pattern via InsertionHole in alloc
    input.sort_by(|_a, b| {
        b.0.set(0);
        Ordering::Less
    });
}
```

To fix this, I'm just removing the mutability/uniqueness where it wasn't required.
2022-01-05 15:05:44 +01:00
bors
181e91567c Auto merge of #92580 - matthiaskrgr:rollup-nzyn65y, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92182 (Label more build steps)
 - #92188 (rustdoc: Clean up NestedAttributesExt trait/implementation)
 - #92322 (Add another implementation example to Debug trait)
 - #92448 (Set font size proportional to user's font size)
 - #92517 (Explicitly pass `PATH` to the Windows exe resolver)
 - #92545 (Extract init_env_logger to crate)
 - #92579 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-05 12:32:28 +00:00
Laurențiu Nicola
2687a93bc8 ⬆️ rust-analyzer 2022-01-05 13:43:32 +02:00
Matthias Krüger
a0673468ae
Rollup merge of #92579 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/92527
2022-01-05 11:26:09 +01:00
Matthias Krüger
d83dd85253
Rollup merge of #92545 - dtolnay:rustlog, r=petrochenkov
Extract init_env_logger to crate

I've been doing some work on rustc_ast_pretty using an out-of-tree main.rs and Cargo.toml with the following:

```toml
[dependencies]
rustc_ast = { path = "../rust/compiler/rustc_ast" }
rustc_ast_pretty = { path = "../rust/compiler/rustc_ast_pretty" }
rustc_span = { path = "../rust/compiler/rustc_span" }
```

Rustc_ast_pretty helpfully uses `tracing::debug!` but I found that in order to enable the debug output, my test crate must depend on rustc_driver which is an enormously bigger dependency than what I have been using so far, and slows down iteration time because an enormous dependency tree between rustc_ast and rustc_driver must now be rebuilt after every ast change.

I pulled out the tracing initialization to a new minimal rustc_log crate so that projects depending on the other rustc crates, like rustc_ast_pretty, can access the `debug!` messages in them without building all the rest of rustc.
2022-01-05 11:26:08 +01:00
Matthias Krüger
42a3acfdb1
Rollup merge of #92517 - ChrisDenton:explicit-path, r=dtolnay
Explicitly pass `PATH` to the Windows exe resolver

This allows for testing different `PATH`s without using the actual environment.
2022-01-05 11:26:07 +01:00
Matthias Krüger
5bf321f9a4
Rollup merge of #92448 - jsha:font-size-access, r=GuillaumeGomez
Set font size proportional to user's font size

According to MDN (https://developer.mozilla.org/en-US/docs/Web/CSS/font-size),

> To maximize accessibility, it is generally best to use values that are relative to the user's default font size.

> Defining font sizes in px is not accessible, because the user cannot change the font size in some browsers.

Note that changing font size (in browser or OS settings) is distinct from the zoom functionality triggered with Ctrl/Cmd-+. Zoom
functionality increases the size of everything on the page, effectively applying a multiplier to all pixel sizes. Font size changes apply to just text.

For relative font sizes, we could use `em`, as we do in several places already. However that has a problem of "compounding" (see MDN article for details). The compounding problem is nicely solved by `rem`, which make font sizes relative to the root element, not the parent element.

Since we were using a hodge-podge of pixel sizes, em, rem, and percentage sizes before, this change switches everything to rem, while keeping the same size relative to our old default of 16px.

16px is still the default on most browsers, for users that haven't set a larger or smaller font size.

Part of #59845. Note: this will conflict with #92404. We should merge that first (once it's done) and I'll resolve the merge conflicts.

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/font-size-access/std/string/struct.String.html
2022-01-05 11:26:06 +01:00
Matthias Krüger
a0262fdf1f
Rollup merge of #92322 - alper:add_debug_trait_documentation, r=dtolnay
Add another implementation example to Debug trait

As per the discussion in: #92276
2022-01-05 11:26:05 +01:00
Matthias Krüger
cc01433d56
Rollup merge of #92188 - vacuus:nested-attributes-ext, r=jyn514
rustdoc: Clean up NestedAttributesExt trait/implementation
2022-01-05 11:26:04 +01:00
Matthias Krüger
e35a4bd8d0
Rollup merge of #92182 - nnethercote:label-more-build-steps, r=Mark-Simulacrum
Label more build steps

Some small improvements.

r? ```@Mark-Simulacrum```
2022-01-05 11:26:03 +01:00
Ralf Jung
e568423815 update Miri 2022-01-05 10:41:22 +01:00
bors
936ce3dab7 Auto merge of #92103 - Kobzol:stable-hash-skip-zero-bytes, r=the8472
Do not hash leading zero bytes of i64 numbers in Sip128 hasher

I was poking into the stable hasher, trying to improve its performance by compressing the number of hashed bytes. First I was experimenting with LEB128, but it was painful to implement because of the many assumptions that the SipHasher makes, so I tried something simpler - just ignoring leading zero bytes. For example, if an 8-byte integer can fit into a 4-byte integer, I will just hash the four bytes.

I wonder if this could produce any hashing ambiguity. Originally I thought so, but then I struggled to find any counter-example where this could cause different values to have the same hash. I'd be glad for any examples that could be broken by this (there are some ways of mitigating it if that would be the case). It could happen if you had e.g. 2x `u8` vs 1x `u16` hashed after one another in two different runs, but that can also happen now, without this "trick". And with collections, it should be fine, because the length is included in their hash.

I gathered some statistics for common values used in the `clap` benchmark. I observed that especially `i64` often had very low values, so I started with that type, let's see what perf does on CI.

There are some tradeoffs that we can try:
1) What types to use this optimization for? `u64`, `u32`, `u16`? Locally it was a slight loss for `u64`, I noticed that its values are often quite large.
2) What byte sizes to check? E.g. we can only distinguish between `u64`/`u32` or `u64`/`u8` instead of `u64`/`u32`/`u16`/`u8` to reduce branching (with `i64` it seemed to be better to go all the way down to `u8` locally though).

(The macro was introduced because I expect that I will be trying out this "trick" for different types).

Can you please schedule a perf. run? Thanks.

r? `@the8472`
2022-01-05 09:27:18 +00:00
Vadim Petrochenkov
55595c5616 ast: Always keep a NodeId in ast::Crate
This makes it more uniform with other expanded nodes
2022-01-05 17:09:37 +08:00
Mahdi Dibaiee
973cf632d3
Remove unsupported types in primitive_to_ty conversion, add FIXME note 2022-01-05 08:04:42 +00:00
Mahdi Dibaiee
19419f3771
add a test case for each supported primitive type 2022-01-05 08:04:40 +00:00
Mahdi Dibaiee
83487b8f27
Rustdoc: resolve associated traits for primitive types
Fixes #90703
2022-01-05 08:03:55 +00:00
luojia65
06f4453027 Add is_riscv_feature_detected!; modify impl of hint::spin_loop
Update library/core/src/hint.rs

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>

Remove redundant config gate
2022-01-05 15:44:52 +08:00
bors
b03c504742 Auto merge of #92498 - camelid:ignore-flaky-test, r=Mark-Simulacrum
Ignore flaky `panic-short-backtrace-windows-x86_64.rs` test for now

Mitigates (but does not fix) #92000.

It has been causing a lot of spurious test failures recently that slow
down the bors queue.
2022-01-05 06:18:57 +00:00