@@ -32,6 +32,7 @@ class LinterRust
3232 @subscriptions .add atom .config .observe ' linter-rust.cargoCommand' ,
3333 (cargoCommand ) =>
3434 @cargoCommand = cargoCommand
35+ @useWorkspaceManifest = cargoCommand .endsWith (' all' )
3536
3637 @subscriptions .add atom .config .observe ' linter-rust.rustcBuildTest' ,
3738 (rustcBuildTest ) =>
@@ -75,6 +76,8 @@ class LinterRust
7576 cmdPath = if cmd[0 ]? then path .dirname cmd[0 ] else __dirname
7677 args = cmd .slice 1
7778 env .PATH = cmdPath + path .delimiter + env .PATH
79+ cargoManifestFile = @ locateCargo curDir
80+ cargoManifestDir = path .dirname cargoManifestFile
7881
7982 # we set flags only for intermediate json support
8083 if errorMode == errorModes .FLAGS_JSON_CARGO
@@ -116,7 +119,8 @@ class LinterRust
116119 # correct file paths
117120 messages .forEach (message) ->
118121 if ! (path .isAbsolute message .location .file )
119- message .location .file = path .join curDir, message .location .file
122+ message .location .file = path .join curDir, message .location .file if fs .existsSync path .join curDir, message .location .file
123+ message .location .file = path .join cargoManifestDir, message .location .file if fs .existsSync path .join cargoManifestDir, message .location .file
120124 messages
121125 else
122126 # whoops, we're in trouble -- let's output as much as we can
@@ -199,8 +203,29 @@ class LinterRust
199203 locateCargo : (curDir ) =>
200204 root_dir = if / ^ win/ .test process .platform then / ^ . :\\ $ / else / ^ \/ $ /
201205 directory = path .resolve curDir
206+ manifest_name = @cargoManifestFilename
207+
202208 loop
203- return path .join directory, @cargoManifestFilename if fs .existsSync path .join directory, @cargoManifestFilename
209+ if fs .existsSync path .join directory, manifest_name
210+ crate_level_manifest = path .join directory , manifest_name
211+
212+ if @useWorkspaceManifest
213+ execOpts =
214+ env : JSON .parse JSON .stringify process .env
215+ cwd : curDir
216+ stream : ' both'
217+
218+ atom_linter .exec (' cargo' , [' locate-project' , ' --workspace' , ' --manifest-path=' + crate_level_manifest], execOpts)
219+ .then (result) =>
220+ {stdout , stderr , exitCode } = result
221+ json = JSON .parse stdout
222+ return json .root
223+ .catch (error) ->
224+ return crate_level_manifest
225+ else
226+ return crate_level_manifest
227+
228+ return path .join directory , manifest_name if fs .existsSync path .join directory, manifest_name
204229 break if root_dir .test directory
205230 directory = path .resolve path .join (directory, ' ..' )
206231 return false
0 commit comments