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

Looking up definitions and implementations doesn't work #7863

Open
4 tasks done
upbqdn opened this issue May 17, 2024 · 6 comments · May be fixed by #7862
Open
4 tasks done

Looking up definitions and implementations doesn't work #7863

upbqdn opened this issue May 17, 2024 · 6 comments · May be fixed by #7862
Labels
is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet

Comments

@upbqdn
Copy link

upbqdn commented May 17, 2024

I confirm that...

  • I have searched the issue tracker, documentation, FAQ, Discourse, and Google, in case this issue has already been reported/resolved.

  • I have read "How to Debug Issues", and will use it to provide as much information about this issue as possible.

  • The issue can be reproduced on the latest available commit of Doom.

  • The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. (Unstable versions end in .50, .60, or .9x)

Expected behavior

In Rust, pressing g d should jump to the definition of the object under the cursor, and pressing SPC c i should bring up a list of implementations for the type under the cursor.

Current behavior

Pressing g d shows a list of strings matching the name of the thing under the cursor instead of jumping to its definition.

Pressing SPC c i with a cursor placed on type T returns "Couldn't find the implementations of T" with the following backtrace:

Debugger entered--Lisp error: (wrong-number-of-arguments #<subr xref--group-name-for-display> 2)
  xref--group-name-for-display("/.../frost/frost-core/src/frost.rs" "/.../frost/")
  #f(compiled-function (xref) #<bytecode -0x10e25c9957e3de55>)(#s(xref-item :summary #("#[derive(Clone)]" 0 1 (face font-lock-preprocessor-face fontified t) 1 2 (face (rainbow-delimiters-depth-1-face font-lock-preprocessor-face) fontified t) 2 8 (face font-lock-preprocessor-face fontified t) 8 9 (face (rainbow-delimiters-depth-2-face font-lock-preprocessor-face) fontified t) 9 14 (face (font-lock-preprocessor-face xref-match) fontified t) 14 15 (face (rainbow-delimiters-depth-2-face font-lock-preprocessor-face) fontified t) 15 16 (face (rainbow-delimiters-depth-1-face font-lock-preprocessor-face) fontified t)) :location #s(xref-file-location :file "/home/m/zcash/frost/frost-core/src/frost.rs" :line 71 :column 9)))
  consult-xref--candidates()
  consult-xref(#f(compiled-function (&rest _) #<bytecode 0xb8b83b8f4f0bd24>) ((window . #<window 3 on frost.rs>) (display-action) (auto-jump)))
  lsp-show-xrefs((#s(xref-item :summary #("#[derive(Clone)]" 0 1 (face font-lock-preprocessor-face fontified t) 1 2 (face (rainbow-delimiters-depth-1-face font-lock-preprocessor-face) fontified t) 2 8 (face font-lock-preprocessor-face fontified t) 8 9 (face (rainbow-delimiters-depth-2-face font-lock-preprocessor-face) fontified t) 9 14 (face (font-lock-preprocessor-face xref-match) fontified t) 14 15 (face (rainbow-delimiters-depth-2-face font-lock-preprocessor-face) fontified t) 15 16 (face (rainbow-delimiters-depth-1-face font-lock-preprocessor-face) fontified t)) :location #s(xref-file-location :file "/home/m/zcash/frost/frost-core/src/frost.rs" :line 71 :column 9)) #s(xref-item :summary #("impl<C> BindingFactorList<C>" 0 4 (face font-lock-keyword-face fontified t) 4 5 (face (rainbow-delimiters-depth-1-face) fontified t) 5 6 (face font-lock-type-face fontified t) 6 7 (face (rainbow-delimiters-depth-1-face) fontified t) 7 8 (fontified t) 8 25 (face (font-lock-type-face xref-match) fontified t) 25 26 (face (rainbow-delimiters-depth-1-face xref-match) fontified t) 26 27 (face (font-lock-type-face xref-match) fontified t) 27 28 (face (rainbow-delimiters-depth-1-face xref-match) fontified t)) :location #s(xref-file-location :file "/home/m/zcash/frost/frost-core/src/frost.rs" :line 74 :column 8)) #s(xref-item :summary #("impl<C> Index<Identifier<C>> for BindingFactorList..." 0 4 (face font-lock-keyword-face fontified t) 4 5 (face (rainbow-delimiters-depth-1-face) fontified t) 5 6 (face font-lock-type-face fontified t) 6 7 (face (rainbow-delimiters-depth-1-face) fontified t) 7 8 (fontified t) 8 13 (face font-lock-type-face fontified t) 13 14 (face (rainbow-delimiters-depth-1-face) fontified t) 14 24 (face font-lock-type-face fontified t) 24 25 (face (rainbow-delimiters-depth-2-face) fontified t) 25 26 (face font-lock-type-face fontified t) 26 27 (face (rainbow-delimiters-depth-2-face) fontified t) 27 28 (face (rainbow-delimiters-depth-1-face) fontified t) 28 29 (fontified t) 29 32 (face font-lock-keyword-face fontified t) 32 33 (fontified t) 33 50 (face (font-lock-type-face xref-match) fontified t) ...) :location #s(xref-file-location :file "/home/m/zcash/frost/frost-core/src/frost.rs" :line 90 :column 33))) nil t)
  lsp-find-locations("textDocument/implementation" nil :display-action nil :references? t)
  lsp-find-implementation()
  funcall-interactively(lsp-find-implementation)
  call-interactively(lsp-find-implementation)
  (if (commandp handler) (call-interactively handler) (funcall handler identifier))
  +lookup--run-handler(lsp-find-implementation #("BindingFactorList" 0 17 (identifier-at-point t face font-lock-type-face fontified t)))
  (condition-case e (+lookup--run-handler handler identifier) ((debug error) (if doom-inhibit-log nil (doom--log "Lookup handler %S threw an error: %s" handler e)) 'fail))
  (let ((wconf (current-window-configuration)) (result (condition-case e (+lookup--run-handler handler identifier) ((debug error) (if doom-inhibit-log nil (doom--log "Lookup handler %S threw an error: %s" handler e)) 'fail)))) (cond ((eq result 'fail) (set-window-configuration wconf) nil) ((or (get handler '+lookup-async) (eq result 'deferred))) ((or result (null origin) (/= (point-marker) origin)) (prog1 (point-marker) (set-window-configuration wconf)))))
  (condition-case e (let ((wconf (current-window-configuration)) (result (condition-case e (+lookup--run-handler handler identifier) ((debug error) (if doom-inhibit-log nil (doom--log "Lookup handler %S threw an error: %s" handler e)) 'fail)))) (cond ((eq result 'fail) (set-window-configuration wconf) nil) ((or (get handler '+lookup-async) (eq result 'deferred))) ((or result (null origin) (/= (point-marker) origin)) (prog1 (point-marker) (set-window-configuration wconf))))) ((debug error user-error) (message "Lookup handler %S: %s" handler e) nil))
  +lookup--run-handlers(lsp-find-implementation #("BindingFactorList" 0 17 (identifier-at-point t face font-lock-type-face fontified t)) #<marker at 2140 in frost.rs>)
  run-hook-wrapped(+lookup--run-handlers lsp-find-implementation #("BindingFactorList" 0 17 (identifier-at-point t face font-lock-type-face fontified t)) #<marker at 2140 in frost.rs>)
  (if arg (let* ((handler (and t (intern-soft (completing-read "Select lookup handler: " (delete-dups ...) nil t))))) (if handler (+lookup--run-handlers handler identifier origin) (user-error "No lookup handler selected"))) (run-hook-wrapped handlers #'+lookup--run-handlers identifier origin))
  (let* ((origin (point-marker)) (handlers (plist-get (list :definition '+lookup-definition-functions :implementations '+lookup-implementations-functions :type-definition '+lookup-type-definition-functions :references '+lookup-references-functions :documentation '+lookup-documentation-functions :file '+lookup-file-functions) prop)) (result (if arg (let* ((handler (and t ...))) (if handler (+lookup--run-handlers handler identifier origin) (user-error "No lookup handler selected"))) (run-hook-wrapped handlers #'+lookup--run-handlers identifier origin)))) (unwind-protect (if (cond ((null result) (message "No lookup handler could find %S" identifier) nil) ((markerp result) (funcall (or display-fn #'switch-to-buffer) (marker-buffer result)) (goto-char result) result) (result)) (progn (save-current-buffer (set-buffer (marker-buffer origin)) (better-jumper-set-jump (marker-position origin))) result)) (set-marker origin nil)))
  +lookup--jump-to(:implementations #("BindingFactorList" 0 17 (identifier-at-point t face font-lock-type-face fontified t)) nil nil)
  (cond ((null identifier) (user-error "Nothing under point")) ((+lookup--jump-to :implementations identifier nil arg)) ((user-error "Couldn't find the implementations of %S" (substring-no-properties identifier))))
  +lookup/implementations(#("BindingFactorList" 0 17 (identifier-at-point t face font-lock-type-face fontified t)) nil)
  funcall-interactively(+lookup/implementations #("BindingFactorList" 0 17 (identifier-at-point t face font-lock-type-face fontified t)) nil)
  command-execute(+lookup/implementations)

Steps to reproduce

  1. Install fresh Doom.
  2. Enable lsp (or (lsp +eglot)) and (rust +lsp).
  3. Open a Rust project.
  4. Navigate the cursor to a suitable type and press g d or SPC c i.

System Information

https://pastebin.com/21ua6bpy

@upbqdn upbqdn added is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet labels May 17, 2024
@sincebyte
Copy link

sincebyte commented May 17, 2024

same with the issue in java project

@kilesduli
Copy link

this issue seems related to #7862.

@sincebyte
Copy link

this issue seems related to #7862.

(unpin! consult)

The issue disappeared

@upbqdn upbqdn linked a pull request May 17, 2024 that will close this issue
3 tasks
@upbqdn upbqdn changed the title Looking up definitions and implementations in Rust doesn't work Looking up definitions and implementations doesn't work May 17, 2024
@dmcardle
Copy link

Setting (unpin! consult) also did the trick for me — now I can jump to definitions again in an eglot/clangd project.

Of course, I had to run doom upgrade first to upgrade consult. Based on the upgrade output, I guess it must be one of these upstream commits that fixed the issue: minad/consult@c87b0bf...21d87b9

@upbqdn
Copy link
Author

upbqdn commented May 17, 2024

If the solution mentioned above is not clear to anyone:

  1. Place (unpin! consult) in your packages.el.
  2. Run either doom upgrade or doom sync -u.

@raszi
Copy link
Contributor

raszi commented May 28, 2024

It was the same issue with Clojure, unpinning the consult package solved the problem as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:bug Something isn't working as intended needs-triage Issue hasn't been assessed yet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

5 participants