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

Attribute macros support #789

Closed
zeenix opened this issue Jun 29, 2021 · 17 comments
Closed

Attribute macros support #789

zeenix opened this issue Jun 29, 2021 · 17 comments

Comments

@zeenix
Copy link

zeenix commented Jun 29, 2021

Recently attribute macros support was landed in rust-analyzer. However, I didn't see it working. Today I looked at the PR description and realized that I need to enable explicitly but when I enter the following line in my CoC config:

"rust-analyzer.experimental.procAttrMacros": true,

I'm told that it's not a valid property and it's also not listed in the properties in the README. Could you please add this configuration?

@fannheyward
Copy link
Owner

:CocUpdate to upgrade coc-rust-analyzer, it's added in latest release.

@zeenix
Copy link
Author

zeenix commented Jun 29, 2021

:CocUpdate to upgrade coc-rust-analyzer, it's added in latest release.

I did and it says "[coc.nvim] Update completed", but I still see the same error/warning.

@zeenix
Copy link
Author

zeenix commented Jun 29, 2021

I also did CocCommand rust-analyzer.upgrade just to be sure but still the same and I don't see completion working. :(

@zeenix
Copy link
Author

zeenix commented Jun 29, 2021

oh, this time I got an error on CocUpdate:

 Error on update coc-rust-analyzer: Error: coc-rust-analyzer 0.46.3 requires coc.nvim >= >=0.0.80, please update coc.nvim.

On subsequent attempts, the update seems to succeed but then I'm back to my original problem.

@fannheyward
Copy link
Owner

Looks like you're using an old coc.nvim, what's the output of :CocInfo? Upgrade your coc.nvim please.

@zeenix
Copy link
Author

zeenix commented Jun 29, 2021

Looks like you're using an old coc.nvim, what's the output of :CocInfo? Upgrade your coc.nvim please.

You're correct. I upgraded successfully but seems now my nodejs is too old. :( Coc exits on vim launch and CocInfo says:

Error: Node version v10.19.0 < 12.12.0, please upgrade node.js

I guess I need to reinstall nodejs from another source as I'm already on the latest version available on my Ubuntu 20.04:

nodejs is already the newest version (10.19.0~dfsg-3ubuntu1).

@fannheyward
Copy link
Owner

You can ignore the node warning, coc can work on nodejs 10. But it's recommended to use nodejs 12, nodejs 10 is already end of life.

@zeenix
Copy link
Author

zeenix commented Jun 29, 2021

So I managed to upgrade everything I believe. However, I can't really test the new attribute macro feature as rust-analyzer-based completion in general isn't working for me any for some reason (it used to). :( Here is my configuration:

{
       "rust-analyzer.cargo.loadOutDirsFromCheck": true,                                            
       "rust-analyzer.procMacro.enable": true
}        

and here is what :CocInfo says after I've tried completion:

ndefined## versions                                                               
                                                                                                   
vim version: VIM - Vi IMproved 8.1 8012269    
node version: v14.17.1                         
coc.nvim version: 0.0.80-131f6b267f    
coc.nvim directory: /home/zeenix/.vim/plugged/coc.nvim    
term: dumb              
platform: linux         
              
## Log of coc.nvim                       
                               
2021-06-29T14:14:30.166 INFO (pid:519870) [services] - registered service "rust-analyzer"    
2021-06-29T14:14:30.169 INFO (pid:519870) [services] - Rust Analyzer Language Server state change: stopped => starting    
2021-06-29T14:14:30.179 INFO (pid:519870) [language-client-index] - Language server "rust-analyzer" started with 519884    
2021-06-29T14:14:30.203 INFO (pid:519870) [services] - Rust Analyzer Language Server state change: starting => running    
2021-06-29T14:14:30.211 INFO (pid:519870) [services] - service rust-analyzer started    
2021-06-29T14:14:30.336 INFO (pid:519870) [plugin] - coc.nvim 0.0.80-131f6b267f initialized with node: v14.17.1 after 317ms    
2021-06-29T14:14:36.639 INFO (pid:519870) [completion-complete] - Results from: around    
2021-06-29T14:14:37.950 INFO (pid:519870) [completion-complete] - Results from: around    
2021-06-29T14:14:59.371 INFO (pid:519870) [attach] - receive notification: showInfo []    
2021-06-29T14:15:03.460 INFO (pid:519870) [attach] - receive notification: highlight []    
2021-06-29T14:15:39.051 INFO (pid:519870) [completion-complete] - Results from: around    
2021-06-29T14:15:43.131 INFO (pid:519870) [completion-complete] - Results from: around    
2021-06-29T14:15:44.543 INFO (pid:519870) [completion-complete] - Results from: around    
2021-06-29T14:15:45.443 INFO (pid:519870) [completion-complete] - Results from: around    
2021-06-29T14:16:07.148 INFO (pid:519870) [attach] - receive notification: showInfo []    

btw, I now get error on another config:

  Property rust-analyzer.cargo.loadOutDirsFromCheck is not allowed. 

@fannheyward
Copy link
Owner

This configuration has been renamed to another one.

@zeenix
Copy link
Author

zeenix commented Jun 29, 2021

This configuration has been renamed to another one.

Readme needs to be updated then. :)

