Commit Graph

25358 Commits

Author SHA1 Message Date
bors
5f8a6f67b9 Auto merge of #15020 - Veykril:perf2, r=Veykril
Count query entries in memory usage command
2023-06-09 23:50:34 +00:00
Lukas Wirth
ccce893577 Count query entries in memory usage command 2023-06-10 01:49:32 +02:00
Lukas Wirth
b6fb35f20c Shrink hir_expand::attr::AttrInput by boxing a variant 2023-06-10 01:21:52 +02:00
bors
993299ee3f Auto merge of #15019 - HKalbasi:nightly-mir-eval-panic, r=HKalbasi
Fix panic in displaying const trait objects

I hope this fixes the panic on recent nightly stdlib, but I didn't test it locally.
2023-06-09 22:43:58 +00:00
hkalbasi
6fbf6ef514 Fix panic in displaying const trait objects 2023-06-10 02:10:52 +03:30
bors
60d952e902 Auto merge of #14979 - DropDemBits:structure-snippets-migrate-1, r=Veykril
internal: Migrate some assists to use the structured snippet API

Migrates the following assists:

- `add_missing_impl_members`
- `extract_type_alias`

As an additional requirement, these assists are also migrated to use the mutable AST API, since otherwise there would be overlapping `Indel` spans
2023-06-09 19:26:01 +00:00
bors
425619dd28 Auto merge of #15014 - Wilfred:document_sysroot, r=Veykril
Document the sysroot field in JsonProject

rust-analyzer supports both `sysroot` and `sysroot_src` in `rust-project.json`. Document `sysroot` and show example values for both fields.
2023-06-09 18:37:25 +00:00
bors
2796851961 Auto merge of #14998 - Veykril:eager-mapping, r=Veykril
internal: Lazy eager macros

This PR makes eager macros less eager. We now only eagerly expand the input of them, while the actual expansion of the macro itself now happens like other lazy macros.
This change allows unifying a lot of macro handling between the two now, most of the special casing now happens for `include!` specifically as it is a very unique macro (by having two inputs that come from differing files).
Fixes https://github.com/rust-lang/rust-analyzer/issues/14841
Fixes https://github.com/rust-lang/rust-analyzer/issues/14996
2023-06-09 11:15:12 +00:00
Lukas Wirth
a02b9b279e internal: Lazy eager macros 2023-06-09 13:02:13 +02:00
bors
9973b11218 Auto merge of #15012 - lowr:patch/generate-fn-async-ret-ty, r=HKalbasi
Infer return type for async function in `generate_function`

Part of #10122

In `generate_function` assist, when we infer the return type of async function we're generating, we should retrieve the type of parent await expression rather than the call expression itself.
2023-06-09 09:00:45 +00:00
Wilfred Hughes
5da14237eb Document the sysroot field in JsonProject
rust-analyzer supports both `sysroot` and `sysroot_src` in
`rust-project.json`. Document `sysroot` and show example values for
both fields.
2023-06-08 14:56:37 -07:00
bors
9c03aa1ac2 Auto merge of #14997 - lnicola:fix-warning, r=Veykril
internal: Fix dependency warning

Hope this doesn't break #14984 again.
2023-06-08 15:48:58 +00:00
Ryo Yoshida
32768fe310
Infer return type for async function in generate_function 2023-06-09 00:32:52 +09:00
bors
9157927772 Auto merge of #15006 - HKalbasi:format-panic, r=HKalbasi
Fix unwrap on None in expanding format args

fix #15002
2023-06-07 20:48:09 +00:00
hkalbasi
30e16e20d0 Fix unwrap on None in expanding format args 2023-06-08 00:17:22 +03:30
bors
dcab226210 Auto merge of #15005 - beyarkay:rebuild-to-rebuilt-typo, r=lnicola
Fix typo in reload.rs

Thanks for the amazing LSP! I found a small typo and fixed it.
2023-06-07 19:01:35 +00:00
beyarkay
dac660dc1d Fix typo in reload.rs 2023-06-07 20:57:27 +02:00
bors
085a3112ae Auto merge of #15000 - lowr:fix/builtin-derive-bound-for-assoc, r=HKalbasi
fix: only generate trait bound for associated types in field types

Given the following definitions:

```rust
trait Trait {
    type A;
    type B;
    type C;
}

#[derive(Clone)]
struct S<T: Trait>
where
    T::A: Send,
{
    qualified: <T as Trait>::B,
    shorthand: T::C,
}
```

we currently expand the derive macro to:

```rust
impl<T> Clone for S<T>
where
    T: Trait + Clone,
    T::A: Clone,
    T::B: Clone,
    T::C: Clone,
{ /* ... */ }
```

This does not match how rustc expands it. Specifically, `Clone` bounds for `T::A` and `T::B` should not be generated.

The criteria for associated types to get bound seem to be 1) the associated type appears as part of field types AND 2) it's written in the shorthand form. I have no idea why rustc doesn't consider qualified associated types (there's even a comment that suggests they should be considered; see rust-lang/rust#50730), but it's important to follow rustc.
2023-06-07 13:00:24 +00:00
Ryo Yoshida
4f0c6fac17
fix: only generate trait bound for associated types in field types 2023-06-07 20:52:49 +09:00
Laurențiu Nicola
08ef169435 Fix dependency warning 2023-06-07 12:34:38 +03:00
bors
1c25885bd2 Auto merge of #14995 - Veykril:proc-macro-slow-test, r=lnicola
fix: Fix proc-macro slow test
2023-06-07 05:04:33 +00:00
Lukas Wirth
a6bef7808f fix: Fix proc-macro slow test 2023-06-07 07:03:27 +02:00
bors
058e2d2bdd Auto merge of #14925 - viktorlott:inline-const-expr-as-static-str, r=HKalbasi
feat: inline const as literal

Assist: inline_const_as_literal

Evaluate and inline const variable as literal.

```rust
const STRING: &str = "Hello, World!";

fn something() -> &'static str {
    STR$0ING
}
```
->
```rust
const STRING: &str = "Hello, World!";

fn something() -> &'static str {
    "Hello, World!"
}
```
2023-06-06 21:30:30 +00:00
bors
f3145dc1f1 Auto merge of #14994 - Veykril:ci-fix, r=Veykril
fix: Fix ci never running on nightly when proc-macro things change

Was wondering why this wasn't running on the subtree sync ...
2023-06-06 21:03:56 +00:00
Lukas Wirth
ef09558575 fix: Fix ci never running on nightly when proc-macro things change 2023-06-06 23:02:58 +02:00
Viktor Lott
eef716d5f2 fix: use render_eval instead of inlined expr 2023-06-06 12:08:11 +02:00
Viktor Lott
2d4cb780b6 fix: Use render_eval for all builtins 2023-06-06 00:34:00 +02:00
Viktor Lott
8103a10a78 update assist to include more literals 2023-06-06 00:34:00 +02:00
Viktor Lott
094c1e7b86 feat: inline const expr as static str 2023-06-06 00:34:00 +02:00
bors
d42d55feaa Auto merge of #14988 - lnicola:sync-from-rust, r=lnicola
internal: Sync from rust
2023-06-05 16:55:06 +00:00
Laurențiu Nicola
338f969181 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2023-06-05 19:54:30 +03:00
Laurențiu Nicola
bbd695589e Merge commit 'ed87e0a20a9d196a5ea659ea46ae9574be666d4f' into sync-from-ra 2023-06-05 15:10:05 +03:00
bors
ed87e0a20a Auto merge of #14984 - lnicola:rm-test-gate, r=Veykril
Bring back sysroot-abi feature

https://github.com/rust-lang/rust/pull/112305
2023-06-05 11:54:45 +00:00
Laurențiu Nicola
768a6c5931 Add back sysroot-abi feature gate to rust-analyzer 2023-06-05 14:43:31 +03:00
Laurențiu Nicola
c48062fe2a Merge commit 'aa9bc8612514d216f84eec218dfd19ab83f3598a' into sync-from-ra 2023-06-05 12:04:23 +03:00
bors
aa9bc86125 Auto merge of #14980 - lnicola:sync-from-rust, r=lnicola
Sync from downstream
2023-06-05 08:33:53 +00:00
Laurențiu Nicola
c3dbe7c717 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2023-06-05 11:07:47 +03:00
bors
c6a3fe051a Auto merge of #14978 - HKalbasi:lifetime-display, r=HKalbasi
Emit `'_` for lifetime generics in `HirDisplay`

This makes the generated code not linted by `rust_2018_idioms` lint. But that is an allow by default lint, so should we do this? Maybe we should only do this for `DisplayTarget::SourceCode`?
2023-06-05 07:26:30 +00:00
hkalbasi
5531d46c95 Emit '_ for lifetime generics in HirDisplay 2023-06-05 10:55:47 +03:30
DropDemBits
dd5f05590e
Migrate extract_type_alias to mutable ast 2023-06-05 00:24:12 -04:00
DropDemBits
e6e72bf9d5
Migrate add_missing_impl_members to mutable ast
`replace_derive_with_manual_impl` was slightly since it used
`add_trait_assoc_items_to_impl`
(which was also used by `add_missing_impl_members`)
2023-06-05 00:23:10 -04:00
bors
2f1b7cedcf Auto merge of #14971 - lowr:fix/captured-item-ty-outer-binder, r=HKalbasi
fix: consider outer binders when folding captured items' type

Fixes #14966

Basically, the crash is caused by us producing a broken type and passing it to chalk: `&dyn for<type> [for<> Implemented(^1.0: A<^0.0>)]` (notice the innermost bound var `^0.0` has no corresponding binder). It's created in `CapturedItemWithoutTy::with_ty()`, which didn't consider outer binders when folding types to replace placeholders with bound variables.

The fix is one-liner, but I've also refactored the surrounding code a little.
2023-06-04 18:25:23 +00:00
bors
5545961df2 Auto merge of #14976 - HKalbasi:mir-fix, r=HKalbasi
Fix missing terminator for slice pattern
2023-06-04 17:30:16 +00:00
hkalbasi
b4907a531f Fix missing terminator for slice pattern 2023-06-04 20:59:27 +03:30
bors
17426835d8 Auto merge of #14972 - HKalbasi:mir-fix, r=HKalbasi
Fix `unused-mut` false positive for `Box`
2023-06-04 12:26:39 +00:00
hkalbasi
0408af6453 Fix unused-mut false positive for Box 2023-06-04 15:56:01 +03:30
Ryo Yoshida
f549cacc1d
Destructure InferenceResult in resolve_all()
so that whenever new fields are added we don't forget to handle them.
2023-06-04 20:38:40 +09:00
Ryo Yoshida
a3789eabc9
Minor refactorings
- use `DefWithBodyId::as_generic_def_id()`
- add comments on `InferenceResult` invariant
- move local helper function to bottom to comply with style guide
2023-06-04 19:39:49 +09:00
Ryo Yoshida
275afd6e79
fix: consider outer binders when folding captured items' type 2023-06-04 19:38:47 +09:00
bors
9d5c34a80e Auto merge of #14970 - HKalbasi:mir-fix, r=HKalbasi
Detect "bound more than once" error and suppress `need-mut` for it.

Fix the `need-mut` false positive for `izip!`
2023-06-04 09:33:53 +00:00