Skip to content

Commit 2d176d6

Browse files
committed
Use the currently selected channel to execute Clippy
1 parent 26b579e commit 2d176d6

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

ui/frontend/reducers/output/clippy.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ interface State {
1919
}
2020

2121
interface ClippyRequestBody {
22-
code: string;
23-
edition: string;
22+
channel: string;
2423
crateType: string;
24+
edition: string;
25+
code: string;
2526
}
2627

2728
const ClippyResponseBody = z.object({

ui/frontend/selectors/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const getStable = (state: State) => state.versions.stable?.rustc;
120120
const getBeta = (state: State) => state.versions.beta?.rustc;
121121
const getNightly = (state: State) => state.versions.nightly?.rustc;
122122
const getRustfmt = createSelector(selectedChannelVersionsSelector, (versions) => versions?.rustfmt);
123-
const getClippy = (state: State) => state.versions.nightly?.clippy;
123+
const getClippy = createSelector(selectedChannelVersionsSelector, (versions) => versions?.clippy);
124124
const getMiri = (state: State) => state.versions?.nightly?.miri;
125125

126126
const versionNumber = (v: Version | undefined) => v ? v.version : '';
@@ -319,10 +319,11 @@ export const anyNotificationsToShowSelector = createSelector(
319319
);
320320

321321
export const clippyRequestSelector = createSelector(
322-
codeSelector,
323-
editionSelector,
322+
channelSelector,
324323
getCrateType,
325-
(code, edition, crateType) => ({ code, edition, crateType }),
324+
editionSelector,
325+
codeSelector,
326+
(channel, crateType, edition, code) => ({ channel, crateType, edition, code }),
326327
);
327328

328329
export const formatRequestSelector = createSelector(

ui/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,13 @@ struct FormatResponse {
374374

375375
#[derive(Debug, Clone, Deserialize)]
376376
struct ClippyRequest {
377-
code: String,
378377
#[serde(default)]
379-
edition: String,
378+
channel: Option<String>,
380379
#[serde(default = "default_crate_type", rename = "crateType")]
381380
crate_type: String,
381+
#[serde(default)]
382+
edition: String,
383+
code: String,
382384
}
383385

384386
#[derive(Debug, Clone, Serialize)]

ui/src/server_axum.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,13 +1109,19 @@ pub(crate) mod api_orchestrator_integration_impls {
11091109

11101110
fn try_from(other: crate::ClippyRequest) -> std::result::Result<Self, Self::Error> {
11111111
let crate::ClippyRequest {
1112-
code,
1113-
edition,
1112+
channel,
11141113
crate_type,
1114+
edition,
1115+
code,
11151116
} = other;
11161117

1118+
let channel = match channel {
1119+
Some(c) => parse_channel(&c)?,
1120+
None => Channel::Nightly,
1121+
};
1122+
11171123
Ok(ClippyRequest {
1118-
channel: Channel::Nightly, // TODO: use what user has submitted
1124+
channel,
11191125
crate_type: parse_crate_type(&crate_type)?,
11201126
edition: parse_edition(&edition)?,
11211127
code,
@@ -1126,10 +1132,13 @@ pub(crate) mod api_orchestrator_integration_impls {
11261132
#[derive(Debug, Snafu)]
11271133
pub(crate) enum ParseClippyRequestError {
11281134
#[snafu(context(false))]
1129-
Edition { source: ParseEditionError },
1135+
Channel { source: ParseChannelError },
11301136

11311137
#[snafu(context(false))]
11321138
CrateType { source: ParseCrateTypeError },
1139+
1140+
#[snafu(context(false))]
1141+
Edition { source: ParseEditionError },
11331142
}
11341143

11351144
impl From<WithOutput<ClippyResponse>> for crate::ClippyResponse {

0 commit comments

Comments
 (0)