Commit Graph

881 Commits

Author SHA1 Message Date
Jonas Marcello
4ee2e469a2 Rename the method that returns struct paramaters 2023-02-27 18:08:20 +01:00
Jonas Marcello
9957bb361d Add const generics to doctest names for structt 2023-02-27 18:08:20 +01:00
Jonas Marcello
8bc75c4c28 return Iterator instead of Vec for combined lifetime and argument parameters 2023-02-27 18:08:20 +01:00
Jonas Marcello
9942cc425b Fix 14142: Annotate lifetime paramaters in doctest runnables 2023-02-27 18:08:17 +01:00
Lukas Wirth
29a4453d55 Merge the two autoref vecs into one in autoderef_method_receiver 2023-02-27 16:01:16 +01:00
Lukas Wirth
9e5fa74279 Simplify 2023-02-27 15:51:45 +01:00
bors
b38fcde3ba Auto merge of #14213 - swarnimarun:raw-ptr-ty, r=Veykril
add: clean api to get `raw_ptr` type

There doesn't seem to be an API to fetch the type of `raw_ptr`, which is helpful for a project I work on.

Notes:

- I am unsure about the function name, do let me know if I should use something else.
- Also unsure about where to add tests, for hir changes. Will fix it as needed.
2023-02-27 10:45:29 +00:00
Swarnim Arun
832f8bfe2b
rename: as_raw_ptr_ty to remove_raw_ptr 2023-02-27 15:57:26 +05:30
bors
2e479158bb Auto merge of #14208 - Kohei316:master, r=Veykril
fix:add a case in which remainig is None in resolveing types when resolving hir path.

fix #14030 The variable type is being determined incorrectly
This PR fixed a problem in which `go to definition` is jumping to the incorrect position because it was failing to resolve the type in case it defined in the module when resolving hir.
In addition, I added a test for this issue and refactored the related code.
This is my first PR and I am using a translation tool to write this text. Let me know if you have any problems.
2023-02-27 08:40:39 +00:00
Swarnim Arun
9a481d1ecf
add: clean api to get raw_ptr type 2023-02-27 10:59:20 +05:30
morine0122
aa877645a6 Fix resolving types when resolving HIR and add a related test 2023-02-26 21:50:39 +09:00
Lukas Wirth
3c0f20a7bd internal: Enable smallvec's union feature 2023-02-14 17:01:01 +01:00
bors
eeceba7480 Auto merge of #14065 - lowr:patch/generate-generic-function, r=Veykril
Support generic function in `generate_function` assist

Part of #3639

This PR adds support for generic function generation in `generate_function` assist. Now the assist looks for generic parameters and trait bounds in scope, filters out irrelevant ones, and generates new function with them.

See `fn_generic_params()` for the outline of the procedure, and see comments on `filter_unnecessary_bounds()` for criteria for filtering. I think it's good criteria for most cases, but I'm open to opinions and suggestions.

The diff is pretty big, but it should run in linear time w.r.t. the number of nodes we operate on and should be fast enough.

Some notes:
- When we generate function in an existing impl, generic parameters may cause name conflict. While we can detect the conflict and rename conflicting params, I didn't find it worthwhile mainly because it's really easy to resolve on IDE: use Rename functionality.
- I've implemented graph structure myself, because we don't have graph library as a dependency and we only need the simplest one.
  - Although `petgraph` is in our dependency graph and I was initially looking to use it, we don't actually depend on it AFAICT since it's only used in chalk's specialization graph handling, which we don't use. I'd be happy to replace my implementation with `petgraph` if it's okay to use it though.
- There are some caveats that I consider out of scope of this PR. See FIXME notes on added tests.
2023-02-02 09:06:22 +00:00
Ryo Yoshida
3edde6fcc1
Support generic function in generate_function assist 2023-01-31 21:05:25 +09:00
Ryo Yoshida
32955c30cd
Add method to get generic parameters in a type 2023-01-31 21:05:23 +09:00
Ryo Yoshida
0df70d37fc
Minor refactoring 2023-01-31 21:05:04 +09:00
Lukas Wirth
54da0bfbf0 Record method resolution for call expressions 2023-01-27 11:06:41 +01:00
Ryo Yoshida
e9f14c505f
Remove TypeWalk and use TypeFlags instead 2023-01-24 19:44:58 +09:00
Lukas Wirth
1535881836 Replace SmolStr usage with lang item enum for lang items 2023-01-21 17:55:45 +01:00
Laurențiu Nicola
392a6ee422 Bump once_cell 2023-01-21 08:48:46 +02:00
bvanjoi
8fa69f9f7d feat: array match 2023-01-20 10:59:30 +08:00
bors
fa874627f0 Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril
Use workspace.dependencies to declare local dependencies
2023-01-17 10:29:27 +00:00
Lukas Wirth
bed4db3c62 Use workspace.dependencies to declare local dependencies 2023-01-17 10:52:26 +01:00
Lukas Wirth
e4858fe480 Specify authors, edition and license via workspace.package 2023-01-16 16:44:00 +01:00
Lukas Wirth
679df2adf1 Specify rust-version via workspace.package 2023-01-16 16:33:01 +01:00
Ryo Yoshida
8afaaa54b0
Add TraitRef for HIR 2023-01-16 20:55:51 +09:00
bors
c78b9f0068 Auto merge of #13949 - WaffleLapkin:either_ast_node, r=Veykril
minor: implement `AstNode` for `Either`

