Skip to content

Commit decc9ab

Browse files
lilyballalexcrichton
authored andcommitted
---
yaml --- r: 118733 b: refs/heads/snap-stage3 c: 1273f94 h: refs/heads/master i: 118731: 7db93cc v: v3
1 parent 55eaa1c commit decc9ab

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: b1646cbfd908dc948b251e362669af421100647a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 918eda59bee9a627919d11b7bc9f909d7a9676ff
4+
refs/heads/snap-stage3: 1273f94cbb19608e6a4e02c54d8543f6fe648a47
55
refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/etc/vim/autoload/rust.vim

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,39 @@ function! rust#CompleteExpand(lead, line, pos)
130130
return glob(escape(a:lead, "*?[") . '*', 0, 1)
131131
endfunction
132132

133+
" Emit {{{1
134+
135+
function! rust#Emit(type, args)
136+
call s:WithPath(function("s:Emit"), a:type, a:args)
137+
endfunction
138+
139+
function! s:Emit(path, type, args)
140+
try
141+
let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc"
142+
143+
let args = [a:path, '--emit', a:type, '-o', '-'] + a:args
144+
let output = system(shellescape(rustc) . " " . join(map(args, "shellescape(v:val)")))
145+
if v:shell_error
146+
echohl WarningMsg
147+
echo output
148+
echohl None
149+
else
150+
new
151+
silent put =output
152+
1
153+
d
154+
if a:type == "ir"
155+
setl filetype=llvm
156+
elseif a:type == "asm"
157+
setl filetype=asm
158+
endif
159+
setl buftype=nofile
160+
setl bufhidden=hide
161+
setl noswapfile
162+
endif
163+
endtry
164+
endfunction
165+
133166
" Utility functions {{{1
134167

135168
function! s:WithPath(func, ...)

branches/snap-stage3/src/etc/vim/doc/rust.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,27 @@ COMMANDS *rust-commands*
107107
If |g:rustc_path| is defined, it is used as the path to rustc.
108108
Otherwise it is assumed rustc can be found in $PATH.
109109

110+
:RustEmitIr [args] *:RustEmitIr*
111+
Compiles the current file to LLVM IR and displays the results
112+
in a new split. If the current file has unsaved changes, it
113+
will be saved first using |:update|. If the current file is an
114+
unnamed buffer, it will be written to a temporary file first.
115+
116+
The arguments given to |:RustEmitIr| will be passed to rustc.
117+
118+
If |g:rustc_path| is defined, it is used as the path to rustc.
119+
Otherwise it is assumed rustc can be found in $PATH.
120+
121+
:RustEmitAsm [args] *:RustEmitAsm*
122+
Compiles the current file to assembly and displays the results
123+
in a new split. If the current file has unsaved changes, it
124+
will be saved first using |:update|. If the current file is an
125+
unnamed buffer, it will be written to a temporary file first.
126+
127+
The arguments given to |:RustEmitAsm| will be passed to rustc.
128+
129+
If |g:rustc_path| is defined, it is used as the path to rustc.
130+
Otherwise it is assumed rustc can be found in $PATH.
110131

111132
==============================================================================
112133
MAPPINGS *rust-mappings*

branches/snap-stage3/src/etc/vim/ftplugin/rust.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ command! -nargs=* -complete=file -bang -bar -buffer RustRun call rust#Run(<bang>
6666
" See |:RustExpand| for docs
6767
command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -bar -buffer RustExpand call rust#Expand(<bang>0, [<f-args>])
6868

69+
" See |:RustEmitIr| for docs
70+
command! -nargs=* -bar -buffer RustEmitIr call rust#Emit("ir", [<f-args>])
71+
72+
" See |:RustEmitAsm| for docs
73+
command! -nargs=* -bar -buffer RustEmitAsm call rust#Emit("asm", [<f-args>])
74+
6975
" Mappings {{{1
7076

7177
" Bind ⌘R in MacVim to :RustRun
@@ -91,6 +97,8 @@ let b:undo_ftplugin = "
9197
\|unlet! b:rust_last_rustc_args b:rust_last_args
9298
\|delcommand RustRun
9399
\|delcommand RustExpand
100+
\|delcommand RustEmitIr
101+
\|delcommand RustEmitAsm
94102
\|nunmap <buffer> <D-r>
95103
\|nunmap <buffer> <D-R>
96104
\|nunmap <buffer> [[

0 commit comments

Comments
 (0)