]> git.lizzy.rs Git - rust.git/log
rust.git
18 months agoAuto merge of #105855 - arcnmx:rust-analyzer-2022-12, r=lnicola
bors [Mon, 9 Jan 2023 21:14:32 +0000 (21:14 +0000)]
Auto merge of #105855 - arcnmx:rust-analyzer-2022-12, r=lnicola

:arrow_up: rust-analyzer

Updates rust-analyzer to https://github.com/rust-lang/rust-analyzer/commit/368e0bb32f1178cf162c2ce5f7e10b7ae211eb26

This is a continuation/replacement of #105834, close that if this is chosen instead.

18 months ago:arrow_up: rust-analyzer
arcnmx [Mon, 9 Jan 2023 18:36:22 +0000 (10:36 -0800)]
:arrow_up: rust-analyzer

Merge commit '368e0bb32f1178cf162c2ce5f7e10b7ae211eb26'

18 months agoAuto merge of #106637 - fee1-dead-contrib:rollup-ticvmsd, r=fee1-dead
bors [Mon, 9 Jan 2023 18:20:00 +0000 (18:20 +0000)]
Auto merge of #106637 - fee1-dead-contrib:rollup-ticvmsd, r=fee1-dead

Rollup of 10 pull requests

Successful merges:

 - #105292 (Change a commit_if_ok call to probe)
 - #105655 (Remove invalid case for mutable borrow suggestion)
 - #106047 (Fix ui constant tests for big-endian platforms)
 - #106061 (Enable Shadow Call Stack for Fuchsia on AArch64)
 - #106164 (Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`)
 - #106291 (Fix incorrect suggestion for extra `&` in pattern)
 - #106389 (Simplify some canonical type alias names)
 - #106468 (Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`)
 - #106549 (Use fmt named parameters in rustc_borrowck)
 - #106614 (error-code docs improvements (No. 2))

Failed merges:

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

18 months agoAuto merge of #13848 - ian-h-chamberlain:feature/color-compiler-diagnostics, r=ian...
bors [Mon, 9 Jan 2023 17:07:35 +0000 (17:07 +0000)]
Auto merge of #13848 - ian-h-chamberlain:feature/color-compiler-diagnostics, r=ian-h-chamberlain

Colorize `cargo check` diagnostics in VSCode via text decorations

Fixes #13648

