]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #92636 - compiler-errors:normalize-generator-const-expr, r=oli-obk
Matthias Krüger [Mon, 10 Jan 2022 10:03:07 +0000 (11:03 +0100)]
Rollup merge of #92636 - compiler-errors:normalize-generator-const-expr, r=oli-obk

Normalize generator-local types with unevaluated constants

Normalize generator-interior types in addition to (i.e. instead of just) erasing regions, since sometimes we collect types with unevaluated const exprs.

Fixes #84737
Fixes #88171
Fixes #92091
Fixes #92634
Probably also fixes #73114, but that one has no code I could test. It looks like it's the same issue, though.

2 years agoRollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomez
Matthias Krüger [Mon, 10 Jan 2022 10:03:06 +0000 (11:03 +0100)]
Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomez

Make source links look cleaner

Change from syntaxy-looking [src] to the plain word "source".

Change the syntaxy-looking `[-]` at the top of the page to say "collapse".

Reduce opacity of rightside content.

Part of #59851

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/source-link-2/std/string/struct.String.html

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/display.20of.20source.20link).

2 years agoRollup merge of #92357 - GuillaumeGomez:fix-doc-comment-backline-removal, r=camelid
Matthias Krüger [Mon, 10 Jan 2022 10:03:05 +0000 (11:03 +0100)]
Rollup merge of #92357 - GuillaumeGomez:fix-doc-comment-backline-removal, r=camelid

Fix invalid removal of newlines from doc comments

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

Before:

![Screenshot from 2021-12-28 17-02-11](https://user-images.githubusercontent.com/3050060/147585187-c8e67531-c1b4-457d-9d30-d5b44bf91fea.png)

After:

![Screenshot from 2021-12-28 17-02-25](https://user-images.githubusercontent.com/3050060/147585190-30aa0398-1fc7-4fe7-9e8b-5c475d4f9613.png)

r? `@camelid`

2 years agoRollup merge of #92248 - compiler-errors:normalize-type-for-pointee, r=jackh726
Matthias Krüger [Mon, 10 Jan 2022 10:03:03 +0000 (11:03 +0100)]
Rollup merge of #92248 - compiler-errors:normalize-type-for-pointee, r=jackh726

Normalize struct tail type when checking Pointee trait

Let's go ahead and implement the FIXMEs by properly normalizing the struct-tail type when satisfying a Pointee obligation. This should fix the ICE when we try to calculate a layout depending on `<Ty as Pointee>::Metadata` later.
Fixes #92128
Fixes #92577

Additionally, mark the obligation as ambiguous if there are any infer types in that struct-tail type. This has the effect of causing `<_ as Pointee>::Metadata` to be properly replaced with an infer variable ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/traits/project.rs#L813)) and registered as an obligation... this turns out to be very important in unifying function parameters with formals that are assoc types.

Fixes #91446

2 years agoAuto merge of #92278 - Aaron1011:fix-fingerprint-caching, r=michaelwoerister
bors [Mon, 10 Jan 2022 00:26:07 +0000 (00:26 +0000)]
Auto merge of #92278 - Aaron1011:fix-fingerprint-caching, r=michaelwoerister

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.

2 years agoAuto merge of #92534 - Aaron1011:hash-hir, r=petrochenkov
bors [Sun, 9 Jan 2022 16:03:41 +0000 (16:03 +0000)]
Auto merge of #92534 - Aaron1011:hash-hir, r=petrochenkov

Hash `Ident` spans in all HIR structures

This PR removes all of the `#[stable_hasher(project(name))]`
attributes used in HIR structs. While these attributes are not known
to be causing any issues in practice, we need to hash these in
order for the incremental system to work correctly -
a query could be otherwise be incorrectly marked green
when a change occures in one of the `Span`s that it uses.

2 years agoAuto merge of #92690 - matthiaskrgr:rollup-rw0oz05, r=matthiaskrgr
bors [Sun, 9 Jan 2022 12:43:37 +0000 (12:43 +0000)]
Auto merge of #92690 - matthiaskrgr:rollup-rw0oz05, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #92055 (Add release notes for 1.58)
 - #92490 (Move crate drop-down to search results page)
 - #92510 (Don't resolve blocks in foreign functions)
 - #92573 (expand: Refactor InvocationCollector visitor for better code reuse)
 - #92608 (rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes)
 - #92657 (Implemented const casts of raw pointers)
 - #92671 (Make `Atomic*::from_mut` return `&mut Atomic*`)
 - #92673 (Remove useless collapse toggle on "all items" page)

Failed merges:

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

2 years agoRollup merge of #92673 - GuillaumeGomez:remove-all-items-toggle, r=jsha
Matthias Krüger [Sun, 9 Jan 2022 12:38:34 +0000 (13:38 +0100)]
Rollup merge of #92673 - GuillaumeGomez:remove-all-items-toggle, r=jsha

Remove useless collapse toggle on "all items" page

When clicking on this toggle, nothing happens because there is nothing to collapse. Instead of keeping it around, let's just remove it.

Before:

![Screenshot from 2022-01-08 16-02-38](https://user-images.githubusercontent.com/3050060/148649149-821a1e77-8c34-4975-b50a-984ca8865518.png)

After:

![Screenshot from 2022-01-08 16-02-32](https://user-images.githubusercontent.com/3050060/148649154-b5912a97-9229-46bd-be3c-df3c3fa3ac8f.png)

r? `@jsha`

2 years agoRollup merge of #92671 - WaffleLapkin:atomic_from_mut_unique_ref, r=m-ou-se
Matthias Krüger [Sun, 9 Jan 2022 12:38:33 +0000 (13:38 +0100)]
Rollup merge of #92671 - WaffleLapkin:atomic_from_mut_unique_ref, r=m-ou-se

Make `Atomic*::from_mut` return `&mut Atomic*`

```rust
impl Atomic* {
    pub fn from_mut(v: &mut bool) -> &mut Self;
    //                               ^^^^---- previously was just a &
}
```

This PR makes `from_mut` atomic methods tracked in #76314 return unique references to atomic types, instead of shared ones. This makes `from_mut` and `get_mut` inverses of each other, allowing to undo either of them by the other.

r? `@RalfJung`
(as Ralf was [concerned](https://github.com/rust-lang/rust/issues/76314#issuecomment-955062593) about this)

2 years agoRollup merge of #92657 - Kixunil:ptr_as_const_mut, r=m-ou-se
Matthias Krüger [Sun, 9 Jan 2022 12:38:33 +0000 (13:38 +0100)]
Rollup merge of #92657 - Kixunil:ptr_as_const_mut, r=m-ou-se

Implemented const casts of raw pointers

This adds `as_mut()` method for `*const T` and `as_const()` for `*mut T`
which are intended to make casting of consts safer. This was discussed
in the [internals discussion][discussion].

Given that this is a simple change and multiple people agreed to it including `@RalfJung` I decided to go ahead and open the PR.

[discussion]: https://internals.rust-lang.org/t/casting-constness-can-be-risky-heres-a-simple-fix/15933

2 years agoRollup merge of #92608 - petrochenkov:doctrscope3, r=CraftSpider
Matthias Krüger [Sun, 9 Jan 2022 12:38:32 +0000 (13:38 +0100)]
Rollup merge of #92608 - petrochenkov:doctrscope3, r=CraftSpider

rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes

The refactoring parts of https://github.com/rust-lang/rust/pull/88679, shouldn't cause any slowdowns.
r? `@jyn514`

2 years agoRollup merge of #92573 - petrochenkov:ltrattr3, r=Aaron1011
Matthias Krüger [Sun, 9 Jan 2022 12:38:31 +0000 (13:38 +0100)]
Rollup merge of #92573 - petrochenkov:ltrattr3, r=Aaron1011

expand: Refactor InvocationCollector visitor for better code reuse

The refactoring part of https://github.com/rust-lang/rust/pull/92473.

Invocation collector visitor logic now lives in two main functions:
- `fn flat_map_node`, corresponding to "one to many" expansions
- `fn visit_node`, corresponding to "one to one" expansions

All specific mut visitor methods now use one of these functions.

The new `InvocationCollectorNode` trait implemented for all `AstFragment` nodes provides the necessary small pieces of functionality required to implement the `(flat_map,visit)_node` functions.
r? `@Aaron1011`

2 years agoRollup merge of #92510 - inquisitivecrystal:foreign-block, r=cjgillot
Matthias Krüger [Sun, 9 Jan 2022 12:38:30 +0000 (13:38 +0100)]
Rollup merge of #92510 - inquisitivecrystal:foreign-block, r=cjgillot

Don't resolve blocks in foreign functions

Although it is an error for a foreign function to have a block, it is still possible at the level of the AST. #74204 made AST lowering skip over blocks belonging to foreign functions, since they're invalid. However, resolve still treated these blocks normally, resulting in a mismatch between the HIR and resolve, which could cause an ICE under certain circumstances. This PR changes resolve to skip over blocks belonging to foreign functions, as AST lowering does.

Fixes #91370.

r? ``@cjgillot``

2 years agoRollup merge of #92490 - jsha:crates-in-results, r=GuillaumeGomez
Matthias Krüger [Sun, 9 Jan 2022 12:38:29 +0000 (13:38 +0100)]
Rollup merge of #92490 - jsha:crates-in-results, r=GuillaumeGomez

Move crate drop-down to search results page

This reduces clutter on doc pages.

Part of #59840

r? ```@GuillaumeGomez```

Demo: https://rustdoc.crud.net/jsha/crates-in-results/std/index.html?search=str

2 years agoRollup merge of #92055 - tmandry:relnotes-1.58, r=pietroalbini
Matthias Krüger [Sun, 9 Jan 2022 12:38:28 +0000 (13:38 +0100)]
Rollup merge of #92055 - tmandry:relnotes-1.58, r=pietroalbini

Add release notes for 1.58

r? `@rust-lang/release`

2 years agoAuto merge of #92086 - petrochenkov:modchild, r=jackh726
bors [Sun, 9 Jan 2022 10:02:49 +0000 (10:02 +0000)]
Auto merge of #92086 - petrochenkov:modchild, r=jackh726

rustc_metadata: Optimize and document module children decoding

The first commit limits the item in the `item_children`/`each_child_of_item` query to modules (in name resolution sense) and adds a corresponding assertion.
The `associated_item_def_ids` query collecting children of traits and impls specifically now uses a simplified implementation not decoding unnecessary data instead of `each_child_of_item`, this gives a nice performance improvement.

The second commit does some renaming that clarifies the terminology used for all items in a module vs `use` items only.

2 years agoAuto merge of #92497 - bjorn3:remove_lazy_meta_min_size, r=eddyb
bors [Sun, 9 Jan 2022 01:29:22 +0000 (01:29 +0000)]
Auto merge of #92497 - bjorn3:remove_lazy_meta_min_size, r=eddyb

Remove LazyMeta::min_size

It is extremely conservative and as such barely reduces the size of encoded Lazy distances, but does increase complexity.

2 years agorustc_middle: Rename `Export` to `ModChild` and add some comments
Vadim Petrochenkov [Tue, 21 Dec 2021 03:24:43 +0000 (11:24 +0800)]
rustc_middle: Rename `Export` to `ModChild` and add some comments

Also rename `module_exports`/`export_map` to `module_reexports`/`reexport_map` for clarity.

2 years agorustc_metadata: Rename `item_children(_untracked)` to `module_children(_untracked)`
Vadim Petrochenkov [Thu, 23 Dec 2021 08:12:34 +0000 (16:12 +0800)]
rustc_metadata: Rename `item_children(_untracked)` to `module_children(_untracked)`

And `each_child_of_item` to `for_each_module_child`

2 years agorustc_metadata: Optimize and document module children decoding
Vadim Petrochenkov [Sat, 18 Dec 2021 12:07:58 +0000 (20:07 +0800)]
rustc_metadata: Optimize and document module children decoding

2 years agoAuto merge of #92068 - fee1-dead:libcore2021, r=m-ou-se
bors [Sat, 8 Jan 2022 21:41:48 +0000 (21:41 +0000)]
Auto merge of #92068 - fee1-dead:libcore2021, r=m-ou-se

Switch all libraries to the 2021 edition

The fix for https://github.com/rust-lang/rust/issues/88638#issuecomment-996620107 is to simply add const-stability for these functions.

r? `@m-ou-se`

Closes #88638.

2 years agoremove float methods
Pietro Albini [Sat, 8 Jan 2022 20:34:01 +0000 (21:34 +0100)]
remove float methods

2 years agoAuto merge of #91919 - Aaron1011:query-recursive-read, r=michaelwoerister
bors [Sat, 8 Jan 2022 18:32:31 +0000 (18:32 +0000)]
Auto merge of #91919 - Aaron1011:query-recursive-read, r=michaelwoerister

Don't perform any new queries while reading a query result on disk

In addition to being very confusing, this can cause us to add dep node edges between two queries that would not otherwise have an edge.

We now panic if any new dep node edges are created during the deserialization of a query result. This requires serializing the full `AdtDef` to disk, instead of just serializing the `DefId` and invoking the `adt_def` query during deserialization.

I'll probably split this up into several smaller PRs for perf runs.

2 years agoImplemented const casts of raw pointers
Martin Habovstiak [Fri, 7 Jan 2022 23:03:02 +0000 (00:03 +0100)]
Implemented const casts of raw pointers

This adds `as_mut()` method for `*const T` and `as_const()` for `*mut T`
which are intended to make casting of consts safer. This was discussed
in the [internals discussion][discussion].

[discussion]: https://internals.rust-lang.org/t/casting-constness-can-be-risky-heres-a-simple-fix/15933

2 years agoAuto merge of #90639 - matthewjasper:leaf-def-cache, r=cjgillot
bors [Sat, 8 Jan 2022 15:20:33 +0000 (15:20 +0000)]
Auto merge of #90639 - matthewjasper:leaf-def-cache, r=cjgillot

Add a query for resolving an impl item from the trait item

This makes finding the item in an impl that implements a given trait item a query. This is for a few reasons:

- To slightly improve performance
- To avoid having to do name resolution during monomorphisation
- To make it easier to implement potential future features that create anonymous associated items

2 years agoRemove useless collapse toggle on "all items" page
Guillaume Gomez [Sat, 8 Jan 2022 15:03:44 +0000 (16:03 +0100)]
Remove useless collapse toggle on "all items" page

2 years agoMake source links look cleaner
Jacob Hoffman-Andrews [Sat, 4 Dec 2021 01:09:04 +0000 (17:09 -0800)]
Make source links look cleaner

Change from syntaxy-looking [src] to the plain word "source".

2 years agoMake `Atomic*::from_mut` return `&mut Atomic*`
Maybe Waffle [Sat, 8 Jan 2022 13:57:20 +0000 (16:57 +0300)]
Make `Atomic*::from_mut` return `&mut Atomic*`

2 years agoRemove LazyMeta::min_size
bjorn3 [Sun, 2 Jan 2022 17:20:37 +0000 (18:20 +0100)]
Remove LazyMeta::min_size

It is extremely conservative and as such barely reduces the size of
encoded Lazy distances, but does increase complexity.

2 years agoAuto merge of #92639 - pietroalbini:bump-version, r=pietroalbini
bors [Sat, 8 Jan 2022 12:06:40 +0000 (12:06 +0000)]
Auto merge of #92639 - pietroalbini:bump-version, r=pietroalbini

Bump version to 1.60.0

Part of the release process, cc `@rust-lang/release`

r? `@ghost`

2 years agoAuto merge of #91305 - camelid:rm-cond, r=GuillaumeGomez
bors [Sat, 8 Jan 2022 08:55:46 +0000 (08:55 +0000)]
Auto merge of #91305 - camelid:rm-cond, r=GuillaumeGomez

rustdoc: Remove apparently unnecessary conditional in `doc_value`

I need to remove this conditional for #91072, but while it seems
unnecessary, we are not certain. So, the plan is to first remove the
conditional and see if any regressions pop up before doing the refactor.
This way, it will be easier to revert if there are subtle regressions.

r? `@jyn514`

2 years agoAuto merge of #92664 - ehuss:rollup-t9yrvk5, r=ehuss
bors [Sat, 8 Jan 2022 06:01:37 +0000 (06:01 +0000)]
Auto merge of #92664 - ehuss:rollup-t9yrvk5, r=ehuss

Rollup of 8 pull requests

Successful merges:

 - #84640 (Implement `TryFrom<char>` for `u8`)
 - #92336 (Remove &self from PrintState::to_string)
 - #92375 (Consolidate checking for msvc when generating debuginfo)
 - #92568 (Add note about non_exhaustive to variant_count)
 - #92600 (Add some missing `#[must_use]` to some `f{32,64}` operations)
 - #92610 (Create CSS class instead of using inline style for search results)
 - #92632 (Implement stabilization of `#[feature(available_parallelism)]`)
 - #92650 (Fix typo in `StableCrateId` docs)

Failed merges:

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

2 years agoRollup merge of #92650 - pierwill:patch-2, r=michaelwoerister
Eric Huss [Sat, 8 Jan 2022 04:21:02 +0000 (20:21 -0800)]
Rollup merge of #92650 - pierwill:patch-2, r=michaelwoerister

Fix typo in `StableCrateId` docs

2 years agoRollup merge of #92632 - yoshuawuyts:stabilize-available-parallelism, r=joshtriplett
Eric Huss [Sat, 8 Jan 2022 04:21:01 +0000 (20:21 -0800)]
Rollup merge of #92632 - yoshuawuyts:stabilize-available-parallelism, r=joshtriplett

Implement stabilization of `#[feature(available_parallelism)]`

Stabilized in https://github.com/rust-lang/rust/issues/74479#issuecomment-984379800. Closes https://github.com/rust-lang/rust/issues/74479. Thanks!

cc/ ``@rust-lang/libs-api``

2 years agoRollup merge of #92610 - GuillaumeGomez:css-class-instead-of-inline-style, r=jsha
Eric Huss [Sat, 8 Jan 2022 04:21:01 +0000 (20:21 -0800)]
Rollup merge of #92610 - GuillaumeGomez:css-class-instead-of-inline-style, r=jsha

Create CSS class instead of using inline style for search results

I saw this change in the update you proposed in https://github.com/rust-lang/rust/pull/92404. :)

r? ``@jsha``

2 years agoRollup merge of #92600 - asquared31415:float-must-use, r=joshtriplett
Eric Huss [Sat, 8 Jan 2022 04:21:00 +0000 (20:21 -0800)]
Rollup merge of #92600 - asquared31415:float-must-use, r=joshtriplett

Add some missing `#[must_use]` to some `f{32,64}` operations

This PR adds `#[must_use]` to the following methods:
 - `f32::recip`
 - `f32::max`
 - `f32::min`
 - `f32::maximum`
 - `f32::minimum`
 and their equivalents in `f64`.
 These methods all produce a new value without modifying the original and so are pointless to call without using the result.

2 years agoRollup merge of #92568 - Mark-Simulacrum:non-exhaustive-variant-count, r=the8472
Eric Huss [Sat, 8 Jan 2022 04:20:59 +0000 (20:20 -0800)]
Rollup merge of #92568 - Mark-Simulacrum:non-exhaustive-variant-count, r=the8472

Add note about non_exhaustive to variant_count

Since `variant_count` isn't returning something opaque, I thought it makes sense to explicitly call out that its return value may change for some enums.

cc #73662

2 years agoRollup merge of #92375 - wesleywiser:consolidate_debuginfo_msvc_check, r=michaelwoerister
Eric Huss [Sat, 8 Jan 2022 04:20:58 +0000 (20:20 -0800)]
Rollup merge of #92375 - wesleywiser:consolidate_debuginfo_msvc_check, r=michaelwoerister

Consolidate checking for msvc when generating debuginfo

If the target we're generating code for is msvc, then we do two main
things differently: we generate type names in a C++ style instead of a
Rust style and we generate debuginfo for enums differently.

I've refactored the code so that there is one function
(`cpp_like_debuginfo`) which determines if we should use the C++ style
of naming types and other debuginfo generation or the regular Rust one.

r? ``@michaelwoerister``

This PR is not urgent so please don't let it interrupt your holidays! 🎄 🎁

2 years agoRollup merge of #92336 - dtolnay:printstateself, r=michaelwoerister
Eric Huss [Sat, 8 Jan 2022 04:20:56 +0000 (20:20 -0800)]
Rollup merge of #92336 - dtolnay:printstateself, r=michaelwoerister

Remove &self from PrintState::to_string

The point of `PrintState::to_string` is to create a `State` and evaluate the caller's closure on it:

https://github.com/rust-lang/rust/blob/e9fbe79292783972a222afd270db3f77c0b4f3c8/compiler/rustc_ast_pretty/src/pprust/state.rs#L868-L872

Making the caller *also* construct and pass in a `State`, which is then ignored, was confusing.

2 years agoRollup merge of #84640 - ids1024:u8_from_char, r=m-ou-se
Eric Huss [Sat, 8 Jan 2022 04:20:55 +0000 (20:20 -0800)]
Rollup merge of #84640 - ids1024:u8_from_char, r=m-ou-se

Implement `TryFrom<char>` for `u8`

Previously suggested in https://github.com/rust-lang/rfcs/issues/2854.

It makes sense to have this since `char` implements `From<u8>`. Likewise `u32`, `u64`, and `u128` (since #79502) implement `From<char>`.

2 years agoFix accidental undo of 5e1972eba7e95e68f6fc05b07dec15fb1e553e1b
Noah Lev [Fri, 7 Jan 2022 22:16:56 +0000 (14:16 -0800)]
Fix accidental undo of 5e1972eba7e95e68f6fc05b07dec15fb1e553e1b

2 years agoUpdate clippy for associated item changes
Matthew Jasper [Thu, 18 Nov 2021 22:33:49 +0000 (22:33 +0000)]
Update clippy for associated item changes

2 years agoAdd query to avoid name comparison in `leaf_def`
Matthew Jasper [Thu, 18 Nov 2021 22:29:07 +0000 (22:29 +0000)]
Add query to avoid name comparison in `leaf_def`

2 years agoMove associated_item* providers to their own module
Matthew Jasper [Thu, 18 Nov 2021 21:44:45 +0000 (21:44 +0000)]
Move associated_item* providers to their own module

2 years agoImplement `TryFrom<char>` for `u8`
Ian Douglas Scott [Wed, 28 Apr 2021 04:05:26 +0000 (21:05 -0700)]
Implement `TryFrom<char>` for `u8`

Previously suggested in https://github.com/rust-lang/rfcs/issues/2854.

It makes sense to have this since `char` implements `From<u8>`. Likewise
`u32`, `u64`, and `u128` (since #79502) implement `From<char>`.

2 years agoAdd `trait_item_def_id` to `AssocItem`
Matthew Jasper [Thu, 18 Nov 2021 21:35:42 +0000 (21:35 +0000)]
Add `trait_item_def_id` to `AssocItem`

This allows avoiding some lookups by name

2 years agoDeserialization less in associated_item_def_ids
Matthew Jasper [Thu, 18 Nov 2021 20:59:12 +0000 (20:59 +0000)]
Deserialization less in associated_item_def_ids

2 years agoConsolidate checking for msvc when generating debuginfo
Wesley Wiser [Tue, 28 Dec 2021 21:57:18 +0000 (16:57 -0500)]
Consolidate checking for msvc when generating debuginfo

If the target we're generating code for is msvc, then we do two main
things differently: we generate type names in a C++ style instead of a
Rust style and we generate debuginfo for enums differently.

I've refactored the code so that there is one function
(`cpp_like_debuginfo`) which determines if we should use the C++ style
of naming types and other debuginfo generation or the regular Rust one.

2 years agoClarify that -C strip is only in rustc, not cargo, in 1.58
Tyler Mandry [Fri, 7 Jan 2022 16:49:14 +0000 (16:49 +0000)]
Clarify that -C strip is only in rustc, not cargo, in 1.58

2 years agoFix broken link
Tyler Mandry [Fri, 7 Jan 2022 16:48:47 +0000 (16:48 +0000)]
Fix broken link

2 years agoFix typo in `StableCrateId` docs
pierwill [Fri, 7 Jan 2022 16:26:26 +0000 (10:26 -0600)]
Fix typo in `StableCrateId` docs

2 years agobump version to 1.60.0
Pietro Albini [Fri, 7 Jan 2022 09:04:15 +0000 (10:04 +0100)]
bump version to 1.60.0

2 years agorustdoc: Introduce a resolver cache for sharing data between early doc link resolutio...
Vadim Petrochenkov [Sun, 29 Aug 2021 18:41:46 +0000 (21:41 +0300)]
rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes

2 years agoexpand: Import more AST enums
Vadim Petrochenkov [Fri, 7 Jan 2022 06:54:16 +0000 (14:54 +0800)]
expand: Import more AST enums

2 years agoexpand: Refactor `InvocationCollector` visitor for better code reuse
Vadim Petrochenkov [Wed, 5 Jan 2022 06:15:44 +0000 (14:15 +0800)]
expand: Refactor `InvocationCollector` visitor for better code reuse

2 years agoexpand: Remove some unnecessary `self` mutability
Vadim Petrochenkov [Wed, 5 Jan 2022 06:10:07 +0000 (14:10 +0800)]
expand: Remove some unnecessary `self` mutability

2 years agoexpand: Rename some `AstFragment`s to match AST structures
Vadim Petrochenkov [Wed, 5 Jan 2022 05:56:45 +0000 (13:56 +0800)]
expand: Rename some `AstFragment`s to match AST structures

2 years agoNormalize generator-local types with unevaluated constants
Michael Goulet [Fri, 7 Jan 2022 03:08:04 +0000 (19:08 -0800)]
Normalize generator-local types with unevaluated constants

2 years agoStabilize `#[feature(available_parallelism)]`
Yoshua Wuyts [Fri, 7 Jan 2022 00:04:37 +0000 (01:04 +0100)]
Stabilize `#[feature(available_parallelism)]`

2 years agoAuto merge of #92627 - matthiaskrgr:rollup-xmz0rib, r=matthiaskrgr
bors [Thu, 6 Jan 2022 22:56:13 +0000 (22:56 +0000)]
Auto merge of #92627 - matthiaskrgr:rollup-xmz0rib, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #91055 (return the correct type for closures in `type_of`)
 - #92207 (Delay remaining `span_bug`s in drop elaboration)
 - #92417 (Fix spacing and ordering of words in pretty printed Impl)
 - #92504 (Exit nonzero on rustc -Wall)
 - #92559 (RustWrapper: adapt to new AttributeMask API)
 - #92589 (Break the loop)
 - #92607 (rustc_metadata: Some minor cleanups and optimizations)
 - #92620 (Remove unused `ExtendDefault` struct)

Failed merges:

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

2 years agoRollup merge of #92620 - steffahn:remove_unused_ExtendDefault_struct, r=Mark-Simulacrum
Matthias Krüger [Thu, 6 Jan 2022 22:15:23 +0000 (23:15 +0100)]
Rollup merge of #92620 - steffahn:remove_unused_ExtendDefault_struct, r=Mark-Simulacrum

Remove unused `ExtendDefault` struct

As noted in https://github.com/rust-lang/rust/pull/77850#issuecomment-1002272054, this struct is no longer used.

2 years agoRollup merge of #92607 - petrochenkov:doctrscope2, r=cjgillot
Matthias Krüger [Thu, 6 Jan 2022 22:15:21 +0000 (23:15 +0100)]
Rollup merge of #92607 - petrochenkov:doctrscope2, r=cjgillot

rustc_metadata: Some minor cleanups and optimizations

Mostly extracted from https://github.com/rust-lang/rust/pull/88679 (which is otherwise a rustdoc PR).
r? ``@cjgillot``

2 years agoRollup merge of #92589 - ChrisDenton:break-loop, r=Mark-Simulacrum
Matthias Krüger [Thu, 6 Jan 2022 22:15:20 +0000 (23:15 +0100)]
Rollup merge of #92589 - ChrisDenton:break-loop, r=Mark-Simulacrum

Break the loop

A missing break statement lead to an infinite loop in bootstrap.py.

I also added a short sleep so it's not constantly running at 100%. But I can remove that if it's not wanted.

Fixes #76661

2 years agoRollup merge of #92559 - durin42:llvm-14-attributemask, r=nikic
Matthias Krüger [Thu, 6 Jan 2022 22:15:18 +0000 (23:15 +0100)]
Rollup merge of #92559 - durin42:llvm-14-attributemask, r=nikic

RustWrapper: adapt to new AttributeMask API

Upstream LLVM change 9290ccc3c1a1 migrated attribute removal to use
AttributeMask instead of AttrBuilder, so we need to follow suit here.

r? ``@nagisa`` cc ``@nikic``

2 years agoRollup merge of #92504 - dtolnay:wall, r=jackh726
Matthias Krüger [Thu, 6 Jan 2022 22:15:17 +0000 (23:15 +0100)]
Rollup merge of #92504 - dtolnay:wall, r=jackh726

Exit nonzero on rustc -Wall

Previously `rustc -Wall /dev/null` would print a paragraph explaining that `-Wall` is not a thing in Rust, but would then exit 0. I believe exiting 0 is not the right behavior. For something like `rustc --version` or `rustc --help` or `rustc -C help` the user is requesting rustc to print some information; rustc prints that information and exits 0 because what the user requested has been accomplished. In the case of `rustc -Wall path/to/main.rs`, I don't find it correct to conceptualize this as "the user requested rustc to print information about the fact that Wall doesn't exist". The user requested a particular thing, and despite rustc knowing what they probably meant and informing them about that, the thing they requested has *not* been accomplished. Thus a nonzero exit code is needed.

2 years agoRollup merge of #92417 - dtolnay:printimpl, r=jackh726
Matthias Krüger [Thu, 6 Jan 2022 22:15:16 +0000 (23:15 +0100)]
Rollup merge of #92417 - dtolnay:printimpl, r=jackh726

Fix spacing and ordering of words in pretty printed Impl

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{}", repro!(impl<T> Struct<T> {}));
    println!("{}", repro!(impl<T> const Trait for T {}));
}
```

Before:&ensp;`impl <T> Struct<T> {}`
After:&ensp;`impl<T> Struct<T> {}`

Before:&ensp;`impl const <T> Trait for T {}` :crying_cat_face:
After:&ensp;`impl<T> const Trait for T {}`

2 years agoRollup merge of #92207 - tmiasko:delay-drop-elaboration-bug, r=jackh726
Matthias Krüger [Thu, 6 Jan 2022 22:15:14 +0000 (23:15 +0100)]
Rollup merge of #92207 - tmiasko:delay-drop-elaboration-bug, r=jackh726

Delay remaining `span_bug`s in drop elaboration

This follows changes from #67967 and converts remaining `span_bug`s into
delayed bugs, since for const items drop elaboration might be executed
on a MIR which failed borrowck.

Fixes #81708.
Fixes #91816.

2 years agoRollup merge of #91055 - lcnr:type_of-closures, r=nikomatsakis
Matthias Krüger [Thu, 6 Jan 2022 22:15:13 +0000 (23:15 +0100)]
Rollup merge of #91055 - lcnr:type_of-closures, r=nikomatsakis

return the correct type for closures in `type_of`

A bit unhappy about the way `typeck::check_crate` works rn. Would have preferred to not change `CollectItemTypesVisitor` in this way.

r? ``@nikomatsakis``

2 years agoExit nonzero on rustc -Wall
David Tolnay [Sun, 2 Jan 2022 22:24:11 +0000 (14:24 -0800)]
Exit nonzero on rustc -Wall

2 years agoremove unused ExtendDefault struct
Frank Steffahn [Thu, 6 Jan 2022 17:48:10 +0000 (18:48 +0100)]
remove unused ExtendDefault struct

2 years agoAuto merge of #92609 - matthiaskrgr:rollup-ldp47ot, r=matthiaskrgr
bors [Thu, 6 Jan 2022 15:30:46 +0000 (15:30 +0000)]
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

2 years agoCreate CSS class instead of using inline style for search results
Guillaume Gomez [Thu, 6 Jan 2022 12:08:57 +0000 (13:08 +0100)]
Create CSS class instead of using inline style for search results

2 years agoAuto merge of #89819 - davidtwco:issue-81024-multiple-crates-multiple-dwarves, r...
bors [Thu, 6 Jan 2022 12:21:10 +0000 (12:21 +0000)]
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`

2 years agoRollup merge of #92443 - mdibaiee:90703/resolve-traits-of-primitive-types, r=Manishearth
Matthias Krüger [Thu, 6 Jan 2022 11:01:05 +0000 (12:01 +0100)]
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.

2 years agoRollup merge of #92404 - GuillaumeGomez:src-font-size, r=jsha
Matthias Krüger [Thu, 6 Jan 2022 11:01:04 +0000 (12:01 +0100)]
Rollup merge of #92404 - GuillaumeGomez:src-font-size, r=jsha

Fix font size for [src] links in headers

Fixes #90384.

cc `@jsha`
r? `@camelid`

2 years agoRollup merge of #92389 - chordtoll:test-92015, r=Mark-Simulacrum
Matthias Krüger [Thu, 6 Jan 2022 11:01:03 +0000 (12:01 +0100)]
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.

2 years agoRollup merge of #92360 - jackh726:param-heuristics-1, r=davidtwco
Matthias Krüger [Thu, 6 Jan 2022 11:01:02 +0000 (12:01 +0100)]
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

2 years agoRollup merge of #92349 - avitex:fix-rustdoc-private-doc-tests, r=GuillaumeGomez
Matthias Krüger [Thu, 6 Jan 2022 11:01:01 +0000 (12:01 +0100)]
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](https://github.com/rust-lang/rust/blob/e91ad5fc62bdee4a29c18baa5fad2ca42fc91bf4/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.

2 years agoRollup merge of #92288 - yescallop:patch-1, r=m-ou-se
Matthias Krüger [Thu, 6 Jan 2022 11:01:00 +0000 (12:01 +0100)]
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.

2 years agoRollup merge of #92058 - jsha:run-on-hover, r=GuillaumeGomez
Matthias Krüger [Thu, 6 Jan 2022 11:00:59 +0000 (12:00 +0100)]
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

2 years agoRevert "bootstrap: copy `llvm-dwp` to sysroot"
David Wood [Fri, 3 Dec 2021 14:34:35 +0000 (14:34 +0000)]
Revert "bootstrap: copy `llvm-dwp` to sysroot"

This reverts commit 241160de72b5b55187ca54243e2a6e82e336d07c.

2 years agocg: use thorin instead of llvm-dwp
David Wood [Fri, 3 Dec 2021 14:24:05 +0000 (14:24 +0000)]
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>
2 years agosess/cg: re-introduce split dwarf kind
David Wood [Fri, 8 Oct 2021 16:10:17 +0000 (16:10 +0000)]
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>
2 years agorustc_metadata: Split `fn get_implementations_for_trait` into two functions
Vadim Petrochenkov [Thu, 6 Jan 2022 07:13:22 +0000 (15:13 +0800)]
rustc_metadata: Split `fn get_implementations_for_trait` into two functions

2 years agorustc_metadata: Make `opt_item_ident` in decoder faster and stricter
Vadim Petrochenkov [Thu, 6 Jan 2022 04:23:01 +0000 (12:23 +0800)]
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`

2 years agoadd some missing must use to float ops
asquared31415 [Wed, 5 Jan 2022 23:58:45 +0000 (18:58 -0500)]
add some missing must use to float ops

2 years agorustc_metadata: Make attribute decoding slightly faster and stricter
Vadim Petrochenkov [Thu, 6 Jan 2022 04:13:41 +0000 (12:13 +0800)]
rustc_metadata: Make attribute decoding slightly faster and stricter

Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions

2 years agorustc_middle: Add a method for getting a `SimplifiedType` definition/ID
Vadim Petrochenkov [Thu, 6 Jan 2022 04:02:00 +0000 (12:02 +0800)]
rustc_middle: Add a method for getting a `SimplifiedType` definition/ID

Import `SimplifiedType` more

2 years agoAdd regression test
inquisitivecrystal [Mon, 3 Jan 2022 06:23:31 +0000 (22:23 -0800)]
Add regression test

2 years agoDo not resolve blocks in foreign functions
inquisitivecrystal [Mon, 3 Jan 2022 05:11:16 +0000 (21:11 -0800)]
Do not resolve blocks in foreign functions

2 years agoSimplify :target CSS selector
Guillaume Gomez [Wed, 5 Jan 2022 20:28:19 +0000 (21:28 +0100)]
Simplify :target CSS selector

2 years agoRustWrapper: simplify removing attributes
Augie Fackler [Wed, 5 Jan 2022 18:51:59 +0000 (13:51 -0500)]
RustWrapper: simplify removing attributes

Avoids some extra conversions. Spotted by nikic during review.

2 years agoBreak the loop
Chris Denton [Wed, 5 Jan 2022 17:55:52 +0000 (17:55 +0000)]
Break the loop

A missing break statement lead to an infinite loop in bootstrap.py.

2 years agoMove crate drop-down to search results page
Jacob Hoffman-Andrews [Sun, 2 Jan 2022 04:48:34 +0000 (23:48 -0500)]
Move crate drop-down to search results page

This reduces clutter on doc pages.

2 years agoSwitch to es6 for eslint
Jacob Hoffman-Andrews [Sun, 2 Jan 2022 14:46:59 +0000 (09:46 -0500)]
Switch to es6 for eslint

Also update Node to v16.9.0, es-check to 6.1.1, and eslint to 8.6.0.

2 years agoAdd test for [src] font-size in headers
Guillaume Gomez [Wed, 29 Dec 2021 13:56:07 +0000 (14:56 +0100)]
Add test for [src] font-size in headers

2 years agoFix font size for [src] links in headers
Guillaume Gomez [Wed, 29 Dec 2021 13:55:49 +0000 (14:55 +0100)]
Fix font size for [src] links in headers

2 years agoAddress review comments
Aaron Hill [Wed, 5 Jan 2022 15:30:49 +0000 (10:30 -0500)]
Address review comments

2 years agoAuto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgr
bors [Wed, 5 Jan 2022 15:28:36 +0000 (15:28 +0000)]
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 (:arrow_up: rust-analyzer)

Failed merges:

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

2 years agoAdjust assert_default_hashing_controls
Aaron Hill [Sun, 26 Dec 2021 22:45:21 +0000 (17:45 -0500)]
Adjust assert_default_hashing_controls