]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoerister
Manish Goregaokar [Wed, 15 Sep 2021 21:56:56 +0000 (14:56 -0700)]
Rollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoerister

Introduce -Z remap-cwd-prefix switch

This switch remaps any absolute paths rooted under the current
working directory to a new value. This includes remapping the
debug info in `DW_AT_comp_dir` and `DW_AT_decl_file`.

Importantly, this flag does not require passing the current working
directory to the compiler, such that the command line can be
run on any machine (with the same input files) and produce the
same results. This is critical property for debugging compiler
issues that crop up on remote machines.

This is based on adetaylor's https://github.com/rust-lang/rust/commit/dbc4ae7cba0ba8d650b91ddd459b86a02a2d05c5

Major Change Proposal: https://github.com/rust-lang/compiler-team/issues/450
Discussed on #38322. Would resolve issue #87325.

2 years agoAllow `panic!("{}", computed_str)` in const fn.
Gary Guo [Tue, 14 Sep 2021 18:14:37 +0000 (19:14 +0100)]
Allow `panic!("{}", computed_str)` in const fn.

2 years agoAdd tracking issue for unix_chown
Josh Triplett [Wed, 15 Sep 2021 20:09:54 +0000 (13:09 -0700)]
Add tracking issue for unix_chown

2 years agoAllow call to get_body_with_borrowck_facts without -Z polonius
Will Crichton [Wed, 15 Sep 2021 18:45:31 +0000 (11:45 -0700)]
Allow call to get_body_with_borrowck_facts without -Z polonius

2 years agoMake rustc_mir_dataflow::framework::graphviz and rustc_mir_transform::MirPass public
Will Crichton [Wed, 15 Sep 2021 18:41:37 +0000 (11:41 -0700)]
Make rustc_mir_dataflow::framework::graphviz and rustc_mir_transform::MirPass public

2 years agoUpdate the backtrace crate
Henrik Böving [Wed, 15 Sep 2021 18:32:35 +0000 (20:32 +0200)]
Update the backtrace crate

https://github.com/rust-lang/backtrace-rs/pull/437 fixed backtraces in
OpenBSD -> update it here as well so OpenBSD Rust code can produce
proper backtraces.

2 years agoUpdate clobber_abi list to include k[1-7] regs
Commeownist [Wed, 15 Sep 2021 18:31:59 +0000 (21:31 +0300)]
Update clobber_abi list to include k[1-7] regs

2 years agoDisable both reproducible-build tests for crate-type=bin
danakj [Wed, 15 Sep 2021 17:37:22 +0000 (13:37 -0400)]
Disable both reproducible-build tests for crate-type=bin

These tests fail on Windows, as the build is not deterministic there for
bin targets.

Issue https://github.com/rust-lang/rust/issues/88982 is filed for this
problem.

2 years agoMove some tests to more reasonable directories
Caio [Wed, 15 Sep 2021 17:03:27 +0000 (14:03 -0300)]
Move some tests to more reasonable directories

2 years agoUse explicit log level in tracing instrument macro
Tomasz Miąsko [Mon, 6 Sep 2021 00:00:00 +0000 (00:00 +0000)]
Use explicit log level in tracing instrument macro

Specify a log level in tracing instrument macro explicitly.

Additionally reduce the used log level from a default info level to a
debug level (all of those appear to be developer oriented logs, so there
should be no need to include them in release builds).

2 years agoDisable RemoveZsts in generators to avoid query cycles
Tomasz Miąsko [Wed, 15 Sep 2021 00:00:00 +0000 (00:00 +0000)]
Disable RemoveZsts in generators to avoid query cycles

Querying layout of a generator requires its optimized MIR. Thus
computing layout during MIR optimization of a generator might create a
query cycle. Disable RemoveZsts in generators to avoid the issue
(similar approach is used in ConstProp transform already).

2 years agoMake two functions private
bjorn3 [Wed, 15 Sep 2021 16:44:31 +0000 (18:44 +0200)]
Make two functions private

2 years agoInline with_interner
bjorn3 [Wed, 15 Sep 2021 16:44:17 +0000 (18:44 +0200)]
Inline with_interner

2 years agoMove the Lock into symbol::Interner
bjorn3 [Wed, 15 Sep 2021 16:33:41 +0000 (18:33 +0200)]
Move the Lock into symbol::Interner

This makes it easier to make the symbol interner (near) lock free in
case of concurrent accesses in the future.

2 years agoDisable validate_maintainers.
Eric Huss [Wed, 15 Sep 2021 16:25:06 +0000 (09:25 -0700)]
Disable validate_maintainers.

2 years agodocs(std): add docs for cof_from_cstr impls
Michael Howell [Wed, 15 Sep 2021 16:14:20 +0000 (09:14 -0700)]
docs(std): add docs for cof_from_cstr impls

CC #51430

2 years agochore(rustc_expand): fix typo in comment
Michael Howell [Wed, 15 Sep 2021 16:13:18 +0000 (09:13 -0700)]
chore(rustc_expand): fix typo in comment

2 years agoVerify bin crates are not deterministic on Windows
danakj [Wed, 15 Sep 2021 15:49:12 +0000 (11:49 -0400)]
Verify bin crates are not deterministic on Windows

This disables the remap_cwd_bin test which is failing on windows,
and adds a test for --remap-path-prefix making a bin crate
instead, to see if it will fail the same way.

2 years agoMove object safety suggestions to the end of the error
Esteban Kuber [Sun, 12 Sep 2021 18:49:56 +0000 (18:49 +0000)]
Move object safety suggestions to the end of the error

2 years agoFast reject for NeedsNonConstDrop
Deadbeef [Wed, 15 Sep 2021 13:26:12 +0000 (13:26 +0000)]
Fast reject for NeedsNonConstDrop

2 years agoAuto merge of #87867 - bjorn3:unique_type_id_interner, r=wesleywiser
bors [Wed, 15 Sep 2021 12:34:31 +0000 (12:34 +0000)]
Auto merge of #87867 - bjorn3:unique_type_id_interner, r=wesleywiser

