Auto merge of #17275 - roife:fix-issue-17012, r=Veykril · rust-lang/rust@56d77b9 (original) (raw)

`@@ -3,7 +3,7 @@ import * as vscode from "vscode";

`

3

3

`import * as path from "path";

`

4

4

`import type * as ra from "./lsp_ext";

`

5

5

``

6

``

`-

import { Cargo, type ExecutableInfo, getRustcId, getSysroot } from "./toolchain";

`

``

6

`+

import { Cargo, getRustcId, getSysroot } from "./toolchain";

`

7

7

`import type { Ctx } from "./ctx";

`

8

8

`import { prepareEnv } from "./run";

`

9

9

`import { unwrapUndefinable } from "./undefinable";

`

`@@ -12,7 +12,6 @@ const debugOutput = vscode.window.createOutputChannel("Debug");

`

12

12

`type DebugConfigProvider = (

`

13

13

`config: ra.Runnable,

`

14

14

`executable: string,

`

15

``

`-

cargoWorkspace: string,

`

16

15

`env: Record<string, string>,

`

17

16

`sourceFileMap?: Record<string, string>,

`

18

17

`) => vscode.DebugConfiguration;

`

`@@ -134,7 +133,7 @@ async function getDebugConfiguration(

`

134

133

`}

`

135

134

``

136

135

`const env = prepareEnv(runnable, ctx.config.runnablesExtraEnv);

`

137

``

`-

const { executable, workspace: cargoWorkspace } = await getDebugExecutableInfo(runnable, env);

`

``

136

`+

const executable = await getDebugExecutable(runnable, env);

`

138

137

`let sourceFileMap = debugOptions.sourceFileMap;

`

139

138

`if (sourceFileMap === "auto") {

`

140

139

`// let's try to use the default toolchain

`

`@@ -148,13 +147,7 @@ async function getDebugConfiguration(

`

148

147

`}

`

149

148

``

150

149

`const provider = unwrapUndefinable(knownEngines[debugEngine.id]);

`

151

``

`-

const debugConfig = provider(

`

152

``

`-

runnable,

`

153

``

`-

simplifyPath(executable),

`

154

``

`-

cargoWorkspace,

`

155

``

`-

env,

`

156

``

`-

sourceFileMap,

`

157

``

`-

);

`

``

150

`+

const debugConfig = provider(runnable, simplifyPath(executable), env, sourceFileMap);

`

158

151

`if (debugConfig.type in debugOptions.engineSettings) {

`

159

152

`const settingsMap = (debugOptions.engineSettings as any)[debugConfig.type];

`

160

153

`for (var key in settingsMap) {

`

`@@ -176,21 +169,20 @@ async function getDebugConfiguration(

`

176

169

`return debugConfig;

`

177

170

`}

`

178

171

``

179

``

`-

async function getDebugExecutableInfo(

`

``

172

`+

async function getDebugExecutable(

`

180

173

`runnable: ra.Runnable,

`

181

174

`env: Record<string, string>,

`

182

``

`-

): Promise {

`

``

175

`+

): Promise {

`

183

176

`const cargo = new Cargo(runnable.args.workspaceRoot || ".", debugOutput, env);

`

184

``

`-

const executableInfo = await cargo.executableInfoFromArgs(runnable.args.cargoArgs);

`

``

177

`+

const executable = await cargo.executableFromArgs(runnable.args.cargoArgs);

`

185

178

``

186

179

`// if we are here, there were no compilation errors.

`

187

``

`-

return executableInfo;

`

``

180

`+

return executable;

`

188

181

`}

`

189

182

``

190

183

`function getCCppDebugConfig(

`

191

184

`runnable: ra.Runnable,

`

192

185

`executable: string,

`

193

``

`-

cargoWorkspace: string,

`

194

186

`env: Record<string, string>,

`

195

187

`sourceFileMap?: Record<string, string>,

`

196

188

`): vscode.DebugConfiguration {

`

`@@ -200,7 +192,7 @@ function getCCppDebugConfig(

`

200

192

`name: runnable.label,

`

201

193

`program: executable,

`

202

194

`args: runnable.args.executableArgs,

`

203

``

`-

cwd: cargoWorkspace || runnable.args.workspaceRoot,

`

``

195

`+

cwd: runnable.args.cwd || runnable.args.workspaceRoot || ".",

`

204

196

` sourceFileMap,

`

205

197

` env,

`

206

198

`// See https://github.com/rust-lang/rust-analyzer/issues/16901#issuecomment-2024486941

`

`@@ -213,7 +205,6 @@ function getCCppDebugConfig(

`

213

205

`function getCodeLldbDebugConfig(

`

214

206

`runnable: ra.Runnable,

`

215

207

`executable: string,

`

216

``

`-

cargoWorkspace: string,

`

217

208

`env: Record<string, string>,

`

218

209

`sourceFileMap?: Record<string, string>,

`

219

210

`): vscode.DebugConfiguration {

`

`@@ -223,7 +214,7 @@ function getCodeLldbDebugConfig(

`

223

214

`name: runnable.label,

`

224

215

`program: executable,

`

225

216

`args: runnable.args.executableArgs,

`

226

``

`-

cwd: cargoWorkspace || runnable.args.workspaceRoot,

`

``

217

`+

cwd: runnable.args.cwd || runnable.args.workspaceRoot || ".",

`

227

218

`sourceMap: sourceFileMap,

`

228

219

`sourceLanguages: ["rust"],

`

229

220

` env,

`

`@@ -233,7 +224,6 @@ function getCodeLldbDebugConfig(

`

233

224

`function getNativeDebugConfig(

`

234

225

`runnable: ra.Runnable,

`

235

226

`executable: string,

`

236

``

`-

cargoWorkspace: string,

`

237

227

`env: Record<string, string>,

`

238

228

`_sourceFileMap?: Record<string, string>,

`

239

229

`): vscode.DebugConfiguration {

`

`@@ -244,7 +234,7 @@ function getNativeDebugConfig(

`

244

234

`target: executable,

`

245

235

`// See https://github.com/WebFreak001/code-debug/issues/359

`

246

236

`arguments: quote(runnable.args.executableArgs),

`

247

``

`-

cwd: cargoWorkspace || runnable.args.workspaceRoot,

`

``

237

`+

cwd: runnable.args.cwd || runnable.args.workspaceRoot || ".",

`

248

238

` env,

`

249

239

`valuesFormatting: "prettyPrinters",

`

250

240

`};

`