Commit graph

247945 commits

Author SHA1 Message Date
bors ecda4642ef Auto merge of #16705 - regexident:resolve-callable-exprs, r=Veykril
Add public function for resolving callable AST exprs to their HIR equivalents

(the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to walk a `hir::Function`'s AST, resolving callable exprs within to their HIR equivalents)
2024-02-29 14:46:21 +00:00
bors a6606d1767 Auto merge of #16698 - regexident:param-derives, r=Veykril
Derive `PartialEq`, `Eq` & `Hash` for `hir::Param`

Since `hir::SelfParam`, as well as all members of `hir::Param` already implement `PartialEq`, `Eq` & `Hash` it seems reasonable to also make `hir::Param` implement those.

(the change is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to collect params in a `HashSet`)
2024-02-29 14:33:37 +00:00
bors ef2acb6ff3 Auto merge of #16695 - Veykril:revert-16541, r=Veykril
internal: Revert #16541

Closes https://github.com/rust-lang/rust-analyzer/issues/16602
2024-02-29 14:20:57 +00:00
bors 71eb5400a3 Auto merge of #16638 - Lindronics:destructure-struct-binding, r=Veykril
feature: Add `destructure_struct_binding`

Adds an assist for destructuring a struct in a binding (#8673). I saw that #13997 has been abandoned for a while, so I thought I'd give it a go.

## Example

```rust
let foo = Foo { bar: 1, baz: 2 };
let bar2 = foo.bar;
let baz2 = foo.baz;
let foo2 = foo;

let fizz = Fizz(1, 2);
let buzz = fizz.0;
```
becomes
```rust
let Foo { bar, baz } = Foo { bar: 1, baz: 2 };
let bar2 = bar;
let baz2 = baz;
let foo2 = todo!();

let Fizz(_0, _1) = Fizz(1, 2);
let buzz = _0;
```

More examples in the tests.

## What is included?

- [x] Destructure record, tuple, and unit struct bindings
- [x] Edit field usages
- [x] Non-exhaustive structs in foreign crates and private fields get hidden behind `..`
- [x] Nested bindings
- [x] Carry over `mut` and `ref mut` in nested bindings to fields, i.e. `let Foo { ref mut bar } = ...` becomes `let Foo { bar: Bar { baz: ref mut baz } } = ...`
- [x] Attempt to resolve collisions with other names in the scope
- [x] If the binding is to a reference, field usages are dereferenced if required
- [x] Use shorthand notation if possible

## Known limitations

- `let foo = Foo { bar: 1 }; foo;` currently results in `let Foo { bar } = Foo { bar: 1 }; todo!();` instead of reassembling the struct. This requires user intervention.
- Unused fields are not currently omitted. I thought that this is more ergonomic, as there already is a quick fix action for adding `: _` to unused field patterns.
2024-02-29 14:07:50 +00:00
bors 0ec6015b6e Auto merge of #16709 - ShoyuVanilla:fix-goto-index-mut, r=Veykril
fix: Goto definition for `index_mut`

Mostly same with #16696.
0ac05c0527/crates/hir-ty/src/infer/mutability.rs (L103-L133)
Thankfully, we are doing similar method resolutions so we can use them like the mentioned PR.
As there are only three `LangItem`s having `Mut` in there names; `FnMut`, `DerefMut` and `IndexMut`, I think that this is the last one 😄
2024-02-29 13:55:23 +00:00
Guillaume Gomez 8e817af3ae Update ui tests 2024-02-29 14:43:43 +01:00
bors 384d26fc7e Auto merge of #121800 - GuillaumeGomez:rollup-wob2qcz, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - #118217 (Document which methods on `f64` are precise)
 - #119748 (Increase visibility of `join_path` and `split_paths`)
 - #121412 (platform docs: clarify hexagon-unknown-none-elf example, add hexagon-unknown-linux-musl)
 - #121654 (Fix `async Fn` confirmation for `FnDef`/`FnPtr`/`Closure` types)
 - #121700 (CFI: Don't compress user-defined builtin types)
 - #121765 (add platform-specific function to get the error number for HermitOS)
 - #121781 (bootstrap/format: send larger batches to rustfmt)
 - #121788 (bootstrap: fix clap deprecated warnings)
 - #121792 (Improve renaming suggestion when item starts with underscore)
 - #121793 (Document which methods on `f32` are precise)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-29 13:35:16 +00:00
Guillaume Gomez 5ce15af6b1 Make invalid_doc_attributes deny by default 2024-02-29 14:34:58 +01:00
Guillaume Gomez bc23b84386
Rollup merge of #121793 - tbu-:pr_floating_point_32, r=Amanieu
Document which methods on `f32` are precise

Same as #118217 but for `f32`.
2024-02-29 14:33:53 +01:00
Guillaume Gomez 8a74df9c22
Rollup merge of #121792 - GuillaumeGomez:improve-suggestion, r=michaelwoerister
Improve renaming suggestion when item starts with underscore

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

It goes from:

```terminal
error[E0433]: failed to resolve: use of undeclared type `Foo`
 --> src/foo.rs:6:13
  |
6 |     let _ = Foo::Bar;
  |             ^^^ use of undeclared type `Foo`
  |
help: an enum with a similar name exists, consider changing it
  |
1 | enum Foo {
  |      ~~~
```

to:

```terminal
error[E0433]: failed to resolve: use of undeclared type `Foo`
 --> foo.rs:6:13
  |
6 |     let _ = Foo::Bar;
  |             ^^^ use of undeclared type `Foo`
  |
help: an enum with a similar name exists, consider renaming `_Foo` into `Foo`
  |
1 | enum Foo {
  |      ~~~

error: aborting due to 1 previous error
```
2024-02-29 14:33:53 +01:00
Guillaume Gomez 7147112c8c
Rollup merge of #121788 - klensy:clap-deprecated-fix, r=clubby789
bootstrap: fix clap deprecated warnings

Run 'cargo check --features clap/deprecated' and fix warnings
2024-02-29 14:33:52 +01:00
Guillaume Gomez b52b6997a3
Rollup merge of #121781 - RalfJung:bootstrap-fmt, r=clubby789
bootstrap/format: send larger batches to rustfmt

This helps on systems with low core counts. To benchmark this I made a lot of files be modified:
```
for FILE in $(find compiler/ -name "*.rs"); do echo "// end of the file" >>$FILE; done
```
Then I ran
```
hyperfine "./x.py fmt -j1" -w 1 -r 4
```
Before this patch:
```
Benchmark 1: ./x.py fmt -j1
  Time (mean ± σ):      3.426 s ±  0.032 s    [User: 4.681 s, System: 1.376 s]
  Range (min … max):    3.389 s …  3.462 s    4 runs
```
With this patch:
```
Benchmark 1: ./x.py fmt -j1
  Time (mean ± σ):      2.530 s ±  0.054 s    [User: 4.042 s, System: 0.467 s]
  Range (min … max):    2.452 s …  2.576 s    4 runs
```
2024-02-29 14:33:52 +01:00
Guillaume Gomez ad74598dbc
Rollup merge of #121765 - hermit-os:errno, r=ChrisDenton
add platform-specific function to get the error number for HermitOS

Extending `std` to get the last error number for HermitOS.

HermitOS is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-02-29 14:33:51 +01:00
Guillaume Gomez b2c3279984
Rollup merge of #121700 - rcvalle:rust-cfi-dont-compress-user-defined-builtin-types, r=compiler-errors
CFI: Don't compress user-defined builtin types

Doesn't compress user-defined builtin types (see https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin and https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression).
2024-02-29 14:33:51 +01:00
Guillaume Gomez 5978b6ff83
Rollup merge of #121654 - compiler-errors:async-fn-for-fn-def, r=oli-obk
Fix `async Fn` confirmation for `FnDef`/`FnPtr`/`Closure` types

Fixes three issues:
1. The code in `extract_tupled_inputs_and_output_from_async_callable` was accidentally getting the *future* type and the *output* type (returned by the future) messed up for fnptr/fndef/closure types. :/
2. We have a (class of) bug(s) in the old solver where we don't really support higher ranked built-in `Future` goals for generators. This is not possible to hit on stable code, but [can be hit with `unboxed_closures`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e935de7181e37e13515ad01720bcb899) (#121653).
    * I'm opting not to fix that in this PR. Instead, I just instantiate placeholders when confirming `async Fn` goals.
4. Fixed a bug when generating `FnPtr` shims for `async Fn` trait goals.

r? oli-obk
2024-02-29 14:33:50 +01:00
Guillaume Gomez 1ee54538a3
Rollup merge of #121412 - androm3da:bcain/update_hex_docs_03, r=Amanieu
platform docs: clarify hexagon-unknown-none-elf example, add hexagon-unknown-linux-musl
2024-02-29 14:33:50 +01:00
Guillaume Gomez 0c2cb39f95
Rollup merge of #118217 - tbu-:pr_floating_point, r=Amanieu
Document which methods on `f64` are precise
2024-02-29 14:33:49 +01:00
Niklas Lindorfer dc7b502689
Fix usage in other assist 2024-02-29 13:17:45 +00:00
Niklas Lindorfer 7c30c70658
Attempt resolving name collisions 2024-02-29 13:17:45 +00:00
Niklas Lindorfer b203a07d92
Handle bindings to refs 2024-02-29 13:17:45 +00:00
Niklas Lindorfer ed230048dc
Add destructure_struct_binding action
Separate into create and apply edit

Rename usages

Hacky name map

Add more tests

Handle non-exhaustive

Add some more TODOs

Private fields

Use todo

Nesting

Improve rest token generation

Cleanup

Doc -> regular comment

Support mut
2024-02-29 13:17:44 +00:00
Aaron Chen fb81ee8bd7
Fix links in rustc doc 2024-02-29 21:03:49 +08:00
Tobias Bucher 7400f22d92 Document which methods on f32 are precise
Same as #118217 but for `f32`.
2024-02-29 12:38:21 +01:00
bors 5717e52d17 Auto merge of #3335 - rust-lang:rustup-2024-02-29, r=saethlin
Automatic Rustup
2024-02-29 11:25:45 +00:00
Guillaume Gomez 451fd98153 Update UI test checking suggestion message to rename type starting with underscore 2024-02-29 12:08:03 +01:00
Guillaume Gomez 3770cf7abf Improve suggestion to rename type starting with underscore to make it more obvious what is actually suggested 2024-02-29 12:07:41 +01:00
Tobias Bucher b5307f5d95 Document the precision of f64 methods 2024-02-29 11:58:13 +01:00
bors 71a7b66f20 Auto merge of #121790 - jhpratt:rollup-yocg203, r=jhpratt
Rollup of 10 pull requests

Successful merges:

 - #119748 (Increase visibility of `join_path` and `split_paths`)
 - #120291 (Have `String` use `SliceIndex` impls from `str`)
 - #121723 (Two diagnostic things)
 - #121740 (Changing some attributes to only_local.)
 - #121745 (Deeply normalize obligations in `refining_impl_trait`)
 - #121748 (Restore the standard library review rotation to its former glory)
 - #121768 (Implement unwind safety for Condvar on all platforms )
 - #121777 (Fix typo in `rustc_passes/messages.ftl`)
 - #121778 (Document potential memory leak in unbounded channel)
 - #121779 (Remove unused diagnostic struct)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-29 10:28:59 +00:00
Jacob Pratt 698cec8d61
Rollup merge of #121779 - mu001999:clean, r=Nilstrieb
Remove unused diagnostic struct

Detected by #121752
2024-02-29 05:25:30 -05:00
Jacob Pratt 20a1bf6c17
Rollup merge of #121778 - ibraheemdev:patch-19, r=RalfJung
Document potential memory leak in unbounded channel

Follow up on https://github.com/rust-lang/rust/pull/121646.
2024-02-29 05:25:29 -05:00
Jacob Pratt d6e0f5cb0c
Rollup merge of #121777 - sisungo:master, r=oli-obk
Fix typo in `rustc_passes/messages.ftl`

Line 190 contains unpaired parentheses:

```
passes_doc_cfg_hide_takes_list =
    `#[doc(cfg_hide(...)]` takes a list of attributes
```

The `#[doc(cfg_hide(...)]` contains unpaired parentheses. This PR changes it to `#[doc(cfg_hide(...))]`, which made the parentheses paired.
2024-02-29 05:25:29 -05:00
Jacob Pratt 769eb2cd61
Rollup merge of #121768 - ecton:condvar-unwindsafe, r=m-ou-se
Implement unwind safety for Condvar on all platforms

Closes #118009

This commit adds unwind safety consistency to Condvar. Previously, only select platforms implemented unwind safety through auto traits. Known by this committer: On Linux, `Condvar` implemented `UnwindSafe` but on Mac and Windows, it did not. This change changes the implementation from auto to explicit.

In #118009, it was suggested that the platform differences were a bug and that a simple PR could address this. In trying to determine the best information to put in the `#[stable]` attribute, it [was suggested](https://github.com/rust-lang/rust/issues/121690#issuecomment-1968298470) I copy the stability information from the previous unwind safety implementations.
2024-02-29 05:25:29 -05:00
Jacob Pratt b55347aa11
Rollup merge of #121748 - Amanieu:restore-libs-rotation, r=Amanieu
Restore the standard library review rotation to its former glory

This adds 7 reviewers to the standard library review rotation, bringing the total back up to 10 people. Specifically:

* On the main rotation: ``@cuviper`` ``@Mark-Simulacrum`` ``@m-ou-se`` ``@Amanieu`` ``@Nilstrieb`` ``@workingjubilee`` ``@joboet`` ``@jhpratt``
* For `core` only: ``@scottmcm``
* For `std` only: ``@ChrisDenton``

For everyone pinged here, please confirm that you are happy to be added to the review rotation.
2024-02-29 05:25:28 -05:00
Jacob Pratt 23351388d0
Rollup merge of #121745 - compiler-errors:refining-impl-trait-deeply-norm, r=lcnr
Deeply normalize obligations in `refining_impl_trait`

We somewhat awkwardly use semantic comparison when checking the `refining_impl_trait` lint. This relies on us being able to normalize bounds eagerly to avoid cases where an unnormalized alias is not considered equal to a normalized alias. Since `normalize` in the new solver is a noop, let's use `deeply_normalize` instead.

r? lcnr

cc ``@tmandry,`` this should fix your bug lol
2024-02-29 05:25:28 -05:00
Jacob Pratt 69716291c3
Rollup merge of #121740 - surechen:change_attribute_to_local_20240228, r=lcnr
Changing some attributes to only_local.

Modified according to https://github.com/rust-lang/compiler-team/issues/505.

r?  ``@lcnr``
2024-02-29 05:25:27 -05:00
Jacob Pratt b098b17b47
Rollup merge of #121723 - nnethercote:two-diagnostic-things, r=oli-obk
Two diagnostic things

Two minor improvements to diagnostics-related things.

r? ``@RalfJung``
2024-02-29 05:25:27 -05:00
Jacob Pratt 6d865038a5
Rollup merge of #120291 - pitaj:string-sliceindex, r=Amanieu
Have `String` use `SliceIndex` impls from `str`

This PR simplifies the implementation of `Index` and `IndexMut` on `String`, and in the process enables indexing `String` by any user types that implement `SliceIndex<str>`.

Similar to #47832

r? libs

Not sure if this warrants a crater run.
2024-02-29 05:25:26 -05:00
Jacob Pratt 06d487888b
Rollup merge of #119748 - tgross35:suggest-path-split, r=Amanieu
Increase visibility of `join_path` and `split_paths`

Add some crosslinking among `std::env` pages to make it easier to discover `join_paths` and `split_paths`. Also add aliases to help anyone searching for `PATH`.
2024-02-29 05:25:26 -05:00
klensy f2d9bfb35f fix clap warnings
Run 'cargo check --features clap/deprecated' and fix warnings
2024-02-29 13:05:43 +03:00
lcnr 8c5e83df85 track overflowing goals for overfow errors 2024-02-29 10:28:22 +01:00
Zalathar a7832b14b1 Make the success arms of if lhs || rhs meet up in a separate block
In the previous code, the success block of `lhs` would jump directly to the
success block of `rhs`. However, `rhs_success_block` could already contain
statements that are specific to the RHS, and the direct goto causes them to be
executed in the LHS success path as well.

This patch therefore creates a fresh block that the LHS and RHS success blocks
can both jump to.
2024-02-29 20:24:43 +11:00
lcnr 3605a09ca2 stash overflowing obligations in fulfill 2024-02-29 10:14:02 +01:00
lcnr dd4be4cb2f extract fulfillment err creation 2024-02-29 10:14:02 +01:00
lcnr 5ec9b8d778 distinguish recursion limit based overflow for diagnostics
also change the number of allowed fixpoint steps to be fixed instead
of using the `log` of the total recursion depth.
2024-02-29 10:14:02 +01:00
Nicholas Nethercote 607bf653c2 Avoid unnecessary color local variable. 2024-02-29 20:12:43 +11:00
Amanieu d'Antras ad4c932ac4 Restore the standard library review rotation to its former glory 2024-02-29 08:58:58 +00:00
Ralf Jung a9596fbf2a make mutable_references_err not bitwidth-dependent 2024-02-29 09:34:15 +01:00
Ralf Jung 3cc8c8d44b allow statics pointing to mutable statics 2024-02-29 09:34:15 +01:00
Ralf Jung c54d92c56e bootstrap/format: send larger batches to rustfmt 2024-02-29 08:01:06 +01:00
sisungo da37c8f1f2
Fix tests that are affected by this change 2024-02-29 14:59:10 +08:00