Use a separate interner type for UniqueTypeId

Using symbol::Interner makes it very easy to mixup UniqueTypeId symbols
with the global interner. In fact the Debug implementation of
UniqueTypeId did exactly this.

Using a separate interner type also avoids prefilling the interner with
unused symbols and allow for optimizing the symbol interner for parallel
access without negatively affecting the single threaded module codegen.

2 years agoAuto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu
bors [Wed, 15 Sep 2021 09:30:00 +0000 (09:30 +0000)]
Auto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu

Remove `cfg(doc)` from std::os module reexports to fix rustdoc linking issues

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

I tested it based on https://github.com/rust-lang/rust/pull/88292.

Not sure if it's the best approach, but at least it makes thing a bit simpler.

cc `@jyn514`

2 years agoinline(always) on check_recursion_limit
Deadbeef [Wed, 15 Sep 2021 09:17:35 +0000 (09:17 +0000)]
inline(always) on check_recursion_limit

2 years agoAuto merge of #88558 - fee1-dead:const-drop, r=oli-obk
bors [Wed, 15 Sep 2021 03:51:03 +0000 (03:51 +0000)]
Auto merge of #88558 - fee1-dead:const-drop, r=oli-obk

Const drop

The changes are pretty primitive at this point. But at least it works. ^-^

Problems with the current change that I can think of now:
 - [x] `~const Drop` shouldn't change anything in the non-const world.
 - [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`.
 - [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue.

Fixes #88424.

Significant Changes:

- `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue)
- `T: ~const Drop` will not be linted like `T: Drop`.
- Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others.