![colored-rustc-diagnostics](https://user-images.githubusercontent.com/11131775/209479884-10eef8ca-37b4-4aae-88f7-3591ac01b25e.gif)

Use ANSI control characters to display text decorations matching the VScode terminal theme, and strip them out when providing text content for rustc diagnostics.

This adds the small [`anser`](https://www.npmjs.com/package/anser) library (MIT license, no dependencies) to parse the control codes, and it also supports HTML output so it should be fairly easy to switch to a rendered HTML/webview implementation in the future

I also updated the default `cargo check` command to use the rendered ANSI diagnostics, although I'm not sure if it makes sense to put this kind of thing behind a feature flag, or whether it might have any issues on Windows (as I believe ANSI codes are not used for colorization there)?

18 months agoAdd docs for `colorDiagnosticOutput` capability
Ian Chamberlain [Mon, 9 Jan 2023 16:44:38 +0000 (11:44 -0500)]
Add docs for `colorDiagnosticOutput` capability

18 months agoUse experimental capability to enable color codes
Ian Chamberlain [Wed, 4 Jan 2023 17:04:45 +0000 (12:04 -0500)]
Use experimental capability to enable color codes

18 months agoStrip colors before matching preview diagnostics
Ian Chamberlain [Tue, 3 Jan 2023 15:49:47 +0000 (10:49 -0500)]
Strip colors before matching preview diagnostics

18 months agoUpdate docs to include note about ANSI diagnostics
Ian Chamberlain [Sun, 25 Dec 2022 18:52:42 +0000 (13:52 -0500)]
Update docs to include note about ANSI diagnostics

18 months agoDefault to use colored ANSI diagnostics
Ian Chamberlain [Wed, 28 Dec 2022 14:41:24 +0000 (09:41 -0500)]
Default to use colored ANSI diagnostics

18 months agoParse + decorate rendered ANSI cargo output
Ian Chamberlain [Tue, 3 Jan 2023 15:16:16 +0000 (10:16 -0500)]
Parse + decorate rendered ANSI cargo output

Use ANSI control characters to display text decorations matching the
VScode terminal theme, and strip them out when providing text content
for rustc diagnostics.

This adds the small `anser` library to parse the control codes, and it
also supports HTML output so it should be fairly easy to switch to a
rendered HTML/webview implementation if desired.

18 months agoAuto merge of #13915 - Veykril:lsp-server-msg, r=Veykril
bors [Mon, 9 Jan 2023 16:04:04 +0000 (16:04 +0000)]
Auto merge of #13915 - Veykril:lsp-server-msg, r=Veykril

Make it clearer when the server expects an initialized notification

18 months agoMake it clearer when the server expects an initialized notification
Lukas Wirth [Mon, 9 Jan 2023 16:03:36 +0000 (17:03 +0100)]
Make it clearer when the server expects an initialized notification

18 months agoAuto merge of #13799 - Veykril:flycheck, r=Veykril
bors [Mon, 9 Jan 2023 15:35:38 +0000 (15:35 +0000)]
Auto merge of #13799 - Veykril:flycheck, r=Veykril

Rename `checkOnSave` settings to `check`

Now that flychecks can be triggered without saving the setting name doesn't make that much sense anymore. This PR renames it to just `check`, but keeps `checkOnSave` as the enabling setting.

18 months agoRollup merge of #106614 - Ezrashaw:ui-test-fixups-2, r=GuillaumeGomez
fee1-dead [Mon, 9 Jan 2023 15:35:32 +0000 (23:35 +0800)]
Rollup merge of #106614 - Ezrashaw:ui-test-fixups-2, r=GuillaumeGomez

error-code docs improvements (No. 2)

- Added empty error-code docs for `E0208`, `E0640` and `E0717` with the "internal" header as discussed on Discord.
- Wrote docs and UI test for `E0711`, again with the header.
- `tidy` changes are common-sense and make everything pass, `style.rs` hack is annoying though.

r? ```@GuillaumeGomez```

18 months agoRollup merge of #106549 - wcampbell0x2a:use-fmt-named-parameters-borrowck, r=estebank
fee1-dead [Mon, 9 Jan 2023 15:35:31 +0000 (23:35 +0800)]
Rollup merge of #106549 - wcampbell0x2a:use-fmt-named-parameters-borrowck, r=estebank

Use fmt named parameters in rustc_borrowck

18 months agoRollup merge of #106468 - compiler-errors:err-instability, r=lcnr
fee1-dead [Mon, 9 Jan 2023 15:35:31 +0000 (23:35 +0800)]
Rollup merge of #106468 - compiler-errors:err-instability, r=lcnr

Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`

I have no idea how to test this reliably, but I've **manually** verified it fixes the instability in #106417 that isn't due to dtolnay/trybuild#212.

Fixes #106417

18 months agoRollup merge of #106389 - compiler-errors:no-canonicalized, r=lcnr
fee1-dead [Mon, 9 Jan 2023 15:35:30 +0000 (23:35 +0800)]
Rollup merge of #106389 - compiler-errors:no-canonicalized, r=lcnr

Simplify some canonical type alias names

* delete the `Canonicalized<'tcx>` type alias in favor for `Canonical<'tcx>`
* `CanonicalizedQueryResponse` -> `CanonicalQueryResponse`

I don't particularly care about the latter, but it should be consistent. We could alternatively delete the first alias and rename the struct to `Canonicalized`, and then keep the name of `CanonicalizedQueryResponse` untouched.

18 months agoRollup merge of #106291 - obeis:issue-106182, r=oli-obk
fee1-dead [Mon, 9 Jan 2023 15:35:29 +0000 (23:35 +0800)]
Rollup merge of #106291 - obeis:issue-106182, r=oli-obk

Fix incorrect suggestion for extra `&` in pattern

Closes #106182

18 months agoRollup merge of #106164 - compiler-errors:check-region-tweak, r=oli-obk
fee1-dead [Mon, 9 Jan 2023 15:35:29 +0000 (23:35 +0800)]
Rollup merge of #106164 - compiler-errors:check-region-tweak, r=oli-obk

Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`

Makes sense for this function to live with its sibling `resolve_regions_and_report_errors`, around which it's basically just a wrapper.

18 months agoRollup merge of #106061 - ilovepi:fuchsia-scs, r=oli-obk
fee1-dead [Mon, 9 Jan 2023 15:35:28 +0000 (23:35 +0800)]
Rollup merge of #106061 - ilovepi:fuchsia-scs, r=oli-obk

Enable Shadow Call Stack for Fuchsia on AArch64

Fuchsia already uses SCS by default for C/C++ code on ARM hardware. This patch allows SCS to be used for Rust code as well.

18 months agoRollup merge of #106047 - uweigand:s390x-test-bigendian-ui, r=oli-obk
fee1-dead [Mon, 9 Jan 2023 15:35:27 +0000 (23:35 +0800)]
Rollup merge of #106047 - uweigand:s390x-test-bigendian-ui, r=oli-obk

Fix ui constant tests for big-endian platforms

A number of tests under ui/const-ptr and ui/consts are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the stderr test files.

Fix this by a combination of two types of changes:

- Where possible (i.e. where the particular value of a constant does not affect the purpose of the test), choose constant values that have the same encoding on big- and little-endian platforms.

- Where this is not possible, provide a normalize-stderr-test rule that transforms the printed big-endian encoding of such constants into the corresponding little-endian form.

Fixes part of https://github.com/rust-lang/rust/issues/105383.

18 months agoRollup merge of #105655 - RedDocMD:bug-105645, r=oli-obk
fee1-dead [Mon, 9 Jan 2023 15:35:27 +0000 (23:35 +0800)]
Rollup merge of #105655 - RedDocMD:bug-105645, r=oli-obk

Remove invalid case for mutable borrow suggestion

If we have a call such as `foo(&mut buf)` and after reference
collapsing the type is inferred as `&T` where-as the required type is
`&mut T`, don't suggest `foo(&mut mut buf)`. This is wrong syntactically
and the issue lies elsewhere, not in the borrow.

Fixes #105645

18 months agoRollup merge of #105292 - JulianKnodt:no_eager_commit, r=BoxyUwU
fee1-dead [Mon, 9 Jan 2023 15:35:26 +0000 (23:35 +0800)]
Rollup merge of #105292 - JulianKnodt:no_eager_commit, r=BoxyUwU

Change a commit_if_ok call to probe

Removes an over-eager `commit_if_ok` which makes inference worse.

I'm not entirely sure whether it's ok to remove the check that types are the same, because casting seems to cause equality checks with incorrect types?

Fixes #105037

r? ```@BoxyUwU```

18 months agoAuto merge of #101947 - aliemjay:astconv-normalize, r=lcnr
bors [Mon, 9 Jan 2023 15:29:59 +0000 (15:29 +0000)]
Auto merge of #101947 - aliemjay:astconv-normalize, r=lcnr

Don't normalize in AstConv

See individual commits.

Fixes #101350
Fixes #54940

18 months agoAuto merge of #13914 - WaffleLapkin:qualify_method_call_rewrite, r=lnicola
bors [Mon, 9 Jan 2023 15:22:51 +0000 (15:22 +0000)]
Auto merge of #13914 - WaffleLapkin:qualify_method_call_rewrite, r=lnicola

minor: Make `qualify_method_call` `RefactorRewrite`

See https://github.com/rust-lang/rust-analyzer/pull/13825#issuecomment-1363289767

18 months agoAuto merge of #13890 - lowr:fix/unescape-inline-mod-name, r=Veykril
bors [Mon, 9 Jan 2023 15:07:06 +0000 (15:07 +0000)]
Auto merge of #13890 - lowr:fix/unescape-inline-mod-name, r=Veykril

fix: unescape inline module names in module resolution

Fixes #13884

18 months agoAuto merge of #13863 - danieleades:approx-constant, r=Veykril
bors [Mon, 9 Jan 2023 14:53:46 +0000 (14:53 +0000)]
Auto merge of #13863 - danieleades:approx-constant, r=Veykril

minor: suppress 'clippy::approx_constant' lint in test case

suppresses a false positive clippy lint

18 months agoAuto merge of #13825 - WaffleLapkin:ufcs_to_method_call_and_back, r=Veykril
bors [Mon, 9 Jan 2023 14:37:40 +0000 (14:37 +0000)]
Auto merge of #13825 - WaffleLapkin:ufcs_to_method_call_and_back, r=Veykril

feat: Add `unqualify_method_call` assist

...which is the inverse of `qualify_method_call` assist.

![Peek 2022-12-22 22-47](https://user-images.githubusercontent.com/38225716/209206554-8f067206-6fa6-48f8-849e-f6d36ee2e5a1.gif)

Optional future work:
- import the trait if needed
- remove excess references when auto-ref is possible

18 months agoMake `qualify_method_call` `RefactorRewrite`
Maybe Waffle [Mon, 9 Jan 2023 14:26:48 +0000 (14:26 +0000)]
Make `qualify_method_call` `RefactorRewrite`

18 months agoAuto merge of #13810 - tfpk:tfpk/macro-inline, r=Veykril
bors [Mon, 9 Jan 2023 14:24:41 +0000 (14:24 +0000)]
Auto merge of #13810 - tfpk:tfpk/macro-inline, r=Veykril

Add action to expand a declarative macro once, inline. Fixes #13598

This commit adds a new r-a method, `expandMacroInline`, which expands the macro that's currently selected. See  #13598 for the most applicable issue; though I suspect it'll resolve part of #5949 and make #11888 significantly easier).

The macro works like this:

![rust-analyser-feature](https://user-images.githubusercontent.com/10906982/208813167-3123e379-8fd5-4206-a4f4-5af1129565f9.gif)

I have 2 questions before this PR can be merged:

1. **Should we rustfmt the output?** The advantage of doing this is neater code. The disadvantages are we'd have to format the whole expr/stmt/block (since there's no point just formatting one part, especially over multiple lines), and maybe it moves the code around more in weird ways. My suggestion here is to start off by not doing any formatting; and if it appears useful we can decide to do formatting in a later release.
2.   **Is it worth solving the `$crate` hygiene issue now?** -- I think this PR is usable as of right now for some use-cases; but it is annoying that many common macros (i.e. `println!()`, `format!()`) can't be expanded further unless the user guesses the correct `$crate` value. The trouble with solving that issue is that I think it's complicated and imperfect. If we do solve it; we'd also need to either change the existing `expandMacro`/`expandMacroInline` commands; provide some option to allow/disallow `$crate` expanding; or come to some other compromise.

18 months agoRename assist: `convert_ufcs_to_method` => `unqualify_method_call`
Maybe Waffle [Mon, 9 Jan 2023 13:59:02 +0000 (13:59 +0000)]
Rename assist: `convert_ufcs_to_method` => `unqualify_method_call`

18 months agoAuto merge of #13891 - bvanjoi:reverse-whitespace-in-assists, r=Veykril
bors [Mon, 9 Jan 2023 14:11:40 +0000 (14:11 +0000)]
Auto merge of #13891 - bvanjoi:reverse-whitespace-in-assists, r=Veykril

fix: keep whitespace in extract function handler

Fixed #13874

18 months agoSimplify code with @Veykril's suggestion.
Tom Kunc [Mon, 9 Jan 2023 14:01:41 +0000 (07:01 -0700)]
Simplify code with @Veykril's suggestion.

18 months agoAdd `convert_ufcs_to_method` assist
Maybe Waffle [Tue, 6 Dec 2022 17:34:47 +0000 (17:34 +0000)]
Add `convert_ufcs_to_method` assist

18 months agoAuto merge of #13816 - WaffleLapkin:postfix_adjustment_hints, r=Veykril
bors [Mon, 9 Jan 2023 13:47:46 +0000 (13:47 +0000)]
Auto merge of #13816 - WaffleLapkin:postfix_adjustment_hints, r=Veykril

Postfix adjustment hints

# Basic Description

This PR implements "postfix" adjustment hints:
![2022-12-21_19-27](https://user-images.githubusercontent.com/38225716/208941721-d48d316f-a918-408a-9757-8d4e2b402a66.png)

They are identical to normal adjustment hints, but are rendered _after_ the expression. E.g. `expr.*` instead of `*expr`. ~~This mirrors "postfix deref" feature that I'm planning to eventually propose to the compiler.~~

# Motivation

The advantage of being postfix is that you need to add parentheses less often:

![2022-12-21_19-38](https://user-images.githubusercontent.com/38225716/208944302-16718112-14a4-4438-8aed-797766391c63.png)
![2022-12-21_19-37](https://user-images.githubusercontent.com/38225716/208944281-d9614888-6597-41ee-bf5d-a081d8048f94.png)

This is because a lot of "reborrow" hints are caused by field access or method calls, both of which are postfix and have higher "precedence" than prefix `&` and `*`.

Also IMHO it just looks nicer and it's more clear what is happening (order of operations).

# Modes

However, there are some cases where postfix hints need parentheses but prefix don't (for example `&x` being turned into `(&x).*.*.&` or `&**&x`).

This PR allows users to choose which look they like more. There are 4 options (`rust-analyzer.inlayHints.expressionAdjustmentHints.mode` setting):
- `prefix` — always use prefix hints (default, what was used before that PR)
- `postfix` — always use postfix hints
- `prefer_prefix` — try to minimize number of parentheses, breaking ties in favor of prefix
- `prefer_postfix` — try to minimize number of parentheses, breaking ties in favor of postfix

Comparison of all modes:

![2022-12-21_19-53](https://user-images.githubusercontent.com/38225716/208947482-26357c82-2b42-47d9-acec-835f5f03f6b4.png)
![2022-12-21_19-49](https://user-images.githubusercontent.com/38225716/208946731-fe566d3b-52b2-4846-994d-c2cecc769e0f.png)
![2022-12-21_19-48](https://user-images.githubusercontent.com/38225716/208946742-6e237f44-805e-469a-a3db-03d8f76e1317.png)
![2022-12-21_19-47](https://user-images.githubusercontent.com/38225716/208946747-79f25fae-e3ea-47d2-8d27-cb4eeac034fe.png)

# Edge cases

Where are some rare cases where chain hints weirdly interact with adjustment hints, for example (note `SourceAnalyzer.&`):

![image](https://user-images.githubusercontent.com/38225716/208947958-41c12971-f1f0-4a41-a930-47939cce9f58.png)

This is pre-existing, you can get the same effect with prefix hints (`SourceAnalyzer)`).

----

Another weird thing is this:

![2022-12-21_20-00](https://user-images.githubusercontent.com/38225716/208948590-ea26d325-2108-4b35-abaa-716a65a1ae99.png)

Here `.&` is a hint and `?` is written in the source code. It looks like `?` is part of the hint because `?.` is ligature in my font. IMO this is a bug in vscode, but still worth mentioning (I'm also too lazy to report it there...).

# Fixed bugs

I've used the "needs parens" API and this accidentally fixed a bug with parens around `as`, see the test diff:
```diff,rust
     let _: *const u32  = &mut 0u32 as *mut u32;
                        //^^^^^^^^^^^^^^^^^^^^^<mut-ptr-to-const-ptr>
+                       //^^^^^^^^^^^^^^^^^^^^^(
+                       //^^^^^^^^^^^^^^^^^^^^^)
...
     let _: *const u32  = &mut 0u32 as *mut u32;
                        //^^^^^^^^^^^^^^^^^^^^^<mut-ptr-to-const-ptr>
+                       //^^^^^^^^^^^^^^^^^^^^^(
+                       //^^^^^^^^^^^^^^^^^^^^^)
```

# Changelog

changelog feature Add an option to make adjustment hints (aka reborrow hints) postfix
changelog fix Fix placement of parentheses around `as` casts for adjustment hints

18 months agoAdd a fixme to remove hacks
Maybe Waffle [Mon, 9 Jan 2023 13:37:37 +0000 (13:37 +0000)]
Add a fixme to remove hacks

18 months agoAdd a "bug" test for adjustment hints to check for status quo
Maybe Waffle [Wed, 21 Dec 2022 15:31:57 +0000 (15:31 +0000)]
Add a "bug" test for adjustment hints to check for status quo

18 months agoAdd an option to minimize parentheses for adjustment hints
Maybe Waffle [Wed, 21 Dec 2022 15:00:05 +0000 (15:00 +0000)]
Add an option to minimize parentheses for adjustment hints

18 months agoAuto merge of #13843 - Overpeek:master, r=Veykril
bors [Mon, 9 Jan 2023 13:34:51 +0000 (13:34 +0000)]
Auto merge of #13843 - Overpeek:master, r=Veykril

fix: generate async delegate methods

Fixes a bug where the generated async method doesn't await the result before returning it.

This is an example of what the output looked like:
```rust
struct Age<T>(T);
impl<T> Age<T> {
    pub(crate) async fn age<J, 'a>(&'a mut self, ty: T, arg: J) -> T {
        self.0
    }
}
struct Person<T> {
    age: Age<T>,
}
impl<T> Person<T> {
    pub(crate) async fn age<J, 'a>(&'a mut self, ty: T, arg: J) -> T {
        self.age.age(ty, arg) // .await is missing
    }
}
```
The `.await` is missing, so the return type is `impl Future<Output = T>` instead of `T`

18 months agoImplement postfix adjustment hints
Maybe Waffle [Tue, 20 Dec 2022 22:07:00 +0000 (22:07 +0000)]
Implement postfix adjustment hints

I'd say "First stab at implementing..." but I've been working on this
for a month already lol

18 months agoRename checkOnSave settings to check
Lukas Wirth [Mon, 9 Jan 2023 13:15:13 +0000 (14:15 +0100)]
Rename checkOnSave settings to check

18 months agoRename checkOnSave settings to flycheck
Lukas Wirth [Tue, 20 Dec 2022 10:31:07 +0000 (11:31 +0100)]
Rename checkOnSave settings to flycheck

18 months agoAuto merge of #13763 - rami3l:fix/gen-partial-eq-generic, r=Veykril
bors [Mon, 9 Jan 2023 13:02:09 +0000 (13:02 +0000)]
Auto merge of #13763 - rami3l:fix/gen-partial-eq-generic, r=Veykril

fix: add generic `TypeBoundList` in generated derivable impl

Potentially fixes #13727.

Continuing with the work in #13732, this fix tries to add correct type bounds in the generated `impl` block:

```diff
  enum Either<T, U> {
      Left(T),
      Right(U),
  }

- impl<T, U> PartialEq for Either<T, U> {
+ impl<T: PartialEq, U: PartialEq> PartialEq for Either<T, U> {
      fn eq(&self, other: &Self) -> bool {
          match (self, other) {
              (Self::Left(l0), Self::Left(r0)) => l0 == r0,
              (Self::Right(l0), Self::Right(r0)) => l0 == r0,
              _ => false,
          }
      }
  }
```

18 months agoAuto merge of #106340 - saethlin:propagate-operands, r=oli-obk
bors [Mon, 9 Jan 2023 11:59:51 +0000 (11:59 +0000)]
Auto merge of #106340 - saethlin:propagate-operands, r=oli-obk

Always permit ConstProp to exploit arithmetic identities

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

Initially, I thought I would need to enable operand propagation then do something else, but actually https://github.com/rust-lang/rust/pull/74491 already has the fix for the issue in question! It looks like this optimization was put under MIR opt level 3 due to possible soundness/stability implications, then demoted further to MIR opt level 4 when MIR opt level 2 became associated with `--release`.

Perhaps in the past we were doing CTFE on optimized MIR? We aren't anymore, so this optimization has no stability implications.

r? `@oli-obk`

18 months agoAuto merge of #13744 - vtta:numthreads, r=Veykril
bors [Mon, 9 Jan 2023 11:53:23 +0000 (11:53 +0000)]
Auto merge of #13744 - vtta:numthreads, r=Veykril

feat: add the ability to limit the number of threads launched by `main_loop`

## Motivation
`main_loop` defaults to launch as many threads as cpus in one machine. When developing on multi-core remote servers on multiple projects, this will lead to thousands of idle threads being created. This is very annoying when one wants check whether his program under developing is running correctly via `htop`.

<img width="756" alt="image" src="https://user-images.githubusercontent.com/41831480/206656419-fa3f0dd2-e554-4f36-be1b-29d54739930c.png">

## Contribution
This patch introduce the configuration option `rust-analyzer.numThreads` to set the desired thread number used by the main thread pool.
This should have no effects on the performance as not all threads are actually used.
<img width="1325" alt="image" src="https://user-images.githubusercontent.com/41831480/206656834-fe625c4c-b993-4771-8a82-7427c297fd41.png">

## Demonstration
The following is a snippet of `lunarvim` configuration using my own build.
```lua
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer" })
require("lvim.lsp.manager").setup("rust_analyzer", {
  cmd = { "env", "RA_LOG=debug", "RA_LOG_FILE=/tmp/ra-test.log",
    "/home/jlhu/Projects/rust-analyzer/target/debug/rust-analyzer",
  },
  init_options = {
    numThreads = 4,
  },
  settings = {
    cachePriming = {
      numThreads = 8,
    },
  },
})

```

## Limitations
The `numThreads` can only be modified via `initializationOptions` in early initialisation because everything has to wait until the thread pool starts including the dynamic settings modification support.
The `numThreads` also does not reflect the end results of how many threads is actually created, because I have not yet tracked down everything that spawns threads.

18 months agoAuto merge of #13684 - unvalley:extract-expressions-from-format-string, r=Veykril
bors [Mon, 9 Jan 2023 11:40:48 +0000 (11:40 +0000)]
Auto merge of #13684 - unvalley:extract-expressions-from-format-string, r=Veykril

feat: extract_expressions_from_format_string

closes #13640
- rename to `extract_expressions_from_format_string`
- leave identifier from format string
- but this is from rustc version 1.65.0
- Should I add flag or something?

Note: the assist behaves below cases for now. I'll create an issue for these.
```rs
let var = 1 + 1;
// ok
format!("{var} {1+1}");   // → format!("{var} {}", 1+1);
format!("{var:?} {1+1}"); // → format!("{var:?} {}", 1 + 1);
format!("{var} {var} {1+1}"); // → format!("{var} {var} {}", 1 + 1);

// breaks (need to handle minimum width by postfix`$`)
format!("{var:width$} {1+1}"); // → format!("{var:width\$} {}", 1+1);
format!("{var:.prec$} {1+1}"); // → format!("{var:.prec\$} {}", 1+1);
format!("Hello {:1$}! {1+1}", "x" 5); // → format("Hello {:1\$}! {}", "x", 1+1);
format!("Hello {:width$}! {1+1}", "x", width = 5); // → println!("Hello {:width\$}! {}", "x", 1+1);
```

https://user-images.githubusercontent.com/38400669/204344911-f1f8fbd2-706d-414e-b1ab-d309376efb9b.mov

18 months agoAuto merge of #13458 - cameron1024:suggest-checked-wrapping-saturating, r=Veykril
bors [Mon, 9 Jan 2023 11:24:44 +0000 (11:24 +0000)]
Auto merge of #13458 - cameron1024:suggest-checked-wrapping-saturating, r=Veykril

add wrapping/checked/saturating assist

This addresses #13452

I'm not sure about the structure of the code. I'm not sure if it needs to be 3 separate assists, and if that means it needs to be in 3 separate files as well.

Most of the logic is in `util.rs`, which feels funny to me, but there seems to be a pattern of 1 assist per file, and this seems better than duplicating the logic.

Let me know if anything needs changes :grin:

18 months agofix: add_format_like_completions to handle no exprs
unvalley [Mon, 28 Nov 2022 16:39:27 +0000 (01:39 +0900)]
fix: add_format_like_completions to handle no exprs

18 months agodocs: update assist comment
unvalley [Sun, 27 Nov 2022 09:24:43 +0000 (18:24 +0900)]
docs: update assist comment

18 months agochore: update assist label name
unvalley [Sun, 27 Nov 2022 08:23:46 +0000 (17:23 +0900)]
chore: update assist label name

18 months agofeat: extract only expressions from format string
unvalley [Sun, 27 Nov 2022 06:36:26 +0000 (15:36 +0900)]
feat: extract only expressions from format string

18 months agotest: fix arg_type test
unvalley [Sun, 27 Nov 2022 05:49:30 +0000 (14:49 +0900)]
test: fix arg_type test

18 months agofix: to leave Ident in parse_format_exprs
unvalley [Sun, 27 Nov 2022 05:44:32 +0000 (14:44 +0900)]
fix: to leave Ident in parse_format_exprs

18 months agofix: ide assist handlers order
unvalley [Sat, 26 Nov 2022 14:01:52 +0000 (23:01 +0900)]
fix: ide assist handlers order

18 months agofix: rename to extract_expressions_from_format_string
unvalley [Sat, 26 Nov 2022 14:00:03 +0000 (23:00 +0900)]
fix: rename to extract_expressions_from_format_string

18 months agoRefactor replace_arith assists into one module
Lukas Wirth [Mon, 9 Jan 2023 10:59:09 +0000 (11:59 +0100)]
Refactor replace_arith assists into one module

18 months agoAuto merge of #13905 - rust-lang:dependabot/npm_and_yarn/editors/code/d3-color-and...
bors [Mon, 9 Jan 2023 10:37:46 +0000 (10:37 +0000)]
Auto merge of #13905 - rust-lang:dependabot/npm_and_yarn/editors/code/d3-color-and-d3-graphviz-3.1.0, r=Veykril

Bump d3-color and d3-graphviz in /editors/code

Bumps [d3-color](https://github.com/d3/d3-color) to 3.1.0 and updates ancestor dependency [d3-graphviz](https://github.com/magjac/d3-graphviz). These dependencies need to be updated together.

Updates `d3-color` from 2.0.0 to 3.1.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/d3/d3-color/releases">d3-color's releases</a>.</em></p>
<blockquote>
<h2>v3.1.0</h2>
<ul>
<li>Add <a href="https://github.com/d3/d3-color/blob/main/README.md#rgb_clamp"><em>rgb</em>.clamp</a> and <a href="https://github.com/d3/d3-color/blob/main/README.md#hsl_clamp"><em>hsl</em>.clamp</a>. <a href="https://github-redirect.dependabot.com/d3/d3-color/issues/102">#102</a></li>
<li>Add <a href="https://github.com/d3/d3-color/blob/main/README.md#color_formatHex8"><em>color</em>.formatHex8</a>. <a href="https://github-redirect.dependabot.com/d3/d3-color/issues/103">#103</a></li>
<li>Fix <a href="https://github.com/d3/d3-color/blob/main/README.md#color_formatHsl"><em>color</em>.formatHsl</a> to clamp values to the expected range. <a href="https://github-redirect.dependabot.com/d3/d3-color/issues/83">#83</a></li>
<li>Fix catastrophic backtracking when parsing colors. <a href="https://github-redirect.dependabot.com/d3/d3-color/issues/89">#89</a> <a href="https://github-redirect.dependabot.com/d3/d3-color/issues/97">#97</a> <a href="https://github-redirect.dependabot.com/d3/d3-color/issues/99">#99</a> <a href="https://github-redirect.dependabot.com/d3/d3-color/issues/100">#100</a> <a href="https://security.snyk.io/vuln/SNYK-JS-D3COLOR-1076592">SNYK-JS-D3COLOR-1076592</a></li>
</ul>
<h2>v3.0.1</h2>
<ul>
<li>Make build reproducible.</li>
</ul>
<h2>v3.0.0</h2>
<ul>
<li>Adopt type: module.</li>
</ul>
<p>This package now requires Node.js 12 or higher. For more, please read <a href="https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c">Sindre Sorhus’s FAQ</a>.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/d3/d3-color/commit/7a1573ed260de4fd97d061975244841132adde92"><code>7a1573e</code></a> 3.1.0</li>
<li><a href="https://github.com/d3/d3-color/commit/75c19c40c246e4b3fbcfdeeba29249c51ccf6524"><code>75c19c4</code></a> update LICENSE</li>
<li><a href="https://github.com/d3/d3-color/commit/ef94e0125cce176e2df2f877c70741f4e2856073"><code>ef94e01</code></a> update dependencies</li>
<li><a href="https://github.com/d3/d3-color/commit/5e9f7579dd32a74664f5000ee99aa87e3e463c2b"><code>5e9f757</code></a> method shorthand</li>
<li><a href="https://github.com/d3/d3-color/commit/e4bc34e46cba08c4b7209f2bea74ef570c000b86"><code>e4bc34e</code></a> formatHex8 (<a href="https://github-redirect.dependabot.com/d3/d3-color/issues/103">#103</a>)</li>
<li><a href="https://github.com/d3/d3-color/commit/ac660c6b6bd60a2f1cd255fe04ead7d1b053861d"><code>ac660c6</code></a> {rgb,hsl}.clamp() (<a href="https://github-redirect.dependabot.com/d3/d3-color/issues/102">#102</a>)</li>
<li><a href="https://github.com/d3/d3-color/commit/70e3a041f1890e63855fad693891652b36f48195"><code>70e3a04</code></a> clamp HSL format (<a href="https://github-redirect.dependabot.com/d3/d3-color/issues/101">#101</a>)</li>
<li><a href="https://github.com/d3/d3-color/commit/994d8fd95181484a5a27c5edc919aa625781432d"><code>994d8fd</code></a> avoid backtracking (<a href="https://github-redirect.dependabot.com/d3/d3-color/issues/100">#100</a>)</li>
<li><a href="https://github.com/d3/d3-color/commit/7d61bbe6e426a7f3d3f4520a8b31cfc92dc69ee7"><code>7d61bbe</code></a> 3.0.1</li>
<li><a href="https://github.com/d3/d3-color/commit/93bc4ff5423ecbefb6607724384bf6ca788d13b6"><code>93bc4ff</code></a> related <a href="https://github-redirect.dependabot.com/d3/d3/issues/3">d3/d33</a>; extract copyrights from LICENSE</li>
<li>Additional commits viewable in <a href="https://github.com/d3/d3-color/compare/v2.0.0...v3.1.0">compare view</a></li>
</ul>
</details>
<br />

Updates `d3-graphviz` from 4.1.1 to 5.0.2
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/magjac/d3-graphviz/releases">d3-graphviz's releases</a>.</em></p>
<blockquote>
<h2>v5.0.2</h2>
<p>See the <a href="https://github.com/magjac/d3-graphviz/blob/master/CHANGELOG.md#502">CHANGELOG</a> for details.</p>
<h2>v5.0.1</h2>
<p>See the <a href="https://github.com/magjac/d3-graphviz/blob/master/CHANGELOG.md#501">CHANGELOG</a> for details.</p>
<h2>v5.0.0</h2>
<p>See the <a href="https://github.com/magjac/d3-graphviz/blob/master/CHANGELOG.md#500">CHANGELOG</a> for details.</p>
<h2>v4.5.0</h2>
<p>See the <a href="https://github.com/magjac/d3-graphviz/blob/master/CHANGELOG.md#450">CHANGELOG</a> for details.</p>
<h2>v4.4.0</h2>
<p>See the <a href="https://github.com/magjac/d3-graphviz/blob/master/CHANGELOG.md#440">CHANGELOG</a> for details.</p>
<h2>v4.3.0</h2>
<p>See the <a href="https://github.com/magjac/d3-graphviz/blob/master/CHANGELOG.md#430">CHANGELOG</a> for details.</p>
<h2>v4.2.0</h2>
<p>See the <a href="https://github.com/magjac/d3-graphviz/blob/master/CHANGELOG.md#420">CHANGELOG</a> for details.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/magjac/d3-graphviz/blob/master/CHANGELOG.md">d3-graphviz's changelog</a>.</em></p>
<blockquote>
<h2>[5.0.2] – 2022-12-27</h2>
<h3>Fixed</h3>
<ul>
<li>Failed to resolve entry for package &quot;d3-graphviz&quot; <a href="https://github-redirect.dependabot.com/magjac/d3-graphviz/issues/263">#263</a></li>
</ul>
<h2>[5.0.1] – 2022-12-27</h2>
<h3>Fixed</h3>
<ul>
<li>Failed to resolve entry for package &quot;d3-graphviz&quot; (partial fix) <a href="https://github-redirect.dependabot.com/magjac/d3-graphviz/issues/263">#263</a></li>
</ul>
<h2>[5.0.0] – 2022-12-26</h2>
<p><strong>Note:</strong> This release contains breaking changes compared to version 4.5.0.</p>
<h3>Changed</h3>
<ul>
<li>Like <a href="https://github.com/d3/d3/blob/main/CHANGES.md#changes-in-d3-70">D3
v7</a>,
d3-graphviz now ships as a pure ES module and requires Node.js 14 or
higher. This is a <strong>breaking change</strong>. For more, please read <a href="https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c">Sindre
Sorhus’s
FAQ</a>. For
background and details, see <a href="https://github-redirect.dependabot.com/d3/d3/issues/3469">this D3
issue</a>.</li>
<li>Upgrade to <a href="https://github.com/d3/d3/blob/main/CHANGES.md#changes-in-d3-70">D3 version
7</a>
(version 3 of its
<a href="https://github.com/d3/d3#installing">microlibraries</a>).</li>
<li>Upgrade <code>`@​hpcc-js/wasm</code>` to 2.5.0 (Graphviz 7.0.5)</li>
</ul>
<h2>[4.5.0] – 2022-12-11</h2>
<h3>Changed</h3>
<ul>
<li>Upgrade <code>`@​hpcc-js/wasm</code>` to 1.16.6 (Graphviz 7.0.1)</li>
</ul>
<h2>[4.4.0] – 2022-09-12</h2>
<h3>Changed</h3>
<ul>
<li>Upgrade <code>`@​hpcc-js/wasm</code>` to 1.16.1 (Graphviz 6.0.1)</li>
</ul>
<h2>[4.3.0] – 2022-09-10</h2>
<h3>Changed</h3>
<ul>
<li>Upgrade <code>`@​hpcc-js/wasm</code>` to 1.15.7 (Graphviz unchanged at 5.0.1)  (thanks <a href="https://github.com/mrdrogdrog"><code>`@​mrdrogdrog</code></a>)</li>`
</ul>
<h2>[4.2.0] – 2022-09-06</h2>
<h3>Changed</h3>
<ul>
<li>Upgrade Graphviz to version 5.0.1 through <code>`@​hpcc-js/wasm</code>` version 1.15.4 (thanks <a href="https://github.com/mrdrogdrog"><code>`@​mrdrogdrog</code></a>)</li>`
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/magjac/d3-graphviz/commit/21a1f57612ec94fde0a37bdd4b23af0cfd257c96"><code>21a1f57</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/magjac/d3-graphviz/issues/268">#268</a> from magjac/release-5.0.2</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/3c96187ad3f50c3b0e90a203fabc708485fdd159"><code>3c96187</code></a> add version 5.0.2 to CHANGELOG</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/82c34adb337cfc278cab0804bac86b8b0e904af6"><code>82c34ad</code></a> update version to 5.0.2</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/493e14927c7a76c1ec80e601b064a21053eb3495"><code>493e149</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/magjac/d3-graphviz/issues/267">#267</a> from magjac/fix-main-module-exports-in-package-json-a...</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/1903eea4e55c3d40edf9f520a528d9a651dd04b4"><code>1903eea</code></a> add simple-default-export-test.js</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/ccd6b90f36f5be92568ccaa2ea2ab96073579e5b"><code>ccd6b90</code></a> correct default export in package.json</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/d32e81cbfb05df87fb0bf72f892fc184482f9775"><code>d32e81c</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/magjac/d3-graphviz/issues/266">#266</a> from magjac/release-5.0.1</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/d0651e56ec668faddacde490758a1c638fe7e495"><code>d0651e5</code></a> add version 5.0.1 to CHANGELOG</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/0c06f6246be1491fc60f75ba4ac82a40bcfeffa2"><code>0c06f62</code></a> update version to 5.0.1</li>
<li><a href="https://github.com/magjac/d3-graphviz/commit/2df0d3a66f421b6c3aaf7f02646b616c518781c9"><code>2df0d3a</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/magjac/d3-graphviz/issues/265">#265</a> from magjac/fix-main-module-exports-in-package-json</li>
<li>Additional commits viewable in <a href="https://github.com/magjac/d3-graphviz/compare/v4.1.1...v5.0.2">compare view</a></li>
</ul>
</details>
<br />

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting ``@dependabot` rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- ``@dependabot` rebase` will rebase this PR
- ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it
- ``@dependabot` merge` will merge this PR after your CI passes on it
- ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it
- ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging
- ``@dependabot` reopen` will reopen this PR if it is closed
- ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` use these labels` will set the current labels as the default for future PRs for this repo and language
- ``@dependabot` use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- ``@dependabot` use these assignees` will set the current assignees as the default for future PRs for this repo and language
- ``@dependabot` use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/rust-lang/rust-analyzer/network/alerts).

</details>

18 months agoClean up
kadmin [Wed, 21 Dec 2022 21:53:52 +0000 (21:53 +0000)]
Clean up

Simplify match statement

Add multiple tests
- 1 test for checking `N + 1 + 1` does not unify with `N+1`
- 2 tests for checking that a function that uses two parameters only returns the parameter that
  is actually used.
- Check exact repeat predicates

18 months agoCheck for duplicates
kadmin [Tue, 20 Dec 2022 21:11:19 +0000 (21:11 +0000)]
Check for duplicates

18 months agoSet !const_evaluatable if ambig. and not inferred
kadmin [Tue, 20 Dec 2022 03:36:32 +0000 (03:36 +0000)]
Set !const_evaluatable if ambig. and not inferred

This prevents an ICE due to a value not actually being evaluatable later.

18 months agoChange based on comments
kadmin [Tue, 13 Dec 2022 09:51:13 +0000 (09:51 +0000)]
Change based on comments

Instead of just switching to a probe, check for different matches, and see how many there are.
If one, unify it, otherwise return true and let it be unified later.

18 months agoChange commit_if_ok to probe
kadmin [Sun, 4 Dec 2022 19:58:03 +0000 (19:58 +0000)]
Change commit_if_ok to probe

18 months agoAuto merge of #106582 - compiler-errors:better-spans-on-bad-tys, r=lcnr
bors [Mon, 9 Jan 2023 08:40:08 +0000 (08:40 +0000)]
Auto merge of #106582 - compiler-errors:better-spans-on-bad-tys, r=lcnr

Improve spans of non-WF implied bound types

Fixes #60980

18 months agoAuto merge of #106616 - compiler-errors:rollup-emcj0o3, r=compiler-errors
bors [Mon, 9 Jan 2023 05:09:45 +0000 (05:09 +0000)]
Auto merge of #106616 - compiler-errors:rollup-emcj0o3, r=compiler-errors

Rollup of 8 pull requests

Successful merges:

 - #104163 (Don't derive Debug for `OnceWith` & `RepeatWith`)
 - #106131 (Mention "signature" rather than "fn pointer" when impl/trait methods are incompatible)
 - #106363 (Structured suggestion for `&mut dyn Iterator` when possible)
 - #106497 (Suggest using clone when we have &T and T implemented Clone)
 - #106584 (Document that `Vec::from_raw_parts[_in]` must be given a pointer from the correct allocator.)
 - #106600 (Suppress type errors that come from private fields)
 - #106602 (Add goml scripts to tidy checks)
 - #106606 (Do not emit structured suggestion for turbofish with wrong span)

Failed merges:

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

18 months agofix: fix CI errors
Ezra Shaw [Mon, 9 Jan 2023 02:44:33 +0000 (15:44 +1300)]
fix: fix CI errors

18 months agoRollup merge of #106606 - estebank:bad-nested-turbofish, r=compiler-errors
Michael Goulet [Mon, 9 Jan 2023 03:57:56 +0000 (19:57 -0800)]
Rollup merge of #106606 - estebank:bad-nested-turbofish, r=compiler-errors

Do not emit structured suggestion for turbofish with wrong span

Fix #79161.

18 months agoRollup merge of #106602 - GuillaumeGomez:tidy-goml-scripts, r=Mark-Simulacrum
Michael Goulet [Mon, 9 Jan 2023 03:57:56 +0000 (19:57 -0800)]
Rollup merge of #106602 - GuillaumeGomez:tidy-goml-scripts, r=Mark-Simulacrum

Add goml scripts to tidy checks

r? ``@notriddle``

18 months agoRollup merge of #106600 - compiler-errors:no-private-field-ty-err, r=estebank
Michael Goulet [Mon, 9 Jan 2023 03:57:55 +0000 (19:57 -0800)]
Rollup merge of #106600 - compiler-errors:no-private-field-ty-err, r=estebank

Suppress type errors that come from private fields

Fixes #57320

There was some discussion here (https://github.com/rust-lang/rust/issues/57320#issuecomment-451308420), but I honestly think the second error is worth suppressing regardless.

I would be open to feedback though -- perhaps we can suppress the `.len()` suggestion if there's type error (since we have access to [`Expectation`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/enum.Expectation.html), we can determine that).

r? ``@estebank``

18 months agoRollup merge of #106584 - kpreid:vec-allocator, r=JohnTitor
Michael Goulet [Mon, 9 Jan 2023 03:57:54 +0000 (19:57 -0800)]
Rollup merge of #106584 - kpreid:vec-allocator, r=JohnTitor

Document that `Vec::from_raw_parts[_in]` must be given a pointer from the correct allocator.

Currently, the documentation of `Vec::from_raw_parts` and `Vec::from_raw_parts_in` says nothing about what allocator the pointer must come from. This PR adds that missing information explicitly.

18 months agoRollup merge of #106497 - chenyukang:yukang/fix-106443-sugg-clone, r=estebank
Michael Goulet [Mon, 9 Jan 2023 03:57:54 +0000 (19:57 -0800)]
Rollup merge of #106497 - chenyukang:yukang/fix-106443-sugg-clone, r=estebank

Suggest using clone when we have &T and T implemented Clone

Fixes #106443

18 months agoRollup merge of #106363 - estebank:mutability-mismatch-arg, r=Nilstrieb
Michael Goulet [Mon, 9 Jan 2023 03:57:53 +0000 (19:57 -0800)]
Rollup merge of #106363 - estebank:mutability-mismatch-arg, r=Nilstrieb

Structured suggestion for `&mut dyn Iterator` when possible

Fix #37914.

18 months agoRollup merge of #106131 - compiler-errors:not-ptrs, r=davidtwco
Michael Goulet [Mon, 9 Jan 2023 03:57:53 +0000 (19:57 -0800)]
Rollup merge of #106131 - compiler-errors:not-ptrs, r=davidtwco

Mention "signature" rather than "fn pointer" when impl/trait methods are incompatible

Fixes #80929
Fixes #67296

18 months agoRollup merge of #104163 - H4x5:once-repeat-with-debug, r=dtolnay
Michael Goulet [Mon, 9 Jan 2023 03:57:52 +0000 (19:57 -0800)]
Rollup merge of #104163 - H4x5:once-repeat-with-debug, r=dtolnay

Don't derive Debug for `OnceWith` & `RepeatWith`

Closures don't impl Debug, so the derived impl is kinda useless. The behavior of not debug-printing closures is consistent with the rest of the iterator adapters/sources.

18 months agodocs/test: add error-docs and UI test for `E0711`
Ezra Shaw [Sun, 8 Jan 2023 08:36:19 +0000 (21:36 +1300)]
docs/test: add error-docs and UI test for `E0711`

18 months agodocs/test: add empty error-docs for `E0208`, `E0640` and `E0717`
Ezra Shaw [Sun, 8 Jan 2023 08:35:50 +0000 (21:35 +1300)]
docs/test: add empty error-docs for `E0208`, `E0640` and `E0717`

18 months agoAuto merge of #90291 - geeklint:loosen_weak_debug_bound, r=dtolnay
bors [Sun, 8 Jan 2023 22:40:38 +0000 (22:40 +0000)]
Auto merge of #90291 - geeklint:loosen_weak_debug_bound, r=dtolnay

Loosen the bound on the Debug implementation of Weak.

Both `rc::Weak<T>` and `sync::Weak<T>` currently require `T: Debug` in their own `Debug` implementations, but they don't currently use it;  they only ever print a fixed string.

A general implementation of Debug for Weak that actually attempts to upgrade and rely on the contents is unlikely in the future because it may have unbounded recursion in the presence of reference cycles, which Weak is commonly used in.  (This was the justification for why the current implementation [was implemented the way it is](https://github.com/rust-lang/rust/pull/19388/commits/f0976e2cf3f6b0027f118b791e0888b29fbb41a7)).

When I brought it up [on the forum](https://internals.rust-lang.org/t/could-the-bound-on-weak-debug-be-relaxed/15504), it was suggested that, even if an implementation is specialized in the future that relies on the data stored within the Weak, it would likely rely on specialization anyway, and could therefore easily specialize on the Debug bound as well.

18 months agoDo not emit structured suggestion for turbofish with wrong span
Esteban Küber [Sun, 8 Jan 2023 22:27:13 +0000 (22:27 +0000)]
Do not emit structured suggestion for turbofish with wrong span

Fix #79161.

18 months agoFix tidy issues in goml scripts
Guillaume Gomez [Sun, 8 Jan 2023 20:29:57 +0000 (21:29 +0100)]
Fix tidy issues in goml scripts

18 months agoAdd goml scripts to tidy checks
Guillaume Gomez [Sun, 8 Jan 2023 20:29:45 +0000 (21:29 +0100)]
Add goml scripts to tidy checks

18 months agoSuppress type errors that come from private fields
Michael Goulet [Sun, 8 Jan 2023 19:45:23 +0000 (19:45 +0000)]
Suppress type errors that come from private fields

18 months agoDon't store spans in assumed_wf_types actually
Michael Goulet [Sun, 8 Jan 2023 19:02:58 +0000 (19:02 +0000)]
Don't store spans in assumed_wf_types actually

18 months agoNormalize assumed_wf_types after wfchecking is complete, for better spans
Michael Goulet [Sun, 8 Jan 2023 03:14:27 +0000 (03:14 +0000)]
Normalize assumed_wf_types after wfchecking is complete, for better spans

18 months agoImprove spans of non-WF implied bound types
Michael Goulet [Sun, 8 Jan 2023 02:40:59 +0000 (02:40 +0000)]
Improve spans of non-WF implied bound types

18 months agoAuto merge of #106449 - GuillaumeGomez:rustdoc-gui-retry-mechanism, r=Mark-Simulacrum
bors [Sun, 8 Jan 2023 17:49:31 +0000 (17:49 +0000)]
Auto merge of #106449 - GuillaumeGomez:rustdoc-gui-retry-mechanism, r=Mark-Simulacrum

Add retry mechanism for rustdoc GUI tests to reduce flakyness

Part of #93784.

I added 3 retries for failing GUI tests. An important note: if more than half of total tests fail, I don't retry because it's very likely not flakyness anymore at this point but a missing update after changes.

18 months agoAuto merge of #13860 - danieleades:clippy, r=lnicola
bors [Sun, 8 Jan 2023 17:29:57 +0000 (17:29 +0000)]
Auto merge of #13860 - danieleades:clippy, r=lnicola

fix a bunch of clippy lints

fixes a bunch of clippy lints for fun and profit

i'm aware of this repo's position on clippy. The changes are split into separate commits so they can be reviewed separately

18 months agoRemove extra space
Yukang [Sun, 8 Jan 2023 14:51:42 +0000 (22:51 +0800)]
Remove extra space

18 months agoAuto merge of #106235 - compiler-errors:rework-bounds-collection, r=davidtwco
bors [Sun, 8 Jan 2023 14:40:52 +0000 (14:40 +0000)]
Auto merge of #106235 - compiler-errors:rework-bounds-collection, r=davidtwco

Rework `Bounds` collection

I think it's weird for the `Bounds` struct in astconv to store its predicates *almost* converted into real predicates... so we do this eagerly, instead of lazily.

18 months agoAuto merge of #105733 - compiler-errors:ty-ct-late-flags, r=cjgillot
bors [Sun, 8 Jan 2023 11:51:41 +0000 (11:51 +0000)]
Auto merge of #105733 - compiler-errors:ty-ct-late-flags, r=cjgillot

Add type flags support for `Ty` and `Const` late-bound variables

I've been working on `for<T>` binders, and these will eventually be useful.

18 months agoAuto merge of #106588 - JohnTitor:rollup-4z80tjx, r=JohnTitor
bors [Sun, 8 Jan 2023 09:00:31 +0000 (09:00 +0000)]
Auto merge of #106588 - JohnTitor:rollup-4z80tjx, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #103104 (Stabilize `main_separator_str`)
 - #106410 (Suggest `mut self: &mut Self` for `?Sized` impls)
 - #106457 (Adjust comments about pre-push.sh hook)
 - #106546 (jsondoclint: Check local items in `paths` are also in `index`.)
 - #106557 (Add some UI tests and reword error-code docs)
 - #106562 (Clarify examples for `VecDeque::get/get_mut`)
 - #106580 (remove unreachable error code `E0313`)
 - #106581 (Do not emit wrong E0308 suggestion for closure mismatch)

Failed merges:

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

18 months agoRollup merge of #106581 - estebank:bad-suggestion, r=compiler-errors
Yuki Okushi [Sun, 8 Jan 2023 08:01:49 +0000 (17:01 +0900)]
Rollup merge of #106581 - estebank:bad-suggestion, r=compiler-errors

Do not emit wrong E0308 suggestion for closure mismatch

Found in #76353.

18 months agoRollup merge of #106580 - Ezrashaw:remove-e0313, r=compiler-errors
Yuki Okushi [Sun, 8 Jan 2023 08:01:49 +0000 (17:01 +0900)]
Rollup merge of #106580 - Ezrashaw:remove-e0313, r=compiler-errors

remove unreachable error code `E0313`

Fixes #103742
Makes #103433 redundant

Implements removal of `E0313`. I agree with the linked issue that this error code is unreachable but if someone could confirm that would be great, are crater runs done for this sort of thing?

Also removed a redundant `// ignore-tidy-filelength` that I found while reading code.

cc ``@GuillaumeGomez`` #61137

18 months agoRollup merge of #106562 - clubby789:vec-deque-example, r=Mark-Simulacrum
Yuki Okushi [Sun, 8 Jan 2023 08:01:48 +0000 (17:01 +0900)]
Rollup merge of #106562 - clubby789:vec-deque-example, r=Mark-Simulacrum

Clarify examples for `VecDeque::get/get_mut`

Closes #106114

``@rustbot`` label +A-docs

18 months agoRollup merge of #106557 - Ezrashaw:ui-test-fixups-1, r=GuillaumeGomez
Yuki Okushi [Sun, 8 Jan 2023 08:01:48 +0000 (17:01 +0900)]
Rollup merge of #106557 - Ezrashaw:ui-test-fixups-1, r=GuillaumeGomez

Add some UI tests and reword error-code docs

Added UI tests for `E0013` and `E0015`. Error code docs for `E0015` were a bit unclear (they referred to all non-const errors in const context, when only non-const functions applied), so I touched them up a bit.

I also fixed up some issues in the new `error_codes.rs` tidy check (linked #106341), that I overlooked previously.

r? ``@GuillaumeGomez``

18 months agoRollup merge of #106546 - aDotInTheVoid:jsondoclint-path-local-item, r=notriddle
Yuki Okushi [Sun, 8 Jan 2023 08:01:47 +0000 (17:01 +0900)]
Rollup merge of #106546 - aDotInTheVoid:jsondoclint-path-local-item, r=notriddle

jsondoclint: Check local items in `paths` are also in `index`.

Would have caught #104064 (if core.json was linted in CI).

Closes #106433.

r? rustdoc

18 months agoRollup merge of #106457 - kadiwa4:no-bless, r=Mark-Simulacrum
Yuki Okushi [Sun, 8 Jan 2023 08:01:47 +0000 (17:01 +0900)]
Rollup merge of #106457 - kadiwa4:no-bless, r=Mark-Simulacrum

Adjust comments about pre-push.sh hook

Follow-up to #101175.

18 months agoRollup merge of #106410 - clubby789:borrow-mut-self-mut-self-diag, r=compiler-errors
Yuki Okushi [Sun, 8 Jan 2023 08:01:46 +0000 (17:01 +0900)]
Rollup merge of #106410 - clubby789:borrow-mut-self-mut-self-diag, r=compiler-errors

Suggest `mut self: &mut Self` for `?Sized` impls

Closes #106325
Closes #93078

The suggestion is _probably_ not what the user wants (hence `MaybeIncorrect`) but at least makes the problem in the above issues clearer. It might be better to add a note explaining why this is the case, but I'm not sure how best to word that so this is a start.

``@rustbot`` label +A-diagnostics

18 months agoRollup merge of #103104 - SUPERCILEX:sep-ref, r=dtolnay
Yuki Okushi [Sun, 8 Jan 2023 08:01:46 +0000 (17:01 +0900)]
Rollup merge of #103104 - SUPERCILEX:sep-ref, r=dtolnay

Stabilize `main_separator_str`

See reasoning here: https://github.com/rust-lang/rust/issues/94071#issuecomment-1279872605. Closes #94071.

18 months agoMention signature rather than fn pointers when comparing impl/trait methods
Michael Goulet [Sat, 24 Dec 2022 23:17:25 +0000 (23:17 +0000)]
Mention signature rather than fn pointers when comparing impl/trait methods

18 months agoAdd type flags support for Ty and Const late-bound regions
Michael Goulet [Thu, 15 Dec 2022 02:38:39 +0000 (02:38 +0000)]
Add type flags support for Ty and Const late-bound regions

18 months agoDo not emit wrong E0308 suggestion for closure mismatch
Esteban Küber [Sun, 8 Jan 2023 01:53:39 +0000 (01:53 +0000)]
Do not emit wrong E0308 suggestion for closure mismatch