rust-analyzer: Auto-completion doesn't find suggestions with trait-heavy code (e.g. gtk-rs)
For example when taking the example directly from https://gtk-rs.org and typing window.set in the connect_activate() closure, only the functions that are already used in scope (set_title(), set_default_size()) are suggested.
However gtk::ApplicationWindow impls glib::IsA<gtk::Widget> (and various others), via which it is covered by the impl<T: IsA<gtk::Widget>> gtk::WidgetExt for T { ... } blanket impl, which provides lots of other set_... functions.
Maybe the indirection via the IsA trait and the blanket impl is the problem here?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (7 by maintainers)
After #4220 ,
is_writable()is visible forMessagenow.And I just checked, for the case of
gtk::ApplicationWindow:So I think this issue could be closed ?
Thanks for the information! Yes, it is expected. RA should translate it to def-site crate name in lowering. However, it seem like there is some bugs around path resolution for
$cratein associate type, here is a minimal reproducible example :Sure, but that macro is a bit more complicated 😄
glib_wrapper!is defined here . These and the cases below are the ones used for actual objects withIsA. They map toglib_object_wrapper!IsAimpls. There will be one for each parent type and interface that is implemented by a type (e.g.gtk::Buttoninherits among other things fromgtk::Widgetandglib::Objectso there would beIsA<gtk::Widget>andIsA<glib::Object>impls).IsAtrait is defined here and has various super traits that also all come from the same fileT: ObjectTypeinstead ofT: IsA<Object>for reasons I can’t remember, but usually that would beT: IsA<Object>. See for example here forgtk::Button. That’s how methods of parent types are automatically available on sub types, i.e. how one part of OOP inheritance is modeled here.If you have more questions please just ask 😃