Changes not related to `const Drop`ping and/or changes that are insignificant:

 - `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed.
 - Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir.
 - `ty::Destructor` now has a field `constness`, which represents the constness of the destructor.

r? `@oli-obk`

2 years agoConst Deref
Deadbeef [Sun, 12 Sep 2021 15:26:30 +0000 (15:26 +0000)]
Const Deref

2 years agoAdd chown functions to std::os::unix::fs to change the owner and group of files
Josh Triplett [Wed, 15 Sep 2021 01:29:38 +0000 (18:29 -0700)]
Add chown functions to std::os::unix::fs to change the owner and group of files

This is a straightforward wrapper that uses the existing helpers for C
string handling and errno handling.

Having this available is convenient for UNIX utility programs written in
Rust, and avoids having to call unsafe functions like `libc::chown`
directly and handle errors manually, in a program that may otherwise be
entirely safe code.

In addition, these functions provide a more Rustic interface by
accepting appropriate traits and using `None` rather than `-1`.

2 years agoUpdate books
Eric Huss [Wed, 15 Sep 2021 00:57:07 +0000 (17:57 -0700)]
Update books

2 years agoPoint to closure when emitting 'cannot move out' for captured variable
Fabian Wolff [Sun, 25 Jul 2021 18:05:41 +0000 (20:05 +0200)]
Point to closure when emitting 'cannot move out' for captured variable

2 years agoFix handling of `hir::GenericArg::Infer` in `wrong_number_of_generic_args.rs`
Fabian Wolff [Tue, 14 Sep 2021 22:11:18 +0000 (00:11 +0200)]
Fix handling of `hir::GenericArg::Infer` in `wrong_number_of_generic_args.rs`

2 years agoRemove concept of 'completion' from the projection cache
Aaron Hill [Tue, 14 Sep 2021 20:38:53 +0000 (15:38 -0500)]
Remove concept of 'completion' from the projection cache

Fixes #88910

When we initially store a `NormalizedTy` in the projection cache,
we discard all obligations that we can (while ensuring that we
don't cause any issues with incremental compilation).

Marking a projection cache entry as 'completed' discards all
obligations associated with it. This can only cause problems,
since any obligations stored in the cache are there for a reason
(e.g. they evaluate to `EvaluatedToOkModuloRegions`).

This commit removes `complete` and `complete_normalized` entirely.

2 years agoAdd reachable_patterns lint to rfc-2008-non_exhaustive
Devin Ragotzy [Fri, 10 Sep 2021 20:45:04 +0000 (16:45 -0400)]
Add reachable_patterns lint to rfc-2008-non_exhaustive

Add linting on non_exhaustive structs and enum variants

Add ui tests for non_exhaustive reachable lint

Rename to non_exhaustive_omitted_patterns and avoid triggering on if let

2 years agoreview comment: move recovery code to its own function
Esteban Kuber [Tue, 14 Sep 2021 18:16:33 +0000 (18:16 +0000)]
review comment: move recovery code to its own function

2 years agoAuto merge of #73314 - GuillaumeGomez:display-warnings, r=jyn514
bors [Tue, 14 Sep 2021 16:05:44 +0000 (16:05 +0000)]
Auto merge of #73314 - GuillaumeGomez:display-warnings, r=jyn514

Rename "--display-warnings" to "--display-doctest-warnings"

Fixes #41574.

cc `@ollie27`
r? `@kinnison`

2 years agoRemove implementation of `min_align_of` intrinsic
Tomasz Miąsko [Tue, 14 Sep 2021 00:00:00 +0000 (00:00 +0000)]
Remove implementation of `min_align_of` intrinsic

Since 88839 `min_align_of` is lowered to AlignOf operator.

2 years agoReplace cnum_map with tcx.stable_crate_id_to_crate_num() in OnDiskCache.
Michael Woerister [Wed, 8 Sep 2021 16:27:06 +0000 (18:27 +0200)]
Replace cnum_map with tcx.stable_crate_id_to_crate_num() in OnDiskCache.

2 years agorustc_metadata: Remove Metadata::raw_bytes() and use Metadata::blob() directly instead.
Michael Woerister [Tue, 24 Aug 2021 12:39:38 +0000 (14:39 +0200)]
rustc_metadata: Remove Metadata::raw_bytes() and use Metadata::blob() directly instead.

2 years agoRename DefPathHashMap in rustc_metadata so its name does not clash with DefPathHashMa...
Michael Woerister [Wed, 18 Aug 2021 16:29:11 +0000 (18:29 +0200)]
Rename DefPathHashMap in rustc_metadata so its name does not clash with DefPathHashMap in rustc_hir.

2 years agoFix up comment about OnDiskCache::foreign_expn_data.
Michael Woerister [Wed, 21 Jul 2021 11:38:29 +0000 (13:38 +0200)]
Fix up comment about OnDiskCache::foreign_expn_data.

2 years agoMake DefPathHash->DefId panic for if the mapping fails.
Michael Woerister [Tue, 20 Jul 2021 12:18:37 +0000 (14:18 +0200)]
Make DefPathHash->DefId panic for if the mapping fails.

We only use this mapping for cases where we know that it must succeed.
Letting it panic otherwise makes it harder to use the API in unsupported
ways.

2 years agoRemove RawDefId tracking infrastructure from incr. comp. framework.
Michael Woerister [Tue, 20 Jul 2021 12:03:20 +0000 (14:03 +0200)]
Remove RawDefId tracking infrastructure from incr. comp. framework.

This infrastructure is obsolete now with the new encoding scheme for
the DefPathHash->DefIndex maps in crate metadata.

2 years agoStore DefPathHash->DefIndex map in on-disk-hash-table format in crate metadata.
Michael Woerister [Tue, 20 Jul 2021 11:59:12 +0000 (13:59 +0200)]
Store DefPathHash->DefIndex map in on-disk-hash-table format in crate metadata.

This encoding allows for random access without an expensive upfront decoding
state which in turn allows simplifying the DefPathIndex lookup logic without
regressing performance.

2 years agoUse on-disk-hash-table format for DefPathHashMap in hir::definitions.
Michael Woerister [Tue, 20 Jul 2021 11:54:37 +0000 (13:54 +0200)]
Use on-disk-hash-table format for DefPathHashMap in hir::definitions.

2 years agoAllow taking an OwningRef of the crate metadata blob.
Michael Woerister [Tue, 20 Jul 2021 11:51:21 +0000 (13:51 +0200)]
Allow taking an OwningRef of the crate metadata blob.

2 years agoAvoid unnecessary formatting when trace log level is disabled
Tomasz Miąsko [Tue, 14 Sep 2021 00:00:00 +0000 (00:00 +0000)]
Avoid unnecessary formatting when trace log level is disabled

2 years agoAdd test for --display-doctest-warnings option
Guillaume Gomez [Thu, 9 Sep 2021 14:52:48 +0000 (16:52 +0200)]
Add test for --display-doctest-warnings option

2 years agoRename --display-warnings to --display-doctest-warnings
Guillaume Gomez [Thu, 9 Sep 2021 14:52:19 +0000 (16:52 +0200)]
Rename --display-warnings to --display-doctest-warnings

2 years agoAuto merge of #88914 - GuillaumeGomez:rollup-h5svc6w, r=GuillaumeGomez
bors [Tue, 14 Sep 2021 08:46:22 +0000 (08:46 +0000)]
Auto merge of #88914 - GuillaumeGomez:rollup-h5svc6w, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #88033 (Add links for primitives in "jump to definition" feature)
 - #88722 (Make `UnsafeCell::get_mut` const)
 - #88851 (Fix duplicate bounds for const_trait_impl)
 - #88859 (interpreter PointerArithmetic: use new Size helper methods)
 - #88885 (Fix jump def background)
 - #88894 (Improve error message for missing trait in trait impl)
 - #88896 (Reduce possibility of flaky tests)

Failed merges:

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

2 years agoDocument the closure arguments for `reduce`.
Dan Zwell [Tue, 14 Sep 2021 06:22:49 +0000 (14:22 +0800)]
Document the closure arguments for `reduce`.

Fixes issue #88927.

2 years agoAuto merge of #87794 - bonega:enum_niche_prefer_zero, r=nagisa
bors [Mon, 13 Sep 2021 22:14:57 +0000 (22:14 +0000)]
Auto merge of #87794 - bonega:enum_niche_prefer_zero, r=nagisa

Enum should prefer discriminant zero for niche

Given an enum with unassigned zero-discriminant, rust should prefer it for niche selection.
Zero as discriminant for `Option<Enum>` makes it possible for LLVM to optimize resulting asm.

- Eliminate branch when expected value coincides.
- Use smaller instruction `test eax, eax` instead of `cmp eax, ?`
- Possible interaction with zeroed memory?

Example:
```rust

pub enum Size {
    One = 1,
    Two = 2,
    Three = 3,
}

pub fn handle(x: Option<Size>) -> u8 {
    match x {
        None => {0}
        Some(size) => {size as u8}
    }
}
```
In this case discriminant zero is available as a niche.

Above example on nightly:
```asm
 mov     eax, edi
 cmp     al, 4
 jne     .LBB0_2
 xor     eax, eax
.LBB0_2:
 ret
```

PR:
```asm
 mov     eax, edi
 ret
