Skip to content

Missing assert_eq suggestion #1727

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

Closed
max-sixty opened this issue Aug 23, 2019 · 2 comments · Fixed by #1796
Closed

Missing assert_eq suggestion #1727

max-sixty opened this issue Aug 23, 2019 · 2 comments · Fixed by #1796
Labels

Comments

@max-sixty
Copy link

I don't get any suggestions for assert_eq. This was a completely blank project and I tried restarting rust-analyzer.

These are the only as* suggestions I see:

image

Ref #1710 re posting these

@flodiebold
Copy link
Member

Related to #1688

@matklad
Copy link
Member

matklad commented Sep 6, 2019

I think we have these macros in the global macro scope when we run nameres/collect. However, it's not super clear how to expose this to completion infrastructure properly.

The problem is, that the global macro scope is a mutable map, which is cleared after we have processed the crate. We could record snapshots of the map as we process the crate, but that would put an IDE specific concern into the compiler. A more clean separation would be to just traverse the crate in dfs order up to completion point in the ide, collecting macros along the way. This would duplicate nameres logic in IDE though.

A nice short-term 80% solution would be to only process macros from #[macro_use] extern crate, which covers all std macros: for such macros, we already maintain the exported_macros table, and IDE can just look into it.

@matklad matklad added E-medium and removed E-hard labels Sep 6, 2019
bors bot added a commit that referenced this issue Sep 9, 2019
1784: Support textual scoped macros r=matklad a=uHOOCCOOHu

Refactor the old simulation with `global_macro_scope`.

Now it is quite accurate to resolve textual scoped macros.
- Expand textual scoped macros in item and non-item place.
- Support `#[macro_use]` on `mod`.
- Textual scoped macros are collected into `nameres::ModuleScope`, so I think it makes #1727 easier to fix.
- It is implemented in a simple way to `clone()` current scoped macro ids into sub-modules. Though only indices are cloned, it will still increase some resolving time. Well, I've not bench-marked yet.

In my test with vscode extension, it can now successfully expand `dbg!` from `std` without `std::` prefix. "Goto definition" also works. Screenshot here:
<img width="281" alt="Screenshot_20190907_043442" src="https://user-images.githubusercontent.com/14816024/64458794-ddb47900-d128-11e9-95e3-1c8569978825.png">


Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
@bors bors bot closed this as completed in 6ce6744 Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants