Commit graph

12467 commits

Author SHA1 Message Date
Lukas Wirth
091dc26cda perf: Reduce memory usage of salsa slots by 8 bytes 2024-07-19 17:34:48 +02:00
Lukas Wirth
754f53ca1a Test macros doing edition dependent parsing 2024-07-19 16:43:58 +02:00
Lukas Wirth
62eba06591 Prevent generated runner module from being format checked 2024-07-19 16:01:47 +02:00
Lukas Wirth
2dc84abb55 Parse try as a keyword only in edition 2018 and up 2024-07-19 15:43:20 +02:00
Lukas Wirth
f4b2bf5c53 Add basic edition inline parser test support 2024-07-19 15:19:43 +02:00
Lukas Wirth
eae705e5ed Rewrite inline parser test infra to generated proper rust test cases 2024-07-18 10:03:19 +02:00
Lukas Wirth
736723d435 Update test fixtures 2024-07-18 09:09:31 +02:00
Lukas Wirth
20e27b874d Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
Lukas Wirth
835734eed0 Support rustc_skip_during_method_dispatch 2024-07-17 11:46:36 +02:00
Lukas Wirth
f7516d95a7 string is not a keyword 2024-07-17 11:11:57 +02:00
Lukas Wirth
0bffb1345b Add always disabled gen parse support 2024-07-17 10:49:12 +02:00
Lukas Wirth
373e84fb28 Derive kinds information from ungrammar file 2024-07-17 10:04:45 +02:00
Lukas Wirth
7ef5f46c83 Fix incorrect generic parameter hint defaults 2024-07-17 08:52:23 +02:00
Lukas Wirth
811ce15b12 Don't call macro_arg directly in ExpandDatabase::syntax_context 2024-07-16 22:10:42 +02:00
Lukas Wirth
4f031d9768 Set RUSTC_SYSROOT for runnables 2024-07-16 13:48:14 +02:00
Lukas Wirth
41451a26e9 Remove Name::to_smol_str 2024-07-16 12:43:58 +02:00
Lukas Wirth
1a20a0803f More symbol usage 2024-07-16 12:05:16 +02:00
Lukas Wirth
9ce066e6fa Use symbol in cfg 2024-07-16 10:41:42 +02:00
Lukas Wirth
7f8a54bbee Switch token trees to use Symbols 2024-07-16 10:11:59 +02:00
Lukas Wirth
311aaa5a79 Fix incorrect encoding of literals in the proc-macro-api on version 4 2024-07-15 14:51:01 +02:00
bors
c5fc66928e Auto merge of #17559 - Veykril:tokentree, r=Veykril
Encode ident rawness and literal kind separately in tt::Leaf
2024-07-15 11:25:51 +00:00
Lukas Wirth
39eb8c6bc4 Escape fetched env vars in env! expansion 2024-07-15 13:08:29 +02:00
Lukas Wirth
ed2b355872 Add cargo xtask install proc-macro-server 2024-07-15 12:41:02 +02:00
Lukas Wirth
6af77a624e Encode ident rawness and literal kind separately in tt::Leaf 2024-07-15 12:24:40 +02:00
bors
c1d08b5394 Auto merge of #17588 - CamWass:more-rename, r=Veykril
feat: Add incorrect case diagnostics for enum variant fields and all variables/params

Updates the incorrect case diagnostic to check:

1. Fields of enum variants. Example:
```rust
enum Foo {
    Variant { nonSnake: u8 }
}
```
2. All variable bindings, instead of just let bindings and certain match arm patters. Examples:
```rust
match 1 { nonSnake => () }
match 1 { nonSnake @ 1 => () }
match 1 { nonSnake1 @ nonSnake2 => () } // slightly cursed, but these both introduce new
                                        // bindings that are bound to the same value.

const ONE: i32 = 1;
match 1 { nonSnake @ ONE } //  ONE is ignored since it is not a binding

match Some(1) { Some(nonSnake) => () }

struct Foo { field: u8 }
match (Foo { field: 1 } ) {
    Foo { field: nonSnake } => ();
}

struct Foo { nonSnake: u8 } // diagnostic here, at definition
match (Foo { nonSnake: 1 } ) { // no diagnostic here...
    Foo { nonSnake } => ();    // ...or here, since these are not where the name is introduced
}

for nonSnake in [] {}

struct Foo(u8);
for Foo(nonSnake) in [] {}
```
3. All parameter bindings, instead of just top-level binding identifiers. Examples:
```rust
fn func(nonSnake: u8) {} // worked before

struct Foo { field: u8 }
fn func(Foo { field: nonSnake }: Foo) {} // now get diagnostic for nonSnake
```