```

I created this PR because I had a performance regression when I tried to use an enum to represent legal grapheme byte-length for utf8.

Using an enum instead of `NonZeroU8` [here](https://github.com/bonega/yore/blob/d683304f5dfe2e99f769e6ab8adf8d60a0d1d9b3/src/internal/decoder_incomplete.rs#L90)
resulted in a performance regression of about 5%.
I consider this to be a somewhat realistic benchmark.

Thanks to `@ogoffart` for pointing me in the right direction!

Edit: Updated description

2 years agoenum niche allocation grows toward zero if possible
Andreas Liljeqvist [Sun, 8 Aug 2021 11:34:46 +0000 (13:34 +0200)]
enum niche allocation grows toward zero if possible

2 years ago`Wrapping<T>` has the same layout and ABI as `T`
Joshua Liebow-Feeser [Mon, 13 Sep 2021 19:39:45 +0000 (12:39 -0700)]
`Wrapping<T>` has the same layout and ABI as `T`

2 years agoUpdate permissions path for clippy lint
Guillaume Gomez [Mon, 13 Sep 2021 19:27:53 +0000 (21:27 +0200)]
Update permissions path for clippy lint

2 years agoRollup merge of #88896 - GuillaumeGomez:flakyness, r=camelid
Guillaume Gomez [Mon, 13 Sep 2021 19:20:43 +0000 (21:20 +0200)]
Rollup merge of #88896 - GuillaumeGomez:flakyness, r=camelid

Reduce possibility of flaky tests

As asked in https://github.com/rust-lang/rust/pull/88885.

r? ``@camelid``

2 years agoRollup merge of #88894 - FabianWolff:issue-88818, r=estebank
Guillaume Gomez [Mon, 13 Sep 2021 19:20:42 +0000 (21:20 +0200)]
Rollup merge of #88894 - FabianWolff:issue-88818, r=estebank

Improve error message for missing trait in trait impl

Fixes #88818. For the following example:
```rust
struct S { }
impl for S { }
```
the current output is:
```
error: missing trait in a trait impl
 --> t1.rs:2:5
  |
2 | impl for S { }
  |     ^
```
With my changes, I get:
```
error: missing trait in a trait impl
 --> t1.rs:2:5
  |
2 | impl for S { }
  |     ^
  |
help: add a trait here
  |
2 | impl Trait for S { }
  |      +++++
help: for an inherent impl, drop this `for`
  |
2 - impl for S { }
2 + impl S { }
  |
```

2 years agoRollup merge of #88885 - GuillaumeGomez:fix-jump-def-background, r=camelid
Guillaume Gomez [Mon, 13 Sep 2021 19:20:41 +0000 (21:20 +0200)]
Rollup merge of #88885 - GuillaumeGomez:fix-jump-def-background, r=camelid

Fix jump def background

Fixes #88870.

I somehow badly wrote the color in #88111.

r? ``@camelid``

2 years agoRollup merge of #88859 - RalfJung:size-helpers, r=oli-obk
Guillaume Gomez [Mon, 13 Sep 2021 19:20:40 +0000 (21:20 +0200)]
Rollup merge of #88859 - RalfJung:size-helpers, r=oli-obk

interpreter PointerArithmetic: use new Size helper methods

2 years agoRollup merge of #88851 - fee1-dead:dup-bound, r=oli-obk
Guillaume Gomez [Mon, 13 Sep 2021 19:20:39 +0000 (21:20 +0200)]
Rollup merge of #88851 - fee1-dead:dup-bound, r=oli-obk

Fix duplicate bounds for const_trait_impl

Fixes #88383.

Compare the constness of the candidates before winnowing and removing a `~const` `BoundCandidate`.

2 years agoRollup merge of #88722 - WaffleLapkin:unsafe_cell_const_get_mut, r=dtolnay
Guillaume Gomez [Mon, 13 Sep 2021 19:20:39 +0000 (21:20 +0200)]
Rollup merge of #88722 - WaffleLapkin:unsafe_cell_const_get_mut, r=dtolnay

Make `UnsafeCell::get_mut` const

2 years agoRollup merge of #88033 - GuillaumeGomez:jump-to-def-primitive, r=jyn514
Guillaume Gomez [Mon, 13 Sep 2021 19:20:38 +0000 (21:20 +0200)]
Rollup merge of #88033 - GuillaumeGomez:jump-to-def-primitive, r=jyn514

Add links for primitives in "jump to definition" feature

Follow-up of #84176.

I created a function `primitive_from_str` which is code that was originally in `collect_intra_doc_links::resolve_primitive` to prevent code duplication.

I also created the `primitive_link_url` function which is somewhat similar to `primitive_link` but too much different to merge both of them.

r? ``@jyn514``

2 years agoMove fortanix module position in std::os reexports for alpha sort
Guillaume Gomez [Tue, 7 Sep 2021 13:44:08 +0000 (15:44 +0200)]
Move fortanix module position in std::os reexports for alpha sort

2 years agoRemove usage of cfg_if in std/src/os/mod.rs
Guillaume Gomez [Fri, 3 Sep 2021 19:13:52 +0000 (21:13 +0200)]
Remove usage of cfg_if in std/src/os/mod.rs

2 years agoSimplify std::os module reexports to fix rustdoc linking issues
Guillaume Gomez [Fri, 3 Sep 2021 15:21:52 +0000 (17:21 +0200)]
Simplify std::os module reexports to fix rustdoc linking issues

2 years ago * Enable generate-link-to-def feature on a rustdoc GUI test
Guillaume Gomez [Sun, 12 Sep 2021 13:43:30 +0000 (15:43 +0200)]
 * Enable generate-link-to-def feature on a rustdoc GUI test
 * Add test for jump-to-def links background color

2 years agoImprove error message for type mismatch in generator arguments
Fabian Wolff [Mon, 13 Sep 2021 17:39:30 +0000 (19:39 +0200)]
Improve error message for type mismatch in generator arguments

2 years agoAuto merge of #87915 - estebank:fancy-spans, r=oli-obk
bors [Mon, 13 Sep 2021 16:31:12 +0000 (16:31 +0000)]
Auto merge of #87915 - estebank:fancy-spans, r=oli-obk

Use smaller spans for some structured suggestions

Use more accurate suggestion spans for

* argument parse error
* fully qualified path
* missing code block type
* numeric casts

2 years agoAdd negative test in macro-braces-dot-question.rs.
Mara Bos [Mon, 13 Sep 2021 15:50:59 +0000 (17:50 +0200)]
Add negative test in macro-braces-dot-question.rs.

2 years agoAdd test for primitive in "jump to definition" feature
Guillaume Gomez [Sat, 14 Aug 2021 18:17:43 +0000 (20:17 +0200)]
Add test for primitive in "jump to definition" feature

2 years agoAdd support for primitives in "jump to definition" feature
Guillaume Gomez [Sat, 14 Aug 2021 18:17:28 +0000 (20:17 +0200)]
Add support for primitives in "jump to definition" feature

2 years agoHighlight the const function if error happened because of a bound on the impl block
Waffle [Mon, 13 Sep 2021 13:36:14 +0000 (16:36 +0300)]
Highlight the const function if error happened because of a bound on the impl block

Currently, for the following code, the compiler produces the errors like the
following error:
```rust
struct Type<T>