No clue about why completion doesn't work for me anymore?

@fannheyward
Copy link
Owner

fannheyward commented Jun 30, 2021

@zeenix This configuration has been renamed in rust-lang/rust-analyzer#7868, README updated.

Have no idea thy completion doesn't work for you.

@zeenix
Copy link
Author

zeenix commented Jun 30, 2021

Have no idea thy completion doesn't work for you.

Probably rust-analyzer having issues with our codebase. 🤷

@zeenix
Copy link
Author

zeenix commented Jul 1, 2021

Have no idea thy completion doesn't work for you.

Probably rust-analyzer having issues with our codebase. shrug

I actually tried different projects but it won't work. It's actually much worse, even renaming and highlighting won't work. :( To ensure the issue is not in coc, vim or my vim configuration, I tested against a C project using coc-clangd but all the features seem to work fine there, so it's either coc-rust-analyzer or rust-analyzer problem. :CocInfo says:

## versions

vim version: VIM - Vi IMproved 8.1 8012269
node version: v14.17.1
coc.nvim version: 0.0.80-131f6b267f
coc.nvim directory: /home/zeenix/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2021-07-01T15:20:57.398 INFO (pid:641633) [services] - registered service "rust-analyzer"
2021-07-01T15:20:57.399 INFO (pid:641633) [services] - Rust Analyzer Language Server state change: stopped => starting
2021-07-01T15:20:57.403 INFO (pid:641633) [language-client-index] - Language server "rust-analyzer" started with 641644
2021-07-01T15:20:57.428 INFO (pid:641633) [services] - Rust Analyzer Language Server state change: starting => running
2021-07-01T15:20:57.435 INFO (pid:641633) [services] - service rust-analyzer started
2021-07-01T15:20:57.672 INFO (pid:641633) [plugin] - coc.nvim 0.0.80-131f6b267f initialized with node: v14.17.1 after 402ms
2021-07-01T15:21:04.164 INFO (pid:641633) [attach] - receive notification: rename []
2021-07-01T15:21:05.830 WARN (pid:641633) [plugin] - Slow action "rename" cost 1666ms
2021-07-01T15:21:08.168 INFO (pid:641633) [attach] - receive notification: highlight []
2021-07-01T15:21:12.136 INFO (pid:641633) [attach] - receive notification: rename []
2021-07-01T15:21:15.587 WARN (pid:641633) [plugin] - Slow action "highlight" cost 7419ms
2021-07-01T15:21:17.320 INFO (pid:641633) [attach] - receive notification: rename []
2021-07-01T15:21:23.341 INFO (pid:641633) [attach] - receive notification: highlight []
2021-07-01T15:21:24.517 WARN (pid:641633) [plugin] - Slow action "highlight" cost 1175ms
2021-07-01T15:21:27.860 INFO (pid:641633) [attach] - receive notification: rename []
2021-07-01T15:21:31.866 INFO (pid:641633) [attach] - receive notification: highlight []
2021-07-01T15:21:37.869 WARN (pid:641633) [plugin] - Slow action "highlight" cost 6002ms
2021-07-01T15:21:43.184 INFO (pid:641633) [attach] - receive notification: rename []
2021-07-01T15:21:49.544 INFO (pid:641633) [attach] - receive notification: rename []
2021-07-01T15:21:57.936 INFO (pid:641633) [attach] - receive notification: showInfo []
2021-07-01T15:22:01.982 INFO (pid:641633) [attach] - receive notification: highlight []
2021-07-01T15:22:18.077 INFO (pid:641633) [attach] - receive notification: highlight []
2021-07-01T15:22:52.241 INFO (pid:641633) [completion-complete] - Results from: around
2021-07-01T15:22:53.361 INFO (pid:641633) [attach] - receive notification: startCompletion [
  {                                                                    
    word: '',
    bufnr: 1,                            
    col: 6,                       
    synname: '',
    filepath: '/home/zeenix/checkout/smol-rs/async-broadcast/src/lib.rs',
    blacklist: [],                                                     
    line: '    s.',
    filetype: 'rust',                         
    linenr: 160,                              
    input: '',                                                
    colnr: 7,                                                 
    changedtick: 8
  }          
]                                                                 
2021-07-01T15:22:53.737 INFO (pid:641633) [attach] - receive notification: startCompletion [
  {  
    word: '',                                   
    bufnr: 1,                                    
    col: 6,                
    synname: '',             
    filepath: '/home/zeenix/checkout/smol-rs/async-broadcast/src/lib.rs',
    blacklist: [],                      
    line: '    s.',          
    filetype: 'rust',      
    linenr: 160,               
    input: '',                
    colnr: 7,                       
    changedtick: 8                  
  }          
]    
2021-07-01T15:22:54.243 WARN (pid:641633) [plugin] - Slow action "startCompletion" cost 505ms
2021-07-01T15:22:58.037 INFO (pid:641633) [attach] - receive notification: startCompletion [
  {        
    word: 'try',
    bufnr: 1,              
    col: 6,        
    synname: '',           
    filepath: '/home/zeenix/checkout/smol-rs/async-broadcast/src/lib.rs',
    blacklist: [],                  
    line: '    s.try',      
    filetype: 'rust',
    linenr: 160,
    input: 'try',
    colnr: 10,
    changedtick: 11
  }                   
]                     
2021-07-01T15:22:58.401 INFO (pid:641633) [attach] - receive notification: startCompletion [
  {                                                                                                      
    word: 'try',                                                                                         
    bufnr: 1,            
    col: 6,                    
    synname: '',                        
    filepath: '/home/zeenix/checkout/smol-rs/async-broadcast/src/lib.rs',
    blacklist: [],         
    line: '    s.try',         
    filetype: 'rust',   
    linenr: 160,
    input: 'try',        
    colnr: 10,
    changedtick: 11                                             
  }                      
]       
2021-07-01T15:22:58.769 INFO (pid:641633) [attach] - receive notification: startCompletion [
  {                      
    word: 'try',
    bufnr: 1,
    col: 6,            
    synname: '',                                                     
    filepath: '/home/zeenix/checkout/smol-rs/async-broadcast/src/lib.rs',
    blacklist: [],
    line: '    s.try',
    filetype: 'rust',
    linenr: 160,
    input: 'try',
    colnr: 10,
    changedtick: 11
  }
]
2021-07-01T15:22:59.274 INFO (pid:641633) [completion-complete] - Results from: around
2021-07-01T15:22:59.276 WARN (pid:641633) [plugin] - Slow action "startCompletion" cost 506ms

