@@ -64,14 +64,16 @@ class LinterRust
64
64
@ initCmd (textEditor .getPath (), ableToJSONErrors).then (result) =>
65
65
[file , cmd ] = result
66
66
env = JSON .parse JSON .stringify process .env
67
+ curDir = path .dirname file
67
68
cwd = curDir
68
69
command = cmd[0 ]
69
70
args = cmd .slice 1
71
+ env .PATH = path .dirname (cmd[0 ]) + path .delimiter + env .PATH
70
72
71
73
if ableToJSONErrors
72
- additional = if env .RUSTFLAGS ? then ' ' + env .RUSTFLAGS else ' '
73
- env .RUSTFLAGS = ' --error-format=json ' + additional
74
-
74
+ if ! env .RUSTFLAGS ? or ! ( env .RUSTFLAGS . indexOf ( ' --error-format=json ' ) >= 0 )
75
+ additional = if env .RUSTFLAGS ? then ' ' + env . RUSTFLAGS else ' '
76
+ env . RUSTFLAGS = ' --error-format=json ' + additional
75
77
sb_exec .exec (command, args, {env : env, cwd : cwd, stream : ' both' })
76
78
.then (result) =>
77
79
{stdout , stderr , exitCode } = result
@@ -238,13 +240,14 @@ class LinterRust
238
240
when ' clippy' then [' clippy' ]
239
241
else [' build' ]
240
242
241
- if not @useCargo or not @cargoManifestFilename
243
+ cargoManifestPath = @ locateCargo path .dirname editingFile
244
+ if not @useCargo or not cargoManifestPath
242
245
Promise .resolve ().then () =>
243
246
cmd = [@rustcPath ]
244
247
.concat rustcArgs
245
- if @cargoManifestFilename
248
+ if cargoManifestPath
246
249
cmd .push ' -L'
247
- cmd .push path .join path .dirname (@cargoManifestFilename ), @cargoDependencyDir
250
+ cmd .push path .join path .dirname (cargoManifestPath ), @cargoDependencyDir
248
251
compilationFeatures = @ compilationFeatures (false )
249
252
cmd = cmd .concat compilationFeatures if compilationFeatures
250
253
cmd = cmd .concat [editingFile]
@@ -257,8 +260,8 @@ class LinterRust
257
260
.concat cargoArgs
258
261
.concat [' -j' , @jobsNumber ]
259
262
cmd = cmd .concat compilationFeatures if compilationFeatures
260
- cmd = cmd .concat [' --manifest-path' , @cargoManifestFilename ]
261
- [@cargoManifestFilename , cmd]
263
+ cmd = cmd .concat [' --manifest-path' , cargoManifestPath ]
264
+ [cargoManifestPath , cmd]
262
265
263
266
compilationFeatures : (cargo ) =>
264
267
if @specifiedFeatures .length > 0
0 commit comments