Skip to content

Commit 0277061

Browse files
committed
Auto merge of rust-lang#136391 - ehuss:rust-1.85-beta-backports, r=ehuss
[beta-1.85] backports * [Add `AsyncFn*` to `core` prelude](rust-lang#135852) * [Disable `overflow_delimited_expr` in edition 2024](rust-lang#136312) * [Disable some incorrect rust-analyzer diagnostics on beta](rust-lang#136236) * [fix: Fix #[rustc_deprecated_safe_2024]](rust-lang/rust-analyzer#19044) * [fix: Fix a bug where enum variants were not considered properly in type ns resolution](rust-lang/rust-analyzer#18976) * Update edition-guide * [Add alternatives for static-mut-refs](rust-lang/edition-guide#354) * [Remove rustfmt-overflow-delimited-expr](rust-lang/edition-guide#357)
2 parents 14445aa + cfe3de2 commit 0277061

File tree

10 files changed

+67
-94
lines changed

10 files changed

+67
-94
lines changed

library/core/src/prelude/common.rs

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ pub use crate::marker::{Copy, Send, Sized, Sync, Unpin};
1212
#[stable(feature = "core_prelude", since = "1.4.0")]
1313
#[doc(no_inline)]
1414
pub use crate::ops::{Drop, Fn, FnMut, FnOnce};
15+
#[cfg_attr(bootstrap, unstable(feature = "async_closure", issue = "62290"))]
16+
#[cfg_attr(not(bootstrap), stable(feature = "async_closure", since = "1.85.0"))]
17+
#[doc(no_inline)]
18+
pub use crate::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce};
1519

1620
// Re-exported functions
1721
#[stable(feature = "core_prelude", since = "1.4.0")]

src/doc/style-guide/src/editions.md

-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ For a full history of changes in the Rust 2024 style edition, see the git
3636
history of the style guide. Notable changes in the Rust 2024 style edition
3737
include:
3838