Could it be that rust-analyzer is too slow for coc and coc just ignores it's result/times out?

@fannheyward
Copy link
Owner

  1. Set rust-analyzer.trace.server to verbose
  2. Launch vim with rust files
  3. :CocCommand, select workspace showOutput, select rust-analyzer
  4. What's the logs? Any errors?

@fannheyward
Copy link
Owner

What's the output of :CocCommand rust-analyzer.serverVersion?

@zeenix
Copy link
Author

zeenix commented Jul 1, 2021

  • Set rust-analyzer.trace.server to verbose

  • Launch vim with rust files

  • :CocCommand, select workspace showOutput, select rust-analyzer

  • What's the logs? Any errors?

Thanks. Yes, seems there is a crash:

thread '<unnamed>' panicked at 'Internal error, cycle detected:

DatabaseKeyIndex { group_index: 7, query_index: 11, key_index: 680 }
DatabaseKeyIndex { group_index: 7, query_index: 9, key_index: 62 }
', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.16.0/src/lib.rs:490:48
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
   1: std::panicking::begin_panic_fmt
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:437:5
   2: salsa::QueryTable<Q>::get::{{closure}}
   3: <DB as hir_ty::db::HirDatabase>::generic_defaults::__shim
   4: <DB as hir_ty::db::HirDatabase>::generic_defaults
   5: hir_ty::lower::substs_from_path_segment
   6: hir_ty::lower::<impl hir_ty::TraitRef>::from_resolved_path
   7: hir_ty::lower::<impl hir_ty::TraitRef>::from_path
   8: hir_ty::lower::<impl hir_ty::GenericPredicate>::from_type_bound
   9: hir_ty::lower::<impl hir_ty::GenericPredicate>::from_where_predicate
  10: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
  11: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
  12: <hir_ty::db::GenericPredicatesForParamQuery as salsa::plumbing::QueryFunction>::execute
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::read
  16: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  17: <DB as hir_ty::db::HirDatabase>::generic_predicates_for_param::__shim
  18: <DB as hir_ty::db::HirDatabase>::generic_predicates_for_param
  19: hir_ty::utils::all_super_trait_refs
  20: hir_ty::utils::associated_type_by_name_including_super_traits
  21: hir_ty::lower::<impl hir_ty::Ty>::from_partly_resolved_hir_path
  22: hir_ty::lower::<impl hir_ty::Ty>::from_hir_ext
  23: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  24: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
  25: <hir_ty::db::GenericDefaultsQuery as salsa::plumbing::QueryFunction>::execute
  26: salsa::runtime::Runtime::execute_query_implementation
  27: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  28: salsa::derived::slot::Slot<Q,MP>::read
  29: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  30: <DB as hir_ty::db::HirDatabase>::generic_defaults::__shim
  31: <DB as hir_ty::db::HirDatabase>::generic_defaults
  32: hir_ty::lower::substs_from_path_segment
  33: hir_ty::lower::<impl hir_ty::TraitRef>::from_resolved_path
  34: hir_ty::lower::<impl hir_ty::TraitRef>::from_path
  35: <hir_ty::db::ImplTraitQuery as salsa::plumbing::QueryFunction>::execute
  36: salsa::runtime::Runtime::execute_query_implementation
  37: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  38: salsa::derived::slot::Slot<Q,MP>::read
  39: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  40: <DB as hir_ty::db::HirDatabase>::impl_trait::__shim
  41: <DB as hir_ty::db::HirDatabase>::impl_trait
  42: hir_ty::method_resolution::TraitImpls::trait_impls_in_crate_query
  43: salsa::runtime::Runtime::execute_query_implementation
  44: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  45: salsa::derived::slot::Slot<Q,MP>::read
  46: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  47: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate::__shim
  48: hir_ty::method_resolution::TraitImpls::trait_impls_in_deps_query
  49: salsa::runtime::Runtime::execute_query_implementation
  50: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  51: salsa::derived::slot::Slot<Q,MP>::read
  52: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  53: <DB as hir_ty::db::HirDatabase>::trait_impls_in_deps::__shim
  54: hir_ty::traits::chalk::<impl chalk_solve::RustIrDatabase<hir_ty::traits::chalk::interner::Interner> for hir_ty::traits::ChalkContext>::impls_for_trait
  55: chalk_solve::clauses::program_clauses_for_goal
  56: <chalk_recursive::recursive::Solver<I> as chalk_recursive::solve::SolveDatabase<I>>::solve_goal
  57: <chalk_recursive::recursive::RecursiveSolver<I> as chalk_solve::solve::Solver<I>>::solve_limited
  58: hir_ty::traits::solve::{{closure}}
  59: hir_ty::traits::trait_solve_query
  60: salsa::runtime::Runtime::execute_query_implementation
  61: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  62: salsa::derived::slot::Slot<Q,MP>::read
  63: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  64: salsa::QueryTable<Q>::get
  65: <DB as hir_ty::db::HirDatabase>::trait_solve::__shim
  66: <DB as hir_ty::db::HirDatabase>::trait_solve
  67: hir_ty::autoderef::deref
  68: <core::iter::sources::Successors<T,F> as core::iter::traits::iterator::Iterator>::next
  69: core::iter::traits::iterator::Iterator::find_map
  70: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  71: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  72: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  73: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  74: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  75: hir_ty::infer::infer_query
  76: salsa::runtime::Runtime::execute_query_implementation
  77: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  78: salsa::derived::slot::Slot<Q,MP>::read
  79: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  80: <DB as hir_ty::db::HirDatabase>::infer_query::__shim
  81: hir_ty::db::infer_wait
  82: hir_ty::diagnostics::validate_body
  83: hir::code_model::Function::diagnostics
  84: hir::code_model::Module::diagnostics
  85: ide::diagnostics::diagnostics
  86: ide::Analysis::diagnostics
  87: rust_analyzer::handlers::publish_diagnostics
  88: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  89: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
  90: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Trace - 4:39:56 PM] Received response 'textDocument/semanticTokens/full - (1)' in 3131ms. Request failed: content modified (-32801).

What's the output of :CocCommand rust-analyzer.serverVersion?

[coc.nvim] rust-analyzer 60c501f

I guess now I can be confident about this being a rust-analyzer issue and report it there. :) Thanks so much!

@zeenix
Copy link
Author

zeenix commented Jul 1, 2021

I guess now I can be confident about this being a rust-analyzer issue and report it there. :) Thanks so much!

rust-lang/rust-analyzer#9442 (comment)

@zeenix zeenix closed this as completed Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants