-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #999 from rust-lang/no-hide-fmt-error
Do not hide rustfmt output when it failed
- Loading branch information
Showing
5 changed files
with
83 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |