From ebbdd946fb932df14dbfa42113feb7993db4fa1a Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Sat, 20 Nov 2021 16:24:09 +0800 Subject: [PATCH 01/19] rustic-babel: fix cargo run --example detect crate root(#319) --- rustic-cargo.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/rustic-cargo.el b/rustic-cargo.el index 3c6a6e5f..4ffbceba 100644 --- a/rustic-cargo.el +++ b/rustic-cargo.el @@ -478,16 +478,18 @@ When calling this function from `rustic-popup-mode', always use the value of (car compile-history))) (defun rustic-cargo-run-get-relative-example-name () - "Run 'cargo run --example' if current buffer within a 'examples' directory." - (if rustic--buffer-workspace - (let ((relative-filenames - (split-string (file-relative-name buffer-file-name rustic--buffer-workspace) "/"))) - (if (string= "examples" (car relative-filenames)) - (let ((size (length relative-filenames))) - (cond ((eq size 2) (file-name-sans-extension(nth 1 relative-filenames))) ;; examples/single-example1.rs - ((> size 2) (car (nthcdr (- size 2) relative-filenames))) ;; examples/example2/main.rs - (t nil))) nil)) - nil)) + "Run 'cargo run --example' if current buffer within a 'exmaples' directory. +In rust, examples normally runs within single crate or a project member within workspaces." + (let* ((buffer-project-root (rustic-buffer-crate)) + (relative-filenames + (if buffer-project-root + (split-string (file-relative-name buffer-file-name buffer-project-root) "/") + nil))) + (if (and relative-filenames (string= "examples" (car relative-filenames))) + (let ((size (length relative-filenames))) + (cond ((eq size 2) (file-name-sans-extension(nth 1 relative-filenames))) ;; examples/single-example1.rs + ((> size 2) (car (nthcdr (- size 2) relative-filenames))) ;; examples/example2/main.rs + (t nil))) nil))) ;;;###autoload (defun rustic-run-shell-command (&optional arg) From a050f77e77bcc0d3244fa5b5f2c800487cbdcb6f Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Sat, 20 Nov 2021 23:56:35 +0800 Subject: [PATCH 02/19] rustic-cargo: fix buffer crate root(#319) --- rustic-cargo.el | 9 ++++----- rustic.el | 11 +++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/rustic-cargo.el b/rustic-cargo.el index 4ffbceba..b5016925 100644 --- a/rustic-cargo.el +++ b/rustic-cargo.el @@ -480,15 +480,14 @@ When calling this function from `rustic-popup-mode', always use the value of (defun rustic-cargo-run-get-relative-example-name () "Run 'cargo run --example' if current buffer within a 'exmaples' directory. In rust, examples normally runs within single crate or a project member within workspaces." - (let* ((buffer-project-root (rustic-buffer-crate)) + (let* ((buffer-project-root (rustic-buffer-project)) (relative-filenames (if buffer-project-root - (split-string (file-relative-name buffer-file-name buffer-project-root) "/") - nil))) + (split-string (file-relative-name buffer-file-name buffer-project-root) "/") nil))) (if (and relative-filenames (string= "examples" (car relative-filenames))) (let ((size (length relative-filenames))) - (cond ((eq size 2) (file-name-sans-extension(nth 1 relative-filenames))) ;; examples/single-example1.rs - ((> size 2) (car (nthcdr (- size 2) relative-filenames))) ;; examples/example2/main.rs + (cond ((eq size 2) (file-name-sans-extension (nth 1 relative-filenames))) ;; examples/single-example1.rs + ((> size 2) (car (nthcdr (- size 2) relative-filenames))) ;; examples/example2/main.rs (t nil))) nil))) ;;;###autoload diff --git a/rustic.el b/rustic.el index 620c69ad..b26818d4 100644 --- a/rustic.el +++ b/rustic.el @@ -75,6 +75,17 @@ (dir (file-name-directory (cdr (assoc-string "root" output))))) (setq rustic--buffer-workspace dir)))))) +(defun rustic-buffer-project () + "Locate project(crate) root." + (with-temp-buffer + (let ((ret (call-process rustic-cargo-bin nil t nil "locate-project"))) + (when (/= ret 0) + (error "`cargo locate-project' returned %s status: %s" ret (buffer-string))) + (goto-char 0) + (let* ((output (json-read)) + (dir (cdr (assoc-string "root" output)))) + (file-name-directory (directory-file-name dir)))))) + (defun rustic-buffer-crate (&optional nodefault) "Return the crate for the current buffer. When called outside a Rust project, then return `default-directory', From 7996522d592875d537dd027436d715cf91002ee1 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Wed, 1 Dec 2021 16:53:36 +0800 Subject: [PATCH 03/19] rustic-babel: add allow unused, fix typo --- rustic-babel.el | 2 +- rustic-cargo.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rustic-babel.el b/rustic-babel.el index 6cb9830e..52306f26 100644 --- a/rustic-babel.el +++ b/rustic-babel.el @@ -364,7 +364,7 @@ kill the running process." (let ((default-directory dir) (toolchain (cdr (assq :toolchain params)))) (write-region - (concat "#![allow(non_snake_case)]\n" + (concat "#![allow(non_snake_case, unused)]\n" (if use-blocks (rustic-babel-insert-mod use-blocks) "") (if include-blocks (rustic-babel-include-blocks include-blocks) "") (if wrap-main (rustic-babel-ensure-main-wrap body) body)) diff --git a/rustic-cargo.el b/rustic-cargo.el index b5016925..a742b1e1 100644 --- a/rustic-cargo.el +++ b/rustic-cargo.el @@ -478,7 +478,7 @@ When calling this function from `rustic-popup-mode', always use the value of (car compile-history))) (defun rustic-cargo-run-get-relative-example-name () - "Run 'cargo run --example' if current buffer within a 'exmaples' directory. + "Run 'cargo run --example' if current buffer within a 'examples' directory. In rust, examples normally runs within single crate or a project member within workspaces." (let* ((buffer-project-root (rustic-buffer-project)) (relative-filenames From 1a8bc7d21441630ef586f95ca4b2e9636c4663b3 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Sat, 15 Jan 2022 11:26:40 +0800 Subject: [PATCH 04/19] fix: rm rustic-buffer-project --- rustic-cargo.el | 5 ++--- rustic.el | 11 ----------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/rustic-cargo.el b/rustic-cargo.el index a742b1e1..ed80453a 100644 --- a/rustic-cargo.el +++ b/rustic-cargo.el @@ -478,9 +478,8 @@ When calling this function from `rustic-popup-mode', always use the value of (car compile-history))) (defun rustic-cargo-run-get-relative-example-name () - "Run 'cargo run --example' if current buffer within a 'examples' directory. -In rust, examples normally runs within single crate or a project member within workspaces." - (let* ((buffer-project-root (rustic-buffer-project)) + "Run 'cargo run --example' if current buffer within a 'examples' directory." + (let* ((buffer-project-root (rustic-buffer-crate)) (relative-filenames (if buffer-project-root (split-string (file-relative-name buffer-file-name buffer-project-root) "/") nil))) diff --git a/rustic.el b/rustic.el index b26818d4..620c69ad 100644 --- a/rustic.el +++ b/rustic.el @@ -75,17 +75,6 @@ (dir (file-name-directory (cdr (assoc-string "root" output))))) (setq rustic--buffer-workspace dir)))))) -(defun rustic-buffer-project () - "Locate project(crate) root." - (with-temp-buffer - (let ((ret (call-process rustic-cargo-bin nil t nil "locate-project"))) - (when (/= ret 0) - (error "`cargo locate-project' returned %s status: %s" ret (buffer-string))) - (goto-char 0) - (let* ((output (json-read)) - (dir (cdr (assoc-string "root" output)))) - (file-name-directory (directory-file-name dir)))))) - (defun rustic-buffer-crate (&optional nodefault) "Return the crate for the current buffer. When called outside a Rust project, then return `default-directory', From 64b101e337cb9ae8e6537fa5084e421e40253257 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 18:30:36 +0100 Subject: [PATCH 05/19] add file buffer to process plist --- rustic-compile.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rustic-compile.el b/rustic-compile.el index e85ef1cb..e40587f2 100644 --- a/rustic-compile.el +++ b/rustic-compile.el @@ -237,6 +237,7 @@ Set environment variables for rust process." (set-process-sentinel process (plist-get args :sentinel)) (set-process-coding-system process 'utf-8-emacs-unix 'utf-8-emacs-unix) (process-put process 'command (plist-get args :command)) + (process-put process 'file-buffer (plist-get args :file-buffer)) process))) (defun rustic-compilation-setup-buffer (buf dir mode &optional no-mode-line) @@ -283,7 +284,8 @@ ARGS is a plist that affects how the process is run. (process (or (plist-get args :process) rustic-compilation-process-name)) (mode (or (plist-get args :mode) 'rustic-compilation-mode)) (directory (or (plist-get args :directory) (funcall rustic-compile-directory-method))) - (sentinel (or (plist-get args :sentinel) #'compilation-sentinel))) + (sentinel (or (plist-get args :sentinel) #'compilation-sentinel)) + (file-buffer (current-buffer))) (rustic-compilation-setup-buffer buf directory mode) (setq next-error-last-buffer buf) (unless (plist-get args :no-display) @@ -294,6 +296,7 @@ ARGS is a plist that affects how the process is run. (rustic-make-process :name process :buffer buf :command command + :file-buffer file-buffer :filter #'rustic-compilation-filter :sentinel sentinel :file-handler t)))) From 10aeb4c602be4bb0db6e29477582878f169c9485 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 18:31:07 +0100 Subject: [PATCH 06/19] activate old elisp tests for error parsing --- test/rustic-compile-test.el | 46 ++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/test/rustic-compile-test.el b/test/rustic-compile-test.el index de3f405d..46e6c409 100644 --- a/test/rustic-compile-test.el +++ b/test/rustic-compile-test.el @@ -153,6 +153,7 @@ (should (= compilation-num-errors-found 1)))))) (ert-deftest rustic-test-cargo-test () + ;; NOTE: this doesn't seem to be the case anymore ;; compilation-num-errors-found would be 8 with regular compilaton mode ;; due to parsing issues https://github.com/rust-lang/rust-mode/pull/254 (let ((rustic-compile-backtrace "full")) @@ -209,19 +210,32 @@ (with-current-buffer (get-buffer rustic-test-buffer-name) (should (= compilation-num-errors-found 10)))))) -;; ;; TODO: parsing doesn't work -;; (ert-deftest rustic-test-count-warnings () -;; (let* ((string "fn main() { -;; let v1 = vec![1, 2, 3]; -;; let v2 = vec![1, 2, 3]; -;; }") -;; (default-directory (rustic-test-count-error-helper string)) -;; (proc (rustic-compilation-start (split-string "cargo build")))) -;; (while (eq (process-status proc) 'run) -;; (sit-for 0.1)) -;; (with-current-buffer (get-buffer rustic-compilation-buffer-name) -;; (should (= compilation-num-warnings-found 1))))) - - - - +(ert-deftest rustic-test-count-warnings () + (let* ((string "fn main() { + let v1 = vec![1, 2, 3]; + let v2 = vec![1, 2, 3]; + let v3 = vec![1, 2, 3]; + let v4 = vec![1, 2, 3]; + let v5 = vec![1, 2, 3]; + let v6 = vec![1, 2, 3]; + let v7 = vec![1, 2, 3]; + let v8 = vec![1, 2, 3]; + let v9 = vec![1, 2, 3]; + let v10 = vec![1, 2, 3]; + let v11 = vec![1, 2, 3]; + let v12 = vec![1, 2, 3]; + let v13 = vec![1, 2, 3]; + let v14 = vec![1, 2, 3]; + let v15 = vec![1, 2, 3]; + let v16 = vec![1, 2, 3]; + let v17 = vec![1, 2, 3]; + let v18 = vec![1, 2, 3]; + let v19 = vec![1, 2, 3]; + let v20 = vec![1, 2, 3]; + }") + (default-directory (rustic-test-count-error-helper string)) + (proc (rustic-compilation-start (split-string "cargo build")))) + (while (eq (process-status proc) 'run) + (sit-for 0.1)) + (with-current-buffer (get-buffer rustic-compilation-buffer-name) + (should (= compilation-num-warnings-found 20))))) From d3082325e72dbc486e585f8bec3bb0065f9c20fc Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 18:31:49 +0100 Subject: [PATCH 07/19] test value of check command that is stored in process plist --- test/rustic-cargo-test.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/rustic-cargo-test.el b/test/rustic-cargo-test.el index 5976f47b..8e40ae5b 100644 --- a/test/rustic-cargo-test.el +++ b/test/rustic-cargo-test.el @@ -201,5 +201,10 @@ fn test21() { (buffer (process-buffer proc))) (while (eq (process-status proc) 'run) (sit-for 0.01)) + + (should (string= (s-join " " (process-get proc 'command)) + (concat (rustic-cargo-bin) " check " + rustic-cargo-check-arguments))) + (with-current-buffer buffer (should (string-match "^warning:\s" (buffer-substring-no-properties (point-min) (point-max))))))))) From 57379f95fde82132fa5139009f16fcf8726547a6 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 18:32:56 +0100 Subject: [PATCH 08/19] add rustic-default-test-arguments --- rustic-cargo.el | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/rustic-cargo.el b/rustic-cargo.el index b5e6ed86..80cca8b3 100644 --- a/rustic-cargo.el +++ b/rustic-cargo.el @@ -40,6 +40,11 @@ If nil then the project is simply created." :type 'boolean :group 'rustic-cargo) +(defcustom rustic-default-test-arguments "--workspace --benches --tests --all-features" + "Default arguments when running clippy." + :type 'string + :group 'rustic-cargo) + (defcustom rustic-cargo-check-arguments "--workspace --benches --tests --all-features" "Default arguments when running 'cargo check'." :type 'string @@ -90,6 +95,15 @@ stored in this variable.") (when rustic-cargo-test-disable-warnings (setq-local rustic-compile-rustflags "-Awarnings"))) +(defun rustic-cargo-run-test (test) + "Run TEST which can be a single test or mod name." + (let* ((command (list (rustic-cargo-bin) "test" test)) + (c (append command)) + (buf rustic-test-buffer-name) + (proc rustic-test-process-name) + (mode 'rustic-cargo-test-mode)) + (rustic-compilation c (list :buffer buf :process proc :mode mode)))) + ;;;###autoload (defun rustic-cargo-test-run (&optional test-args) "Start compilation process for 'cargo test' with optional TEST-ARGS." @@ -112,10 +126,13 @@ When calling this function from `rustic-popup-mode', always use the value of (interactive "P") (rustic-cargo-test-run (cond (arg - (setq rustic-test-arguments (read-from-minibuffer "Cargo test arguments: " rustic-test-arguments))) + (setq rustic-test-arguments (read-from-minibuffer "Cargo test arguments: " rustic-default-test-arguments))) ((eq major-mode 'rustic-popup-mode) - rustic-test-arguments) - (t "")))) + (if (> (length rustic-test-arguments) 0) + rustic-test-arguments + rustic-default-test-arguments)) + (t + rustic-default-test-arguments)))) ;;;###autoload (defun rustic-cargo-test-rerun () @@ -130,7 +147,13 @@ When calling this function from `rustic-popup-mode', always use the value of (rustic-compilation-process-live) (-if-let (test-to-run (setq rustic-test-arguments (rustic-cargo--get-test-target))) - (rustic-cargo-run-test test-to-run) + (let* ((command (list (rustic-cargo-bin) "test" test-to-run)) + (c (append command)) + (buf rustic-test-buffer-name) + (proc rustic-test-process-name) + (mode 'rustic-cargo-test-mode)) + (rustic-compilation c (list :buffer buf :process proc :mode mode))) + (rustic-cargo-run-test test-to-run) (message "Could not find test at point."))) ;;;###autoload @@ -141,15 +164,6 @@ When calling this function from `rustic-popup-mode', always use the value of (rustic-cargo--get-current-mod))) (rustic-cargo-test))) -(defun rustic-cargo-run-test (test) - "Run TEST which can be a single test or mod name." - (let* ((command (list (rustic-cargo-bin) "test" test)) - (c (append command)) - (buf rustic-test-buffer-name) - (proc rustic-test-process-name) - (mode 'rustic-cargo-test-mode)) - (rustic-compilation c (list :buffer buf :process proc :mode mode)))) - (defconst rustic-cargo-mod-regexp "^\s*mod\s+\\([[:word:][:multibyte:]_][[:word:][:multibyte:]_[:digit:]]*\\)\s*{") (defconst rustic-cargo-fn-regexp From a151b8ec9e17bcc66a5264bfb33dca71f170cc40 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 18:33:09 +0100 Subject: [PATCH 09/19] use rustic-default-clippy-arguments in prompt when called with C-u --- rustic-clippy.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustic-clippy.el b/rustic-clippy.el index 6dcd067d..1b0f0384 100644 --- a/rustic-clippy.el +++ b/rustic-clippy.el @@ -63,7 +63,7 @@ When calling this function from `rustic-popup-mode', always use the value of (interactive "P") (rustic-cargo-clippy-run :params (cond (arg - (setq rustic-clippy-arguments (read-from-minibuffer "Cargo clippy arguments: " rustic-clippy-arguments))) + (setq rustic-clippy-arguments (read-from-minibuffer "Cargo clippy arguments: " rustic-default-clippy-arguments))) ((eq major-mode 'rustic-popup-mode) (if (> (length rustic-clippy-arguments) 0) rustic-clippy-arguments From 819543871356b7deaddcc099a814395887162226 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 18:49:32 +0100 Subject: [PATCH 10/19] add test for rustic-cargo-test --- test/rustic-cargo-test.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/rustic-cargo-test.el b/test/rustic-cargo-test.el index 8e40ae5b..c4658c8d 100644 --- a/test/rustic-cargo-test.el +++ b/test/rustic-cargo-test.el @@ -208,3 +208,22 @@ fn test21() { (with-current-buffer buffer (should (string-match "^warning:\s" (buffer-substring-no-properties (point-min) (point-max))))))))) + +(ert-deftest rustic-cargo-test-test () + (let* ((string "mod tests { +#[test] +fn test() { +} +}") + (buf (rustic-test-count-error-helper-new string)) + (default-directory (buffer-file-name buf))) + (with-current-buffer buf + (let* ((proc (rustic-cargo-test)) + (buffer (process-buffer proc))) + (while (eq (process-status proc) 'run) + (sit-for 0.01)) + (with-current-buffer buffer + (should (eq major-mode 'rustic-cargo-test-mode))) + (should (string= (s-join " " (process-get proc 'command)) + (concat (rustic-cargo-bin) " test " + rustic-default-test-arguments))))))) From fb0a480afff4c009f1b995a78bfc5d1cd93e67df Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 25 Dec 2021 18:16:07 +0100 Subject: [PATCH 11/19] use function rustic-cargo-bin instead of cargo --- rustic-cargo.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rustic-cargo.el b/rustic-cargo.el index 80cca8b3..db32a774 100644 --- a/rustic-cargo.el +++ b/rustic-cargo.el @@ -249,7 +249,7 @@ Execute process in PATH." (inhibit-read-only t)) (make-process :name rustic-cargo-outdated-process-name :buffer buf - :command '("cargo" "outdated" "--depth" "1") + :command `(,(rustic-cargo-bin) "outdated" "--depth" "1") :filter #'rustic-cargo-outdated-filter :sentinel #'rustic-cargo-outdated-sentinel :file-handler t) @@ -301,7 +301,7 @@ Execute process in PATH." "Ask whether to install crate CRATE." (let ((cmd (format "cargo install cargo-%s" crate))) (when (yes-or-no-p (format "Cargo-%s missing. Install ? " crate)) - (async-shell-command cmd "cargo" "cargo-error")))) + (async-shell-command cmd (rustic-cargo-bin) "cargo-error")))) (defun rustic-cargo-outdated-generate-menu (packages) "Re-populate the `tabulated-list-entries' with PACKAGES." From 8012b539fc81fe05bb1c6d81705c2fe696a8a893 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 19:06:29 +0100 Subject: [PATCH 12/19] fix previous commit --- rustic-cargo.el | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/rustic-cargo.el b/rustic-cargo.el index db32a774..3de0fa42 100644 --- a/rustic-cargo.el +++ b/rustic-cargo.el @@ -41,7 +41,7 @@ If nil then the project is simply created." :group 'rustic-cargo) (defcustom rustic-default-test-arguments "--workspace --benches --tests --all-features" - "Default arguments when running clippy." + "Default arguments when running 'cargo test'." :type 'string :group 'rustic-cargo) @@ -147,13 +147,7 @@ When calling this function from `rustic-popup-mode', always use the value of (rustic-compilation-process-live) (-if-let (test-to-run (setq rustic-test-arguments (rustic-cargo--get-test-target))) - (let* ((command (list (rustic-cargo-bin) "test" test-to-run)) - (c (append command)) - (buf rustic-test-buffer-name) - (proc rustic-test-process-name) - (mode 'rustic-cargo-test-mode)) - (rustic-compilation c (list :buffer buf :process proc :mode mode))) - (rustic-cargo-run-test test-to-run) + (rustic-cargo-run-test test-to-run) (message "Could not find test at point."))) ;;;###autoload From fcbfbe7d14f5ad1eb0d3d39a4de2af7a1ebaa235 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 19:55:41 +0100 Subject: [PATCH 13/19] support cargo-lints close #341 --- README.md | 1 + rustic-clippy.el | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index ff5da771..76cc8c6e 100644 --- a/README.md +++ b/README.md @@ -516,6 +516,7 @@ before being used. - `rustic-cargo-bench` run 'cargo bench' for the current project - `rustic-cargo-build-doc` build the documentation for the current project - `rustic-cargo-doc` open the documentation for the current project in a browser +- `rustic-cargo-lints` called with `rustic-lints-arguments` ## Clippy diff --git a/rustic-clippy.el b/rustic-clippy.el index 1b0f0384..0ac19a71 100644 --- a/rustic-clippy.el +++ b/rustic-clippy.el @@ -17,6 +17,11 @@ :type 'string :group 'rustic-cargo) +(defcustom rustic-lints-arguments "-f custom_lints.toml clippy" + "Default arguments when running cargo-lints." + :type 'string + :group 'rustic-cargo) + (defvar rustic-clippy-process-name "rustic-cargo-clippy-process" "Process name for clippy processes.") @@ -53,6 +58,18 @@ :sentinel (plist-get args :sentinel) :no-display (plist-get args :silent))))) +;;;###autoload +(defun rustic-cargo-lints () + "Run cargo-lints with optional ARGS." + (interactive) + (let* ((command `(,rustic-cargo-bin + "lints" + ,@(rustic-lints-arguments))) + (buf rustic-clippy-buffer-name) + (proc rustic-clippy-process-name) + (mode 'rustic-cargo-clippy-mode)) + (rustic-compilation command (list :buffer buf :process proc :mode mode)))) + ;;;###autoload (defun rustic-cargo-clippy (&optional arg) "Run 'cargo clippy'. From 6bda15ca17e8fe39af40b95e77d885104eab6b0c Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sat, 29 Jan 2022 21:02:59 +0100 Subject: [PATCH 14/19] remove deprecated variable --- rustic-cargo.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rustic-cargo.el b/rustic-cargo.el index 3de0fa42..fc147848 100644 --- a/rustic-cargo.el +++ b/rustic-cargo.el @@ -97,8 +97,7 @@ stored in this variable.") (defun rustic-cargo-run-test (test) "Run TEST which can be a single test or mod name." - (let* ((command (list (rustic-cargo-bin) "test" test)) - (c (append command)) + (let* ((c (list (rustic-cargo-bin) "test" test)) (buf rustic-test-buffer-name) (proc rustic-test-process-name) (mode 'rustic-cargo-test-mode)) From 4aca1c28676fa53d5784b7aee3565f26d43751e9 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sun, 30 Jan 2022 12:54:23 +0100 Subject: [PATCH 15/19] bump version to 2.6 --- rustic.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustic.el b/rustic.el index 2d97db19..b9a2e081 100644 --- a/rustic.el +++ b/rustic.el @@ -1,6 +1,6 @@ ;;; rustic.el --- Rust development environment -*-lexical-binding: t-*- -;; Version: 2.5 +;; Version: 2.6 ;; Author: Mozilla ;; ;; Keywords: languages From c7b4bf610e685378825f2651a0a3d769d8363568 Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sun, 30 Jan 2022 14:31:58 +0100 Subject: [PATCH 16/19] split rustic-lints-arguments --- rustic-clippy.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustic-clippy.el b/rustic-clippy.el index 0ac19a71..95e9bb7f 100644 --- a/rustic-clippy.el +++ b/rustic-clippy.el @@ -64,7 +64,7 @@ (interactive) (let* ((command `(,rustic-cargo-bin "lints" - ,@(rustic-lints-arguments))) + ,@(split-string rustic-lints-arguments))) (buf rustic-clippy-buffer-name) (proc rustic-clippy-process-name) (mode 'rustic-cargo-clippy-mode)) From f47b07b765603e04adf68f8228ebf5541bcbe95b Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sun, 30 Jan 2022 14:32:35 +0100 Subject: [PATCH 17/19] again missing function call for rustic-cargo-bin --- rustic-clippy.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustic-clippy.el b/rustic-clippy.el index 95e9bb7f..3d221e5a 100644 --- a/rustic-clippy.el +++ b/rustic-clippy.el @@ -62,7 +62,7 @@ (defun rustic-cargo-lints () "Run cargo-lints with optional ARGS." (interactive) - (let* ((command `(,rustic-cargo-bin + (let* ((command `(,(rustic-cargo-bin) "lints" ,@(split-string rustic-lints-arguments))) (buf rustic-clippy-buffer-name) From a5b36607f347df913ab8165dcd4e0a58b0901c3e Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sun, 30 Jan 2022 14:55:33 +0100 Subject: [PATCH 18/19] extend committed test-project to check subcrate error parsing --- .gitignore | 1 + test/test-project/Cargo.lock | 7 +++++++ test/test-project/Cargo.toml | 3 ++- test/test-project/crates/test-crate/Cargo.toml | 3 +++ test/test-project/crates/test-crate/src/lib.rs | 1 + test/test-project/test-workspace/Cargo.toml | 1 - 6 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 test/test-project/Cargo.lock create mode 100644 test/test-project/crates/test-crate/Cargo.toml create mode 100644 test/test-project/crates/test-crate/src/lib.rs delete mode 100644 test/test-project/test-workspace/Cargo.toml diff --git a/.gitignore b/.gitignore index dcae2038..d53827f9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.cask /config.mk *autoloads.el +test/test-project/target \ No newline at end of file diff --git a/test/test-project/Cargo.lock b/test/test-project/Cargo.lock new file mode 100644 index 00000000..be5aa8f9 --- /dev/null +++ b/test/test-project/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "test-workspace" +version = "0.0.1" diff --git a/test/test-project/Cargo.toml b/test/test-project/Cargo.toml index f741b14a..2abd9359 100644 --- a/test/test-project/Cargo.toml +++ b/test/test-project/Cargo.toml @@ -1 +1,2 @@ -# Dummy file needed for test +[workspace] +members = ["crates/*"] \ No newline at end of file diff --git a/test/test-project/crates/test-crate/Cargo.toml b/test/test-project/crates/test-crate/Cargo.toml new file mode 100644 index 00000000..3223ebea --- /dev/null +++ b/test/test-project/crates/test-crate/Cargo.toml @@ -0,0 +1,3 @@ +[package] +name = "test-workspace" +version = "0.0.1" \ No newline at end of file diff --git a/test/test-project/crates/test-crate/src/lib.rs b/test/test-project/crates/test-crate/src/lib.rs new file mode 100644 index 00000000..c7452f6f --- /dev/null +++ b/test/test-project/crates/test-crate/src/lib.rs @@ -0,0 +1 @@ +uuse libc; diff --git a/test/test-project/test-workspace/Cargo.toml b/test/test-project/test-workspace/Cargo.toml deleted file mode 100644 index f741b14a..00000000 --- a/test/test-project/test-workspace/Cargo.toml +++ /dev/null @@ -1 +0,0 @@ -# Dummy file needed for test From 63a6ba631e362f83c8ab89bd9e8bf1a68462981e Mon Sep 17 00:00:00 2001 From: brotzeit Date: Sun, 30 Jan 2022 20:15:20 +0100 Subject: [PATCH 19/19] update rust-test-workspace-location --- test/rustic-workspace-test.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/rustic-workspace-test.el b/test/rustic-workspace-test.el index df9c3da6..016c7b52 100644 --- a/test/rustic-workspace-test.el +++ b/test/rustic-workspace-test.el @@ -1,11 +1,13 @@ ;; -*- lexical-binding: t -*- ;; Before editing, eval (load-file "test-helper.el") -(ert-deftest rust-test-workspace-location () +(ert-deftest rust-test-workspace-crate-location () (should (equal (funcall rustic-compile-directory-method) default-directory)) - (let* ((test-workspace (expand-file-name "test/test-project/test-workspace/" default-directory)) - (default-directory test-workspace)) - (should (equal (funcall rustic-compile-directory-method) test-workspace)))) + (let* ((test-workspace (expand-file-name "test/test-project/")) + (test-crate (expand-file-name "test/test-project/crates/test-crate/"))) + (let ((default-directory (expand-file-name "src" test-crate))) + (should (string= (rustic-buffer-workspace) test-workspace)) + (should (string= (rustic-buffer-crate) test-crate))))) ;; just test if project-root function works for different versions (ert-deftest rust-test-project-root ()