Skip to content

Commit

Permalink
Merge #2963 #2967
Browse files Browse the repository at this point in the history
2963: Emacs fixes r=matklad a=flodiebold

 - use provided environment for runnables (finally set `RUST_BACKTRACE`)
 - implement `selectAndApplySourceChange` so auto-import works 🙂 

cc @brotzeit 

2967: Disable optimizations for some build-time crates r=matklad a=lnicola

This speeds up a release build on my laptop from 4m 13s to 3m 33s. It's a bit disappointing, but we don't get perfect parallelism during the build. The non-RA dependencies finish building around 72s as opposed to 112s.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
  • Loading branch information
4 people committed Feb 1, 2020
3 parents 8e0ad99 + 2586cf9 + f83154d commit a878f39
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
19 changes: 19 additions & 0 deletions Cargo.toml
Expand Up @@ -10,5 +10,24 @@ debug = 0
incremental = true
debug = 0 # set this to 1 or 2 to get more useful backtraces in debugger

# ideally, we would use `build-override` here, but some crates are also
# needed at run-time and we end up compiling them twice
[profile.release.package.proc-macro2]
opt-level = 0
[profile.release.package.quote]
opt-level = 0
[profile.release.package.syn]
opt-level = 0
[profile.release.package.serde_derive]
opt-level = 0
[profile.release.package.chalk-derive]
opt-level = 0
[profile.release.package.chalk-macros]
opt-level = 0
[profile.release.package.salsa-macros]
opt-level = 0
[profile.release.package.xtask]
opt-level = 0

[patch.'crates-io']
# rowan = { path = "../rowan" }
13 changes: 11 additions & 2 deletions editors/emacs/rust-analyzer.el
Expand Up @@ -38,7 +38,9 @@

(defconst rust-analyzer--action-handlers
'(("rust-analyzer.applySourceChange" .
(lambda (p) (rust-analyzer--apply-source-change-command p)))))
(lambda (p) (rust-analyzer--apply-source-change-command p)))
("rust-analyzer.selectAndApplySourceChange" .
(lambda (p) (rust-analyzer--select-and-apply-source-change-command p)))))

(defun rust-analyzer--uri-filename (text-document)
(lsp--uri-to-path (gethash "uri" text-document)))
Expand Down Expand Up @@ -71,6 +73,12 @@
(let ((data (-> p (ht-get "arguments") (lsp-seq-first))))
(rust-analyzer--apply-source-change data)))

(defun rust-analyzer--select-and-apply-source-change-command (p)
(let* ((options (-> p (ht-get "arguments") (lsp-seq-first)))
(chosen-option (lsp--completing-read "Select option:" options
(-lambda ((&hash "label")) label))))
(rust-analyzer--apply-source-change chosen-option)))

(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection (lambda () rust-analyzer-command))
Expand Down Expand Up @@ -143,7 +151,8 @@

(defun rust-analyzer-run (runnable)
(interactive (list (rust-analyzer--select-runnable)))
(-let (((&hash "env" "bin" "args" "label") runnable))
(-let* (((&hash "env" "bin" "args" "label") runnable)
(compilation-environment (-map (-lambda ((k v)) (concat k "=" v)) (ht-items env))))
(compilation-start
(string-join (append (list bin) args '()) " ")
;; cargo-process-mode is nice, but try to work without it...
Expand Down

0 comments on commit a878f39

Please sign in to comment.