]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #87251 - GuillaumeGomez:item-info-width, r=notriddle
Guillaume Gomez [Mon, 19 Jul 2021 09:37:46 +0000 (11:37 +0200)]
Rollup merge of #87251 - GuillaumeGomez:item-info-width, r=notriddle

Fix "item info" width

Fixes #87202.

It now looks again like this:

![Screenshot from 2021-07-18 12-33-27](https://user-images.githubusercontent.com/3050060/126064005-013acabc-7f17-4436-8dfc-cb6b9bc24413.png)

cc `@jyn514`

r? `@notriddle`

2 years agoRollup merge of #87236 - sunfishcode:avoid-locking-args, r=joshtriplett
Guillaume Gomez [Mon, 19 Jul 2021 09:37:45 +0000 (11:37 +0200)]
Rollup merge of #87236 - sunfishcode:avoid-locking-args, r=joshtriplett

Simplify command-line argument initialization on unix

Simplify Rust's command-line argument initialization code on unix:
 - The cleanup code isn't needed, because it was just zeroing out non-owning variables at runtime cleanup time. After 91c3eee1735ad72b579f99cbb6919c3471747d94, Rust's command-line initialization code on unix no longer allocates `CString`s and a `Vec` at startup time.
 - The `Mutex` isn't needed; if there's somehow a call to `args()` before argument initialization has happened, the code returns return an empty list, which we can do with a null check.

With these changes, a simple cdylib that doesn't use threads avoids getting `pthread_mutex_lock`/`pthread_mutex_unlock` in its symbol table.

2 years agoRollup merge of #87227 - bstrie:asm2arch, r=Amanieu
Guillaume Gomez [Mon, 19 Jul 2021 09:37:44 +0000 (11:37 +0200)]
Rollup merge of #87227 - bstrie:asm2arch, r=Amanieu

Move asm! and global_asm! to core::arch

Follow-up to https://github.com/rust-lang/stdarch/pull/1183 .

Implements the libs-api team decision from rust-lang/rust#84019 (comment) .

In order to not break nightly users, this PR also adds the newly-moved items to the prelude. However, a decision will need to be made before stabilization as to whether these items should remain in the prelude. I will file an issue for this separately.

Fixes #84019 .

r? `@Amanieu`

2 years agoRollup merge of #87210 - notriddle:notriddle/rustdoc-sidebar-headers, r=GuillaumeGomez
Guillaume Gomez [Mon, 19 Jul 2021 09:37:42 +0000 (11:37 +0200)]
Rollup merge of #87210 - notriddle:notriddle/rustdoc-sidebar-headers, r=GuillaumeGomez

Rustdoc accessibility: make the sidebar headers actual headers

Part of #87059

Preview it at: https://notriddle.com/notriddle-rustdoc-test/rustdoc-sidebar-header/std/index.html

2 years agoRollup merge of #86230 - GuillaumeGomez:nocapture, r=camelid
Guillaume Gomez [Mon, 19 Jul 2021 09:37:41 +0000 (11:37 +0200)]
Rollup merge of #86230 - GuillaumeGomez:nocapture, r=camelid

Add --nocapture option to rustdoc

Fixes https://github.com/rust-lang/rust/issues/26309.
Fixes #45724.

Once this PR is merged, I'll send a PR to cargo to also pass `--nocapture` to rustdoc.

cc `@jyn514`
r? `@camelid`

2 years agoAuto merge of #87196 - oxalica:option-insert-must-use, r=joshtriplett
bors [Mon, 19 Jul 2021 07:03:36 +0000 (07:03 +0000)]
Auto merge of #87196 - oxalica:option-insert-must-use, r=joshtriplett

Mark `Option::insert` as must_use

Some people seems misled by the function name and use it in case where a simple assignment just works.
If the return value is not used, `option = Some(value);` should be preferred instead of `option.insert(value);`

2 years agoAuto merge of #87146 - Aaron1011:better-macro-lint, r=petrochenkov
bors [Mon, 19 Jul 2021 04:22:51 +0000 (04:22 +0000)]
Auto merge of #87146 - Aaron1011:better-macro-lint, r=petrochenkov

Compute a better `lint_node_id` during expansion

When we need to emit a lint at a macro invocation, we currently use the
`NodeId` of its parent definition (e.g. the enclosing function). This
means that any `#[allow]` / `#[deny]` attributes placed 'closer' to the
macro (e.g. on an enclosing block or statement) will have no effect.

This commit computes a better `lint_node_id` in `InvocationCollector`.
When we visit/flat_map an AST node, we assign it a `NodeId` (earlier
than we normally would), and store than `NodeId` in current
`ExpansionData`. When we collect a macro invocation, the current
`lint_node_id` gets cloned along with our `ExpansionData`, allowing it
to be used if we need to emit a lint later on.

This improves the handling of `#[allow]` / `#[deny]` for
`SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` and some `asm!`-related lints.
The 'legacy derive helpers' lint retains its current behavior
(I've inlined the now-removed `lint_node_id` function), since
there isn't an `ExpansionData` readily available.

2 years agoAuto merge of #86848 - notriddle:notriddle/drop-dyn, r=varkor
bors [Mon, 19 Jul 2021 01:41:54 +0000 (01:41 +0000)]
Auto merge of #86848 - notriddle:notriddle/drop-dyn, r=varkor

feat(rustc_lint): add `dyn_drop`

Based on the conversation in #86747.

Explanation
-----------

A trait object bound of the form `dyn Drop` is most likely misleading and not what the programmer intended.

`Drop` bounds do not actually indicate whether a type can be trivially dropped or not, because a composite type containing `Drop` types does not necessarily implement `Drop` itself. Naïvely, one might be tempted to write a deferred drop system, to pull cleaning up memory out of a latency-sensitive code path, using `dyn Drop` trait objects. However, this breaks down e.g. when `T` is `String`, which does not implement `Drop`, but should probably be accepted.

To write a trait object bound that accepts anything, use a placeholder trait with a blanket implementation.

```rust
trait Placeholder {}
impl<T> Placeholder for T {}
fn foo(_x: Box<dyn Placeholder>) {}
```

2 years agoAuto merge of #87004 - JamieCunliffe:pgo-gc-sections, r=Mark-Simulacrum
bors [Sun, 18 Jul 2021 23:14:31 +0000 (23:14 +0000)]
Auto merge of #87004 - JamieCunliffe:pgo-gc-sections, r=Mark-Simulacrum

Don't use gc-sections with profile-generate.

When building with profile-generate don't call gc_sections as this can
can sometimes strip out profile data. This missing information in the
prof files can then result in missing functions when using the profile
information.

#78226

r? `@Mark-Simulacrum`

2 years agoMove asm! and global_asm! to core::arch
bstrie [Sat, 17 Jul 2021 18:48:00 +0000 (14:48 -0400)]
Move asm! and global_asm! to core::arch

2 years agoAuto merge of #86950 - tmiasko:personality, r=nagisa
bors [Sun, 18 Jul 2021 20:33:23 +0000 (20:33 +0000)]
Auto merge of #86950 - tmiasko:personality, r=nagisa

Use existing declaration of rust_eh_personality

If crate declares `rust_eh_personality`, re-use existing declaration
as otherwise attempts to set function attributes that follow the
declaration will fail (unless it happens to have exactly the same
type signature as the one predefined in the compiler).

Fixes #70117.
Fixes https://github.com/rust-lang/rust/pull/81469#issuecomment-809428126; probably.

2 years agofix(clippy): add missing allow(dyn_drop)
Michael Howell [Sun, 18 Jul 2021 14:57:03 +0000 (07:57 -0700)]
fix(clippy): add missing allow(dyn_drop)

2 years agoAdd `#![allow(dyn_drop)]` to test cases with `dyn Drop` in them
Michael Howell [Sat, 3 Jul 2021 18:52:19 +0000 (11:52 -0700)]
Add `#![allow(dyn_drop)]` to test cases with `dyn Drop` in them

These are all testing corner-cases in the compiler.
Adding a new warning broke these test cases, but --cap-lints stops
it from actually breaking things in production.

2 years agofeat(rustc_lint): add `dyn_drop`
Michael Howell [Sat, 3 Jul 2021 18:20:01 +0000 (11:20 -0700)]
feat(rustc_lint): add `dyn_drop`

Based on the conversation in #86747.

Explanation
-----------

A trait object bound of the form `dyn Drop` is most likely misleading
and not what the programmer intended.

`Drop` bounds do not actually indicate whether a type can be trivially
dropped or not, because a composite type containing `Drop` types does
not necessarily implement `Drop` itself. Naïvely, one might be tempted
to write a deferred drop system, to pull cleaning up memory out of a
latency-sensitive code path, using `dyn Drop` trait objects. However,
this breaks down e.g. when `T` is `String`, which does not implement
`Drop`, but should probably be accepted.

To write a trait object bound that accepts anything, use a placeholder
trait with a blanket implementation.

```rust
trait Placeholder {}
impl<T> Placeholder for T {}
fn foo(_x: Box<dyn Placeholder>) {}
```

2 years agoAuto merge of #87252 - RalfJung:miri, r=RalfJung
bors [Sun, 18 Jul 2021 13:11:39 +0000 (13:11 +0000)]
Auto merge of #87252 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/87222
Cc `@rust-lang/miri` r? `@ghost`

2 years agoupdate Miri
Ralf Jung [Sun, 18 Jul 2021 10:43:39 +0000 (12:43 +0200)]
update Miri

2 years agoAuto merge of #86698 - cjgillot:modc, r=estebank
bors [Sun, 18 Jul 2021 10:42:23 +0000 (10:42 +0000)]
Auto merge of #86698 - cjgillot:modc, r=estebank

Move OnDiskCache to rustc_query_impl.

This should be the last remnant of the query implementation that was still in rustc_middle.

2 years agoAdd test to check width of item-info
Guillaume Gomez [Sun, 18 Jul 2021 10:32:26 +0000 (12:32 +0200)]
Add test to check width of item-info

2 years agoFix item info display
Guillaume Gomez [Sun, 18 Jul 2021 10:25:49 +0000 (12:25 +0200)]
Fix item info display

2 years agoAdd invalid rust code for test
Guillaume Gomez [Fri, 9 Jul 2021 09:06:20 +0000 (11:06 +0200)]
Add invalid rust code for test

2 years agoDon't capture child process output at all when --no-capture is used
Guillaume Gomez [Fri, 9 Jul 2021 08:58:02 +0000 (10:58 +0200)]
Don't capture child process output at all when --no-capture is used

2 years agoAdd doc for --nocapture
Guillaume Gomez [Fri, 11 Jun 2021 20:20:40 +0000 (22:20 +0200)]
Add doc for --nocapture

2 years agoAdd test for rustdoc --nocapture option
Guillaume Gomez [Fri, 11 Jun 2021 20:11:35 +0000 (22:11 +0200)]
Add test for rustdoc --nocapture option

2 years agoAdd --nocapture option to rustdoc
Guillaume Gomez [Fri, 11 Jun 2021 14:53:32 +0000 (16:53 +0200)]
Add --nocapture option to rustdoc

2 years agoRemove deadlock virtual call.
Camille GILLOT [Mon, 28 Jun 2021 19:33:47 +0000 (21:33 +0200)]
Remove deadlock virtual call.

2 years agoMove OnDiskCache to rustc_query_impl.
Camille GILLOT [Mon, 28 Jun 2021 19:12:01 +0000 (21:12 +0200)]
Move OnDiskCache to rustc_query_impl.

2 years agoAuto merge of #87242 - JohnTitor:rollup-t9rmwpo, r=JohnTitor
bors [Sun, 18 Jul 2021 08:15:17 +0000 (08:15 +0000)]
Auto merge of #87242 - JohnTitor:rollup-t9rmwpo, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #86763 (Add a regression test for issue-63355)
 - #86814 (Recover from a misplaced inner doc comment)
 - #86843 (Check that const parameters of trait methods have compatible types)
 - #86889 (rustdoc: Cleanup ExternalCrate)
 - #87092 (Remove nondeterminism in multiple-definitions test)
 - #87170 (Add diagnostic items for Clippy)
 - #87183 (fix typo in compile_fail doctest)
 - #87205 (rustc_middle: remove redundant clone)

Failed merges:

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

2 years agoAuto merge of #87071 - inquisitivecrystal:inclusive-range, r=estebank
bors [Sun, 18 Jul 2021 05:58:16 +0000 (05:58 +0000)]
Auto merge of #87071 - inquisitivecrystal:inclusive-range, r=estebank

Add diagnostics for mistyped inclusive range

Inclusive ranges are correctly typed as `..=`. However, it's quite easy to think of it as being like `==`, and type `..==` instead. This PR adds helpful diagnostics for this case.

Resolves #86395 (there are some other cases there, but I think those should probably have separate issues).

r? `@estebank`

2 years agoRollup merge of #87205 - matthiaskrgr:clippy_cln, r=oli-obk
Yuki Okushi [Sun, 18 Jul 2021 05:21:59 +0000 (14:21 +0900)]
Rollup merge of #87205 - matthiaskrgr:clippy_cln, r=oli-obk

rustc_middle: remove redundant clone

found while looking through some clippy lint warnings

2 years agoRollup merge of #87183 - RalfJung:option-doctest, r=jyn514
Yuki Okushi [Sun, 18 Jul 2021 05:21:58 +0000 (14:21 +0900)]
Rollup merge of #87183 - RalfJung:option-doctest, r=jyn514

fix typo in compile_fail doctest

Fixes a typo introduced by https://github.com/rust-lang/rust/pull/86211. For some reason this typo makes Miri go all crazy when running libcore doctests (https://github.com/rust-lang/miri/issues/1852). Kudos to ``@hyd-dev`` for noticing the typo.

Cc ``@tlyu`` ``@joshtriplett``

2 years agoRollup merge of #87170 - xFrednet:clippy-5393-add-diagnostic-items, r=Manishearth...
Yuki Okushi [Sun, 18 Jul 2021 05:21:57 +0000 (14:21 +0900)]
Rollup merge of #87170 - xFrednet:clippy-5393-add-diagnostic-items, r=Manishearth,oli-obk

Add diagnostic items for Clippy

This adds a bunch of diagnostic items to `std`/`core`/`alloc` functions, structs and traits used in Clippy. The actual refactorings in Clippy to use these items will be done in a different PR in Clippy after the next sync.

This PR doesn't include all paths Clippy uses, I've only gone through the first 85 lines of Clippy's [`paths.rs`](https://github.com/rust-lang/rust-clippy/blob/ecf85f4bdc319f9d9d853d1fff68a8a25e64c7a8/clippy_utils/src/paths.rs) (after rust-lang/rust-clippy#7466) to get some feedback early on. I've also decided against adding diagnostic items to methods, as it would be nicer and more scalable to access them in a nicer fashion, like adding a `is_diagnostic_assoc_item(did, sym::Iterator, sym::map)` function or something similar (Suggested by `@camsteffen` [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/Diagnostic.20Item.20Naming.20Convention.3F/near/225024603))

There seems to be some different naming conventions when it comes to diagnostic items, some use UpperCamelCase (`BinaryHeap`) and some snake_case (`hashmap_type`). This PR uses UpperCamelCase for structs and traits and snake_case with the module name as a prefix for functions. Any feedback on is this welcome.

cc: rust-lang/rust-clippy#5393

r? `@Manishearth`

2 years agoRollup merge of #87092 - ricobbe:fix-raw-dylib-multiple-definitions, r=petrochenkov
Yuki Okushi [Sun, 18 Jul 2021 05:21:56 +0000 (14:21 +0900)]
Rollup merge of #87092 - ricobbe:fix-raw-dylib-multiple-definitions, r=petrochenkov

Remove nondeterminism in multiple-definitions test

Compare all fields in `DllImport` when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function.  Restore the multiple-definitions test.

Resolves #87084.

2 years agoRollup merge of #86889 - jyn514:crate-cleanup, r=camelid
Yuki Okushi [Sun, 18 Jul 2021 05:21:55 +0000 (14:21 +0900)]
Rollup merge of #86889 - jyn514:crate-cleanup, r=camelid

rustdoc: Cleanup ExternalCrate

- Remove unnecessary CrateNum from Cache.externs
- Remove trival impl Clean for CrateNum

2 years agoRollup merge of #86843 - FabianWolff:issue-86820, r=lcnr
Yuki Okushi [Sun, 18 Jul 2021 05:21:54 +0000 (14:21 +0900)]
Rollup merge of #86843 - FabianWolff:issue-86820, r=lcnr

Check that const parameters of trait methods have compatible types

This PR fixes #86820. The problem is that this currently passes the type checker:
```rust
trait Tr {
    fn foo<const N: u8>(self) -> u8;
}

impl Tr for f32 {
    fn foo<const N: bool>(self) -> u8 { 42 }
}
```
i.e. the type checker fails to check whether const parameters in `impl` methods have the same type as the corresponding declaration in the trait. With my changes, I get, for the above code:
```
error[E0053]: method `foo` has an incompatible const parameter type for trait
 --> test.rs:6:18
  |
6 |     fn foo<const N: bool>(self) -> u8 { 42 }
  |                  ^
  |
note: the const parameter `N` has type `bool`, but the declaration in trait `Tr::foo` has type `u8`
 --> test.rs:2:18
  |
2 |     fn foo<const N: u8>(self) -> u8;
  |                  ^

error: aborting due to previous error
```
This fixes #86820, where an ICE happens later on because the trait method is declared with a const parameter of type `u8`, but the `impl` uses one of type `usize`:
> `expected int of size 8, but got size 1`

2 years agoRollup merge of #86814 - Aaron1011:inner-doc-recover, r=estebank
Yuki Okushi [Sun, 18 Jul 2021 05:21:53 +0000 (14:21 +0900)]
Rollup merge of #86814 - Aaron1011:inner-doc-recover, r=estebank

Recover from a misplaced inner doc comment

Fixes #86781

2 years agoRollup merge of #86763 - JohnTitor:test-63355, r=oli-obk
Yuki Okushi [Sun, 18 Jul 2021 05:21:52 +0000 (14:21 +0900)]
Rollup merge of #86763 - JohnTitor:test-63355, r=oli-obk

Add a regression test for issue-63355

Closes #63355
r? ``@nikomatsakis``

2 years agoAdd test for `#[allow]` for warnings on attribute macro
Aaron Hill [Sat, 17 Jul 2021 13:31:13 +0000 (08:31 -0500)]
Add test for `#[allow]` for warnings on attribute macro

2 years agoOnly use `assign_id!` for ast nodes that support attributes
Aaron Hill [Sat, 17 Jul 2021 13:22:09 +0000 (08:22 -0500)]
Only use `assign_id!` for ast nodes that support attributes

2 years agoAdd additional missing lint handling logic
Aaron Hill [Thu, 15 Jul 2021 19:26:27 +0000 (14:26 -0500)]
Add additional missing lint handling logic

2 years agoAdd missing `visit_expr_field`
Aaron Hill [Thu, 15 Jul 2021 01:07:56 +0000 (20:07 -0500)]
Add missing `visit_expr_field`

2 years agoCompute a better `lint_node_id` during expansion
Aaron Hill [Wed, 14 Jul 2021 23:24:12 +0000 (18:24 -0500)]
Compute a better `lint_node_id` during expansion

When we need to emit a lint at a macro invocation, we currently use the
`NodeId` of its parent definition (e.g. the enclosing function). This
means that any `#[allow]` / `#[deny]` attributes placed 'closer' to the
macro (e.g. on an enclosing block or statement) will have no effect.

This commit computes a better `lint_node_id` in `InvocationCollector`.
When we visit/flat_map an AST node, we assign it a `NodeId` (earlier
than we normally would), and store than `NodeId` in current
`ExpansionData`. When we collect a macro invocation, the current
`lint_node_id` gets cloned along with our `ExpansionData`, allowing it
to be used if we need to emit a lint later on.

This improves the handling of `#[allow]` / `#[deny]` for
`SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` and some `asm!`-related lints.
The 'legacy derive helpers' lint retains its current behavior
(I've inlined the now-removed `lint_node_id` function), since
there isn't an `ExpansionData` readily available.

2 years agoAuto merge of #85686 - ptrojahn:loop_reinitialize, r=estebank
bors [Sun, 18 Jul 2021 02:13:12 +0000 (02:13 +0000)]
Auto merge of #85686 - ptrojahn:loop_reinitialize, r=estebank

Add help on reinitialization between move and access

Fixes #83760

2 years agox.py fmt
Dan Gohman [Sun, 18 Jul 2021 01:31:51 +0000 (18:31 -0700)]
x.py fmt

2 years agoAuto merge of #87129 - FabianWolff:issue-75356, r=varkor
bors [Sat, 17 Jul 2021 22:51:07 +0000 (22:51 +0000)]
Auto merge of #87129 - FabianWolff:issue-75356, r=varkor

Warn about useless assignments of variables/fields to themselves

This PR fixes #75356. Following `@varkor's` suggestion in https://github.com/rust-lang/rust/issues/75356#issuecomment-700339154, I have implemented this warning as part of the `dead_code` lint. Unlike the `-Wself-assign` implementation in [Clang](https://github.com/llvm/llvm-project/blob/56e6d4742e6909bd7d2db201cc5e0e3e77c6f282/clang/lib/Sema/SemaExpr.cpp#L13875-L13909), my implementation also warns about self-assignments of struct fields (`s.x = s.x`).

r? `@varkor`

2 years agoRemove an unnecessary `Mutex` around argument initialization.
Dan Gohman [Sat, 17 Jul 2021 19:33:31 +0000 (12:33 -0700)]
Remove an unnecessary `Mutex` around argument initialization.

In the command-line argument initialization code, remove the Mutex
around the `ARGV` and `ARGC` variables, and simply check whether
ARGV is non-null before dereferencing it. This way, if either of
ARGV or ARGC is not initialized, we'll get an empty argument list.

This allows simple cdylibs to avoid having
`pthread_mutex_lock`/`pthread_mutex_unlock` appear in their symbol
tables if they don't otherwise use threads.

2 years agoRemove args cleanup code.
Dan Gohman [Sat, 17 Jul 2021 12:47:39 +0000 (05:47 -0700)]
Remove args cleanup code.

As of 91c3eee1735ad72b579f99cbb6919c3471747d94, the global ARGC and ARGV
no longer reference dynamically-allocated memory, so they don't need to
be cleaned up.

2 years agoAuto merge of #87203 - jackh726:logging, r=nikomatsakis
bors [Sat, 17 Jul 2021 20:23:58 +0000 (20:23 +0000)]
Auto merge of #87203 - jackh726:logging, r=nikomatsakis

Some perf optimizations and logging

Various bits of (potential) perf optimizations and some logging additions/changes pulled out from #85499

The only not extremely straightforward change is adding `needs_normalization` in `trait::project`. This is just a perf optimization to avoid fold through a type with *only* opaque types in `UserFacing` mode (as they aren't replaced).

This should be a simple PR for *anyone* to review, so I'm going to let highfive assign. But I'll go ahead and cc `@nikomatsakis` in case he has time today.

2 years agoAdd needs_normalization
jackh726 [Fri, 16 Jul 2021 20:23:42 +0000 (16:23 -0400)]
Add needs_normalization

2 years agoSome perf optimizations and logging
jackh726 [Fri, 16 Jul 2021 20:23:42 +0000 (16:23 -0400)]
Some perf optimizations and logging

2 years agoFix sidebar-mobile test to focus on an actual focusable element
Michael Howell [Sat, 17 Jul 2021 18:53:59 +0000 (11:53 -0700)]
Fix sidebar-mobile test to focus on an actual focusable element

2 years agoFix test cases for header titles in sidebar
Michael Howell [Sat, 17 Jul 2021 16:45:07 +0000 (09:45 -0700)]
Fix test cases for header titles in sidebar

2 years agoRemove redundant CSS
Michael Howell [Sat, 17 Jul 2021 05:00:22 +0000 (22:00 -0700)]
Remove redundant CSS

2 years agoRustdoc accessibility: make the sidebar headers actual headers
Michael Howell [Sat, 17 Jul 2021 04:58:23 +0000 (21:58 -0700)]
Rustdoc accessibility: make the sidebar headers actual headers

Part of #87059

Preview it at: https://notriddle.com/notriddle-rustdoc-test/rustdoc-sidebar-header/std/index.html

2 years agoAuto merge of #86676 - cjgillot:localexpn, r=petrochenkov
bors [Sat, 17 Jul 2021 17:56:46 +0000 (17:56 +0000)]
Auto merge of #86676 - cjgillot:localexpn, r=petrochenkov

Make expansions stable for incr. comp.

This PR aims to make expansions stable for incr. comp. by using the same architecture as definitions:
- the interned identifier `ExpnId` contains a `CrateNum` and a crate-local id;
- bidirectional maps `ExpnHash <-> ExpnId` are setup;
- incr. comp. on-disk cache saves and reconstructs expansions using their `ExpnHash`.

I tried to use as many `LocalExpnId` as I could in the resolver code, but I may have missed a few opportunities.

All this will allow to use an `ExpnId` as a query key, and to force this query without recomputing caller queries. For instance, this will be used to implement #85999.

r? `@petrochenkov`

2 years agoSimplify Expn creation.
Camille GILLOT [Thu, 15 Jul 2021 11:45:38 +0000 (13:45 +0200)]
Simplify Expn creation.

2 years agoRename expn_info -> expn_data.
Camille GILLOT [Thu, 15 Jul 2021 11:34:33 +0000 (13:34 +0200)]
Rename expn_info -> expn_data.

2 years agoPass ExpnData by reference.
Camille GILLOT [Mon, 12 Jul 2021 14:56:13 +0000 (16:56 +0200)]
Pass ExpnData by reference.

2 years agoAlways hash spans in expn.
Camille GILLOT [Sun, 27 Jun 2021 19:30:20 +0000 (21:30 +0200)]
Always hash spans in expn.

2 years agoDrop ExpnData::krate.
Camille GILLOT [Sun, 27 Jun 2021 18:06:26 +0000 (20:06 +0200)]
Drop ExpnData::krate.

2 years agoDrop orig_id.
Camille GILLOT [Sun, 27 Jun 2021 17:14:29 +0000 (19:14 +0200)]
Drop orig_id.

2 years agoEncode ExpnId using ExpnHash for incr. comp.
Camille GILLOT [Sun, 27 Jun 2021 13:51:25 +0000 (15:51 +0200)]
Encode ExpnId using ExpnHash for incr. comp.

2 years agoChoose encoding format in caller code.
Camille GILLOT [Sun, 27 Jun 2021 08:38:06 +0000 (10:38 +0200)]
Choose encoding format in caller code.

2 years agoUse LocalExpnId where possible.
Camille GILLOT [Fri, 25 Jun 2021 18:43:04 +0000 (20:43 +0200)]
Use LocalExpnId where possible.

2 years agoMake the CrateNum part of the ExpnId.
Camille GILLOT [Sat, 10 Jul 2021 21:34:41 +0000 (23:34 +0200)]
Make the CrateNum part of the ExpnId.

2 years agoAuto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obk
bors [Sat, 17 Jul 2021 15:26:27 +0000 (15:26 +0000)]
Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obk

CTFE/Miri engine Pointer type overhaul

This fixes the long-standing problem that we are using `Scalar` as a type to represent pointers that might be integer values (since they point to a ZST). The main problem is that with int-to-ptr casts, there are multiple ways to represent the same pointer as a `Scalar` and it is unclear if "normalization" (i.e., the cast) already happened or not. This leads to ugly methods like `force_mplace_ptr` and `force_op_ptr`.
Another problem this solves is that in Miri, it would make a lot more sense to have the `Pointer::offset` field represent the full absolute address (instead of being relative to the `AllocId`). This means we can do ptr-to-int casts without access to any machine state, and it means that the overflow checks on pointer arithmetic are (finally!) accurate.

To solve this, the `Pointer` type is made entirely parametric over the provenance, so that we can use `Pointer<AllocId>` inside `Scalar` but use `Pointer<Option<AllocId>>` when accessing memory (where `None` represents the case that we could not figure out an `AllocId`; in that case the `offset` is an absolute address). Moreover, the `Provenance` trait determines if a pointer with a given provenance can be cast to an integer by simply dropping the provenance.

I hope this can be read commit-by-commit, but the first commit does the bulk of the work. It introduces some FIXMEs that are resolved later.
Fixes https://github.com/rust-lang/miri/issues/841
Miri PR: https://github.com/rust-lang/miri/pull/1851
r? `@oli-obk`

2 years agoAuto merge of #86761 - Alexhuszagh:master, r=estebank
bors [Sat, 17 Jul 2021 12:56:22 +0000 (12:56 +0000)]
Auto merge of #86761 - Alexhuszagh:master, r=estebank

Update Rust Float-Parsing Algorithms to use the Eisel-Lemire algorithm.

# Summary

Rust, although it implements a correct float parser, has major performance issues in float parsing. Even for common floats, the performance can be 3-10x [slower](https://arxiv.org/pdf/2101.11408.pdf) than external libraries such as [lexical](https://github.com/Alexhuszagh/rust-lexical) and [fast-float-rust](https://github.com/aldanor/fast-float-rust).

Recently, major advances in float-parsing algorithms have been developed by Daniel Lemire, along with others, and implement a fast, performant, and correct float parser, with speeds up to 1200 MiB/s on Apple's M1 architecture for the [canada](https://github.com/lemire/simple_fastfloat_benchmark/blob/0e2b5d163d4074cc0bde2acdaae78546d6e5c5f1/data/canada.txt) dataset, 10x faster than Rust's 130 MiB/s.

In addition, [edge-cases](https://github.com/rust-lang/rust/issues/85234) in Rust's [dec2flt](https://github.com/rust-lang/rust/tree/868c702d0c9a471a28fb55f0148eb1e3e8b1dcc5/library/core/src/num/dec2flt) algorithm can lead to over a 1600x slowdown relative to efficient algorithms. This is due to the use of Clinger's correct, but slow [AlgorithmM and Bellepheron](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.45.4152&rep=rep1&type=pdf), which have been improved by faster big-integer algorithms and the Eisel-Lemire algorithm, respectively.

Finally, this algorithm provides substantial improvements in the number of floats the Rust core library can parse. Denormal floats with a large number of digits cannot be parsed, due to use of the `Big32x40`, which simply does not have enough digits to round a float correctly. Using a custom decimal class, with much simpler logic, we can parse all valid decimal strings of any digit count.

```rust
// Issue in Rust's dec2fly.
"2.47032822920623272088284396434110686182e-324".parse::<f64>();   // Err(ParseFloatError { kind: Invalid })
```

# Solution

This pull request implements the Eisel-Lemire algorithm, modified from [fast-float-rust](https://github.com/aldanor/fast-float-rust) (which is licensed under Apache 2.0/MIT), along with numerous modifications to make it more amenable to inclusion in the Rust core library. The following describes both features in fast-float-rust and improvements in fast-float-rust for inclusion in core.

**Documentation**

Extensive documentation has been added to ensure the code base may be maintained by others, which explains the algorithms as well as various associated constants and routines. For example, two seemingly magical constants include documentation to describe how they were derived as follows:

```rust
    // Round-to-even only happens for negative values of q
    // when q ≥ −4 in the 64-bit case and when q ≥ −17 in
    // the 32-bitcase.
    //
    // When q ≥ 0,we have that 5^q ≤ 2m+1. In the 64-bit case,we
    // have 5^q ≤ 2m+1 ≤ 2^54 or q ≤ 23. In the 32-bit case,we have
    // 5^q ≤ 2m+1 ≤ 2^25 or q ≤ 10.
    //
    // When q < 0, we have w ≥ (2m+1)×5^−q. We must have that w < 2^64
    // so (2m+1)×5^−q < 2^64. We have that 2m+1 > 2^53 (64-bit case)
    // or 2m+1 > 2^24 (32-bit case). Hence,we must have 2^53×5^−q < 2^64
    // (64-bit) and 2^24×5^−q < 2^64 (32-bit). Hence we have 5^−q < 2^11
    // or q ≥ −4 (64-bit case) and 5^−q < 2^40 or q ≥ −17 (32-bitcase).
    //
    // Thus we have that we only need to round ties to even when
    // we have that q ∈ [−4,23](in the 64-bit case) or q∈[−17,10]
    // (in the 32-bit case). In both cases,the power of five(5^|q|)
    // fits in a 64-bit word.
    const MIN_EXPONENT_ROUND_TO_EVEN: i32;
    const MAX_EXPONENT_ROUND_TO_EVEN: i32;
```

This ensures maintainability of the code base.

**Improvements for Disguised Fast-Path Cases**

The fast path in float parsing algorithms attempts to use native, machine floats to represent both the significant digits and the exponent, which is only possible if both can be exactly represented without rounding. In practice, this means that the significant digits must be 53-bits or less and the then exponent must be in the range `[-22, 22]` (for an f64). This is similar to the existing dec2flt implementation.

However, disguised fast-path cases exist, where there are few significant digits and an exponent above the valid range, such as `1.23e25`. In this case, powers-of-10 may be shifted from the exponent to the significant digits, discussed at length in https://github.com/rust-lang/rust/issues/85198.

**Digit Parsing Improvements**

Typically, integers are parsed from string 1-at-a-time, requiring unnecessary multiplications which can slow down parsing. An approach to parse 8 digits at a time using only 3 multiplications is described in length [here](https://johnnylee-sde.github.io/Fast-numeric-string-to-int/). This leads to significant performance improvements, and is implemented for both big and little-endian systems.

**Unsafe Changes**

Relative to fast-float-rust, this library makes less use of unsafe functionality and clearly documents it. This includes the refactoring and documentation of numerous unsafe methods undesirably marked as safe. The original code would look something like this, which is deceptively marked as safe for unsafe functionality.

```rust
impl AsciiStr {
    #[inline]
    pub fn step_by(&mut self, n: usize) -> &mut Self {
        unsafe { self.ptr = self.ptr.add(n) };
        self
    }
}

...

#[inline]
fn parse_scientific(s: &mut AsciiStr<'_>) -> i64 {
    // the first character is 'e'/'E' and scientific mode is enabled
    let start = *s;
    s.step();
    ...
}
```

The new code clearly documents safety concerns, and does not mark unsafe functionality as safe, leading to better safety guarantees.

```rust
impl AsciiStr {
    /// Advance the view by n, advancing it in-place to (n..).
    pub unsafe fn step_by(&mut self, n: usize) -> &mut Self {
        // SAFETY: same as step_by, safe as long n is less than the buffer length
        self.ptr = unsafe { self.ptr.add(n) };
        self
    }
}

...

/// Parse the scientific notation component of a float.
fn parse_scientific(s: &mut AsciiStr<'_>) -> i64 {
    let start = *s;
    // SAFETY: the first character is 'e'/'E' and scientific mode is enabled
    unsafe {
        s.step();
    }
    ...
}
```

This allows us to trivially demonstrate the new implementation of dec2flt is safe.

**Inline Annotations Have Been Removed**

In the previous implementation of dec2flt, inline annotations exist practically nowhere in the entire module. Therefore, these annotations have been removed, which mostly does not impact [performance](https://github.com/aldanor/fast-float-rust/issues/15#issuecomment-864485157).

**Fixed Correctness Tests**

Numerous compile errors in `src/etc/test-float-parse` were present, due to deprecation of `time.clock()`, as well as the crate dependencies with `rand`. The tests have therefore been reworked as a [crate](https://github.com/Alexhuszagh/rust/tree/master/src/etc/test-float-parse), and any errors in `runtests.py` have been patched.

**Undefined Behavior**

An implementation of `check_len` which relied on undefined behavior (in fast-float-rust) has been refactored, to ensure that the behavior is well-defined. The original code is as follows:

```rust
    #[inline]
    pub fn check_len(&self, n: usize) -> bool {
        unsafe { self.ptr.add(n) <= self.end }
    }
```

And the new implementation is as follows:

```rust
    /// Check if the slice at least `n` length.
    fn check_len(&self, n: usize) -> bool {
        n <= self.as_ref().len()
    }
```

Note that this has since been fixed in [fast-float-rust](https://github.com/aldanor/fast-float-rust/pull/29).

**Inferring Binary Exponents**

Rather than explicitly store binary exponents, this new implementation infers them from the decimal exponent, reducing the amount of static storage required. This removes the requirement to store [611 i16s](https://github.com/rust-lang/rust/blob/868c702d0c9a471a28fb55f0148eb1e3e8b1dcc5/library/core/src/num/dec2flt/table.rs#L8).

# Code Size

The code size, for all optimizations, does not considerably change relative to before for stripped builds, however it is **significantly** smaller prior to stripping the resulting binaries. These binary sizes were calculated on x86_64-unknown-linux-gnu.

**new**

Using rustc version 1.55.0-dev.

opt-level|size|size(stripped)
|:-:|:-:|:-:|
0|400k|300K
1|396k|292K
2|392k|292K
3|392k|296K
s|396k|292K
z|396k|292K

**old**

Using rustc version 1.53.0-nightly.

opt-level|size|size(stripped)
|:-:|:-:|:-:|
0|3.2M|304K
1|3.2M|292K
2|3.1M|284K
3|3.1M|284K
s|3.1M|284K
z|3.1M|284K

# Correctness

The dec2flt implementation passes all of Rust's unittests and comprehensive float parsing tests, along with numerous other tests such as Nigel Toa's comprehensive float [tests](https://github.com/nigeltao/parse-number-fxx-test-data) and Hrvoje Abraham  [strtod_tests](https://github.com/ahrvoje/numerics/blob/master/strtod/strtod_tests.toml). Therefore, it is unlikely that this algorithm will incorrectly round parsed floats.

# Issues Addressed

This will fix and close the following issues:

- resolves #85198
- resolves #85214
- resolves #85234
- fixes #31407
- fixes #31109
- fixes #53015
- resolves #68396
- closes https://github.com/aldanor/fast-float-rust/issues/15

2 years agoCorrected symbol order after adding diagnostic items
xFrednet [Sat, 17 Jul 2021 10:20:43 +0000 (12:20 +0200)]
Corrected symbol order after adding diagnostic items

2 years agoAuto merge of #87124 - Andy-Python-Programmer:code_model_uefi_patch, r=petrochenkov
bors [Sat, 17 Jul 2021 10:15:33 +0000 (10:15 +0000)]
Auto merge of #87124 - Andy-Python-Programmer:code_model_uefi_patch, r=petrochenkov

Use small code model for UEFI targets

* Since the code model only applies to the code and not the data and the code model
only applies to functions you call through using `call`, `jmp` and data with `lea`, etc…

  If you are calling functions using the function pointers from the UEFI structures the code
  model does not apply in that case. It’s just related to the address space size of your own binary.
  Since UEFI (uefi is all relocatable) uses relocatable PEs (relocatable code does not care about the
  code model) so, we use the small code model here.

* Since applications don't usually take gigabytes of memory, setting the
target to use the small code model should result in better codegen (comparable
with majority of other targets).

  Large code models are also known for generating horrible code, for
  example 16 bytes of code to load a single 8-byte value.

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
2 years agoAuto merge of #86062 - nagisa:nagisa/what-a-lie, r=estebank
bors [Sat, 17 Jul 2021 07:54:03 +0000 (07:54 +0000)]
Auto merge of #86062 - nagisa:nagisa/what-a-lie, r=estebank

Do not allow JSON targets to set is-builtin: true

Note that this will affect (and make builds fail for) all of the projects out there that have target files invalid in this way. Crater, however, does not really cover these kinds of the codebases, so it is quite difficult to measure the impact. That said, the target files invalid in this way can start causing build failures each time LLVM is upgraded, anyway, so it is probably a good opportunity to disallow this property, entirely.

Another approach considered was to simply not parse this field anymore, which would avoid making the builds explicitly fail, but it wasn't clear to me if `is-builtin` was always set unintentionally… In case this was the case, I'd expect people to file a feature request stating specifically for what purpose they were using `is-builtin`.

Fixes #86017

2 years agoChanged dec2flt to use the Eisel-Lemire algorithm.
Alex Huszagh [Sat, 17 Jul 2021 05:30:34 +0000 (00:30 -0500)]
Changed dec2flt to use the Eisel-Lemire algorithm.

Implementation is based off fast-float-rust, with a few notable changes.

- Some unsafe methods have been removed.
- Safe methods with inherently unsafe functionality have been removed.
- All unsafe functionality is documented and provably safe.
- Extensive documentation has been added for simpler maintenance.
- Inline annotations on internal routines has been removed.
- Fixed Python errors in src/etc/test-float-parse/runtests.py.
- Updated test-float-parse to be a library, to avoid missing rand dependency.
- Added regression tests for #31109 and #31407 in core tests.
- Added regression tests for #31109 and #31407 in ui tests.
- Use the existing slice primitive to simplify shared dec2flt methods
- Remove Miri ignores from dec2flt, due to faster parsing times.

- resolves #85198
- resolves #85214
- resolves #85234
- fixes #31407
- fixes #31109
- fixes #53015
- resolves #68396
- closes https://github.com/aldanor/fast-float-rust/issues/15

2 years agoUse small code model for UEFI targets
Andy-Python-Programmer [Wed, 14 Jul 2021 09:19:27 +0000 (19:19 +1000)]
Use small code model for UEFI targets

* Since the code model only applies to the code and not the data and the code model
only applies to functions you call through using `call`, `jmp` and data with `lea`, etc…

If you are calling functions using the function pointers from the UEFI structures the code
model does not apply in that case. It’s just related to the address space size of your own binary.
Since UEFI (uefi is all relocatable) uses relocatable PEs (relocatable code does not care about the
code model) so, we use the small code model here.

* Since applications don't usually take gigabytes of memory, setting the
target to use the small code model should result in better codegen (comparable
with majority of other targets).

Large code models are also known for generating horrible code, for
example 16 bytes of code to load a single 8-byte value.

* Use the LLVM default code model for the architecture for the
x86_64-unknown-uefi targets. For reference small is the default
code model on x86 in LLVM: <https://github.com/llvm/llvm-project/blob/7de2173c2a4c45711831cfee3ccf53690c76ff07/llvm/lib/Target/X86/X86TargetMachine.cpp#L204>

* Remove the comments too as they are not UEFI-specific and applies
to pretty much any target. I added them before as I was explicitily
setting the code model to small.

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
2 years agoAuto merge of #87195 - yaahc:move-assert_matches-again, r=oli-obk
bors [Sat, 17 Jul 2021 00:35:36 +0000 (00:35 +0000)]
Auto merge of #87195 - yaahc:move-assert_matches-again, r=oli-obk

rename assert_matches module

Fixes nightly breakage introduced in https://github.com/rust-lang/rust/pull/86947

2 years agorustc_middle: remove redundant clone
Matthias Krüger [Fri, 16 Jul 2021 22:42:53 +0000 (00:42 +0200)]
rustc_middle: remove redundant clone

found while looking through some clippy lint warnings

2 years agoAuto merge of #83898 - Aaron1011:feature/hir-wf, r=estebank
bors [Fri, 16 Jul 2021 21:54:42 +0000 (21:54 +0000)]
Auto merge of #83898 - Aaron1011:feature/hir-wf, r=estebank

Add initial implementation of HIR-based WF checking for diagnostics

During well-formed checking, we walk through all types 'nested' in
generic arguments. For example, WF-checking `Option<MyStruct<u8>>`
will cause us to check `MyStruct<u8>` and `u8`. However, this is done
on a `rustc_middle::ty::Ty`, which has no span information. As a result,
any errors that occur will have a very general span (e.g. the
definintion of an associated item).

This becomes a problem when macros are involved. In general, an
associated type like `type MyType = Option<MyStruct<u8>>;` may
have completely different spans for each nested type in the HIR. Using
the span of the entire associated item might end up pointing to a macro
invocation, even though a user-provided span is available in one of the
nested types.

This PR adds a framework for HIR-based well formed checking. This check
is only run during error reporting, and is used to obtain a more precise
span for an existing error. This is accomplished by individually
checking each 'nested' type in the HIR for the type, allowing us to
find the most-specific type (and span) that produces a given error.

The majority of the changes are to the error-reporting code. However,
some of the general trait code is modified to pass through more
information.

Since this has no soundness implications, I've implemented a minimal
version to begin with, which can be extended over time. In particular,
this only works for HIR items with a corresponding `DefId` (e.g. it will
not work for WF-checking performed within function bodies).

2 years agoAdd initial implementation of HIR-based WF checking for diagnostics
Aaron Hill [Sun, 4 Apr 2021 20:55:39 +0000 (16:55 -0400)]
Add initial implementation of HIR-based WF checking for diagnostics

During well-formed checking, we walk through all types 'nested' in
generic arguments. For example, WF-checking `Option<MyStruct<u8>>`
will cause us to check `MyStruct<u8>` and `u8`. However, this is done
on a `rustc_middle::ty::Ty`, which has no span information. As a result,
any errors that occur will have a very general span (e.g. the
definintion of an associated item).

This becomes a problem when macros are involved. In general, an
associated type like `type MyType = Option<MyStruct<u8>>;` may
have completely different spans for each nested type in the HIR. Using
the span of the entire associated item might end up pointing to a macro
invocation, even though a user-provided span is available in one of the
nested types.

This PR adds a framework for HIR-based well formed checking. This check
is only run during error reporting, and is used to obtain a more precise
span for an existing error. This is accomplished by individually
checking each 'nested' type in the HIR for the type, allowing us to
find the most-specific type (and span) that produces a given error.

The majority of the changes are to the error-reporting code. However,
some of the general trait code is modified to pass through more
information.

Since this has no soundness implications, I've implemented a minimal
version to begin with, which can be extended over time. In particular,
this only works for HIR items with a corresponding `DefId` (e.g. it will
not work for WF-checking performed within function bodies).

2 years agoCheck that const parameters of trait methods have compatible types
Fabian Wolff [Sat, 3 Jul 2021 15:56:09 +0000 (17:56 +0200)]
Check that const parameters of trait methods have compatible types

2 years agoi sweat to god
Jane Lusby [Fri, 16 Jul 2021 20:25:11 +0000 (13:25 -0700)]
i sweat to god

2 years agopls this time
Jane Lusby [Fri, 16 Jul 2021 19:16:39 +0000 (12:16 -0700)]
pls this time

2 years agoAuto merge of #87201 - GuillaumeGomez:rollup-4loi2q9, r=GuillaumeGomez
bors [Fri, 16 Jul 2021 19:04:16 +0000 (19:04 +0000)]
Auto merge of #87201 - GuillaumeGomez:rollup-4loi2q9, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #87107 (Loop over all opaque types instead of looking at just the first one with the same DefId)
 - #87158 (Suggest full enum variant for local modules)
 - #87174 (Stabilize `[T; N]::map()`)
 - #87179 (Mark `const_trait_impl` as active)
 - #87180 (feat(rustdoc): open sidebar menu when links inside it are focused)
 - #87188 (Add GUI test for auto-hide-trait-implementations setting)
 - #87200 (TAIT: Infer all inference variables in opaque type substitutions via InferCx)

Failed merges:

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

2 years agofix ui tests
Jane Lusby [Fri, 16 Jul 2021 18:26:20 +0000 (11:26 -0700)]
fix ui tests

2 years agoConsider all fields when comparing DllImports, to remove nondetermininsm in multiple...
Richard Cobbe [Mon, 12 Jul 2021 19:46:27 +0000 (12:46 -0700)]
Consider all fields when comparing DllImports, to remove nondetermininsm in multiple-definitions test

2 years agoavoid manual Debug impls by adding extra Provenance bounds to types
Ralf Jung [Fri, 16 Jul 2021 17:50:59 +0000 (19:50 +0200)]
avoid manual Debug impls by adding extra Provenance bounds to types

I wish the derive macro would support adding extra where clauses...

2 years agoRollup merge of #87200 - oli-obk:fixup_fixup_opaque_types, r=nikomatsakis
Guillaume Gomez [Fri, 16 Jul 2021 17:54:12 +0000 (19:54 +0200)]
Rollup merge of #87200 - oli-obk:fixup_fixup_opaque_types, r=nikomatsakis

TAIT: Infer all inference variables in opaque type substitutions via InferCx

The previous algorithm was correct for the example given in its
documentation, but when the TAIT was declared as a free item
instead of an associated item, the generic parameters were the
wrong ones.

cc `@spastorino`

r? `@nikomatsakis`

2 years agoRollup merge of #87188 - GuillaumeGomez:gui-test-auto-hide-trait-impl, r=notriddle
Guillaume Gomez [Fri, 16 Jul 2021 17:54:10 +0000 (19:54 +0200)]
Rollup merge of #87188 - GuillaumeGomez:gui-test-auto-hide-trait-impl, r=notriddle

Add GUI test for auto-hide-trait-implementations setting

Fixes #85592.

r? ``@notriddle``

2 years agoRollup merge of #87180 - notriddle:notriddle/sidebar-keyboard-mobile, r=GuillaumeGomez
Guillaume Gomez [Fri, 16 Jul 2021 17:54:08 +0000 (19:54 +0200)]
Rollup merge of #87180 - notriddle:notriddle/sidebar-keyboard-mobile, r=GuillaumeGomez

feat(rustdoc): open sidebar menu when links inside it are focused

Fixes #87172

Based on #87167 (which should be merged first)

r? ``@GuillaumeGomez``

Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html

2 years agoRollup merge of #87179 - fee1-dead:active-const-impl, r=oli-obk
Guillaume Gomez [Fri, 16 Jul 2021 17:54:06 +0000 (19:54 +0200)]
Rollup merge of #87179 - fee1-dead:active-const-impl, r=oli-obk

Mark `const_trait_impl` as active

See [this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/implementation.20path.20for.20const.20trait.20impls).

r? ``@oli-obk``

2 years agoRollup merge of #87174 - inquisitivecrystal:array-map, r=kennytm
Guillaume Gomez [Fri, 16 Jul 2021 17:54:04 +0000 (19:54 +0200)]
Rollup merge of #87174 - inquisitivecrystal:array-map, r=kennytm

Stabilize `[T; N]::map()`

This stabilizes the `[T; N]::map()` function, gated by the `array_map` feature. The FCP has [already completed.](https://github.com/rust-lang/rust/issues/75243#issuecomment-878448138)

Closes #75243.

2 years agoRollup merge of #87158 - In-line:suggest-full-enum-variant-for-local-module, r=estebank
Guillaume Gomez [Fri, 16 Jul 2021 17:54:02 +0000 (19:54 +0200)]
Rollup merge of #87158 - In-line:suggest-full-enum-variant-for-local-module, r=estebank

Suggest full enum variant for local modules

2 years agoRollup merge of #87107 - oli-obk:tait_double, r=nikomatsakis
Guillaume Gomez [Fri, 16 Jul 2021 17:53:59 +0000 (19:53 +0200)]
Rollup merge of #87107 - oli-obk:tait_double, r=nikomatsakis

Loop over all opaque types instead of looking at just the first one with the same DefId

This exposed a bug in VecMap and is needed for https://github.com/rust-lang/rust/pull/86410 anyway

r? ``@spastorino``

cc ``@nikomatsakis``

2 years agoInfer all inference variables via InferCx
Oli Scherer [Fri, 16 Jul 2021 17:34:23 +0000 (17:34 +0000)]
Infer all inference variables via InferCx

The previous algorithm was correct for the example given in its
documentation, but when the TAIT was declared as a free item
instead of an associated item, the generic parameters were the
wrong ones.

2 years agoAdd some more tracing instrumentation
Oli Scherer [Fri, 16 Jul 2021 17:34:17 +0000 (17:34 +0000)]
Add some more tracing instrumentation

2 years agoAuto merge of #84623 - jackh726:gats-incomplete, r=nikomatsakis
bors [Fri, 16 Jul 2021 16:23:15 +0000 (16:23 +0000)]
Auto merge of #84623 - jackh726:gats-incomplete, r=nikomatsakis

Make GATs no longer an incomplete feature

Blocked on ~#84622~, ~#82272~, ~#76826~

r? `@nikomatsakis`

2 years agoMark `Option::insert` as must_use
oxalica [Fri, 16 Jul 2021 16:19:44 +0000 (00:19 +0800)]
Mark `Option::insert` as must_use

2 years agorename assert_matches module
Jane Lusby [Fri, 16 Jul 2021 16:18:14 +0000 (09:18 -0700)]
rename assert_matches module

2 years agofeat(rustdoc): open sidebar menu when links inside it are focused
Michael Howell [Fri, 16 Jul 2021 15:04:49 +0000 (08:04 -0700)]
feat(rustdoc): open sidebar menu when links inside it are focused

Fixes #87172

Based on #87167 (which should be merged first)

Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html

Co-authored-by: Guillaume Gomez <guillaume.gomez@huawei.com>
2 years agoAuto merge of #87140 - camsteffen:pat-slice-refs, r=oli-obk
bors [Fri, 16 Jul 2021 13:35:48 +0000 (13:35 +0000)]
Auto merge of #87140 - camsteffen:pat-slice-refs, r=oli-obk

Remove refs from Pat slices

Changes `PatKind::Or(&'hir [&'hir Pat<'hir>])` to `PatKind::Or(&'hir [Pat<'hir>])` and others. This is more consistent with `ExprKind`, saves a little memory, and is a little easier to use.

2 years agoAdd GUI test for auto-hide-trait-implementations setting
Guillaume Gomez [Fri, 16 Jul 2021 13:15:23 +0000 (15:15 +0200)]
Add GUI test for auto-hide-trait-implementations setting

2 years agoadd some comments regarding the two major quirks of our memory model
Ralf Jung [Fri, 16 Jul 2021 09:16:32 +0000 (11:16 +0200)]
add some comments regarding the two major quirks of our memory model

2 years agoAuto merge of #87182 - GuillaumeGomez:rollup-whwohua, r=GuillaumeGomez
bors [Fri, 16 Jul 2021 09:28:22 +0000 (09:28 +0000)]
Auto merge of #87182 - GuillaumeGomez:rollup-whwohua, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #86983 (Add or improve natvis definitions for common standard library types)
 - #87069 (ExprUseVisitor: Treat ByValue use of Copy types as ImmBorrow)
 - #87138 (Correct invariant documentation for `steps_between`)
 - #87145 (Make --cap-lints and related options leave crate hash alone)
 - #87161 (RFC2229: Use the correct place type)
 - #87162 (Fix type decl layout "overflow")
 - #87167 (Fix sidebar display on small devices)

Failed merges:

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

2 years agofix typo in compile_fail doctest
Ralf Jung [Fri, 16 Jul 2021 08:31:56 +0000 (10:31 +0200)]
fix typo in compile_fail doctest