Skip to content

Commit a878f39

Browse files
bors[bot]flodieboldlnicola
authored
Merge #2963 #2967
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 <[email protected]> Co-authored-by: Florian Diebold <[email protected]> Co-authored-by: Laurențiu Nicola <[email protected]>
3 parents 8e0ad99 + 2586cf9 + f83154d commit a878f39

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,24 @@ debug = 0
1010
incremental = true
1111
debug = 0 # set this to 1 or 2 to get more useful backtraces in debugger
1212

13+
# ideally, we would use `build-override` here, but some crates are also
14+
# needed at run-time and we end up compiling them twice
15+
[profile.release.package.proc-macro2]
16+
opt-level = 0
17+
[profile.release.package.quote]
18+
opt-level = 0
19+
[profile.release.package.syn]
20+
opt-level = 0
21+
[profile.release.package.serde_derive]
22+
opt-level = 0
23+
[profile.release.package.chalk-derive]
24+
opt-level = 0
25+
[profile.release.package.chalk-macros]
26+
opt-level = 0
27+
[profile.release.package.salsa-macros]
28+
opt-level = 0
29+
[profile.release.package.xtask]
30+
opt-level = 0
31+
1332
[patch.'crates-io']
1433
# rowan = { path = "../rowan" }

editors/emacs/rust-analyzer.el

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838

3939
(defconst rust-analyzer--action-handlers
4040
'(("rust-analyzer.applySourceChange" .
41-
(lambda (p) (rust-analyzer--apply-source-change-command p)))))
41+
(lambda (p) (rust-analyzer--apply-source-change-command p)))
42+
("rust-analyzer.selectAndApplySourceChange" .
43+
(lambda (p) (rust-analyzer--select-and-apply-source-change-command p)))))
4244

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

76+
(defun rust-analyzer--select-and-apply-source-change-command (p)
77+
(let* ((options (-> p (ht-get "arguments") (lsp-seq-first)))
78+
(chosen-option (lsp--completing-read "Select option:" options
79+
(-lambda ((&hash "label")) label))))
80+
(rust-analyzer--apply-source-change chosen-option)))
81+
7482
(lsp-register-client
7583
(make-lsp-client
7684
:new-connection (lsp-stdio-connection (lambda () rust-analyzer-command))
@@ -143,7 +151,8 @@
143151

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

0 commit comments

Comments
 (0)