impl<T: Clone> Type<T> {
fn const f() {}
}
```
```text
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
 --> ./test.rs:3:6
  |
3 | impl<T: Clone> Type<T> {
  |      ^
  |
  = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
  = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
```

This can be confusing (especially to newcomers) since the error mentions
"const fn parameters", but highlights only the impl.

This commits adds function highlighting, changing the error to the following:

```text
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
 --> ./test.rs:3:6
  |
3 | impl<T: Clone> Type<T> {
  |      ^
4 |     pub const fn f() {}
  |     ---------------- function declared as const here
  |
  = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
  = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
```

2 years agoAuto merge of #88766 - ehuss:update-cargo, r=ehuss
bors [Mon, 13 Sep 2021 13:12:34 +0000 (13:12 +0000)]
Auto merge of #88766 - ehuss:update-cargo, r=ehuss

Update cargo

6 commits in 18751dd3f238d94d384a7fe967abfac06cbfe0b9..e515c3277bf0681bfc79a9e763861bfe26bb05db
2021-09-01 14:26:00 +0000 to 2021-09-08 14:32:15 +0000
- Remove log output that may leak tokens (rust-lang/cargo#9873)
- rev = "refs/pull/𑑛/head" (rust-lang/cargo#9859)
- Update suggestion message on bad project name error (rust-lang/cargo#9877)
- clarify what goes into "*-sys" crates (rust-lang/cargo#9871)
- Improve error message when unable to initialize git index repo (rust-lang/cargo#9869)
- Use serde_json to generate cargo_vcs_info.json (rust-lang/cargo#9865)

2 years agoUse a separate interner type for UniqueTypeId
bjorn3 [Sun, 8 Aug 2021 15:24:30 +0000 (17:24 +0200)]
Use a separate interner type for UniqueTypeId

Using symbol::Interner makes it very easy to mixup UniqueTypeId symbols
with the global interner. In fact the Debug implementation of
UniqueTypeId did exactly this.

Using a separate interner type also avoids prefilling the interner with
unused symbols and allow for optimizing the symbol interner for parallel
access without negatively affecting the single threaded module codegen.

2 years agoSuggest replacing an inexisting field for an unmentioned field
Hirochika Matsumoto [Thu, 12 Aug 2021 10:10:44 +0000 (19:10 +0900)]
Suggest replacing an inexisting field for an unmentioned field

This PR adds a suggestion to replace an inexisting field for an
unmentioned field. Given the following code:
```rust
enum Foo {
    Bar { alpha: u8, bravo: u8, charlie: u8 },
}

fn foo(foo: Foo) {
    match foo {
        Foo::Bar {
            alpha,
            beta, // `bravo` miswritten as `beta` here.
            charlie,
        } => todo!(),
    }
}
```
the compiler now emits the error messages below.
```text
error[E0026]: variant `Foo::Bar` does not have a field named `beta`
 --> src/lib.rs:9:13
  |
9 |             beta, // `bravo` miswritten as `beta` here.
  |             ^^^^
  |             |
  |             variant `Foo::Bar` does not have this field
  |             help: `Foo::Bar` has a field named `bravo`: `bravo`
```

Note that this suggestion is available iff the number of inexisting
fields and unmentioned fields are both 1.

2 years agoAuto merge of #88745 - hnj2:allow-trait-impl-missing-code, r=GuillaumeGomez
bors [Mon, 13 Sep 2021 09:41:22 +0000 (09:41 +0000)]
Auto merge of #88745 - hnj2:allow-trait-impl-missing-code, r=GuillaumeGomez

Allow missing code examples in trait impls.

Excludes Trait implementations from the items that need to have doc code examples when using the `rustdoc::missing_doc_code_examples` lint.

For details see #88741

fixes #88741

r? `@jyn514`

2 years agoAuto merge of #88529 - Meziu:master, r=nagisa
bors [Mon, 13 Sep 2021 05:48:03 +0000 (05:48 +0000)]
Auto merge of #88529 - Meziu:master, r=nagisa

ARMv6K Nintendo 3DS Tier 3 target added

Addition of the target specifications to build .elf files for Nintendo 3DS (ARMv6K, Horizon). Requires devkitARM 3DS toolkit for system libraries and arm-none-eabi-gcc linker.

2 years agochore: convert to a multi-part suggestion
Michael Howell [Mon, 13 Sep 2021 02:51:09 +0000 (19:51 -0700)]
chore: convert to a multi-part suggestion

2 years agoAuto merge of #88517 - smoelius:without-patch-versions, r=flip1995
bors [Mon, 13 Sep 2021 02:45:18 +0000 (02:45 +0000)]
Auto merge of #88517 - smoelius:without-patch-versions, r=flip1995

Update Clippy dependencies without patch versions

Trial run for https://github.com/rust-lang/rust-clippy/pull/7606

2 years agoAuto merge of #88839 - nbdd0121:alignof, r=nagisa
bors [Sun, 12 Sep 2021 23:49:24 +0000 (23:49 +0000)]
Auto merge of #88839 - nbdd0121:alignof, r=nagisa

Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.

2 years agoAdd mir opt test for min_align_of -> AlignOf lowering
Gary Guo [Fri, 10 Sep 2021 23:54:10 +0000 (00:54 +0100)]
Add mir opt test for min_align_of -> AlignOf lowering

2 years agoIntroduce NullOp::AlignOf
Gary Guo [Tue, 7 Sep 2021 15:06:07 +0000 (16:06 +0100)]
Introduce NullOp::AlignOf

2 years agoDo not issue E0071 if a type error has already been reported
Fabian Wolff [Sun, 12 Sep 2021 21:07:23 +0000 (23:07 +0200)]
Do not issue E0071 if a type error has already been reported

2 years agoAuto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb
bors [Sun, 12 Sep 2021 20:48:09 +0000 (20:48 +0000)]
Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb

Add -Z panic-in-drop={unwind,abort} command-line option

This PR changes `Drop` to abort if an unwinding panic attempts to escape it, making the process abort instead. This has several benefits:
- The current behavior when unwinding out of `Drop` is very unintuitive and easy to miss: unwinding continues, but the remaining drops in scope are simply leaked.
- A lot of unsafe code doesn't expect drops to unwind, which can lead to unsoundness:
  - https://github.com/servo/rust-smallvec/issues/14
  - https://github.com/bluss/arrayvec/issues/3
- There is a code size and compilation time cost to this: LLVM needs to generate extra landing pads out of all calls in a drop implementation. This can compound when functions are inlined since unwinding will then continue on to process drops in the callee, which can itself unwind, etc.
  - Initial measurements show a 3% size reduction and up to 10% compilation time reduction on some crates (`syn`).

One thing to note about `-Z panic-in-drop=abort` is that *all* crates must be built with this option for it to be sound since it makes the compiler assume that dropping `Box<dyn Any>` will never unwind.

cc https://github.com/rust-lang/lang-team/issues/97

2 years agoReduce possibility of flaky tests
Guillaume Gomez [Sun, 12 Sep 2021 14:34:18 +0000 (16:34 +0200)]
Reduce possibility of flaky tests

2 years agoImprove error message for missing trait in trait impl
Fabian Wolff [Sun, 12 Sep 2021 20:05:52 +0000 (22:05 +0200)]
Improve error message for missing trait in trait impl

2 years agoAuto merge of #88811 - jackh726:issue-88446, r=nikomatsakis
bors [Sun, 12 Sep 2021 17:04:10 +0000 (17:04 +0000)]
Auto merge of #88811 - jackh726:issue-88446, r=nikomatsakis

Use a HashMap for UniverseInfo in mir borrowck

Fixes #88446

r? `@nikomatsakis`

2 years agoFix invalid background for jump-to-def links in source code pages
Guillaume Gomez [Sun, 12 Sep 2021 14:33:57 +0000 (16:33 +0200)]
Fix invalid background for jump-to-def links in source code pages

2 years agoAuto merge of #88881 - Manishearth:rollup-alohfwx, r=Manishearth
bors [Sun, 12 Sep 2021 13:29:56 +0000 (13:29 +0000)]
Auto merge of #88881 - Manishearth:rollup-alohfwx, r=Manishearth

Rollup of 7 pull requests

Successful merges:

 - #88336 ( Detect stricter constraints on gats where clauses in impls vs trait)
 - #88677 (rustc: Remove local variable IDs from `Export`s)
 - #88699 (Remove extra unshallow from cherry-pick checker)
 - #88709 (generic_const_exprs: use thir for abstract consts instead of mir)
 - #88711 (Rework DepthFirstSearch API)
 - #88810 (rustdoc: Cleanup `clean` part 1)
 - #88813 (explicitly link to external `ena` docs)

Failed merges:

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

2 years agoRollup merge of #88813 - lcnr:ena-docs, r=jyn514
Manish Goregaokar [Sun, 12 Sep 2021 10:44:59 +0000 (03:44 -0700)]
Rollup merge of #88813 - lcnr:ena-docs, r=jyn514

explicitly link to external `ena` docs

we currently do not link to the docs of `ena`: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/struct.InferCtxtInner.html#method.const_unification_table

2 years agoRollup merge of #88810 - camelid:cleanup-pt1, r=jyn514
Manish Goregaokar [Sun, 12 Sep 2021 10:44:58 +0000 (03:44 -0700)]
Rollup merge of #88810 - camelid:cleanup-pt1, r=jyn514

rustdoc: Cleanup `clean` part 1

Split out from #88379.

These commits are completely independent of each other, and each is a fairly
small change (the last few are new commits; they are not from #88379):

- Remove unnecessary `Cache.*_did` fields
- rustdoc: Get symbol for `TyParam` directly
- Create a valid `Res` in `external_path()`
- Remove unused `hir_id` parameter from `resolve_type`
- Fix redundant arguments in `external_path()`
- Remove unnecessary `is_trait` argument
- rustdoc: Cleanup a pattern match in `external_generic_args()`

r? ``@jyn514``

2 years agoRollup merge of #88711 - Mark-Simulacrum:fix-dfs-bug, r=jackh726
Manish Goregaokar [Sun, 12 Sep 2021 10:44:57 +0000 (03:44 -0700)]
Rollup merge of #88711 - Mark-Simulacrum:fix-dfs-bug, r=jackh726

Rework DepthFirstSearch API

This expands the API to be more flexible, allowing for more visitation patterns
on graphs. This will be useful to avoid extra datasets (and allocations) in
cases where the expanded DFS API is sufficient.

This also fixes a bug with the previous DFS constructor, which left the start
node not marked as visited (even though it was immediately returned).

Commit written by ```@nikomatsakis``` originally, cherry picked from several commits in work on never type stabilization, but stands alone.

2 years agoRollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnr
Manish Goregaokar [Sun, 12 Sep 2021 10:44:56 +0000 (03:44 -0700)]
Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnr

generic_const_exprs: use thir for abstract consts instead of mir

Changes `AbstractConst` building to use `thir` instead of `mir` so that there's less chance of consts unifying when they shouldn't because lowering to mir dropped information (see `abstract-consts-as-cast-5.rs` test)

r? `@lcnr`

2 years agoRollup merge of #88699 - Mark-Simulacrum:fixes-cherry-picker, r=pietroalbini
Manish Goregaokar [Sun, 12 Sep 2021 10:44:55 +0000 (03:44 -0700)]
Rollup merge of #88699 - Mark-Simulacrum:fixes-cherry-picker, r=pietroalbini

Remove extra unshallow from cherry-pick checker

This is already done by https://github.com/rust-lang/rust/blob/13db8440bbbe42870bc828d4ec3e965b38670277/src/ci/init_repo.sh#L32-L36 on the beta channel, and git throws an error if you attempt to unshallow an already non-shallow repository.

r? ```@pietroalbini```

2 years agoRollup merge of #88677 - petrochenkov:exportid, r=davidtwco
Manish Goregaokar [Sun, 12 Sep 2021 10:44:53 +0000 (03:44 -0700)]
Rollup merge of #88677 - petrochenkov:exportid, r=davidtwco

rustc: Remove local variable IDs from `Export`s

Local variables can never be exported.

2 years agoRollup merge of #88336 - jackh726:gats-where-constraints, r=estebank
Manish Goregaokar [Sun, 12 Sep 2021 10:44:53 +0000 (03:44 -0700)]
Rollup merge of #88336 - jackh726:gats-where-constraints, r=estebank

 Detect stricter constraints on gats where clauses in impls vs trait

I might try to see if I can do a bit more to improve these diagnostics, but any initial feedback is appreciated. I can also do any additional work in a followup PR.

r? `@estebank`

2 years agoAuto merge of #88771 - jackh726:wf_tys_set, r=nikomatsakis
bors [Sun, 12 Sep 2021 10:32:55 +0000 (10:32 +0000)]
Auto merge of #88771 - jackh726:wf_tys_set, r=nikomatsakis

Use FxHashSet instead of Vec for well formed tys

Trying to recover perf from #88312

r? `@ghost`

2 years agoAuto merge of #88765 - mk12:update-llvm, r=cuviper
bors [Sun, 12 Sep 2021 06:43:01 +0000 (06:43 +0000)]
Auto merge of #88765 - mk12:update-llvm, r=cuviper

Update LLVM submodule

This merges upstream `release/13.x` changes to our fork. In particular,
this includes the bugfix https://reviews.llvm.org/D108608 (see also
https://bugs.llvm.org/show_bug.cgi?id=51637).

The motivation for this is fixing Rust coverage in Fuchsia: https://fxbug.dev/77427.

2 years agoAuto merge of #87073 - jyn514:primitive-docs, r=GuillaumeGomez,jyn514
bors [Sun, 12 Sep 2021 02:36:01 +0000 (02:36 +0000)]
Auto merge of #87073 - jyn514:primitive-docs, r=GuillaumeGomez,jyn514

Fix rustdoc handling of primitive items

This is a complicated PR and does a lot of things. I'm willing to split it up a little more if it would help reviewing, but it would be tricky and I'd rather not unless it's necessary.

 ## What does this do?

- Fixes https://github.com/rust-lang/rust/issues/73423.
- Fixes https://github.com/rust-lang/rust/issues/79630. I'm not sure how to test this for the standard library explicitly, but you can see from some of the diffs from the `no_std` tests. I also tested it locally and it works correctly: ![image](https://user-images.githubusercontent.com/23638587/125214383-e1fdd000-e284-11eb-8048-76b5df958aad.png)
- Fixes https://github.com/rust-lang/rust/issues/83083.

## Why are these changes interconnected?

- Allowing anchors (https://github.com/rust-lang/rust/issues/83083) without fixing the online/offline problem (https://github.com/rust-lang/rust/issues/79630) will actually just silently discard the anchors, that's not a fix. The online/offline problem is directly related to the fragment hack; links need to go through `fn href()` to be fixed.
- Technically I could fix the online/offline problem without removing the error on anchors; I am willing to separate that out if it would be helpful for reviewing. However I can't fix the anchor problem without adding docs to core, since rustdoc needs all those primitives to have docs to avoid a fallback, and currently `#![no_std]` crates don't have docs for primitives. I also can't fix the online/offline problem without removing the fragment hack, since otherwise diffs like this will be wrong for some primitives but not others:
```diff
`@@` -385,7 +381,7 `@@` fn resolve_primitive_associated_item(
                         ty::AssocKind::Const => "associatedconstant",
                         ty::AssocKind::Type => "associatedtype",
                     };
-                    let fragment = format!("{}#{}.{}", prim_ty.as_sym(), out, item_name);
+                    let fragment = format!("{}.{}", out, item_name);
                     (Res::Primitive(prim_ty), fragment, Some((kind.as_def_kind(), item.def_id)))
                 })
         })
```
- Adding primitive docs to core without making any other change will cause links to go to `core` instead of `std`, even for crates with `extern crate std`. See "Breaking changes to doc(primitive)" below for why this is the case. That said, I could add some special casing to rustdoc at the same time that would let me separate this change from the others (it would fix https://github.com/rust-lang/rust/issues/73423 but still special-case intra-doc links). I'm willing to separate that out if helpful for reviewing.

### Add primitive documentation to libcore

This works by reusing the same `include!("primitive_docs.rs")` file in both core and std, and then special-casing links in core to use relative links instead of intra-doc links. This doesn't use purely intra-doc links because some of the primitive docs links to items only in std; this doesn't use purely relative links because that introduces new broken links when the docs are re-exported (e.g. String's `&str` deref impl, or Vec's slice deref impl).

Note that this copies the whole file to core, to avoid anyone compiling core to have to set `CARGO_PKG_NAME`. See https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Who.20should.20review.20changes.20to.20linkchecker.3F/near/249939598 for more context. It also adds a tidy check to make sure the two files are kept in sync.

### Fix inconsistent online/offline primitive docs

This does four things:
- Records modules with `doc(primitive)` in `cache.external_paths`. This is necessary for `href()` to find them later.
- Makes `cache.primitive_locations` available to the intra-doc link pass, by refactoring out a `PrimitiveType::primitive_locations` function that only uses `TyCtxt`.
- Special cases modules with `doc(primitive)` to be treated as always public for the purpose of links.
- Removes the fragment hack. cc `@notriddle,` I know you added some comments about this in the code (thank you for that!)

### Breaking changes to `doc(primitive)`

"Breaking" is a little misleading here - these are changes in behavior, none of them will cause code to fail to compile.

Let me preface this by saying I think stabilizing `doc(primitive)` was a uniquely terrible idea. As far as I can tell, it was stabilized by oversight; it's been stable since 1.0. No one should have need to use it except the standard library, and a crater run shows that in fact no one is using it: https://github.com/rust-lang/rust/pull/87050#issuecomment-886166706. I hope to actually make `doc(primitive)` a no-op unless you opt-in with a nightly feature, which will keep crates compiling without forcing rustdoc into trying to keep somewhat arbitrary behavior guarantees; but for now, this just subtly changes some of the behavior if you use `doc(primitive)` in a dependency.

That said, here are the changes:
-  Refactoring out `primitive_locations()` is technically a change in behavior, since it no longer looks for primitives in crates that were passed through `--extern`, but not used by the crate; however, that seems like such an unlikely edge case it's not worth dealing with.
- The precedence given to primitive locations is no longer just arbitrary, it can also be inconsistent from run to run. Let me explain that more: previously, primitive locations were sorted by the `CrateNum`; the comment on that sort said "Favor linking to as local extern as possible, so iterate all crates in reverse topological order." Unfortunately, that's not actually what CrateNum tracks: it measures the order crates are loaded, not the number of intermediate crates between that dependency and the root crate. It happened to work as intended before because the compiler injects `extern crate std;` at the top of every crate, which ensured it would have the first CrateNum other than the current, but every other CrateNum was completely arbitrary (for example, `core` often had a later CrateNum than `std`). This now removes the sort on CrateNum completely and special-cases core instead. In particular, if you depend on both `std` and a crate which defines a `doc(primitive)` module, it's arbitrary whether rustdoc will use the docs from std or the ones from the other crate. cc `@alexcrichton,` you wrote this originally.

cc `@rust-lang/rustdoc`
cc `@rust-lang/libs` for the addition to `core` (the commit you're interested in is https://github.com/rust-lang/rust/pull/87073/commits/91346c8293bb5f41d8e1d2ec9336433664652c53)

2 years agoFix `no_core` and `no_std` rustdoc tests on Windows
Guillaume Gomez [Wed, 25 Aug 2021 15:57:06 +0000 (17:57 +0200)]
Fix `no_core` and `no_std` rustdoc tests on Windows

This prevents the following (very strange) errors:

```
error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x86\\link.exe" "/DEF:C:\\Users\\runneradmin\\AppData\\Local\\Temp\\rustcJih4fa\\lib.def" "/NOLOGO" "/LARGEADDRESSAWARE" "/SAFESEH" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue-15318.issue_15318.0a2a8554-cgu.0.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue-15318.1na9aylmt25n6w3f.rcgu.o" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\native\\rust-test-helpers" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "vcruntime.lib" "ucrt.lib" "/WHOLEARCHIVE:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_core-78744e1360284b1e.rlib" "/WHOLEARCHIVE:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcore-a900fa3d16956226.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcompiler_builtins-eb97e6b4dfd2f421.rlib" "/NXCOMPAT" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "/OUT:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue_15318.dll" "/OPT:REF,ICF" "/DLL" "/IMPLIB:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue_15318.dll.lib" "/DEBUG" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\libstd.natvis"
  = note: LINK : warning LNK4216: Exported entry point __DllMainCRTStartup@12
             Creating library D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll.lib and object D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll.exp
          libcore-a900fa3d16956226.rlib(core-a900fa3d16956226.core.95dedc69-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol __aulldiv referenced in function __ZN4core3num7dec2flt7decimal7Decimal10left_shift17hfb9b6c23d6ff0383E
          libcompiler_builtins-eb97e6b4dfd2f421.rlib(compiler_builtins-eb97e6b4dfd2f421.compiler_builtins.a5ef280a-cgu.51.rcgu.o) : error LNK2001: unresolved external symbol __aulldiv
          libcore-a900fa3d16956226.rlib(core-a900fa3d16956226.core.95dedc69-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol __aullrem referenced in function __ZN4core3fmt3num14parse_u64_into17h90eb20517ec3bd86E
          D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll : fatal error LNK1120: 2 unresolved externals

```

2 years agoFix linkcheck issues
Joshua Nelson [Tue, 13 Jul 2021 21:41:03 +0000 (17:41 -0400)]
Fix linkcheck issues

Most of these are because alloc uses `#[lang_item]` to define methods,
but core documents primitives before those methods are available.

- Fix rustdoc-js-std test

  For some reason this change made CStr not show up in the results for
  `str,u8`. Since it still shows up for str, and since it wasn't a great
  match for that query anyway, I think this is ok to let slide.

- Add test that all primitives can be linked to
- Enable `doc(primitive)` in `core` as well
- Add linkcheck exception specifically for Windows

  Ideally this would be done automatically by the linkchecker by
  replacing `\\` with forward slashes, but this PR is already a ton of
  work ...

- Don't forcibly fail linkchecking if there's a broken intra-doc link on Windows

  Previously, it would exit with a hard error if a missing file had `::`
  in it. This changes it to report a missing file instead, which allows
  adding an exception.

2 years agoFix broken handling of primitive items
Joshua Nelson [Sun, 11 Jul 2021 02:25:36 +0000 (22:25 -0400)]
Fix broken handling of primitive items

- Fix broken handling of primitive associated items
- Remove fragment hack

  Fixes 83083

- more logging
- Update CrateNum hacks

  The CrateNum has no relation to where in the dependency tree the crate
  is, only when it's loaded. Explicitly special-case core instead of
  assuming it will be the first DefId.

- Update and add tests
- Cache calculation of primitive locations

  This could possibly be avoided by passing a Cache into
  collect_intra_doc_links; but that's a much larger change, and doesn't
  seem valuable other than for this.

2 years agodowngrade some logging
Joshua Nelson [Sun, 11 Jul 2021 03:02:10 +0000 (23:02 -0400)]
downgrade some logging