39-
- [#114764](https://github.com/rust-lang/rust/pull/114764) As the last member
40-
of a delimited expression, delimited expressions are generally combinable,
41-
regardless of the number of members. Previously only applied with exactly
42-
one member (except for closures with explicit blocks).
4339
- Miscellaneous `rustfmt` bugfixes.
4440
- Use version-sort (sort `x8`, `x16`, `x32`, `x64`, `x128` in that order).
4541
- Change "ASCIIbetical" sort to Unicode-aware "non-lowercase before lowercase".

src/doc/style-guide/src/expressions.md

+7-48
Original file line numberDiff line numberDiff line change
@@ -818,11 +818,11 @@ E.g., `&&Some(foo)` matches, `Foo(4, Bar)` does not.
818818

819819
## Combinable expressions
820820

821-
When the last argument in a function call is formatted across
822-
multiple-lines, format the outer call as if it were a single-line call,
821+
Where a function call has a single argument, and that argument is formatted
822+
across multiple-lines, format the outer call as if it were a single-line call,
823823
if the result fits. Apply the same combining behaviour to any similar
824824
expressions which have multi-line, block-indented lists of sub-expressions
825-
delimited by parentheses, brackets, or braces. E.g.,
825+
delimited by parentheses (e.g., macros or tuple struct literals). E.g.,
826826

827827
```rust
828828
foo(bar(
@@ -848,61 +848,20 @@ let arr = [combinable(
848848
an_expr,
849849
another_expr,
850850
)];
851-
852-
let x = Thing(an_expr, another_expr, match cond {
853-
A => 1,
854-
B => 2,
855-
});
856-
857-
let x = format!("Stuff: {}", [
858-
an_expr,
859-
another_expr,
860-
]);
861-
862-
let x = func(an_expr, another_expr, SomeStruct {
863-
field: this_is_long,
864-
another_field: 123,
865-
});
866851
```
867852

868853
Apply this behavior recursively.
869854

870-
If the last argument is a multi-line closure with an explicit block,
871-
only apply the combining behavior if there are no other closure arguments.
855+
For a function with multiple arguments, if the last argument is a multi-line
856+
closure with an explicit block, there are no other closure arguments, and all
857+
the arguments and the first line of the closure fit on the first line, use the
858+
same combining behavior:
872859

873860
```rust
874-
// Combinable
875861
foo(first_arg, x, |param| {
876862
action();
877863
foo(param)
878864
})
879-
// Not combinable, because the closure is not the last argument
880-
foo(
881-
first_arg,
882-
|param| {
883-
action();
884-
foo(param)
885-
},
886-
whatever,
887-
)
888-
// Not combinable, because the first line of the closure does not fit
889-
foo(
890-
first_arg,
891-
x,
892-
move |very_long_param_causing_line_to_overflow| -> Bar {
893-
action();
894-
foo(param)
895-
},
896-
)
897-
// Not combinable, because there is more than one closure argument
898-
foo(
899-
first_arg,
900-
|x| x.bar(),
901-
|param| {
902-
action();
903-
foo(param)
904-
},
905-
)
906865
```
907866

908867
## Ranges

src/tools/rust-analyzer/crates/hir-def/src/data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl FunctionData {
9494
.map(Box::new);
9595
let rustc_allow_incoherent_impl = attrs.by_key(&sym::rustc_allow_incoherent_impl).exists();
9696
if flags.contains(FnFlags::HAS_UNSAFE_KW)
97-
&& !crate_graph[krate].edition.at_least_2024()
97+
// && !crate_graph[krate].edition.at_least_2024()
9898
&& attrs.by_key(&sym::rustc_deprecated_safe_2024).exists()
9999
{
100100
flags.remove(FnFlags::HAS_UNSAFE_KW);

src/tools/rust-analyzer/crates/hir-ty/src/lower.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ impl<'a> TyLoweringContext<'a> {
226226
self
227227
}
228228

229-
pub fn push_diagnostic(&mut self, type_ref: TypeRefId, kind: TyLoweringDiagnosticKind) {
230-
let source = match self.types_source_map {
229+
pub fn push_diagnostic(&mut self, type_ref: TypeRefId, _kind: TyLoweringDiagnosticKind) {
230+
let _source = match self.types_source_map {
231231
Some(source_map) => {
232232
let Ok(source) = source_map.type_syntax(type_ref) else {
233233
stdx::never!("error in synthetic type");
@@ -237,7 +237,7 @@ impl<'a> TyLoweringContext<'a> {
237237
}
238238
None => Either::Left(type_ref),
239239
};
240-
self.diagnostics.push(TyLoweringDiagnostic { source, kind });
240+
// self.diagnostics.push(TyLoweringDiagnostic { source, kind });
241241
}
242242
}
243243

src/tools/rustfmt/src/bin/main.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,6 @@ mod test {
817817
options.inline_config = HashMap::from([("version".to_owned(), "Two".to_owned())]);
818818
let config = get_config(None, Some(options));
819819
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
820-
assert_eq!(config.overflow_delimited_expr(), true);
821820
}
822821

823822
#[nightly_only_test]
@@ -827,7 +826,6 @@ mod test {
827826
let config_file = Some(Path::new("tests/config/style-edition/just-version"));
828827
let config = get_config(config_file, Some(options));
829828
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
830-
assert_eq!(config.overflow_delimited_expr(), true);
831829
}
832830

833831
#[nightly_only_test]
@@ -872,7 +870,6 @@ mod test {
872870
]);
873871
let config = get_config(None, Some(options));
874872
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
875-
assert_eq!(config.overflow_delimited_expr(), true);
876873
}
877874

878875
#[nightly_only_test]
@@ -938,7 +935,6 @@ mod test {
938935
options.style_edition = Some(StyleEdition::Edition2024);
939936
let config = get_config(None, Some(options));
940937
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
941-
assert_eq!(config.overflow_delimited_expr(), true);
942938
}
943939

944940
#[nightly_only_test]
@@ -948,6 +944,8 @@ mod test {
948944
let config_file = Some(Path::new("tests/config/style-edition/overrides"));
949945
let config = get_config(config_file, Some(options));
950946
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
947+
// FIXME: this test doesn't really exercise anything, since
948+
// `overflow_delimited_expr` is disabled by default in edition 2024.
951949
assert_eq!(config.overflow_delimited_expr(), false);
952950
}
953951

@@ -959,7 +957,8 @@ mod test {
959957
options.inline_config =
960958
HashMap::from([("overflow_delimited_expr".to_owned(), "false".to_owned())]);
961959
let config = get_config(config_file, Some(options));
962-
assert_eq!(config.style_edition(), StyleEdition::Edition2024);
960+
// FIXME: this test doesn't really exercise anything, since
961+
// `overflow_delimited_expr` is disabled by default in edition 2024.
963962
assert_eq!(config.overflow_delimited_expr(), false);
964963
}
965964
}

src/tools/rustfmt/src/config/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ binop_separator = "Front"
848848
remove_nested_parens = true
849849
combine_control_expr = true
850850
short_array_element_width_threshold = 10
851-
overflow_delimited_expr = true
851+
overflow_delimited_expr = false
852852
struct_field_align_threshold = 0
853853
enum_discrim_align_threshold = 0
854854
match_arm_blocks = true

src/tools/rustfmt/src/config/options.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ config_option_with_style_edition_default!(
627627
RemoveNestedParens, bool, _ => true;
628628
CombineControlExpr, bool, _ => true;
629629
ShortArrayElementWidthThreshold, usize, _ => 10;
630-
OverflowDelimitedExpr, bool, Edition2024 => true, _ => false;
630+
OverflowDelimitedExpr, bool, _ => false;
631631
StructFieldAlignThreshold, usize, _ => 0;
632632
EnumDiscrimAlignThreshold, usize, _ => 0;
633633
MatchArmBlocks, bool, _ => true;
@@ -644,7 +644,7 @@ config_option_with_style_edition_default!(
644644
BlankLinesLowerBound, usize, _ => 0;
645645
EditionConfig, Edition, _ => Edition::Edition2015;
646646
StyleEditionConfig, StyleEdition,
647-
Edition2024 => StyleEdition::Edition2024, _ => StyleEdition::Edition2015;
647+
Edition2024 => StyleEdition::Edition2024, _ => StyleEdition::Edition2015;
648648
VersionConfig, Version, Edition2024 => Version::Two, _ => Version::One;
649649
InlineAttributeWidth, usize, _ => 0;
650650
FormatGeneratedFiles, bool, _ => true;

src/tools/rustfmt/tests/target/configs/style_edition/overflow_delim_expr_2024.rs

+44-29
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ fn combine_blocklike() {
2525
y: value2,
2626
});
2727

28-
do_thing(x, Bar {
29-
x: value,
30-
y: value2,
31-
});
28+
do_thing(
29+
x,
30+
Bar {
31+
x: value,
32+
y: value2,
33+
},
34+
);
3235

3336
do_thing(
3437
x,
@@ -46,12 +49,15 @@ fn combine_blocklike() {
4649
value4_with_longer_name,
4750
]);
4851

49-
do_thing(x, &[
50-
value_with_longer_name,
51-
value2_with_longer_name,
52-
value3_with_longer_name,
53-
value4_with_longer_name,
54-
]);
52+
do_thing(
53+
x,
54+
&[
55+
value_with_longer_name,
56+
value2_with_longer_name,
57+
value3_with_longer_name,
58+
value4_with_longer_name,
59+
],
60+
);
5561

5662
do_thing(
5763
x,
@@ -71,12 +77,15 @@ fn combine_blocklike() {
7177
value4_with_longer_name,
7278
]);
7379

74-
do_thing(x, vec![
75-
value_with_longer_name,
76-
value2_with_longer_name,
77-
value3_with_longer_name,
78-
value4_with_longer_name,
79-
]);
80+
do_thing(
81+
x,
82+
vec![
83+
value_with_longer_name,
84+
value2_with_longer_name,
85+
value3_with_longer_name,
86+
value4_with_longer_name,
87+
],
88+
);
8089

8190
do_thing(
8291
x,
@@ -99,22 +108,28 @@ fn combine_blocklike() {
99108
}
100109

101110
fn combine_struct_sample() {
102-
let identity = verify(&ctx, VerifyLogin {
103-
type_: LoginType::Username,
104-
username: args.username.clone(),
105-
password: Some(args.password.clone()),
106-
domain: None,
107-
})?;
111+
let identity = verify(
112+
&ctx,
113+
VerifyLogin {
114+
type_: LoginType::Username,
115+
username: args.username.clone(),
116+
password: Some(args.password.clone()),
117+
domain: None,
118+
},
119+
)?;
108120
}
109121

110122
fn combine_macro_sample() {
111123
rocket::ignite()
112-
.mount("/", routes![
113-
http::auth::login,
114-
http::auth::logout,
115-
http::cors::options,
116-
http::action::dance,
117-
http::action::sleep,
118-
])
124+
.mount(
125+
"/",
126+
routes![
127+
http::auth::login,
128+
http::auth::logout,
129+
http::cors::options,
130+
http::action::dance,
131+
http::action::sleep,
132+
],
133+
)
119134
.launch();
120135
}

0 commit comments

Comments
 (0)