about summary refs log tree commit diff
path: root/src/tools/rust-analyzer
AgeCommit message (Collapse)AuthorLines
2024-07-16Switch token trees to use SymbolsLukas Wirth-399/+593
2024-07-16Use re-exported Idx and IndexVec in pat_analysisLaurențiu Nicola-3/+2
2024-07-15Fix incorrect encoding of literals in the proc-macro-api on version 4Lukas Wirth-134/+183
2024-07-15Auto merge of #17559 - Veykril:tokentree, r=Veykrilbors-431/+910
Encode ident rawness and literal kind separately in tt::Leaf
2024-07-15Escape fetched env vars in env! expansionLukas Wirth-20/+25
2024-07-15Add cargo xtask install proc-macro-serverLukas Wirth-4/+30
2024-07-15Encode ident rawness and literal kind separately in tt::LeafLukas Wirth-410/+858
2024-07-15Auto merge of #17588 - CamWass:more-rename, r=Veykrilbors-31/+194
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-15Auto merge of #17587 - joshka:jm/edit-name-after-refactor, r=Veykrilbors-36/+80
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-15Auto merge of #17584 - Veykril:landing-page, r=Veykrilbors-792/+1418
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-15Fix stable iteration ordering for `Map<Name, ...>` usagesLukas Wirth-29/+55
2024-07-14Use statics + clone instead of const until const can access staticsLukas Wirth-368/+395
2024-07-14Update manual.adocAnita Hammer-1/+1
2024-07-13Rollup merge of #127434 - onur-ozkan:use-bootstrap-instead-of-rustbuild, ↵Jubilee-1/+1
r=Mark-Simulacrum use "bootstrap" instead of "rustbuild" in comments and docs Let's stick with the single name "bootstrap" to refer to the bootstrap project to avoid confusion. This should make it clearer, especially for new contributors.
2024-07-13Address feedback from @DropDemBitsJosh McKinney-13/+10
- move `edit.rename()` to the end of the function - use a match statement to set `res.command`
2024-07-13feat: Add incorrect case diagnostics for enum variant fields and all variablesCampbell-31/+194
2024-07-12Trigger VSCode to rename after extract variable assist is appliedbors-33/+80
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-13Allow macro expansions into `RestPat` in tuple args work as ellipsis like ↵Shoyu Vanilla-5/+108
plain `RestPat`
2024-07-12Fix cloning Symbols not increasing their ref countLukas Wirth-28/+63
2024-07-12Use Symbol in NameLukas Wirth-761/+756
2024-07-12Add missing docsLukas Wirth-1/+2
2024-07-12Implement rough symbol interning infraLukas Wirth-1/+543
2024-07-11Merge from rust-lang/rustLaurențiu Nicola-83/+3
2024-07-11Preparing for merge from rust-lang/rustLaurențiu Nicola-1/+1
2024-07-11Auto merge of #17571 - winstxnhdw:bool-to-enum-no-dupe, r=Veykrilbors-3/+44
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-10refactor: search for enum semanticallywinstxnhdw-6/+8
2024-07-10Remove faq landing page, improve main oneLukas Wirth-51/+12
2024-07-10Auto merge of #17572 - beetrees:f16-f128, r=Veykrilbors-73/+384
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-10Auto merge of #17544 - MikeWalrus:inlay-hint-generic-param-name, r=Veykrilbors-14/+430
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-10Remove dead code in config.rsLukas Wirth-13/+0
2024-07-10Add `f16` and `f128` supportbeetrees-73/+384
2024-07-09style: prefer type inferencewinstxnhdw-1/+1
- unrelated to the PR but I wanted to change this in #17467
2024-07-09feat: do not add new enum if it already existswinstxnhdw-1/+40
2024-07-08Auto merge of #17558 - beetrees:fix-double-rounding, r=Veykrilbors-33/+47
fix: Fix double rounding of `f32` literals Fixes #17556 by delaying parsing until the type is known. Also adds a test to check the issue is fixed.
2024-07-08fix: Fix double rounding of `f32` literalsbeetrees-33/+47
2024-07-08Remove version check before using `--keep-going`mo8it-25/+7
2024-07-08Rollup merge of #120248 - WaffleLapkin:bonk-ptr-object-casts, ↵Matthias Krüger-71/+0
r=compiler-errors,oli-obk,lnicola Make casts of pointers to trait objects stricter This is an attempt to `fix` https://github.com/rust-lang/rust/issues/120222 and https://github.com/rust-lang/rust/issues/120217. This is done by adding restrictions on casting pointers to trait objects. Before this PR the rules were as follows: > When casting `*const X<dyn A>` -> `*const Y<dyn B>`, principal traits in `A` and `B` must refer to the same trait definition (or no trait). With this PR the rules are changed to > When casting `*const X<dyn Src>` -> `*const Y<dyn Dst>` > - if `Dst` has a principal trait `DstP`, > - `Src` must have a principal trait `SrcP` > - `dyn SrcP` and `dyn DstP` must be the same type (modulo the trait object lifetime, `dyn T+'a` -> `dyn T+'b` is allowed) > - Auto traits in `Dst` must be a subset of auto traits in `Src` > - Not adhering to this is currently a FCW (warn-by-default + `FutureReleaseErrorReportInDeps`), instead of an error > - if `Src` has a principal trait `Dst` must as well > - this restriction will be removed in a follow up PR This ensures that 1. Principal trait's generic arguments match (no `*const dyn Tr<A>` -> `*const dyn Tr<B>` casts, which are a problem for [#120222](https://github.com/rust-lang/rust/issues/120222)) 2. Principal trait's lifetime arguments match (no `*const dyn Tr<'a>` -> `*const dyn Tr<'b>` casts, which are a problem for [#120217](https://github.com/rust-lang/rust/issues/120217)) 3. No auto traits can be _added_ (this is a problem for arbitrary self types, see [this comment](https://github.com/rust-lang/rust/pull/120248#discussion_r1463835350)) Some notes: - We only care about the metadata/last field, so you can still cast `*const dyn T` to `*const WithHeader<dyn T>`, etc - The lifetime of the trait object itself (`dyn A + 'lt`) is not checked, so you can still cast `*mut FnOnce() + '_` to `*mut FnOnce() + 'static`, etc - This feels fishy, but I couldn't come up with a reason it must be checked The diagnostics are currently not great, to say the least, but as far as I can tell this correctly fixes the issues. cc `@oli-obk` `@compiler-errors` `@lcnr`
2024-07-08feat: add inlay hints for generic parametersLiao Junxuan-14/+443
fixes #11091 By default, only hints for const generic parameters are shown.
2024-07-07Add --keep-going to the check commandmo8it-0/+2
2024-07-07Auto merge of #17555 - Veykril:grammar-inline, r=Veykrilbors-41/+1115
internal: Inline generated syntax methods
2024-07-07Inline all the thingsLukas Wirth-0/+1032
2024-07-07HasGenericArgs syntax traitLukas Wirth-41/+83
2024-07-07Auto merge of #17523 - wada314:master, r=Veykrilbors-11/+233
Add an option to use "::" for the external crate prefix. Fixes #11823 . Hi I'm very new to rust-analyzer and not sure how the review process are. Can somebody take a look at this PR? thanks!
2024-07-07fix: Fix callHierarchy LSP violationLukas Wirth-31/+187
2024-07-07Fix stale reference in architecture.mdLukas Wirth-2/+1
2024-07-07Run codegen commands as tests if their results are commitedLukas Wirth-3/+23
2024-07-07Re-implement tidy as an xtask actionLukas Wirth-60/+69
2024-07-07re-generate feature docs in releaseLukas Wirth-1/+2
2024-07-07Drop sourcegenLukas Wirth-229/+0
2024-07-07Move feature-doc generation to xtask codegenLukas Wirth-10/+17