Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control flow analysis #1612

Open
5 of 11 tasks
farodin91 opened this issue Aug 11, 2017 · 2 comments
Open
5 of 11 tasks

Control flow analysis #1612

farodin91 opened this issue Aug 11, 2017 · 2 comments
Assignees
Labels
meta Top level/tracking issue that group collections of related issues subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc.

Comments

@farodin91
Copy link
Contributor

farodin91 commented Aug 11, 2017

Possible parts:

@farodin91 farodin91 changed the title control flow analysis Control flow analysis Aug 11, 2017
@vlad20012
Copy link
Member

I think we should perform type checking (and possibly all of the above) during type inference and save errors into RsInferenceContext (as mapping like expr => error). Then extract errors from the context by an error annotator. But I do not think that we can do any type checking right now. Currently I'm working on something called Expectation, and after implementing it, it should be possible to perform some limited type checking.

@matklad
Copy link
Member

matklad commented Aug 11, 2017

@vlad20012 we also need a limited form of control flow analysis in type inference, to deal with ! type properly: #1599

@mchernyavsky mchernyavsky added the meta Top level/tracking issue that group collections of related issues label Jul 18, 2019
@artemmukhin artemmukhin added the subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc. label Sep 4, 2020
bors bot added a commit that referenced this issue Mar 25, 2021
6829: INSP: Implement unreachable code detection r=dima74 a=ortem

This PR introduces `Unreachable code` inspection to detect and remove unreachable code.

![unreachable_code](https://user-images.githubusercontent.com/4854600/107639621-2ce9cc00-6c82-11eb-8a06-114953a733ab.gif)

Note that now it might produce some false-positive warnings due to #6749 and #6797, so probably it's better to try fixing these issues before merging this. 

Some implementation details:
* Based on the control-flow graph which is already used for several inspections (move analysis, liveness analysis)
* Found unreachable elements are cached by `org.rust.lang.core.types.ExtensionsKt#CONTROL_FLOW_KEY` as well as the  graph itself
* Does not highlight each unreachable element separately, but merges their text ranges instead in order to highlight the widest range

Part of #1612.

changelog: Add `Unreachable code` inspection and quick-fix

6969: COMP: Improve dependency completion when using crates local index r=ortem a=avrong

<img width="400" src="https://user-images.githubusercontent.com/6342851/111127949-6c5b4f00-8585-11eb-8a1f-e1284d32009d.gif">

changelog: Improve performance of dependencies completion in `Cargo.toml` using crates local index. This feature is disabled by default for now. To use it, enable `org.rust.crates.local.index` experimental feature


Co-authored-by: ortem <ortem00@gmail.com>
Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
bors bot added a commit that referenced this issue Mar 25, 2021
6829: INSP: Implement unreachable code detection r=dima74 a=ortem

This PR introduces `Unreachable code` inspection to detect and remove unreachable code.

![unreachable_code](https://user-images.githubusercontent.com/4854600/107639621-2ce9cc00-6c82-11eb-8a06-114953a733ab.gif)

Note that now it might produce some false-positive warnings due to #6749 and #6797, so probably it's better to try fixing these issues before merging this. 

Some implementation details:
* Based on the control-flow graph which is already used for several inspections (move analysis, liveness analysis)
* Found unreachable elements are cached by `org.rust.lang.core.types.ExtensionsKt#CONTROL_FLOW_KEY` as well as the  graph itself
* Does not highlight each unreachable element separately, but merges their text ranges instead in order to highlight the widest range

Part of #1612.

changelog: Add `Unreachable code` inspection and quick-fix

Co-authored-by: ortem <ortem00@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta Top level/tracking issue that group collections of related issues subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc.
Projects
None yet
Development

No branches or pull requests

5 participants