Makes code a little bit nicer
2023-01-14 13:50:11 +00:00
Maybe Waffle
cfc01150bf implement AstNode for Either 2023-01-14 12:45:20 +00:00
Lukas Wirth
27ba598dfe Make inlay hint location links work for more types 2023-01-14 13:30:56 +01:00
Lukas Wirth
bb4e272d8a Refine search for const and function assoc items 2023-01-11 17:10:04 +01:00
bors
f32f64bffc Auto merge of #13929 - danieleades:simplify, r=lnicola
internal: a number of code simplifications
2023-01-11 09:38:34 +00:00
Daniel Eades
ac3844a0bb a number of code simplifications 2023-01-10 18:48:51 +00:00
Daniel Eades
95d14c393c avoid 'cloning' types that implement 'Copy' 2023-01-10 18:20:12 +00:00
Lukas Wirth
621e96bd6a Encode one level of cfg_attr in attr_id 2023-01-09 21:06:13 +01:00
Lukas Wirth
68723043db Split out hir-def attribute handling parts into hir-expand 2023-01-09 19:29:28 +01:00
bors
814ff01620 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 😁
2023-01-09 11:24:44 +00:00
Daniel Eades
efd2c20e96 remove useless conversions 2023-01-02 15:02:54 +00:00
Daniel Eades
cc80c5bd07 remove unnecessary lazy evaluations 2023-01-02 15:02:54 +00:00
Daniel Eades
ed128872eb remove needless borrows 2023-01-02 14:52:32 +00:00
Lukas Wirth
eee7de0225 Diagnose private assoc item accesses 2023-01-01 13:24:48 +01:00
Lukas Wirth
e3d144d17f Diagnose private field accesses 2022-12-31 14:20:59 +01:00
Lukas Wirth
5d54c550e7 Fallback to invisible associated functions and constants if no visible resolutions are found 2022-12-30 23:56:08 +01:00
Yuri Astrakhan
e16c76e3c3 Inline all format arguments where possible
This makes code more readale and concise,
moving all format arguments like `format!("{}", foo)`
into the more compact `format!("{foo}")` form.

The change was automatically created with, so there are far less change
of an accidental typo.

```
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2022-12-24 14:36:10 -05:00
Yuri Astrakhan
e341e996f7 Clippy-fix explicit auto-deref
Seems like these can be safely fixed. With one, I was particularly
surprised -- `Some(pats) => &**pats,` in body.rs?

```
cargo clippy --fix -- -A clippy::all -D clippy::explicit_auto_deref
```
2022-12-23 02:52:14 -05:00
Yuri Astrakhan
1d59c7b667 Remove non-needed clones
I am not certain if this will improve performance,
but it seems having a .clone() without any need should be removed.

This was done with clippy, and manually reviewed:

```
cargo clippy --fix -- -A clippy::all -D clippy::redundant_clone
```
2022-12-23 02:20:03 -05:00
bors
eb3963b22e Auto merge of #13817 - WaffleLapkin:hide_adjustment_hints_outside_of_unsafe, r=Veykril
feat: Add an option to hide adjustment hints outside of `unsafe` blocks and functions

As the title suggests: this PR adds an option (namely `rust-analyzer.inlayHints.expressionAdjustmentHints.hideOutsideUnsafe`) that allows to hide adjustment hints outside of `unsafe` blocks and functions:

![2022-12-21_23-11](https://user-images.githubusercontent.com/38225716/208986376-d607de62-8290-4e16-b7fe-15b762dc5f60.png)

Requested by `@BoxyUwU` <3
2022-12-22 09:37:00 +00:00
Waffle Maybe
1038db5f1d Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-12-21 23:00:12 +00:00
bors
271f7b44d3 Auto merge of #13699 - HKalbasi:inlaylink, r=Veykril
Implement location link for type inlay hints

fix #11701

This actually doesn't work due a problem in vscode: https://github.com/microsoft/vscode/issues/167564
2022-12-21 21:43:38 +00:00
Maybe Waffle
608dc492ea Move is_inside_unsafe to Semantics impl 2022-12-21 20:36:05 +00:00
bors
c2840c809a Auto merge of #13814 - Veykril:layout, r=Veykril
Calculate the TargetDataLayout correctly for the selected target

This fails the tests still since those don't call into rustc yet
2022-12-21 19:38:51 +00:00