 
 ;;; Imenu support
 (defvar rust-imenu-generic-expression
-  (append (loop for item in
-                '("enum" "struct" "type" "mod" "fn" "trait")
-                collect `(nil ,(rust-re-item-def item) 1))
+  (append (mapcar #'(lambda (x)
+                      (list nil (rust-re-item-def x) 1))
+                  '("enum" "struct" "type" "mod" "fn" "trait"))
           `(("Impl" ,(rust-re-item-def "impl") 1)))
   "Value for `imenu-generic-expression' in Rust mode.
 
 Create a flat index of the item definitions in a Rust file.
 
 Imenu will show all the enums, structs, etc. at the same level.
-Implementations will be shown under the `Impl` subheading.
-Use idomenu (imenu with ido-mode) for best mileage.")
+Implementations will be shown under the `Impl` subheading.  Use
+idomenu (imenu with `ido-mode') for best mileage.")
 
 ;;; Defun Motions
 

(define-derived-mode rust-mode rust-parent-mode "Rust"
  "Major mode for Rust code."
  :group 'rust-mode

  ;; Basic syntax
  (set-syntax-table rust-mode-syntax-table)

  ;; Indentation
  (set (make-local-variable 'indent-line-function)
       'rust-mode-indent-line)

  ;; Fonts
  (set (make-local-variable 'font-lock-defaults)
       '(rust-mode-font-lock-keywords nil nil nil nil))

  ;; Misc
  (set (make-local-variable 'comment-start) "// ")
  (set (make-local-variable 'comment-end)   "")
  (set (make-local-variable 'indent-tabs-mode) nil)

  ;; Allow paragraph fills for comments
  (set (make-local-variable 'comment-start-skip)
       "\\(?://[/!]*\\|/\\*[*!]?\\)[[:space:]]*")
  (set (make-local-variable 'paragraph-start)
       (concat "[[:space:]]*\\(?:" comment-start-skip "\\|\\*/?[[:space:]]*\\|\\)$"))
  (set (make-local-variable 'paragraph-separate) paragraph-start)
  (set (make-local-variable 'normal-auto-fill-function) 'rust-do-auto-fill)
  (set (make-local-variable 'fill-paragraph-function) 'rust-fill-paragraph)
  (set (make-local-variable 'fill-forward-paragraph-function) 'rust-fill-forward-paragraph)
  (set (make-local-variable 'adaptive-fill-function) 'rust-find-fill-prefix)
  (set (make-local-variable 'comment-multi-line) t)
  (set (make-local-variable 'comment-line-break-function) 'rust-comment-indent-new-line)
  (set (make-local-variable 'imenu-generic-expression) rust-imenu-generic-expression)
  (set (make-local-variable 'beginning-of-defun-function) 'rust-beginning-of-defun)
  (set (make-local-variable 'end-of-defun-function) 'rust-end-of-defun)
  )


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

(defun rust-mode-reload ()
  (interactive)
  (unload-feature 'rust-mode)
  (require 'rust-mode)
  (rust-mode))

(provide 'rust-mode)

;; Issue #6887: Rather than inheriting the 'gnu compilation error
;; regexp (which is broken on a few edge cases), add our own 'rust

      (concat "^\\s-*\\(?:priv\\|pub\\)?\\s-*"
              (regexp-opt
               '("enum" "struct" "type" "mod" "use" "fn" "static" "impl"
                 "extern" "impl" "static" "trait"))))

(defun rust-beginning-of-defun (&optional arg)
  "Move backward to the beginning of the current defun.
