Skip to content

Commit 8504ef7

Browse files
committed
Offer a choice between fast or comprehensive lint
The default is the fast lint, maintain the current defaults.
1 parent 7295c74 commit 8504ef7

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

doc/rust.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,31 @@ g:rust_shortener_url~
133133
let g:rust_shortener_url = 'https://is.gd/'
134134
<
135135

136+
*g:rustc_syntax_only*
137+
g:rustc_syntax_only~
138+
Set this option to control the syntastic linter.
139+
You can choose between a simple syntax parser or a fuller compilation.
140+
141+
The syntax parser is very fast, but won't catch any compilation
142+
errors. This is the default.
143+
We recommend you enable syntastic's active mode with this setting
144+
(that's the default too). >
145+
let g:rustc_syntax_only = 1
146+
<
147+
148+
The fuller compilation performs a compilation of the entire project.
149+
This makes it really slow on large projects.
150+
If VIM becomes unusable, set syntastic passive mode for Rust. This
151+
will make it so that the lint will only run on |:SyntasticCheck| (see
152+
|syntastic_mode_map|).
153+
>
154+
let g:rustc_syntax_only = 0
155+
" Syntastic passive mode
156+
let g:syntastic_mode_map = {
157+
\ "mode": "active",
158+
\ "active_filetypes": [],
159+
\ "passive_filetypes": ["rust"] }
160+
<
136161

137162
==============================================================================
138163
COMMANDS *rust-commands*

syntax_checkers/rust/rustc.vim

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,28 @@ if exists("g:loaded_syntastic_rust_rustc_checker")
1010
endif
1111
let g:loaded_syntastic_rust_rustc_checker = 1
1212

13+
if !exists('g:rustc_syntax_only')
14+
let g:rustc_syntax_only = 1 "Keep the fast behaviour by default
15+
endif
16+
1317
let s:save_cpo = &cpo
1418
set cpo&vim
1519

1620
function! SyntaxCheckers_rust_rustc_GetLocList() dict
21+
let compiler_params = g:rustc_syntax_only ? '-Zparse-only' : '-Zno-trans'
1722
let cwd = '.' " Don't change cwd as default
1823
let cargo_toml_path = findfile('Cargo.toml', '.;')
1924
if empty(cargo_toml_path) " Plain rs file, not a crate
2025
let makeprg = self.makeprgBuild({
2126
\ 'exe': 'rustc',
22-
\ 'args': '-Zno-trans' })
27+
\ 'args': compiler_params})
2328
else " We are inside a crate
2429
let makeprg = self.makeprgBuild({
2530
\ 'exe': 'cargo',
26-
\ 'args': 'rustc -Zno-trans',
31+
\ 'args': 'rustc ' . compiler_params,
2732
\ 'fname': '' })
2833
" Change cwd to the root of the crate
29-
let cwd = fnamemodify( cargo_toml_path, ':p:h')
34+
let cwd = fnamemodify( cargo_toml_path, ':p:h')
3035
endif
3136

3237
let errorformat =

0 commit comments

Comments
 (0)