Skip to content

Commit 7c5de03

Browse files
committed
Fix dependencies between rust-mode implementations
"rust-prog-mode.el" and "rust-mode-treesitter.el" provide competing implementations of `rust-mode'. Both implementations depend on code in "rust-mode.el", and thus must require that. Doing that is complicated by the fact that "rust-mode.el" loads one of these libraries, depending on `rust-mode-treesitter-derive's value. Address this conflict by: 1. Requiring feature `rust-mode' in the two libraries that implement the `rust-mode' major-mode and that use things defined in "rust-mode.el". 2. Moving the require forms for these two libraries in "rust-mode.el", below the `provide' form for `rust-mode'.
1 parent 1ce4f8e commit 7c5de03

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Diff for: rust-mode-treesitter.el

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
;;; Code:
77

8+
(require 'rust-mode)
9+
10+
;; Do not compile or load on Emacs releases that don't support
11+
;; this. See https://github.com/rust-lang/rust-mode/issues/520.
812
(when (version<= "29.1" emacs-version)
9-
;; We have the when macro because of
10-
;; https://github.com/rust-lang/rust-mode/issues/520
1113
(require 'treesit)
1214
(require 'rust-ts-mode)
13-
(require 'rust-common)
1415

1516
(define-derived-mode rust-mode rust-ts-mode "Rust"
1617
"Major mode for Rust code.

Diff for: rust-mode.el

+6-4
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,19 @@ instead of `prog-mode'. This option requires emacs29+."
7171
map)
7272
"Keymap for Rust major mode.")
7373

74-
(if (and (version<= "29.1" emacs-version) rust-mode-treesitter-derive)
75-
(require 'rust-mode-treesitter)
76-
(require 'rust-prog-mode))
77-
7874
;;;###autoload
7975
(autoload 'rust-mode "rust-mode" "Major mode for Rust code." t)
8076

8177
;;;###autoload
8278
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
8379

8480
(provide 'rust-mode)
81+
82+
(if (and rust-mode-treesitter-derive
83+
(version<= "29.1" emacs-version))
84+
(require 'rust-mode-treesitter)
85+
(require 'rust-prog-mode))
86+
8587
(require 'rust-utils)
8688

8789
;;; rust-mode.el ends here

Diff for: rust-prog-mode.el

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
;; rust-mode code deriving from prog-mode instead of rust-ts-mode
55

66
;;; Code:
7-
(require 'rust-common)
7+
8+
(require 'rust-mode)
89

910
(defvar electric-pair-inhibit-predicate)
1011
(defvar electric-pair-skip-self)

0 commit comments

Comments
 (0)