Subject: 30.0.50; [BUG] Rust eglot tuple struct field completion

From: Ruijie Yu <[email-masked]>
Date: Tue, 21 Mar 2023 10:33:48 +0800

I can't word it, so let me explain via an example.  The Emacs in
question was built a few days ago, FTR.

Also, note that I am using rust-ts-mode as the major mode, since
it is the only builtin rust major mode, with the corresponding grammar
lib cloned and built moments ago.

$ cd "$(mktemp -d)"
$ cargo init --name foo --lib
$ emacs -Q src/lib.rs

Replace src/lib.rs with the following content, then revert buffer and
run `eglot':

--8<---------------cut here---------------start------------->8---
//  -*- mode: rust-ts; -*-
/// 0..=10
#[derive(Default)]
struct Foo(u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32);

fn foo(f: Foo) -> u32 {
    f.
}
--8<---------------cut here---------------end--------------->8---

Put point after "f.", and type any number between (inclusive) 0 and 10,
and type TAB.  Observe that the number is repeated.  This even happens
with 1, where I expect to have "10" as a completion candidate.

I use a rather large tuple struct in this example because I want to
demonstrate that this issue should be happening for all magnitude of
tuple indices, not just a single digit.

--8<---------------cut here---------------start------------->8---
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.37, cairo version 1.17.8) of 2023-03-11 built on fw.net.yu
Repository revision: c6bfffa9fe1af7f4f806e5533ba5f3c33476cf9a
Repository branch: master
System Description: Arch Linux

Configured using:
 'configure --with-pgtk'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PGTK
PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=fcitx
  locale-coding-system: utf-8-unix

Major mode: Rust

Minor modes in effect:
  eglot-inlay-hints-mode: t
  eglot--managed-mode: t
  flymake-mode: t
  text-scale-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils time-date cl-extra eglot external-completion array
filenotify jsonrpc ert pp ewoc debug backtrace find-func xref
flymake-proc flymake warnings icons compile text-property-search comint
ansi-osc ansi-color ring url-util url-parse auth-source eieio eieio-core
cl-macs password-cache json subr-x map url-vars project byte-opt gv
bytecomp byte-compile imenu pcase rust-ts-mode rx c-ts-common treesit
cl-seq thingatpt help-fns radix-tree help-mode files-x format-spec
face-remap vc-git diff-mode easy-mmode vc-dispatcher cl-loaddefs cl-lib
rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win
term/common-win pgtk-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo gtk pgtk lcms2 multi-tty make-network-process
emacs)
--8<---------------cut here---------------end--------------->8---

--
Best,

RY