) => {
+ state.cargoScript = action.payload;
+ },
},
});
@@ -135,16 +141,17 @@ export const {
changePairCharacters,
changePrimaryAction,
changeProcessAssembly,
+ changeCargoScript
} = slice.actions;
export const changeEdition =
(edition: Edition): ThunkAction =>
- (dispatch) => {
- if (edition === Edition.Rust2024) {
- dispatch(changeChannel(Channel.Nightly));
- }
+ (dispatch) => {
+ if (edition === Edition.Rust2024) {
+ dispatch(changeChannel(Channel.Nightly));
+ }
- dispatch(changeEditionRaw(edition));
- };
+ dispatch(changeEditionRaw(edition));
+ };
export default slice.reducer;
diff --git a/ui/frontend/reducers/output/clippy.ts b/ui/frontend/reducers/output/clippy.ts
index 5382c5932..19b08878c 100644
--- a/ui/frontend/reducers/output/clippy.ts
+++ b/ui/frontend/reducers/output/clippy.ts
@@ -23,6 +23,7 @@ interface ClippyRequestBody {
crateType: string;
edition: string;
code: string;
+ cargoScript: boolean;
}
const ClippyResponseBody = z.object({
diff --git a/ui/frontend/reducers/output/execute.ts b/ui/frontend/reducers/output/execute.ts
index 46ac1ded7..c0fe7cda2 100644
--- a/ui/frontend/reducers/output/execute.ts
+++ b/ui/frontend/reducers/output/execute.ts
@@ -83,6 +83,7 @@ export interface ExecuteRequestBody {
code: string;
edition: string;
backtrace: boolean;
+ cargoScript: boolean;
}
const ExecuteResponseBody = z.object({
@@ -108,16 +109,16 @@ const prepareWithCurrentSequenceNumber = (payload: P, sequenceNumber: number)
const sequenceNumberMatches =
(whenMatch: (state: Draft, payload: P) => void) =>
- (state: Draft, action: WsPayloadAction) => {
- const {
- payload,
- meta: { sequenceNumber },
- } = action;
+ (state: Draft, action: WsPayloadAction) => {
+ const {
+ payload,
+ meta: { sequenceNumber },
+ } = action;
- if (sequenceNumber === state.sequenceNumber) {
- whenMatch(state, payload);
- }
- };
+ if (sequenceNumber === state.sequenceNumber) {
+ whenMatch(state, payload);
+ }
+ };
const slice = createSlice({
name: 'output/execute',
@@ -137,17 +138,17 @@ const slice = createSlice({
}),
},
wsExecuteStdin: {
- reducer: () => {},
+ reducer: () => { },
prepare: prepareWithCurrentSequenceNumber,
},
wsExecuteStdinClose: {
- reducer: () => {},
+ reducer: () => { },
prepare: prepareWithCurrentSequenceNumber,
},
wsExecuteKill: {
- reducer: () => {},
+ reducer: () => { },
prepare: prepareWithCurrentSequenceNumber,
},
@@ -231,28 +232,28 @@ export const { wsExecuteRequest, allowLongRun, wsExecuteKill } = slice.actions;
export const performCommonExecute =
(crateType: string, tests: boolean): ThunkAction =>
- (dispatch, getState) => {
- const state = getState();
- const body = executeRequestPayloadSelector(state, { crateType, tests });
- const useWebSocket = executeViaWebsocketSelector(state);
-
- if (useWebSocket) {
- dispatch(wsExecuteRequest(body));
- } else {
- dispatch(performExecute(body));
- }
- };
+ (dispatch, getState) => {
+ const state = getState();
+ const body = executeRequestPayloadSelector(state, { crateType, tests });
+ const useWebSocket = executeViaWebsocketSelector(state);
+
+ if (useWebSocket) {
+ dispatch(wsExecuteRequest(body));
+ } else {
+ dispatch(performExecute(body));
+ }
+ };
const dispatchWhenSequenceNumber =
(cb: (sequenceNumber: number) => A): ThunkAction =>
- (dispatch, getState) => {
- const state = getState();
- const sequenceNumber = currentExecutionSequenceNumberSelector(state);
- if (sequenceNumber) {
- const action = cb(sequenceNumber);
- dispatch(action);
- }
- };
+ (dispatch, getState) => {
+ const state = getState();
+ const sequenceNumber = currentExecutionSequenceNumberSelector(state);
+ if (sequenceNumber) {
+ const action = cb(sequenceNumber);
+ dispatch(action);
+ }
+ };
export const wsExecuteStdin = (payload: string): ThunkAction =>
dispatchWhenSequenceNumber((sequenceNumber) =>
diff --git a/ui/frontend/reducers/output/format.ts b/ui/frontend/reducers/output/format.ts
index efdedea07..40d322aea 100644
--- a/ui/frontend/reducers/output/format.ts
+++ b/ui/frontend/reducers/output/format.ts
@@ -21,6 +21,7 @@ interface FormatRequestBody {
channel: string;
edition: string;
code: string;
+ cargoScript: boolean;
}
const FormatResponseBody = z.object({
diff --git a/ui/frontend/reducers/output/macroExpansion.ts b/ui/frontend/reducers/output/macroExpansion.ts
index 850e965c6..fb7d08a1c 100644
--- a/ui/frontend/reducers/output/macroExpansion.ts
+++ b/ui/frontend/reducers/output/macroExpansion.ts
@@ -21,6 +21,7 @@ interface State {
interface MacroExpansionRequestBody {
code: string;
edition: string;
+ cargoScript: boolean;
}
const MacroExpansionResponseBody = z.object({
diff --git a/ui/frontend/reducers/output/miri.ts b/ui/frontend/reducers/output/miri.ts
index 0c52f12d5..d8cbd8618 100644
--- a/ui/frontend/reducers/output/miri.ts
+++ b/ui/frontend/reducers/output/miri.ts
@@ -21,6 +21,7 @@ interface State {
interface MiriRequestBody {
code: string;
edition: string;
+ cargoScript: boolean;
}
const MiriResponseBody = z.object({
diff --git a/ui/frontend/selectors/index.ts b/ui/frontend/selectors/index.ts
index 8c53cbfe2..417f17075 100644
--- a/ui/frontend/selectors/index.ts
+++ b/ui/frontend/selectors/index.ts
@@ -4,6 +4,7 @@ import { createSelector } from '@reduxjs/toolkit';
import { State } from '../reducers';
import {
Backtrace,
+ CargoScript,
Channel,
Edition,
Focus,
@@ -16,6 +17,7 @@ import {
export const codeSelector = (state: State) => state.code;
export const positionSelector = (state: State) => state.position;
export const selectionSelector = (state: State) => state.selection;
+export const cargoScriptSelector = (state: State) => state.configuration.cargoScript === CargoScript.Enabled
const HAS_TESTS_RE = /^\s*#\s*\[\s*test\s*([^"]*)]/m;
export const hasTestsSelector = createSelector(codeSelector, code => !!code.match(HAS_TESTS_RE));
@@ -375,26 +377,30 @@ export const clippyRequestSelector = createSelector(
getCrateType,
editionSelector,
codeSelector,
- (channel, crateType, edition, code) => ({ channel, crateType, edition, code }),
+ cargoScriptSelector,
+ (channel, crateType, edition, code, cargoScript) => ({ channel, crateType, edition, code, cargoScript }),
);
export const formatRequestSelector = createSelector(
channelSelector,
editionSelector,
codeSelector,
- (channel, edition, code) => ({ channel, edition, code }),
+ cargoScriptSelector,
+ (channel, edition, code, cargoScript) => ({ channel, edition, code, cargoScript }),
);
export const miriRequestSelector = createSelector(
editionSelector,
codeSelector,
- (edition, code) => ({ edition, code }),
+ cargoScriptSelector,
+ (edition, code, cargoScript) => ({ edition, code, cargoScript }),
);
export const macroExpansionRequestSelector = createSelector(
editionSelector,
codeSelector,
- (edition, code) => ({ edition, code })
+ cargoScriptSelector,
+ (edition, code, cargoScript) => ({ edition, code, cargoScript })
);
const focus = (state: State) => state.output.meta.focus;
@@ -472,7 +478,8 @@ export const executeRequestPayloadSelector = createSelector(
(state: State) => state.configuration,
getBacktraceSet,
(_state: State, { crateType, tests }: { crateType: string, tests: boolean }) => ({ crateType, tests }),
- (code, channel, configuration, backtrace, { crateType, tests }) => ({
+ cargoScriptSelector,
+ (code, channel, configuration, backtrace, { crateType, tests }, cargoScript) => ({
channel,
mode: configuration.mode,
edition: configuration.edition,
@@ -480,6 +487,7 @@ export const executeRequestPayloadSelector = createSelector(
tests,
code,
backtrace,
+ cargoScript
}),
);
@@ -491,7 +499,8 @@ export const compileRequestPayloadSelector = createSelector(
runAsTest,
getBacktraceSet,
(_state: State, { target }: { target: string }) => ({ target }),
- (code, channel, configuration, crateType, tests, backtrace, { target }) => ({
+ cargoScriptSelector,
+ (code, channel, configuration, crateType, tests, backtrace, { target }, cargoScript) => ({
channel,
mode: configuration.mode,
edition: configuration.edition,
@@ -503,5 +512,6 @@ export const compileRequestPayloadSelector = createSelector(
demangleAssembly: configuration.demangleAssembly,
processAssembly: configuration.processAssembly,
backtrace,
+ cargoScript
}),
);
diff --git a/ui/frontend/types.ts b/ui/frontend/types.ts
index 0f1721a8f..92c01ab6a 100644
--- a/ui/frontend/types.ts
+++ b/ui/frontend/types.ts
@@ -161,3 +161,8 @@ export enum Focus {
export enum Notification {
RustSurvey2023 = 'rust-survey-2023',
}
+
+export enum CargoScript {
+ Enabled = 'enabled',
+ Disabled = 'disabled'
+}
\ No newline at end of file
diff --git a/ui/src/main.rs b/ui/src/main.rs
index d73d5b0f8..379b40682 100644
--- a/ui/src/main.rs
+++ b/ui/src/main.rs
@@ -335,24 +335,22 @@ struct ErrorJson {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
struct CompileRequest {
target: String,
- #[serde(rename = "assemblyFlavor")]
assembly_flavor: Option,
- #[serde(rename = "demangleAssembly")]
demangle_assembly: Option,
- #[serde(rename = "processAssembly")]
process_assembly: Option,
channel: String,
mode: String,
#[serde(default)]
edition: String,
- #[serde(rename = "crateType")]
crate_type: String,
tests: bool,
#[serde(default)]
backtrace: bool,
code: String,
+ cargo_script: bool,
}
#[derive(Debug, Clone, Serialize)]
@@ -366,6 +364,7 @@ struct CompileResponse {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
struct ExecuteRequest {
channel: String,
mode: String,
@@ -377,6 +376,7 @@ struct ExecuteRequest {
#[serde(default)]
backtrace: bool,
code: String,
+ cargo_script: bool,
}
#[derive(Debug, Clone, Serialize)]
@@ -389,12 +389,14 @@ struct ExecuteResponse {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
struct FormatRequest {
#[serde(default)]
channel: Option,
#[serde(default)]
edition: String,
code: String,
+ cargo_script: bool,
}
#[derive(Debug, Clone, Serialize)]
@@ -408,14 +410,16 @@ struct FormatResponse {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
struct ClippyRequest {
#[serde(default)]
channel: Option,
- #[serde(default = "default_crate_type", rename = "crateType")]
+ #[serde(default = "default_crate_type")]
crate_type: String,
#[serde(default)]
edition: String,
code: String,
+ cargo_script: bool,
}
#[derive(Debug, Clone, Serialize)]
@@ -427,10 +431,12 @@ struct ClippyResponse {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
struct MiriRequest {
code: String,
#[serde(default)]
edition: String,
+ cargo_script: bool,
}
#[derive(Debug, Clone, Serialize)]
@@ -442,10 +448,12 @@ struct MiriResponse {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
struct MacroExpansionRequest {
code: String,
#[serde(default)]
edition: String,
+ cargo_script: bool,
}
#[derive(Debug, Clone, Serialize)]
@@ -504,6 +512,7 @@ struct MetaGistResponse {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
struct EvaluateRequest {
version: String,
optimize: String,
@@ -512,6 +521,7 @@ struct EvaluateRequest {
edition: String,
#[serde(default)]
tests: bool,
+ cargo_script: bool,
}
#[derive(Debug, Clone, Serialize)]
diff --git a/ui/src/metrics.rs b/ui/src/metrics.rs
index b530240e5..eaa05b8ee 100644
--- a/ui/src/metrics.rs
+++ b/ui/src/metrics.rs
@@ -82,6 +82,7 @@ pub(crate) struct LabelsCore {
crate_type: Option,
tests: Option,
backtrace: Option,
+ cargo_script: Option,
}
#[derive(Debug, Copy, Clone)]
@@ -187,6 +188,7 @@ impl Labels {
crate_type,
tests,
backtrace,
+ cargo_script,
} = labels_core;
Self {
endpoint,
@@ -251,6 +253,7 @@ impl HasLabelsCore for coordinator::CompileRequest {
tests,
backtrace,
code: _,
+ cargo_script,
} = *self;
LabelsCore {
@@ -261,6 +264,7 @@ impl HasLabelsCore for coordinator::CompileRequest {
crate_type: Some(crate_type),
tests: Some(tests),
backtrace: Some(backtrace),
+ cargo_script: Some(cargo_script),
}
}
}
@@ -275,6 +279,7 @@ impl HasLabelsCore for coordinator::ExecuteRequest {
tests,
backtrace,
code: _,
+ cargo_script,
} = *self;
LabelsCore {
@@ -285,6 +290,7 @@ impl HasLabelsCore for coordinator::ExecuteRequest {
crate_type: Some(crate_type),
tests: Some(tests),
backtrace: Some(backtrace),
+ cargo_script: Some(cargo_script),
}
}
}
@@ -296,6 +302,7 @@ impl HasLabelsCore for coordinator::FormatRequest {
crate_type,
edition,
code: _,
+ cargo_script,
} = *self;
LabelsCore {
@@ -306,6 +313,7 @@ impl HasLabelsCore for coordinator::FormatRequest {
crate_type: Some(crate_type),
tests: None,
backtrace: None,
+ cargo_script: Some(cargo_script),
}
}
}
@@ -317,6 +325,7 @@ impl HasLabelsCore for coordinator::ClippyRequest {
crate_type,
edition,
code: _,
+ cargo_script,
} = *self;
LabelsCore {
@@ -327,6 +336,7 @@ impl HasLabelsCore for coordinator::ClippyRequest {
crate_type: Some(crate_type),
tests: None,
backtrace: None,
+ cargo_script: Some(cargo_script),
}
}
}
@@ -338,6 +348,7 @@ impl HasLabelsCore for coordinator::MiriRequest {
crate_type,
edition,
code: _,
+ cargo_script,
} = *self;
LabelsCore {
@@ -348,6 +359,7 @@ impl HasLabelsCore for coordinator::MiriRequest {
crate_type: Some(crate_type),
tests: None,
backtrace: None,
+ cargo_script: Some(cargo_script),
}
}
}
@@ -359,6 +371,7 @@ impl HasLabelsCore for coordinator::MacroExpansionRequest {
crate_type,
edition,
code: _,
+ cargo_script,
} = *self;
LabelsCore {
@@ -369,6 +382,7 @@ impl HasLabelsCore for coordinator::MacroExpansionRequest {
crate_type: Some(crate_type),
tests: None,
backtrace: None,
+ cargo_script: Some(cargo_script),
}
}
}
diff --git a/ui/src/server_axum.rs b/ui/src/server_axum.rs
index f0ec1c43d..9e21e3602 100644
--- a/ui/src/server_axum.rs
+++ b/ui/src/server_axum.rs
@@ -1049,6 +1049,7 @@ pub(crate) mod api_orchestrator_integration_impls {
code,
edition,
tests,
+ cargo_script,
} = other;
let mode = if optimize != "0" {
@@ -1071,6 +1072,7 @@ pub(crate) mod api_orchestrator_integration_impls {
tests,
backtrace: false,
code,
+ cargo_script,
})
}
}
@@ -1132,6 +1134,7 @@ pub(crate) mod api_orchestrator_integration_impls {
tests,
backtrace,
code,
+ cargo_script,
} = other;
Ok(Self {
@@ -1148,6 +1151,7 @@ pub(crate) mod api_orchestrator_integration_impls {
tests,
backtrace,
code,
+ cargo_script,
})
}
}
@@ -1205,6 +1209,7 @@ pub(crate) mod api_orchestrator_integration_impls {
tests,
backtrace,
code,
+ cargo_script,
} = other;
Ok(Self {
@@ -1215,6 +1220,7 @@ pub(crate) mod api_orchestrator_integration_impls {
tests,
backtrace,
code,
+ cargo_script,
})
}
}
@@ -1263,6 +1269,7 @@ pub(crate) mod api_orchestrator_integration_impls {
channel,
edition,
code,
+ cargo_script,
} = other;
let channel = match channel {
@@ -1275,6 +1282,7 @@ pub(crate) mod api_orchestrator_integration_impls {
crate_type: CrateType::Binary, // TODO: use what user has submitted
edition: parse_edition(&edition)?,
code,
+ cargo_script,
})
}
}
@@ -1320,6 +1328,7 @@ pub(crate) mod api_orchestrator_integration_impls {
crate_type,
edition,
code,
+ cargo_script,
} = other;
let channel = match channel {
@@ -1332,6 +1341,7 @@ pub(crate) mod api_orchestrator_integration_impls {
crate_type: parse_crate_type(&crate_type)?,
edition: parse_edition(&edition)?,
code,
+ cargo_script,
})
}
}
@@ -1373,13 +1383,18 @@ pub(crate) mod api_orchestrator_integration_impls {
type Error = ParseMiriRequestError;
fn try_from(other: crate::MiriRequest) -> std::result::Result {
- let crate::MiriRequest { code, edition } = other;
+ let crate::MiriRequest {
+ code,
+ edition,
+ cargo_script,
+ } = other;
Ok(MiriRequest {
channel: Channel::Nightly, // TODO: use what user has submitted
crate_type: CrateType::Binary, // TODO: use what user has submitted
edition: parse_edition(&edition)?,
code,
+ cargo_script,
})
}
}
@@ -1415,13 +1430,18 @@ pub(crate) mod api_orchestrator_integration_impls {
type Error = ParseMacroExpansionRequestError;
fn try_from(other: crate::MacroExpansionRequest) -> std::result::Result {
- let crate::MacroExpansionRequest { code, edition } = other;
+ let crate::MacroExpansionRequest {
+ code,
+ edition,
+ cargo_script,
+ } = other;
Ok(MacroExpansionRequest {
channel: Channel::Nightly, // TODO: use what user has submitted
crate_type: CrateType::Binary, // TODO: use what user has submitted
edition: parse_edition(&edition)?,
code,
+ cargo_script,
})
}
}
diff --git a/ui/src/server_axum/websocket.rs b/ui/src/server_axum/websocket.rs
index c54d13d5e..734e6738f 100644
--- a/ui/src/server_axum/websocket.rs
+++ b/ui/src/server_axum/websocket.rs
@@ -83,6 +83,7 @@ struct ExecuteRequest {
tests: bool,
code: String,
backtrace: bool,
+ cargo_script: bool,
}
impl TryFrom for coordinator::ExecuteRequest {
@@ -97,6 +98,7 @@ impl TryFrom for coordinator::ExecuteRequest {
tests,
code,
backtrace,
+ cargo_script,
} = value;
Ok(coordinator::ExecuteRequest {
@@ -107,6 +109,7 @@ impl TryFrom for coordinator::ExecuteRequest {
tests,
backtrace,
code,
+ cargo_script,
})
}
}