Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 2b04862

Browse files
White-Oakgmist
authored andcommitted
Fixed manifest discovery troubles caused bu #81 (#82)
1 parent 02f72a4 commit 2b04862

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/linter-rust.coffee

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ class LinterRust
6464
@initCmd(textEditor.getPath(), ableToJSONErrors).then (result) =>
6565
[file, cmd] = result
6666
env = JSON.parse JSON.stringify process.env
67+
curDir = path.dirname file
6768
cwd = curDir
6869
command = cmd[0]
6970
args = cmd.slice 1
71+
env.PATH = path.dirname(cmd[0]) + path.delimiter + env.PATH
7072

7173
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
7577
sb_exec.exec(command, args, {env: env, cwd: cwd, stream: 'both'})
7678
.then (result) =>
7779
{stdout, stderr, exitCode} = result
@@ -238,13 +240,14 @@ class LinterRust
238240
when 'clippy' then ['clippy']
239241
else ['build']
240242

241-
if not @useCargo or not @cargoManifestFilename
243+
cargoManifestPath = @locateCargo path.dirname editingFile
244+
if not @useCargo or not cargoManifestPath
242245
Promise.resolve().then () =>
243246
cmd = [@rustcPath]
244247
.concat rustcArgs
245-
if @cargoManifestFilename
248+
if cargoManifestPath
246249
cmd.push '-L'
247-
cmd.push path.join path.dirname(@cargoManifestFilename), @cargoDependencyDir
250+
cmd.push path.join path.dirname(cargoManifestPath), @cargoDependencyDir
248251
compilationFeatures = @compilationFeatures(false)
249252
cmd = cmd.concat compilationFeatures if compilationFeatures
250253
cmd = cmd.concat [editingFile]
@@ -257,8 +260,8 @@ class LinterRust
257260
.concat cargoArgs
258261
.concat ['-j', @jobsNumber]
259262
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]
262265

263266
compilationFeatures: (cargo) =>
264267
if @specifiedFeatures.length > 0

0 commit comments

Comments
 (0)