Skip to content

Commit 3dea54d

Browse files
authored
Merge pull request #1139 from rust-lang/default-2024
Make edition 2024 the default
2 parents f698118 + a1a782e commit 3dea54d

File tree

11 files changed

+40
-70
lines changed

11 files changed

+40
-70
lines changed

compiler/base/orchestrator/src/coordinator.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,11 +3074,7 @@ mod tests {
30743074
r#"fn x() { u16::try_from(1u8); }"#,
30753075
[false, false, true, true],
30763076
),
3077-
(
3078-
r#"#![feature(gen_blocks)]
3079-
fn x() { gen { yield 1u8 }; }"#,
3080-
[false, false, false, true],
3081-
),
3077+
(r#"fn x() { let gen = true; }"#, [true, true, true, false]),
30823078
];
30833079

30843080
let tests = params.into_iter().flat_map(|(code, works_in)| {
@@ -3090,7 +3086,6 @@ mod tests {
30903086
code: code.into(),
30913087
edition,
30923088
crate_type: CrateType::Library(LibraryType::Lib),
3093-
channel: Channel::Nightly, // To allow 2024 while it is unstable
30943089
..ARBITRARY_EXECUTE_REQUEST
30953090
};
30963091
let response = coordinator.execute(request).await.unwrap();
@@ -3524,7 +3519,6 @@ mod tests {
35243519
let req = CompileRequest {
35253520
edition,
35263521
code: SUBTRACT_CODE.into(),
3527-
channel: Channel::Nightly, // To allow 2024 while it is unstable
35283522
..ARBITRARY_HIR_REQUEST
35293523
};
35303524

@@ -3855,7 +3849,6 @@ mod tests {
38553849
let req = FormatRequest {
38563850
edition,
38573851
code: code.into(),
3858-
channel: Channel::Nightly, // To allow 2024 while it is unstable
38593852
..ARBITRARY_FORMAT_REQUEST
38603853
};
38613854

@@ -4265,14 +4258,10 @@ mod tests {
42654258
});
42664259

42674260
trait TimeoutExt: Future + Sized {
4268-
#[allow(clippy::type_complexity)]
4269-
fn with_timeout(
4270-
self,
4271-
) -> futures::future::Map<
4272-
tokio::time::Timeout<Self>,
4273-
fn(Result<Self::Output, tokio::time::error::Elapsed>) -> Self::Output,
4274-
> {
4275-
tokio::time::timeout(*TIMEOUT, self).map(|v| v.expect("The operation timed out"))
4261+
async fn with_timeout(self) -> Self::Output {
4262+
tokio::time::timeout(*TIMEOUT, self)
4263+
.await
4264+
.expect("The operation timed out")
42764265
}
42774266
}
42784267

tests/spec/features/compilation_targets_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119

120120
scenario "compiling a library to WebAssembly" do
121121
editor.set <<~EOF
122-
#[no_mangle]
122+
#[unsafe(no_mangle)]
123123
pub fn calculator(a: u8) -> u8 { a + 42 }
124124
EOF
125125

tests/spec/features/editions_spec.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,16 @@
3939

4040
scenario "using the 2024 edition" do
4141
editor.set <<-EOF
42-
#![feature(gen_blocks)]
43-
4442
fn main() {
45-
let mut x = gen { yield 1 };
46-
47-
eprintln!("{:?}", x.next());
48-
eprintln!("{:?}", x.next());
43+
let gen = 1;
4944
}
5045
EOF
5146

5247
in_advanced_options_menu { select '2024' }
5348
click_on("Run")
5449

5550
within(:output, :stderr) do
56-
expect(page).to have_content 'Some(1)'
57-
expect(page).to have_content 'None'
51+
expect(page).to have_content 'found reserved keyword `gen`'
5852
end
5953
end
6054

tests/spec/features/url_parameters_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104

105105
scenario "loading without code or an edition" do
106106
visit '/'
107-
expect(page).to have_edition('2021')
107+
expect(page).to have_edition('2024')
108108
end
109109

110110
def editor

ui/frontend/AdvancedOptionsMenu.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as config from './reducers/configuration';
44
import { Either as EitherConfig, Select as SelectConfig } from './ConfigElement';
55
import MenuGroup from './MenuGroup';
66
import * as selectors from './selectors';
7-
import { Backtrace, Channel, Edition } from './types';
7+
import { Backtrace, Edition } from './types';
88
import { useAppDispatch, useAppSelector } from './hooks';
99

1010
const AdvancedOptionsMenu: React.FC = () => {
@@ -18,9 +18,6 @@ const AdvancedOptionsMenu: React.FC = () => {
1818
const changeEdition = useCallback((e: Edition) => dispatch(config.changeEdition(e)), [dispatch]);
1919
const changeBacktrace = useCallback((b: Backtrace) => dispatch(config.changeBacktrace(b)), [dispatch]);
2020

21-
const channel = useAppSelector((state) => state.configuration.channel);
22-
const switchText = (channel !== Channel.Nightly) ? ' (will select nightly Rust)' : '';
23-
2421
return (
2522
<MenuGroup title="Advanced options">
2623
<SelectConfig
@@ -32,7 +29,7 @@ const AdvancedOptionsMenu: React.FC = () => {
3229
<option value={Edition.Rust2015}>2015</option>
3330
<option value={Edition.Rust2018}>2018</option>
3431
<option value={Edition.Rust2021}>2021</option>
35-
<option value={Edition.Rust2024}>2024{switchText}</option>
32+
<option value={Edition.Rust2024}>2024</option>
3633
</SelectConfig>
3734

3835
<EitherConfig

ui/frontend/Notifications.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,36 @@ import { Portal } from 'react-portal';
33

44
import { Close } from './Icon';
55
import { useAppDispatch, useAppSelector } from './hooks';
6-
import { seenRustSurvey2024 } from './reducers/notifications';
6+
import { seenRust2024IsDefault } from './reducers/notifications';
77
import { allowLongRun, wsExecuteKillCurrent } from './reducers/output/execute';
88
import * as selectors from './selectors';
99

1010
import * as styles from './Notifications.module.css';
1111

12-
const SURVEY_URL = 'https://blog.rust-lang.org/2024/12/05/annual-survey-2024-launch.html';
12+
const EDITION_URL = 'https://doc.rust-lang.org/edition-guide/';
1313

1414
const Notifications: React.FC = () => {
1515
return (
1616
<Portal>
1717
<div className={styles.container}>
18-
<RustSurvey2024Notification />
18+
<Rust2024IsDefaultNotification />
1919
<ExcessiveExecutionNotification />
2020
</div>
2121
</Portal>
2222
);
2323
};
2424

25-
const RustSurvey2024Notification: React.FC = () => {
26-
const showIt = useAppSelector(selectors.showRustSurvey2024Selector);
25+
const Rust2024IsDefaultNotification: React.FC = () => {
26+
const showIt = useAppSelector(selectors.showRust2024IsDefaultSelector);
2727

2828
const dispatch = useAppDispatch();
29-
const seenIt = useCallback(() => dispatch(seenRustSurvey2024()), [dispatch]);
29+
const seenIt = useCallback(() => dispatch(seenRust2024IsDefault()), [dispatch]);
3030

3131
return showIt ? (
3232
<Notification onClose={seenIt}>
33-
Please help us take a look at who the Rust community is composed of, how the Rust project is
34-
doing, and how we can improve the Rust programming experience by completing the{' '}
35-
<a href={SURVEY_URL}>2024 State of Rust Survey</a>. Whether or not you use Rust today, we want
36-
to know your opinions.
33+
As of Rust 1.85, the default edition of Rust is now Rust 2024. Learn more about editions in
34+
the <a href={EDITION_URL}>Edition Guide</a>. To specify which edition to use, use the advanced
35+
compilation options menu.
3736
</Notification>
3837
) : null;
3938
};

ui/frontend/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { addCrateType, editCode } from './reducers/code';
55
import {
66
changeBacktrace,
77
changeChannel,
8-
changeEditionRaw,
8+
changeEdition,
99
changeMode,
1010
changePrimaryAction,
1111
} from './reducers/configuration';
@@ -153,7 +153,7 @@ export function indexPageLoad({
153153
}
154154
}
155155

156-
const edition = maybeEdition || Edition.Rust2021;
156+
const edition = maybeEdition || Edition.Rust2024;
157157

158158
if (code) {
159159
dispatch(editCode(code));
@@ -163,7 +163,7 @@ export function indexPageLoad({
163163

164164
dispatch(changeChannel(channel));
165165
dispatch(changeMode(mode));
166-
dispatch(changeEditionRaw(edition));
166+
dispatch(changeEdition(edition));
167167
};
168168
}
169169

ui/frontend/reducers/configuration.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
22

3-
import { ThunkAction } from '../actions';
43
import {
54
AssemblyFlavor,
65
Backtrace,
@@ -57,7 +56,7 @@ const initialState: State = {
5756
primaryAction: PrimaryActionAuto.Auto,
5857
channel: Channel.Stable,
5958
mode: Mode.Debug,
60-
edition: Edition.Rust2021,
59+
edition: Edition.Rust2024,
6160
backtrace: Backtrace.Disabled,
6261
};
6362

@@ -85,7 +84,7 @@ const slice = createSlice({
8584
state.demangleAssembly = action.payload;
8685
},
8786

88-
changeEditionRaw: (state, action: PayloadAction<Edition>) => {
87+
changeEdition: (state, action: PayloadAction<Edition>) => {
8988
state.edition = action.payload;
9089
},
9190

@@ -149,7 +148,7 @@ export const {
149148
changeBacktrace,
150149
changeChannel,
151150
changeDemangleAssembly,
152-
changeEditionRaw,
151+
changeEdition,
153152
changeEditor,
154153
changeKeybinding,
155154
changeMode,
@@ -162,14 +161,4 @@ export const {
162161
swapTheme,
163162
} = slice.actions;
164163

165-
export const changeEdition =
166-
(edition: Edition): ThunkAction =>
167-
(dispatch) => {
168-
if (edition === Edition.Rust2024) {
169-
dispatch(changeChannel(Channel.Nightly));
170-
}
171-
172-
dispatch(changeEditionRaw(edition));
173-
};
174-
175164
export default slice.reducer;

ui/frontend/reducers/notifications.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ interface State {
1212
seenRustSurvey2022: boolean; // expired
1313
seenRustSurvey2023: boolean; // expired
1414
seenDarkMode: boolean; // expired
15-
seenRustSurvey2024: boolean;
15+
seenRustSurvey2024: boolean; // expired
16+
seenRust2024IsDefault: boolean;
1617
}
1718

1819
const initialState: State = {
@@ -25,7 +26,8 @@ const initialState: State = {
2526
seenRustSurvey2022: true,
2627
seenRustSurvey2023: true,
2728
seenDarkMode: true,
28-
seenRustSurvey2024: false,
29+
seenRustSurvey2024: true,
30+
seenRust2024IsDefault: false,
2931
};
3032

3133
const slice = createSlice({
@@ -34,8 +36,8 @@ const slice = createSlice({
3436
reducers: {
3537
notificationSeen: (state, action: PayloadAction<Notification>) => {
3638
switch (action.payload) {
37-
case Notification.RustSurvey2024: {
38-
state.seenRustSurvey2024 = true;
39+
case Notification.Rust2024IsDefault: {
40+
state.seenRust2024IsDefault = true;
3941
break;
4042
}
4143
}
@@ -45,6 +47,6 @@ const slice = createSlice({
4547

4648
const { notificationSeen } = slice.actions;
4749

48-
export const seenRustSurvey2024 = () => notificationSeen(Notification.RustSurvey2024);
50+
export const seenRust2024IsDefault = () => notificationSeen(Notification.Rust2024IsDefault);
4951

5052
export default slice.reducer;

ui/frontend/selectors/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export const getChannelLabel = createSelector(channelSelector, (channel) => `${c
172172

173173
export const isEditionDefault = createSelector(
174174
editionSelector,
175-
edition => edition == Edition.Rust2021,
175+
edition => edition == Edition.Rust2024,
176176
);
177177

178178
export const getBacktraceSet = (state: State) => (
@@ -360,15 +360,15 @@ const notificationsSelector = (state: State) => state.notifications;
360360

361361
const NOW = new Date();
362362

363-
const RUST_SURVEY_2024_END = new Date('2024-12-23T00:00:00Z');
364-
const RUST_SURVEY_2024_OPEN = NOW <= RUST_SURVEY_2024_END;
365-
export const showRustSurvey2024Selector = createSelector(
363+
const RUST_2024_IS_DEFAULT_END = new Date('2025-04-03T00:00:00Z');
364+
const RUST_2024_IS_DEFAULT_OPEN = NOW <= RUST_2024_IS_DEFAULT_END;
365+
export const showRust2024IsDefaultSelector = createSelector(
366366
notificationsSelector,
367-
notifications => RUST_SURVEY_2024_OPEN && !notifications.seenRustSurvey2024,
367+
notifications => RUST_2024_IS_DEFAULT_OPEN && !notifications.seenRust2024IsDefault,
368368
);
369369

370370
export const anyNotificationsToShowSelector = createSelector(
371-
showRustSurvey2024Selector,
371+
showRust2024IsDefaultSelector,
372372
excessiveExecutionSelector,
373373
(...allNotifications) => allNotifications.some(n => n),
374374
);

ui/frontend/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@ export enum Focus {
165165
}
166166

167167
export enum Notification {
168-
RustSurvey2024 = 'rust-survey-2024',
168+
Rust2024IsDefault = 'rust-2024-is-default',
169169
}

0 commit comments

Comments
 (0)