GNU bug report logs - #79272
[PATCH] rust-ts-mode: handle invalid rust syntax without signaling

Previous Next

Package: emacs;

Reported by: Steven Allen <steven <at> stebalien.com>

Date: Tue, 19 Aug 2025 18:34:01 UTC

Severity: normal

Tags: patch

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

To reply to this bug, email your comments to 79272 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to dev <at> rjt.dev, juri <at> linkov.net, bug-gnu-emacs <at> gnu.org:
bug#79272; Package emacs. (Tue, 19 Aug 2025 18:34:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Steven Allen <steven <at> stebalien.com>:
New bug report received and forwarded. Copy sent to dev <at> rjt.dev, juri <at> linkov.net, bug-gnu-emacs <at> gnu.org. (Tue, 19 Aug 2025 18:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Steven Allen <steven <at> stebalien.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] rust-ts-mode: handle invalid rust syntax without signaling
Date: Tue, 19 Aug 2025 11:32:49 -0700
[Message part 1 (text/plain, inline)]
Tags: patch


Avoid signaling an error when encountering invalid rust syntax. The
signaled error would never be propagated to the user (caught somewhere
in the fontlocking logic, I think) but it would prevent a portion of the
buffer from being fontified.

Notes:

1. I encountered  this error in `rust-ts-mode--fontify-pattern' (and
reproduced it in the attached test). I applied the same fix to
`rust-ts-mode--fontify-scope' to be safe, but I couldn't actually
reproduce an issue there.
2. `treesit-node-parent' and `treesit-node-type' will blindly forward
nil so there's no issue calling (treesit-node-type (treesit-node-parent
node)) even if `node' has no parent.

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, cairo version
 1.18.4) of 2025-08-16 built on Laptop
Repository revision: 68657c30983afe745f9667a0c42bdf6dd7ed4890
Repository branch: merged
Windowing system distributor 'The X.Org Foundation', version 11.0.12101018
System Description: Arch Linux

Configured using:
 'configure
 'CPPFLAGS=-I/run/user/1000/build/emacs-git/src/mps-git/build/include '
 'LDFLAGS=-L/run/user/1000/build/emacs-git/src/mps-git/build/lib -Wl,-O1
 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now
 -Wl,-z,pack-relative-relocs -flto=auto' --prefix=/usr --sysconfdir=/etc
 --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man
 --with-gameuser=:games --with-modules --without-m17n-flt
 --without-selinux --without-pop --without-gconf --disable-gc-mark-trace
 --with-mps=yes --enable-link-time-optimization
 --with-native-compilation=yes --with-xinput2 --with-x-toolkit=no
 --without-toolkit-scroll-bars --without-xaw3d --without-gsettings
 --with-cairo-xcb --without-xft --with-sound=no --with-tree-sitter
 --without-gpm --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=native -mtune=native -O3 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -fomit-frame-pointer
 -fno-math-errno -fno-trapping-math -fno-math-errno -fno-trapping-math
 -flto=auto''

[0001-rust-ts-mode-handle-invalid-rust-syntax-without-sign.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79272; Package emacs. (Thu, 21 Aug 2025 17:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 79272 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Steven Allen <steven <at> stebalien.com>
Cc: Randy Taylor <dev <at> rjt.dev>, 79272 <at> debbugs.gnu.org
Subject: Re: bug#79272: [PATCH] rust-ts-mode: handle invalid rust syntax
 without signaling
Date: Thu, 21 Aug 2025 20:00:06 +0300
close 79272 31.0.50
thanks

> Avoid signaling an error when encountering invalid rust syntax. The
> signaled error would never be propagated to the user (caught somewhere
> in the fontlocking logic, I think) but it would prevent a portion of the
> buffer from being fontified.
>
> Notes:
>
> 1. I encountered  this error in `rust-ts-mode--fontify-pattern' (and
> reproduced it in the attached test). I applied the same fix to
> `rust-ts-mode--fontify-scope' to be safe, but I couldn't actually
> reproduce an issue there.
> 2. `treesit-node-parent' and `treesit-node-type' will blindly forward
> nil so there's no issue calling (treesit-node-type (treesit-node-parent
> node)) even if `node' has no parent.

I couldn't even read your patch without signaling an error :-)

But after applying it as a plain file, the test file opens correctly,
so now pushed.  Thanks.




bug marked as fixed in version 31.0.50, send any further explanations to 79272 <at> debbugs.gnu.org and Steven Allen <steven <at> stebalien.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Thu, 21 Aug 2025 17:02:03 GMT) Full text and rfc822 format available.

This bug report was last modified 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.