Commit Graph

160865 Commits

Author SHA1 Message Date
Noah Lev
1064003f8c Use fragment instead of side channel for prim. assoc. items
I had the epiphany that now that fragments are "semantic" -- rather than
just strings -- they fill the role that used to be handled by the side
channel. I think I may be able to get rid of the other uses of the side
channel using this technique too.
2022-01-06 11:48:47 -08:00
Noah Lev
7e3132adb3 Extract function for reporting feature gate error 2022-01-06 11:48:47 -08:00
Noah Lev
a324fc19d4 Only check for conflicting anchors in one place
This coalesces the checks into one place.
2022-01-06 11:48:47 -08:00
Noah Lev
3b50a4e286 Use DefIds instead of names in UrlFragment
This is the next step in computing more "semantic" information during
intra-doc link collection and then doing rendering all at the end.
2022-01-06 11:48:46 -08:00
Noah Lev
f89e2dd935 Move anchor conflict check to call site
I think it makes the code easier to understand.
2022-01-06 11:40:36 -08:00
Frank Steffahn
d5d752ab1e remove unused ExtendDefault struct 2022-01-06 18:49:55 +01:00
bors
cfa4ac66c1 Auto merge of #92609 - matthiaskrgr:rollup-ldp47ot, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92058 (Make Run button visible on hover)
 - #92288 (Fix a pair of mistyped test cases in `std::net::ip`)
 - #92349 (Fix rustdoc::private_doc_tests lint for public re-exported items)
 - #92360 (Some cleanups around check_argument_types)
 - #92389 (Regression test for borrowck ICE #92015)
 - #92404 (Fix font size for [src] links in headers)
 - #92443 (Rustdoc: resolve associated traits for non-generic primitive types)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-06 15:30:46 +00:00
Guillaume Gomez
26edfc9e31 Create CSS class instead of using inline style for search results 2022-01-06 15:12:01 +01:00
bors
a77cc64af4 Auto merge of #89819 - davidtwco:issue-81024-multiple-crates-multiple-dwarves, r=nagisa
cg: split dwarf for crate dependencies

Fixes #81024.

- 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 in object files and package debuginfo into a DWARF package file (`.dwp`) and `-C split-debuginfo=unpacked` will put debuginfo in 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).

  In the first commit of this PR, I re-introduce 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).
- Split DWARF packaging requires all of the object files to exist, including those in dependencies. ~~Therefore, the second commit of this PR makes rustc keep all objects or dwarf objects for unpacked mode and if the crate is a dependency in packed mode (determined by heuristic: if no linking is taking place), then objects or dwarf objects are kept. Objects are kept if `-Z split-dwarf-kind` is `SplitDwarfKind::Single`, and dwarf objects if `SplitDwarfKind::Split`.~~

  ~~There are other approaches that could be taken to supporting packed Split DWARF with crate dependencies but this seemed like the least complicated and was contained to only rustc. Other potential approaches are described in https://github.com/rust-lang/rust/issues/81024#issuecomment-760478223, I'm happy to change the approach I've taken here if it isn't what we're looking for.~~ See https://github.com/rust-lang/rust/pull/89819#issuecomment-985671867 for the current approach.
- ~~There's still a dependency on `llvm-dwp` after this change, which [we probably want to move away from](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/llvm-dwp.20is.20not.20recommended) but that seems out-of-scope for this PR. Ideally, Split DWARF (in packed or unpacked modes) will be usable on nightly after this lands. If there aren't any bugs reported then it's possible we could allow Split DWARF to be used on stable after this change, it depends whether or not switching away from `llvm-dwp` later would break any guarantees, or whether we'd want to change how we handle this cross-crate case in future.~~ See https://github.com/rust-lang/rust/pull/89819#issuecomment-985671867.

r? `@nagisa`
cc `@alexcrichton`
2022-01-06 12:21:10 +00:00
Matthias Krüger
26a90e4cd7
Rollup merge of #92443 - mdibaiee:90703/resolve-traits-of-primitive-types, r=Manishearth
Rustdoc: resolve associated traits for non-generic primitive types

Fixes #90703

This seems to work:
<img width="457" alt="image" src="https://user-images.githubusercontent.com/2807772/147774059-9556ff96-4519-409e-8ed0-c33ecc436171.png">

I'm just afraid I might have missed some cases / broken previous functionality.

I also have not written tests yet, I will have to take a look to see where tests are and how they are structured, but any help there is also appreciated.
2022-01-06 12:01:05 +01:00
Matthias Krüger
b510278278
Rollup merge of #92404 - GuillaumeGomez:src-font-size, r=jsha
Fix font size for [src] links in headers

Fixes #90384.

cc `@jsha`
r? `@camelid`
2022-01-06 12:01:04 +01:00
Matthias Krüger
96a267ee1f
Rollup merge of #92389 - chordtoll:test-92015, r=Mark-Simulacrum
Regression test for borrowck ICE #92015

This issue has come up a few times. Creating a regression test.
Closes #92015.
2022-01-06 12:01:03 +01:00
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