This is accomplished by changing the way binding identifier patterns are filtered:
- Previously, all binding idents were skipped, except a few classes of "good" binding locations that were checked.
- Now, all binding idents are checked, except field shorthands which are skipped.

Moving from a whitelist to a blacklist potentially makes the analysis more brittle:
If new pattern types are added in the future where ident pats don't introduce new names, then they may incorrectly create diagnostics.

But the benefit of the blacklist approach is simplicity: I think a whitelist approach would need to recursively visit patterns to collect renaming candidates?
2024-07-15 10:07:37 +00:00
bors
82d0187cf8 Auto merge of #17587 - joshka:jm/edit-name-after-refactor, r=Veykril
Trigger VSCode to rename after extract variable assist is applied

When the user applies the "Extract Variable" assist, the cursor is
positioned at the newly inserted variable. This commit adds a command
to the assist that triggers the rename action in VSCode. This way, the
user can quickly rename the variable after applying the assist.

Fixes part of: #17579

https://github.com/user-attachments/assets/4cf38740-ab22-4b94-b0f1-eddd51c26c29

I haven't yet looked at the module or function extraction assists yet.
2024-07-15 09:53:39 +00:00
bors
305bd5d066 Auto merge of #17584 - Veykril:landing-page, r=Veykril
Implement symbol interning infra

Will fix https://github.com/rust-lang/rust-analyzer/issues/15590

My unsafe-fu is not the best but it does satisfy miri.

There is still some follow up work to do, notably a lot of places using strings instead of symbols/names, most notably the token tree.
2024-07-15 09:39:22 +00:00
Lukas Wirth
d95b2f3f4b Fix stable iteration ordering for Map<Name, ...> usages 2024-07-15 11:25:46 +02:00
Lukas Wirth
26fb6a8738 Use statics + clone instead of const until const can access statics 2024-07-14 17:52:59 +02:00
Anita Hammer
b32fc1fcf6
Update manual.adoc 2024-07-14 11:26:41 +01:00
Josh McKinney
e03998bb63
Address feedback from @DropDemBits
- move `edit.rename()` to the end of the function
- use a match statement to set `res.command`
2024-07-13 19:33:35 -07:00
Campbell
6351a20642 feat: Add incorrect case diagnostics for enum variant fields and all variables 2024-07-13 21:54:22 +12:00
bors
377a0a7696
Trigger VSCode to rename after extract variable assist is applied
When the user applies the "Extract Variable" assist, the cursor is
positioned at the newly inserted variable. This commit adds a command
to the assist that triggers the rename action in VSCode. This way, the
user can quickly rename the variable after applying the assist.

Fixes part of: #17579
2024-07-12 19:06:19 -07:00
Lukas Wirth
292b9de2be Fix cloning Symbols not increasing their ref count 2024-07-12 17:13:12 +02:00
Lukas Wirth
602da3fadd Use Symbol in Name 2024-07-12 16:06:44 +02:00
Lukas Wirth
e805055b0e Add missing docs 2024-07-12 16:01:47 +02:00
Lukas Wirth
1bafedbfe9 Implement rough symbol interning infra 2024-07-12 16:01:47 +02:00
Laurențiu Nicola
62bbce2ad2 Merge from rust-lang/rust 2024-07-11 20:06:05 +03:00
Laurențiu Nicola
b159b3fd80 Preparing for merge from rust-lang/rust 2024-07-11 20:05:52 +03:00
bors
fdf7ea6b5b Auto merge of #126777 - Zalathar:normalize-colon, r=lcnr
Require a colon in `//@ normalize-*:` test headers

