Skip to content

Commit

Permalink
Merge pull request #999 from rust-lang/no-hide-fmt-error
Browse files Browse the repository at this point in the history
Do not hide rustfmt output when it failed
  • Loading branch information
shepmaster authored Nov 20, 2023
2 parents b4f8269 + 5497162 commit 31b3fcb
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 61 deletions.
1 change: 1 addition & 0 deletions ui/frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = {
'reducers/output/gist.ts',
'reducers/output/hir.ts',
'reducers/output/llvmIr.ts',
'reducers/output/meta.ts',
'reducers/output/mir.ts',
'reducers/output/wasm.ts',
'reducers/websocket.ts',
Expand Down
1 change: 1 addition & 0 deletions ui/frontend/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ node_modules
!reducers/output/gist.ts
!reducers/output/hir.ts
!reducers/output/llvmIr.ts
!reducers/output/meta.ts
!reducers/output/mir.ts
!reducers/output/wasm.ts
!reducers/websocket.ts
Expand Down
26 changes: 13 additions & 13 deletions ui/frontend/Output.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback } from 'react';
import { useSelector, useDispatch } from 'react-redux';

import * as actions from './actions';
import { changeFocus } from './reducers/output/meta';
import { State } from './reducers';
import { Focus } from './types';

Expand Down Expand Up @@ -52,18 +52,18 @@ const Output: React.FC = () => {
useSelector((state: State) => state.output);

const dispatch = useDispatch();
const focusClose = useCallback(() => dispatch(actions.changeFocus()), [dispatch]);
const focusExecute = useCallback(() => dispatch(actions.changeFocus(Focus.Execute)), [dispatch]);
const focusFormat = useCallback(() => dispatch(actions.changeFocus(Focus.Format)), [dispatch]);
const focusClippy = useCallback(() => dispatch(actions.changeFocus(Focus.Clippy)), [dispatch]);
const focusMiri = useCallback(() => dispatch(actions.changeFocus(Focus.Miri)), [dispatch]);
const focusMacroExpansion = useCallback(() => dispatch(actions.changeFocus(Focus.MacroExpansion)), [dispatch]);
const focusAssembly = useCallback(() => dispatch(actions.changeFocus(Focus.Asm)), [dispatch]);
const focusLlvmIr = useCallback(() => dispatch(actions.changeFocus(Focus.LlvmIr)), [dispatch]);
const focusMir = useCallback(() => dispatch(actions.changeFocus(Focus.Mir)), [dispatch]);
const focusHir = useCallback(() => dispatch(actions.changeFocus(Focus.Hir)), [dispatch]);
const focusWasm = useCallback(() => dispatch(actions.changeFocus(Focus.Wasm)), [dispatch]);
const focusGist = useCallback(() => dispatch(actions.changeFocus(Focus.Gist)), [dispatch]);
const focusClose = useCallback(() => dispatch(changeFocus()), [dispatch]);
const focusExecute = useCallback(() => dispatch(changeFocus(Focus.Execute)), [dispatch]);
const focusFormat = useCallback(() => dispatch(changeFocus(Focus.Format)), [dispatch]);
const focusClippy = useCallback(() => dispatch(changeFocus(Focus.Clippy)), [dispatch]);
const focusMiri = useCallback(() => dispatch(changeFocus(Focus.Miri)), [dispatch]);
const focusMacroExpansion = useCallback(() => dispatch(changeFocus(Focus.MacroExpansion)), [dispatch]);
const focusAssembly = useCallback(() => dispatch(changeFocus(Focus.Asm)), [dispatch]);
const focusLlvmIr = useCallback(() => dispatch(changeFocus(Focus.LlvmIr)), [dispatch]);
const focusMir = useCallback(() => dispatch(changeFocus(Focus.Mir)), [dispatch]);
const focusHir = useCallback(() => dispatch(changeFocus(Focus.Hir)), [dispatch]);
const focusWasm = useCallback(() => dispatch(changeFocus(Focus.Wasm)), [dispatch]);
const focusGist = useCallback(() => dispatch(changeFocus(Focus.Gist)), [dispatch]);

const showStdin = useSelector(selectors.showStdinSelector);

Expand Down
6 changes: 0 additions & 6 deletions ui/frontend/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
DemangleAssembly,
Edition,
Editor,
Focus,
Mode,
Notification,
Orientation,
Expand Down Expand Up @@ -86,7 +85,6 @@ export enum ActionType {
ChangeMode = 'CHANGE_MODE',
ChangeEdition = 'CHANGE_EDITION',
ChangeBacktrace = 'CHANGE_BACKTRACE',
ChangeFocus = 'CHANGE_FOCUS',
EditCode = 'EDIT_CODE',
AddMainFunction = 'ADD_MAIN_FUNCTION',
AddImport = 'ADD_IMPORT',
Expand Down Expand Up @@ -174,9 +172,6 @@ export const reExecuteWithBacktrace = (): ThunkAction => dispatch => {
dispatch(performExecuteOnly());
};

export const changeFocus = (focus?: Focus) =>
createAction(ActionType.ChangeFocus, { focus });

type FetchArg = Parameters<typeof fetch>[0];

export function jsonGet(url: FetchArg) {
Expand Down Expand Up @@ -634,7 +629,6 @@ export type Action =
| ReturnType<typeof changeDemangleAssembly>
| ReturnType<typeof changeEditionRaw>
| ReturnType<typeof changeEditor>
| ReturnType<typeof changeFocus>
| ReturnType<typeof changeKeybinding>
| ReturnType<typeof changeMode>
| ReturnType<typeof changeOrientation>
Expand Down
110 changes: 68 additions & 42 deletions ui/frontend/reducers/output/meta.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,90 @@
import { Action, ActionType } from '../../actions';
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
import { Draft } from 'immer';

import { ActionType } from '../../actions';
import { Focus } from '../../types';
import { performGistLoad, performGistSave } from './gist';
import { performFormat } from './format';
import { performExecute, wsExecuteRequest } from './execute';
import { performCompileAssembly } from './assembly';
import { performExecute, wsExecuteRequest } from './execute';
import { performFormat } from './format';
import { performGistLoad, performGistSave } from './gist';
import { performCompileHir } from './hir';
import { performCompileLlvmIr } from './llvmIr';
import { performCompileMir } from './mir';
import { performCompileWasm } from './wasm';

const DEFAULT: State = {
};
const initialState: State = {};

interface State {
focus?: Focus;
}

export default function meta(state = DEFAULT, action: Action) {
switch (action.type) {
case ActionType.ChangeFocus:
return { ...state, focus: action.focus };
function setExecute(state: Draft<State>) {
state.focus = Focus.Execute;
}
function setGist(state: Draft<State>) {
state.focus = Focus.Gist;
}

case ActionType.RequestClippy:
return { ...state, focus: Focus.Clippy };
const slice = createSlice({
name: 'output/meta',
initialState,
reducers: {
changeFocus: (state, action: PayloadAction<Focus | undefined>) => {
state.focus = action.payload;
},
},
extraReducers: (builder) => {
builder
.addCase(ActionType.RequestClippy, (state) => {
state.focus = Focus.Clippy;
})

case ActionType.RequestMiri:
return { ...state, focus: Focus.Miri };
.addCase(ActionType.RequestMiri, (state) => {
state.focus = Focus.Miri;
})

case ActionType.RequestMacroExpansion:
return { ...state, focus: Focus.MacroExpansion };
.addCase(ActionType.RequestMacroExpansion, (state) => {
state.focus = Focus.MacroExpansion;
})

case performExecute.pending.type:
case wsExecuteRequest.type:
return { ...state, focus: Focus.Execute };
.addCase(performExecute.pending, setExecute)
.addCase(wsExecuteRequest, setExecute)

case performCompileAssembly.pending.type:
return { ...state, focus: Focus.Asm };
.addCase(performCompileAssembly.pending, (state) => {
state.focus = Focus.Asm;
})

case performCompileHir.pending.type:
return { ...state, focus: Focus.Hir };
.addCase(performCompileHir.pending, (state) => {
state.focus = Focus.Hir;
})

case performCompileLlvmIr.pending.type:
return { ...state, focus: Focus.LlvmIr };
.addCase(performCompileLlvmIr.pending, (state) => {
state.focus = Focus.LlvmIr;
})

case performCompileMir.pending.type:
return { ...state, focus: Focus.Mir };
.addCase(performCompileMir.pending, (state) => {
state.focus = Focus.Mir;
})

case performCompileWasm.pending.type:
return { ...state, focus: Focus.Wasm };
.addCase(performCompileWasm.pending, (state) => {
state.focus = Focus.Wasm;
})

default: {
if (performGistLoad.pending.match(action) || performGistSave.pending.match(action)) {
return { ...state, focus: Focus.Gist };
} else if (performFormat.pending.match(action)) {
return { ...state, focus: Focus.Format };
} else if (performFormat.fulfilled.match(action)) {
return { ...state, focus: undefined };
} else {
return state;
}
}
}
}
.addCase(performFormat.pending, (state) => {
state.focus = Focus.Format;
})

.addCase(performFormat.fulfilled, (state, action) => {
if (action.payload.success) {
state.focus = undefined;
}
})

.addCase(performGistLoad.pending, setGist)
.addCase(performGistSave.pending, setGist);
},
});

export const { changeFocus } = slice.actions;

export default slice.reducer;

0 comments on commit 31b3fcb

Please sign in to comment.