aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/code_model.rs
Commit message (Collapse)AuthorAgeFilesLines
* Prevent multiple incorrect case diagnostics in functionsunexge2020-12-231-3/+3
|
* Merge #6964bors[bot]2020-12-221-0/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6964: Add full pattern completions for Struct and Variant patterns r=matklad a=Veykril Just gonna call it full pattern completion as pattern completion is already implemented in a sense by showing idents in pattern position. What this does is basically complete struct and variant patterns where applicable(function params, let statements and refutable pattern locations). This does not replace just completing the corresponding idents of the structs and variants, instead two completions are shown for these, a completion for the ident itself and a completion for the pattern(if the pattern make sense to be used that is). I figured in some cases one would rather type out the pattern manually if it has a lot of fields but you only care about one since this completion would cause one more work in the end since you would have to delete all the extra matched fields again. These completions are tagged as `CompletionKind::Snippet`, not sure if that is the right one here. <details> <summary>some gifs</summary> ![dx2lxgzhj3](https://user-images.githubusercontent.com/3757771/102719967-6987ef80-42f1-11eb-8ae0-8aff53777860.gif) ![EP2E7sJLkB](https://user-images.githubusercontent.com/3757771/102785777-c7264580-439e-11eb-8a64-f142e19fb65b.gif) ![JMNHHWknr9](https://user-images.githubusercontent.com/3757771/102785796-d1e0da80-439e-11eb-934b-218ada31b51c.gif) </details> Co-authored-by: Lukas Wirth <[email protected]>
| * Add completions for patternsLukas Wirth2020-12-201-0/+4
| |
* | Merge #6921bors[bot]2020-12-201-1/+0
|\ \ | |/ |/| | | | | | | | | | | 6921: Higher-ranked trait bounds for where clauses r=flodiebold a=Veykril There is a slight problem with this which is also noted in a FIXME now but `LifetimeParameters` of these ForLifetime where clauses allocate the lifetimes in the corresponding arena as if they were lifetimes of the item itself and not just the clause they belong to. I wasn't entirely sure what I could do about this but given nothing really uses lifetimes like that currently I figured it might be fine? Open to suggestions for that problem. Co-authored-by: Lukas Wirth <[email protected]>
| * Remove obsolete FIXMELukas Wirth2020-12-171-1/+0
| |
* | Align code_model name with ungrammarAleksey Kladov2020-12-201-24/+20
| |
* | Merge #6901bors[bot]2020-12-181-0/+6
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | 6901: Temp fixes panic caused by no ast for proc-macro r=maklad a=edwin0cheng There are some panic when hover/goto definition for proc-macro. It is because in current design, we don't have `ast-node` for proc-macro and then it trigger [this](https://github.com/rust-analyzer/rust-analyzer/blob/479d1f7eec22c3564867223e2093f14774092528/crates/hir/src/has_source.rs#L116) line to panic. This PR is a temp fix for all of these similar to https://github.com/rust-analyzer/rust-analyzer/blob/bd4c352831662762ee7a66da77ec9adf623b0a0a/crates/completion/src/render/macro_.rs#L42 Co-authored-by: Edwin Cheng <[email protected]>
| * | Temp fixes panic caused by no ast for proc-macroEdwin Cheng2020-12-181-0/+6
| | |
* | | Minor API cleanupAleksey Kladov2020-12-171-4/+2
| | |
* | | Make `Attrs::from_attrs_owner` privateJonas Schievink2020-12-171-0/+1
| |/ |/|
* | Rename ImplDef -> ImplAleksey Kladov2020-12-171-11/+11
| | | | | | | | | | | | We used to have `Def` suffix for all symbols, but we moved off from that. `FunctionDef` isn't better than `Function`. Looks like we've forgot to change `Impl` though!
* | decl_check: don't pass `db` around so oftenJonas Schievink2020-12-171-2/+8
| |
* | Make macro def krate mandatoryJonas Schievink2020-12-151-1/+1
|/ | | | Refactors builtin derive support to go through proper name resolution
* Add LifetimeParam resolving to SemanticsLukas Wirth2020-12-141-0/+8
|
* Add Lifetimes to the HIRLukas Wirth2020-12-111-5/+42
|
* Add slightly more profiling detailsJonas Schievink2020-12-041-1/+3
|
* Place cursor correctly when completing assoc fns with selfAleksey Kladov2020-12-011-0/+1
|
* Type-safer API for dealing with parameter lists with optional selfAleksey Kladov2020-12-011-2/+9
|
* Don't use raw identifiersLukas Wirth2020-11-261-2/+2
|
* Add imports in auto completionKirill Bulatov2020-11-161-8/+2
|
* Remove more unreachable pubsAleksey Kladov2020-11-021-9/+5
|
* Fix case where non FnOnce variables is marked callableGrayJack2020-10-261-1/+1
|
*-. Merge #6251 #6310bors[bot]2020-10-231-2/+23
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6251: Semantic Highlight: Add Callable modifier for variables r=matklad a=GrayJack This PR added the `HighlightModifier::Callable` variant and assigned it to variables and parameters that are fn pointers, closures and implements FnOnce trait. This allows to colorize these variables/parameters when used in call expression. 6310: Rewrite algo::diff to support insertion and deletion r=matklad a=Veykril This in turn also makes `algo::diff` generate finer diffs(maybe even minimal diffs?) as insertions and deletions aren't always represented as as replacements of parent nodes now. Required for #6287 to go on. Co-authored-by: GrayJack <[email protected]> Co-authored-by: Lukas Wirth <[email protected]>
| * | Add Callable modifier for variables that implements FnonceGrayJack2020-10-161-2/+23
| | |
* | | Diagnose #[cfg]s in bodiesJonas Schievink2020-10-231-0/+1
| |/ |/|
* | More type safety around namesAleksey Kladov2020-10-201-2/+2
| |
* | Rename declaration_name -> display_nameAleksey Kladov2020-10-201-2/+2
|/ | | | | | | | Declaration names sounds like a name of declaration -- something you can use for analysis. It empathically isn't, and is just a label displayed in various UI. It's important not to confuse the two, least we accidentally mix semantics with UI (I believe, there's already a case of this in the FamousDefs at least).
*-. Merge #6130 #6135bors[bot]2020-10-121-1/+23
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6130: Items case quick fix (snake_case / UPPER_SNAKE_CASE / CamelCase) r=matklad a=popzxc Resolves #4598. After a third try, it finally works. Boy, it appeared tougher than it seemed. Initially I thought like "Ha, `rustc` already tells us where idents are named incorrectly. It shouldn't be that hard, should it?". Well, the problems with the information provided by `rustc` appeared shortly: - `rustc` warnings are `flycheck` warnings, which are slightly aside from our diagnostics with fixes. When we map flycheck diagnostic to LSP, we can convert it into a fix, but only if it's marked as `Applicability::MachineApplicable`. Name case fix is marked `Applicability::MaybeIncorrect`, and for a reason: it only suggest to rename symbol under cursor, without tracking any references. - Warning spawned by `rustc` are identified by string labels rather than enum. It means that if one day the diagnostic will be renamed in `rustc`, `rust-analyzer` code will still compile, but won't find the required diagnostic by name anymore. If by chance this will happen when some unlucky guy will decide to create their first pull request, they'll be confused by suddenly failing tests (likely) not related to their changes. - Even if we'll try to build fixes atop of `rustc` warnings, we'll have to do it in the `rust_analyzer::diagnostics::to_proto` module, which is far less convenient for that matter than `ide` crate. That's why I decided that it's worth a separate `rust-analyzer` diagnostic, which will implement `DiagnosticWithFix` trait. After that, I discovered that currently `hir_ty::diagnostics` only check `DefWithBody` types, like function bodies. I had to add support for diagnostics which look at any `ModuleDef`. And of course, since I'd added a lot of new functionality, it required extensive testing. That explains why the diff is so big for a (looking) relatively small feature. I hope that this PR doesn't only add a small feature, but also creates a base for building another features. ## Example: ![case_quick_fix](https://user-images.githubusercontent.com/12111581/95008475-e07ee780-0622-11eb-9978-62a9ea0e7782.gif) P.S. My eyes were bleeding when I had to write the code for the example... 6135: when generating new function, focus on return type instead of body r=matklad a=bnjjj I made a little change when we use the assist to generate a new function, instead of focusing on the function body, it will focus on return type Co-authored-by: Igor Aleksanov <[email protected]> Co-authored-by: Benjamin Coenen <[email protected]>
| * | Apply case check diagnostic to impl itemsIgor Aleksanov2020-10-121-1/+2
| | |
| * | Add fix for incorrect case diagnosticIgor Aleksanov2020-10-121-25/+15
| | |
| * | Create basic support for names case checks and implement function name case ↵Igor Aleksanov2020-10-121-0/+31
| | | | | | | | | | | | check
* | | Merge #6195bors[bot]2020-10-121-1/+5
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6195: Shorten iterators in associated params r=matklad a=SomeoneToIgnore Applies the same iterator-shortening logic to the iterator associated types, recursively. Before: ![image](https://user-images.githubusercontent.com/2690773/95662735-e6ecf200-0b41-11eb-8e54-28493ad4e644.png) After: <img width="1192" alt="image" src="https://user-images.githubusercontent.com/2690773/95662894-e9038080-0b42-11eb-897d-527571ccac58.png"> Co-authored-by: Kirill Bulatov <[email protected]>
| * | Also replace the associated types with iterKirill Bulatov2020-10-101-1/+5
| |/
* | Remove methodowner & fix formattingZac Pullar-Strecker2020-10-081-38/+1
| |
* | Rebase fixesZac Pullar-Strecker2020-10-081-1/+1
| |
* | Change Option::Some bug to a fixme noteZac Pullar-Strecker2020-10-081-0/+1
| | | | | | | | IMO this is too much work to be worth fixing at the moment.
* | Differentiate method/tymethod by determining 'defaultness'Zac Pullar-Strecker2020-10-081-1/+8
| | | | | | | | | | | | | | | | | | Currently a method only has defaultness if it is a provided trait method, but this will change when specialisation is available and may need to become a concept known to hir. I opted to go for a 'fewest changes' approach given specialisation is still under development.
* | Code reorganisation and field supportZac Pullar-Strecker2020-10-081-1/+47
|/
* Shorten type hints for std::iter IteratorsLukas Wirth2020-10-061-2/+35
|
* Merge #6124bors[bot]2020-10-061-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | 6124: Better normalized crate name usage r=jonas-schievink a=SomeoneToIgnore Closes https://github.com/rust-analyzer/rust-analyzer/issues/5343 Closes https://github.com/rust-analyzer/rust-analyzer/issues/5932 Uses normalized name for code snippets (to be able to test the fix), hover messages and documentation rewrite links (are there any tests for those?). Also renamed the field to better resemble the semantics. Co-authored-by: Kirill Bulatov <[email protected]>
| * Properly name the fieldKirill Bulatov2020-10-021-2/+2
| |
| * Fix the hover dash issuesKirill Bulatov2020-10-021-2/+2
| |
* | Make ImportPrefix a configuration optionLukas Wirth2020-10-051-1/+2
| |
* | Make find_path_prefixed configurableLukas Wirth2020-10-051-1/+2
|/
* Minor clippy performance suggestionskjeremy2020-09-301-1/+1
|
* Don't unnecessarily unnest imports for import insertionLukas Wirth2020-09-251-0/+10
|
* Merge #5846bors[bot]2020-09-241-5/+31
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5846: Add references to fn args during completion r=matklad a=adamrk When completing a function call, if there is an argument taken as a ref or mut ref which matches the name and type of a variable in scope, we will insert a `&` or `&mut` when filling in the function arguments. This addresses https://github.com/rust-analyzer/rust-analyzer/issues/5449. E.g. ```rust fn foo(x: &i32) {} fn main() { let x = 5; foo # completing foo here generates `foo(&x)` now instead of `foo(x)` } ``` Co-authored-by: adamrk <[email protected]>
| * Remove exposing unificationadamrk2020-09-021-6/+0
| |
| * Add back Param structadamrk2020-09-011-2/+12
| |
| * Add references to fn args during completionadamrk2020-08-301-6/+28
| |