Fix byte-compile warnings and correct minimum Emacs version#589
Fix byte-compile warnings and correct minimum Emacs version#589dannywillems wants to merge 3 commits into
Conversation
The `when-let` macro is obsolete as of Emacs 31.1, producing byte-compile warnings. Since the declared minimum is Emacs 25.1, `when-let*` cannot be used as a replacement because it was only introduced in Emacs 26.1. Rewrite the three usages in rust-prog-mode.el using `let` plus `when`, which is available on all supported Emacs versions and preserves the short-circuiting evaluation order of the original code.
Add a dedicated workflow that byte-compiles the package with `byte-compile-error-on-warn` enabled, so that any new byte-compile warning fails CI. It runs on the declared minimum (Emacs 25.1), the current stable (30.1), and the development snapshot. The treesitter integration file is only compiled on Emacs 29.1 and later, matching the runtime guard in rust-mode-treesitter.el. GitHub Actions are kept up to date by the existing dependabot configuration.
rust-cargo.el calls `file-local-name', which was introduced in Emacs 26.1, so the package cannot run on the previously declared minimum of Emacs 25.1. Update the Package-Requires header to 26.1, matching the oldest version actually exercised by the existing test matrix. Also require `subr-x' in rust-cargo.el for `string-trim'. It was only pulled in at compile time via rust-mode.el, leaving the symbol undefined at runtime and unknown to the byte-compiler on Emacs versions before 28, where subr-x is not preloaded. Set the byte-compile workflow minimum to 26.1 accordingly.
|
This is an automated effort to help maintaining packages in the Emacs community. See https://x.com/dwillems42/status/2060720730338185699 and https://dannywillems.github.io/emacs-package-maintenance/ |
Technically true as it uses let* instead of let. In practice it is a drop-in replacement in most of the cases. In the 3 instances in covered in this PR, when-let can be replaced with when-let*. Note that there is no Emacs 31, it hasn't been released yet. It will be soon as the release branch has been cut. So the warning happens only in unreleased versions of Emacs (ej. when running emacs from HEAD). Similarly for the CI change. The tool rust-mode uses for GitHub actions already supports treating warnings as errors (See https://emacs-eask.github.io/Getting-Started/Commands-and-options/#---strict). Instead of adding a new workflow that doesn't follow the same conventions of the other workflow we should update the existing workflow to compile with byte-compile-error-on-warn set to t. Note that emacs 26 was released in 2018. Not even debian bullseye has a version that old.https://packages.debian.org/search?keywords=emacs, if something doesn't work with emacs 26.1 it might be better to drop it from the supported versions. Don't know the maintainers feel about LLM-generated PRs, but it feels incredibly disrespectful to other people to other people to not even review the output of the LLMs for basic sanity checks before opening a PR. |
This PR resolves the byte-compile warnings emitted by rust-mode and
corrects the declared minimum Emacs version to match the features the
package actually uses. All changes are behaviour-preserving.
Fixes
Obsolete
when-letmacro (rust-prog-mode.el)when-letis obsolete as of Emacs 31.1 and emits a byte-compilewarning. Because the package supports older Emacs versions,
when-let*(introduced in Emacs 26.1) is not a drop-in replacement at the lowest
supported version. The three usages are rewritten using
letpluswhen, available on all supported versions, preserving the originalshort-circuiting evaluation order.
Incorrect minimum Emacs version
rust-cargo.el calls
file-local-name, introduced in Emacs 26.1, so thepackage never ran on the declared minimum of Emacs 25.1. The
Package-Requires header is updated to
((emacs "26.1")), matching theoldest version already exercised by the test matrix.
rust-cargo.el also uses
string-trimfrom subr-x, which was onlyrequired at compile time via rust-mode.el. On Emacs versions before 28
(where subr-x is not preloaded) this leaves the symbol undefined at
runtime and unknown to the byte-compiler. A runtime
(require 'subr-x)is added to rust-cargo.el.
CI
A new
byte-compile.ymlworkflow byte-compiles the package withbyte-compile-error-on-warnenabled, on the minimum (26.1), the currentstable (30.1), and the development snapshot, so new warnings fail CI.
The treesitter integration file is only compiled on Emacs 29.1 and
later, matching its runtime guard. GitHub Actions stay current via the
existing dependabot configuration.
Residual warnings
None. The package byte-compiles cleanly with warnings as errors on
Emacs 26.1, 30.1, and snapshot.