Skip to content

♪ EditiooOoOOnnN ! ♫ #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/spec/features/tools_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def code_with_undefined_behavior
expect(page).to have_content('core::fmt::Arguments::new_v1')

# Third-party procedural macro
expect(page).to have_content('block_on(async')
expect(page).to have_content('block_on(body)')

# User-specified declarative macro
expect(page).to have_content('fn created_by_macro() -> i32 { 42 }')
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/features/url_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

scenario "loading without code or an edition" do
visit '/'
expect(page).to have_edition('2018')
expect(page).to have_edition('2021')
end

def editor
Expand Down
12 changes: 0 additions & 12 deletions ui/frontend/AdvancedOptionsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { useSelector, useDispatch } from 'react-redux';
import * as actions from './actions';
import { Either as EitherConfig, Select as SelectConfig } from './ConfigElement';
import MenuGroup from './MenuGroup';
import MenuAside from './MenuAside';
import { State } from './reducers';
import * as selectors from './selectors';
import { Backtrace, Edition } from './types';

const AdvancedOptionsMenu: React.SFC = () => {
const isEditionDefault = useSelector(selectors.isEditionDefault);
const edition = useSelector((state: State) => state.configuration.edition);
const isRust2021Available = useSelector(selectors.isRust2021Available);
const isBacktraceSet = useSelector(selectors.getBacktraceSet);
const backtrace = useSelector((state: State) => state.configuration.backtrace);

Expand All @@ -21,16 +19,13 @@ const AdvancedOptionsMenu: React.SFC = () => {
const changeEdition = useCallback((e) => dispatch(actions.changeEdition(e)), [dispatch]);
const changeBacktrace = useCallback((b) => dispatch(actions.changeBacktrace(b)), [dispatch]);

const Aside = !isRust2021Available && <Rust2021Aside />;

return (
<MenuGroup title="Advanced options">
<SelectConfig
name="Edition"
value={edition}
isNotDefault={!isEditionDefault}
onChange={changeEdition}
aside={Aside}
>
<option value={Edition.Rust2015}>2015</option>
<option value={Edition.Rust2018}>2018</option>
Expand All @@ -49,11 +44,4 @@ const AdvancedOptionsMenu: React.SFC = () => {
);
};

const Rust2021Aside: React.SFC = () => (
<MenuAside>
Note: Rust 2021 currently requires using the Nightly channel, selecting this
option will switch to Nightly.
</MenuAside>
);

export default AdvancedOptionsMenu;
23 changes: 11 additions & 12 deletions ui/frontend/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,29 @@ import * as selectors from './selectors';

import styles from './Notifications.module.css';

const SURVEY_URL = 'https://blog.rust-lang.org/2020/09/10/survey-launch.html';
const EDITION_URL = 'https://doc.rust-lang.org/edition-guide/';

const Notifications: React.SFC = () => {
return (
<Portal>
<div className={styles.container}>
<Rust2020SurveyNotification />
<Rust2021IsDefaultNotification />
</div>
</Portal>
);
};

const Rust2020SurveyNotification: React.SFC = () => {
const showRust2020Survey = useSelector(selectors.showRustSurvey2020Selector);
const Rust2021IsDefaultNotification: React.SFC = () => {
const showRust2021IsDefault = useSelector(selectors.showRust2021IsDefaultSelector);

const dispatch = useDispatch();
const seenRustSurvey2020 = useCallback(() => dispatch(actions.seenRustSurvey2020()), [dispatch]);

return showRust2020Survey && (
<Notification onClose={seenRustSurvey2020}>
We want to know your opinions! Your responses to
the <a href={SURVEY_URL}>2020 State of Rust Survey</a> will
help the project understand its strengths and weaknesses
and establish development priorities for the future!
const seenRust2021IsDefault = useCallback(() => dispatch(actions.seenRust2021IsDefault()), [dispatch]);

return showRust2021IsDefault && (
<Notification onClose={seenRust2021IsDefault}>
As of Rust 1.56, the default edition of Rust is now Rust
2021. Learn more about editions in the <a href={EDITION_URL}>Edition Guide</a>.
To specify which edition to use, use the advanced compilation options menu.
</Notification>
);
};
Expand Down
2 changes: 1 addition & 1 deletion ui/frontend/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ export function performVersionsLoad(): ThunkAction {
const notificationSeen = (notification: Notification) =>
createAction(ActionType.NotificationSeen, { notification });

export const seenRustSurvey2020 = () => notificationSeen(Notification.RustSurvey2020);
export const seenRust2021IsDefault = () => notificationSeen(Notification.Rust2021IsDefault);

export const browserWidthChanged = (isSmall: boolean) =>
createAction(ActionType.BrowserWidthChanged, { isSmall });
Expand Down
2 changes: 1 addition & 1 deletion ui/frontend/reducers/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const DEFAULT: State = {
primaryAction: PrimaryActionAuto.Auto,
channel: Channel.Stable,
mode: Mode.Debug,
edition: Edition.Rust2018,
edition: Edition.Rust2021,
backtrace: Backtrace.Disabled,
};

Expand Down
10 changes: 6 additions & 4 deletions ui/frontend/reducers/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ import { Notification } from '../types';
interface State {
seenRustSurvey2018: boolean; // expired
seenRust2018IsDefault: boolean; // expired
seenRustSurvey2020: boolean;
seenRustSurvey2020: boolean; // expired
seenRust2021IsDefault: boolean;
}

const DEFAULT: State = {
seenRustSurvey2018: true,
seenRust2018IsDefault: true,
seenRustSurvey2020: false,
seenRustSurvey2020: true,
seenRust2021IsDefault: false,
};

export default function notifications(state = DEFAULT, action: Action): State {
switch (action.type) {
case ActionType.NotificationSeen: {
switch (action.notification) {
case Notification.RustSurvey2020: {
return { ...state, seenRustSurvey2020: true };
case Notification.Rust2021IsDefault: {
return { ...state, seenRust2021IsDefault: true };
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions ui/frontend/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export const isNightlyChannel = (state: State) => (
);
export const isWasmAvailable = isNightlyChannel;
export const isHirAvailable = isNightlyChannel;
export const isRust2021Available = isNightlyChannel;

export const getModeLabel = (state: State) => {
const { configuration: { mode } } = state;
Expand All @@ -122,7 +121,7 @@ export const getChannelLabel = (state: State) => {

export const isEditionDefault = createSelector(
editionSelector,
edition => edition == Edition.Rust2018,
edition => edition == Edition.Rust2021,
);

export const getBacktraceSet = (state: State) => (
Expand Down Expand Up @@ -250,15 +249,15 @@ export const codeUrlSelector = createSelector(
const notificationsSelector = (state: State) => state.notifications;

const NOW = new Date();
const RUST_SURVEY_2020_END = new Date('2020-09-24T23:59:59Z');
const RUST_SURVEY_2020_OPEN = NOW <= RUST_SURVEY_2020_END;
export const showRustSurvey2020Selector = createSelector(
const RUST_2021_DEFAULT_END = new Date('2022-01-01T00:00:00Z');
const RUST_2021_DEFAULT_OPEN = NOW <= RUST_2021_DEFAULT_END;
export const showRust2021IsDefaultSelector = createSelector(
notificationsSelector,
notifications => RUST_SURVEY_2020_OPEN && !notifications.seenRustSurvey2020,
notifications => RUST_2021_DEFAULT_OPEN && !notifications.seenRust2021IsDefault,
);

export const anyNotificationsToShowSelector = createSelector(
showRustSurvey2020Selector,
showRust2021IsDefaultSelector,
allNotifications => allNotifications,
);

Expand Down
2 changes: 1 addition & 1 deletion ui/frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export enum Focus {
}

export enum Notification {
RustSurvey2020 = 'rust-survey-2020',
Rust2021IsDefault = 'rust-2021-is-default',
}

export type AceResizeKey = [Focus, number];