The previous parser for `//@ normalize-*` headers (before #126370) was so lax that it did not require `:` after the header name. As a result, the test suite contained a mix of with-colon and without-colon normalize headers, both numbering in the hundreds.

This PR updates the without-colon headers to add a colon (matching the style used by other headers), and then updates the parser to make the colon mandatory.

(Because the normalization parser only runs *after* the header system identifies a normalize header, this will detect and issue an error for relevant headers that lack the colon.)

Addresses one of the points of #126372.
2024-07-11 09:13:15 +00:00
bors
45609a995e Auto merge of #17571 - winstxnhdw:bool-to-enum-no-dupe, r=Veykril
feat: do not add new enum if it already exists

## Summary

This PR introduces a check for the existence of another enum within the current scope, and if it exist, we skip `add_enum_def`.

## Why?

Currently, when using the `bool_to_enum` assist more than once, it is possible to add multiple enum definitions. For example, the following snippet,

```rs
#[derive(PartialEq, Eq)]
enum Bool {
    True,
    False,
}

fn main() {
    let a = Bool::True;
    let b = true;
    println!("Hello, world!");
}
```

will be transformed into,

```rs
#[derive(PartialEq, Eq)]
enum Bool {
    True,
    False,
}

#[derive(PartialEq, Eq)]
enum Bool {
    True,
    False,
}

fn main() {
    let a = Bool::True;
    let b = Bool::True;
    println!("Hello, world!");
}
```

This can be annoying for users to clean up.
2024-07-11 08:55:34 +00:00
Zalathar
b6773591ee Require a colon in //@ normalize-*: headers 2024-07-11 12:23:45 +10:00
bors
e1f45a1442 Auto merge of #127538 - Oneirical:the-sacred-tests, r=jieyouxu
Migrate `issue-83112-incr-test-moved-file`, `type-mismatch-same-crate-name` and `issue-109934-lto-debuginfo` `run-make` tests to rmake or ui

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

I have noticed that the new UI test `debuginfo-lto-alloc` is outputting artifacts that aren't getting cleaned up because of its `-C incremental`. That might be the justification needed to keep it as a run-make test?

Try it on:

// try-job: test-various // previously passed
try-job: armhf-gnu
try-job: aarch64-apple
try-job: x86_64-msvc
2024-07-11 00:56:46 +00:00
winstxnhdw
d33e96ba00 refactor: search for enum semantically 2024-07-10 21:13:13 +01:00
Lukas Wirth
d4a6970ded Remove faq landing page, improve main one 2024-07-10 19:05:32 +02:00
bors
8cc4de631b Auto merge of #17572 - beetrees:f16-f128, r=Veykril
Add `f16` and `f128` support

Adds `f16` and `f128` support, using the `rustc_apfloat` library (also used by `rustc`) for parsing/arithmetic/displaying since the types aren't stable yet so can't be used by rust-analyzer itself.

Issue: #17451
2024-07-10 10:04:30 +00:00
bors
2faa2cb0db Auto merge of #17544 - MikeWalrus:inlay-hint-generic-param-name, r=Veykril
feat: add inlay hints for generic parameters

fixes #11091

By default, only hints for const generic parameters are shown, and this can be configured through `rust-analyzer.inlayHints.genericParameterHints.enable`.

Probably needs more testing.
2024-07-10 09:50:40 +00:00
Lukas Wirth
7da4615763
Remove dead code in config.rs 2024-07-10 11:49:11 +02:00
beetrees
69424f7666
Add f16 and f128 support 2024-07-10 10:43:14 +01:00
bors
0fdfb61795 Auto merge of #127006 - Oneirical:holmes-the-detestive, r=Kobzol
Migrate `extern-flag-pathless`, `silly-file-names`, `metadata-dep-info`, `cdylib-fewer-symbols` and `symbols-include-type-name` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

`cdylib-fewer-symbols` demands a Windows try-job. (Almost guaranteed to fail, but 7 years is a long time)

try-job: x86_64-gnu-distcheck
try-job: x86_64-msvc
try-job: aarch64-apple
2024-07-10 08:51:20 +00:00