From 952e95e8428f1a8c6fd725bc0a2f75cf62f24689 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Tue, 18 Feb 2025 11:09:29 -0500 Subject: [PATCH 1/4] Simplify test timeouts now that async fn in traits is stable --- compiler/base/orchestrator/src/coordinator.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/base/orchestrator/src/coordinator.rs b/compiler/base/orchestrator/src/coordinator.rs index 85645496..e260e7f8 100644 --- a/compiler/base/orchestrator/src/coordinator.rs +++ b/compiler/base/orchestrator/src/coordinator.rs @@ -4265,14 +4265,10 @@ mod tests { }); trait TimeoutExt: Future + Sized { - #[allow(clippy::type_complexity)] - fn with_timeout( - self, - ) -> futures::future::Map< - tokio::time::Timeout, - fn(Result) -> Self::Output, - > { - tokio::time::timeout(*TIMEOUT, self).map(|v| v.expect("The operation timed out")) + async fn with_timeout(self) -> Self::Output { + tokio::time::timeout(*TIMEOUT, self) + .await + .expect("The operation timed out") } } From 09fe39181fbd590dafb6015442425da41ed2a55b Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Tue, 18 Feb 2025 09:50:25 -0500 Subject: [PATCH 2/4] Make edition 2024 the default --- compiler/base/orchestrator/src/coordinator.rs | 9 +-------- tests/spec/features/compilation_targets_spec.rb | 2 +- tests/spec/features/editions_spec.rb | 10 ++-------- tests/spec/features/url_parameters_spec.rb | 2 +- ui/frontend/AdvancedOptionsMenu.tsx | 7 ++----- ui/frontend/actions.ts | 6 +++--- ui/frontend/reducers/configuration.ts | 17 +++-------------- ui/frontend/selectors/index.ts | 2 +- 8 files changed, 14 insertions(+), 41 deletions(-) diff --git a/compiler/base/orchestrator/src/coordinator.rs b/compiler/base/orchestrator/src/coordinator.rs index e260e7f8..75352fcb 100644 --- a/compiler/base/orchestrator/src/coordinator.rs +++ b/compiler/base/orchestrator/src/coordinator.rs @@ -3074,11 +3074,7 @@ mod tests { r#"fn x() { u16::try_from(1u8); }"#, [false, false, true, true], ), - ( - r#"#![feature(gen_blocks)] - fn x() { gen { yield 1u8 }; }"#, - [false, false, false, true], - ), + (r#"fn x() { let gen = true; }"#, [true, true, true, false]), ]; let tests = params.into_iter().flat_map(|(code, works_in)| { @@ -3090,7 +3086,6 @@ mod tests { code: code.into(), edition, crate_type: CrateType::Library(LibraryType::Lib), - channel: Channel::Nightly, // To allow 2024 while it is unstable ..ARBITRARY_EXECUTE_REQUEST }; let response = coordinator.execute(request).await.unwrap(); @@ -3524,7 +3519,6 @@ mod tests { let req = CompileRequest { edition, code: SUBTRACT_CODE.into(), - channel: Channel::Nightly, // To allow 2024 while it is unstable ..ARBITRARY_HIR_REQUEST }; @@ -3855,7 +3849,6 @@ mod tests { let req = FormatRequest { edition, code: code.into(), - channel: Channel::Nightly, // To allow 2024 while it is unstable ..ARBITRARY_FORMAT_REQUEST }; diff --git a/tests/spec/features/compilation_targets_spec.rb b/tests/spec/features/compilation_targets_spec.rb index 9198c3e9..4c4f588d 100644 --- a/tests/spec/features/compilation_targets_spec.rb +++ b/tests/spec/features/compilation_targets_spec.rb @@ -119,7 +119,7 @@ scenario "compiling a library to WebAssembly" do editor.set <<~EOF - #[no_mangle] + #[unsafe(no_mangle)] pub fn calculator(a: u8) -> u8 { a + 42 } EOF diff --git a/tests/spec/features/editions_spec.rb b/tests/spec/features/editions_spec.rb index f828c3db..b5219db7 100644 --- a/tests/spec/features/editions_spec.rb +++ b/tests/spec/features/editions_spec.rb @@ -39,13 +39,8 @@ scenario "using the 2024 edition" do editor.set <<-EOF - #![feature(gen_blocks)] - fn main() { - let mut x = gen { yield 1 }; - - eprintln!("{:?}", x.next()); - eprintln!("{:?}", x.next()); + let gen = 1; } EOF @@ -53,8 +48,7 @@ click_on("Run") within(:output, :stderr) do - expect(page).to have_content 'Some(1)' - expect(page).to have_content 'None' + expect(page).to have_content 'found reserved keyword `gen`' end end diff --git a/tests/spec/features/url_parameters_spec.rb b/tests/spec/features/url_parameters_spec.rb index 4f7d3021..b70c2ccb 100644 --- a/tests/spec/features/url_parameters_spec.rb +++ b/tests/spec/features/url_parameters_spec.rb @@ -104,7 +104,7 @@ scenario "loading without code or an edition" do visit '/' - expect(page).to have_edition('2021') + expect(page).to have_edition('2024') end def editor diff --git a/ui/frontend/AdvancedOptionsMenu.tsx b/ui/frontend/AdvancedOptionsMenu.tsx index a684ed0a..4e73ba6b 100644 --- a/ui/frontend/AdvancedOptionsMenu.tsx +++ b/ui/frontend/AdvancedOptionsMenu.tsx @@ -4,7 +4,7 @@ import * as config from './reducers/configuration'; import { Either as EitherConfig, Select as SelectConfig } from './ConfigElement'; import MenuGroup from './MenuGroup'; import * as selectors from './selectors'; -import { Backtrace, Channel, Edition } from './types'; +import { Backtrace, Edition } from './types'; import { useAppDispatch, useAppSelector } from './hooks'; const AdvancedOptionsMenu: React.FC = () => { @@ -18,9 +18,6 @@ const AdvancedOptionsMenu: React.FC = () => { const changeEdition = useCallback((e: Edition) => dispatch(config.changeEdition(e)), [dispatch]); const changeBacktrace = useCallback((b: Backtrace) => dispatch(config.changeBacktrace(b)), [dispatch]); - const channel = useAppSelector((state) => state.configuration.channel); - const switchText = (channel !== Channel.Nightly) ? ' (will select nightly Rust)' : ''; - return ( { - + ) => { + changeEdition: (state, action: PayloadAction) => { state.edition = action.payload; }, @@ -149,7 +148,7 @@ export const { changeBacktrace, changeChannel, changeDemangleAssembly, - changeEditionRaw, + changeEdition, changeEditor, changeKeybinding, changeMode, @@ -162,14 +161,4 @@ export const { swapTheme, } = slice.actions; -export const changeEdition = - (edition: Edition): ThunkAction => - (dispatch) => { - if (edition === Edition.Rust2024) { - dispatch(changeChannel(Channel.Nightly)); - } - - dispatch(changeEditionRaw(edition)); - }; - export default slice.reducer; diff --git a/ui/frontend/selectors/index.ts b/ui/frontend/selectors/index.ts index 78756147..6369ab73 100644 --- a/ui/frontend/selectors/index.ts +++ b/ui/frontend/selectors/index.ts @@ -172,7 +172,7 @@ export const getChannelLabel = createSelector(channelSelector, (channel) => `${c export const isEditionDefault = createSelector( editionSelector, - edition => edition == Edition.Rust2021, + edition => edition == Edition.Rust2024, ); export const getBacktraceSet = (state: State) => ( From 0440cd98c1ae4df128cb82c4a767385cf2bf5162 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Tue, 18 Feb 2025 10:05:17 -0500 Subject: [PATCH 3/4] Add Rust 2024 default notification --- ui/frontend/Notifications.tsx | 19 ++++++++++++++++++- ui/frontend/reducers/notifications.ts | 8 ++++++++ ui/frontend/selectors/index.ts | 8 ++++++++ ui/frontend/types.ts | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ui/frontend/Notifications.tsx b/ui/frontend/Notifications.tsx index f3e905e9..4efe12ff 100644 --- a/ui/frontend/Notifications.tsx +++ b/ui/frontend/Notifications.tsx @@ -3,19 +3,21 @@ import { Portal } from 'react-portal'; import { Close } from './Icon'; import { useAppDispatch, useAppSelector } from './hooks'; -import { seenRustSurvey2024 } from './reducers/notifications'; +import { seenRust2024IsDefault, seenRustSurvey2024 } from './reducers/notifications'; import { allowLongRun, wsExecuteKillCurrent } from './reducers/output/execute'; import * as selectors from './selectors'; import * as styles from './Notifications.module.css'; const SURVEY_URL = 'https://blog.rust-lang.org/2024/12/05/annual-survey-2024-launch.html'; +const EDITION_URL = 'https://doc.rust-lang.org/edition-guide/'; const Notifications: React.FC = () => { return (
+
@@ -38,6 +40,21 @@ const RustSurvey2024Notification: React.FC = () => { ) : null; }; +const Rust2024IsDefaultNotification: React.FC = () => { + const showIt = useAppSelector(selectors.showRust2024IsDefaultSelector); + + const dispatch = useAppDispatch(); + const seenIt = useCallback(() => dispatch(seenRust2024IsDefault()), [dispatch]); + + return showIt ? ( + + As of Rust 1.85, the default edition of Rust is now Rust 2024. Learn more about editions in + the Edition Guide. To specify which edition to use, use the advanced + compilation options menu. + + ) : null; +}; + const ExcessiveExecutionNotification: React.FC = () => { const showExcessiveExecution = useAppSelector(selectors.excessiveExecutionSelector); const time = useAppSelector(selectors.excessiveExecutionTimeSelector); diff --git a/ui/frontend/reducers/notifications.ts b/ui/frontend/reducers/notifications.ts index 1f159386..77851296 100644 --- a/ui/frontend/reducers/notifications.ts +++ b/ui/frontend/reducers/notifications.ts @@ -13,6 +13,7 @@ interface State { seenRustSurvey2023: boolean; // expired seenDarkMode: boolean; // expired seenRustSurvey2024: boolean; + seenRust2024IsDefault: boolean; } const initialState: State = { @@ -26,6 +27,7 @@ const initialState: State = { seenRustSurvey2023: true, seenDarkMode: true, seenRustSurvey2024: false, + seenRust2024IsDefault: false, }; const slice = createSlice({ @@ -38,6 +40,10 @@ const slice = createSlice({ state.seenRustSurvey2024 = true; break; } + case Notification.Rust2024IsDefault: { + state.seenRust2024IsDefault = true; + break; + } } }, }, @@ -47,4 +53,6 @@ const { notificationSeen } = slice.actions; export const seenRustSurvey2024 = () => notificationSeen(Notification.RustSurvey2024); +export const seenRust2024IsDefault = () => notificationSeen(Notification.Rust2024IsDefault); + export default slice.reducer; diff --git a/ui/frontend/selectors/index.ts b/ui/frontend/selectors/index.ts index 6369ab73..1e5d3a66 100644 --- a/ui/frontend/selectors/index.ts +++ b/ui/frontend/selectors/index.ts @@ -367,8 +367,16 @@ export const showRustSurvey2024Selector = createSelector( notifications => RUST_SURVEY_2024_OPEN && !notifications.seenRustSurvey2024, ); +const RUST_2024_IS_DEFAULT_END = new Date('2025-04-03T00:00:00Z'); +const RUST_2024_IS_DEFAULT_OPEN = NOW <= RUST_2024_IS_DEFAULT_END; +export const showRust2024IsDefaultSelector = createSelector( + notificationsSelector, + notifications => RUST_2024_IS_DEFAULT_OPEN && !notifications.seenRust2024IsDefault, +); + export const anyNotificationsToShowSelector = createSelector( showRustSurvey2024Selector, + showRust2024IsDefaultSelector, excessiveExecutionSelector, (...allNotifications) => allNotifications.some(n => n), ); diff --git a/ui/frontend/types.ts b/ui/frontend/types.ts index cc954562..efe8bd26 100644 --- a/ui/frontend/types.ts +++ b/ui/frontend/types.ts @@ -166,4 +166,5 @@ export enum Focus { export enum Notification { RustSurvey2024 = 'rust-survey-2024', + Rust2024IsDefault = 'rust-2024-is-default', } From a1a782ec74e90c4931be3c54c031c2f2225c03c8 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Tue, 18 Feb 2025 10:07:46 -0500 Subject: [PATCH 4/4] Remove the notification for the Rust 2024 survey --- ui/frontend/Notifications.tsx | 20 +------------------- ui/frontend/reducers/notifications.ts | 10 ++-------- ui/frontend/selectors/index.ts | 8 -------- ui/frontend/types.ts | 1 - 4 files changed, 3 insertions(+), 36 deletions(-) diff --git a/ui/frontend/Notifications.tsx b/ui/frontend/Notifications.tsx index 4efe12ff..73a11cfc 100644 --- a/ui/frontend/Notifications.tsx +++ b/ui/frontend/Notifications.tsx @@ -3,20 +3,18 @@ import { Portal } from 'react-portal'; import { Close } from './Icon'; import { useAppDispatch, useAppSelector } from './hooks'; -import { seenRust2024IsDefault, seenRustSurvey2024 } from './reducers/notifications'; +import { seenRust2024IsDefault } from './reducers/notifications'; import { allowLongRun, wsExecuteKillCurrent } from './reducers/output/execute'; import * as selectors from './selectors'; import * as styles from './Notifications.module.css'; -const SURVEY_URL = 'https://blog.rust-lang.org/2024/12/05/annual-survey-2024-launch.html'; const EDITION_URL = 'https://doc.rust-lang.org/edition-guide/'; const Notifications: React.FC = () => { return (
-
@@ -24,22 +22,6 @@ const Notifications: React.FC = () => { ); }; -const RustSurvey2024Notification: React.FC = () => { - const showIt = useAppSelector(selectors.showRustSurvey2024Selector); - - const dispatch = useAppDispatch(); - const seenIt = useCallback(() => dispatch(seenRustSurvey2024()), [dispatch]); - - return showIt ? ( - - Please help us take a look at who the Rust community is composed of, how the Rust project is - doing, and how we can improve the Rust programming experience by completing the{' '} - 2024 State of Rust Survey. Whether or not you use Rust today, we want - to know your opinions. - - ) : null; -}; - const Rust2024IsDefaultNotification: React.FC = () => { const showIt = useAppSelector(selectors.showRust2024IsDefaultSelector); diff --git a/ui/frontend/reducers/notifications.ts b/ui/frontend/reducers/notifications.ts index 77851296..40643f19 100644 --- a/ui/frontend/reducers/notifications.ts +++ b/ui/frontend/reducers/notifications.ts @@ -12,7 +12,7 @@ interface State { seenRustSurvey2022: boolean; // expired seenRustSurvey2023: boolean; // expired seenDarkMode: boolean; // expired - seenRustSurvey2024: boolean; + seenRustSurvey2024: boolean; // expired seenRust2024IsDefault: boolean; } @@ -26,7 +26,7 @@ const initialState: State = { seenRustSurvey2022: true, seenRustSurvey2023: true, seenDarkMode: true, - seenRustSurvey2024: false, + seenRustSurvey2024: true, seenRust2024IsDefault: false, }; @@ -36,10 +36,6 @@ const slice = createSlice({ reducers: { notificationSeen: (state, action: PayloadAction) => { switch (action.payload) { - case Notification.RustSurvey2024: { - state.seenRustSurvey2024 = true; - break; - } case Notification.Rust2024IsDefault: { state.seenRust2024IsDefault = true; break; @@ -51,8 +47,6 @@ const slice = createSlice({ const { notificationSeen } = slice.actions; -export const seenRustSurvey2024 = () => notificationSeen(Notification.RustSurvey2024); - export const seenRust2024IsDefault = () => notificationSeen(Notification.Rust2024IsDefault); export default slice.reducer; diff --git a/ui/frontend/selectors/index.ts b/ui/frontend/selectors/index.ts index 1e5d3a66..09805f1a 100644 --- a/ui/frontend/selectors/index.ts +++ b/ui/frontend/selectors/index.ts @@ -360,13 +360,6 @@ const notificationsSelector = (state: State) => state.notifications; const NOW = new Date(); -const RUST_SURVEY_2024_END = new Date('2024-12-23T00:00:00Z'); -const RUST_SURVEY_2024_OPEN = NOW <= RUST_SURVEY_2024_END; -export const showRustSurvey2024Selector = createSelector( - notificationsSelector, - notifications => RUST_SURVEY_2024_OPEN && !notifications.seenRustSurvey2024, -); - const RUST_2024_IS_DEFAULT_END = new Date('2025-04-03T00:00:00Z'); const RUST_2024_IS_DEFAULT_OPEN = NOW <= RUST_2024_IS_DEFAULT_END; export const showRust2024IsDefaultSelector = createSelector( @@ -375,7 +368,6 @@ export const showRust2024IsDefaultSelector = createSelector( ); export const anyNotificationsToShowSelector = createSelector( - showRustSurvey2024Selector, showRust2024IsDefaultSelector, excessiveExecutionSelector, (...allNotifications) => allNotifications.some(n => n), diff --git a/ui/frontend/types.ts b/ui/frontend/types.ts index efe8bd26..4b49511c 100644 --- a/ui/frontend/types.ts +++ b/ui/frontend/types.ts @@ -165,6 +165,5 @@ export enum Focus { } export enum Notification { - RustSurvey2024 = 'rust-survey-2024', Rust2024IsDefault = 'rust-2024-is-default', }