Skip to content

Commit cb12198

Browse files
committed
Auto merge of #96846 - matthiaskrgr:rollup-yxu9ot9, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #96617 (Fix incorrect syntax suggestion with `pub async fn`) - #96828 (Further elaborate the lack of guarantees from `Hasher`) - #96829 (Fix the `x.py clippy` command) - #96830 (Add and tweak const-generics tests) - #96835 (Add more eslint rules) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6846164 + 43b3a49 commit cb12198

File tree

9 files changed

+148
-14
lines changed

9 files changed

+148
-14
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -1085,18 +1085,28 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
10851085
self.in_progress_typeck_results.map(|t| t.borrow())
10861086
&& let ty = typeck_results.expr_ty_adjusted(base)
10871087
&& let ty::FnDef(def_id, _substs) = ty.kind()
1088-
&& let Some(hir::Node::Item(hir::Item { span, ident, .. })) =
1088+
&& let Some(hir::Node::Item(hir::Item { ident, span, vis_span, .. })) =
10891089
hir.get_if_local(*def_id)
10901090
{
1091-
err.span_suggestion_verbose(
1092-
span.shrink_to_lo(),
1093-
&format!(
1094-
"alternatively, consider making `fn {}` asynchronous",
1095-
ident
1096-
),
1097-
"async ".to_string(),
1098-
Applicability::MaybeIncorrect,
1091+
let msg = format!(
1092+
"alternatively, consider making `fn {}` asynchronous",
1093+
ident
10991094
);
1095+
if vis_span.is_empty() {
1096+
err.span_suggestion_verbose(
1097+
span.shrink_to_lo(),
1098+
&msg,
1099+
"async ".to_string(),
1100+
Applicability::MaybeIncorrect,
1101+
);
1102+
} else {
1103+
err.span_suggestion_verbose(
1104+
vis_span.shrink_to_hi(),
1105+
&msg,
1106+
" async".to_string(),
1107+
Applicability::MaybeIncorrect,
1108+
);
1109+
}
11001110
}
11011111
}
11021112
}

library/core/src/hash/mod.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,29 @@ pub use macros::Hash;
268268
/// instance (with [`write`] and [`write_u8`] etc.). Most of the time, `Hasher`
269269
/// instances are used in conjunction with the [`Hash`] trait.
270270
///
271-
/// This trait makes no assumptions about how the various `write_*` methods are
271+
/// This trait provides no guarantees about how the various `write_*` methods are
272272
/// defined and implementations of [`Hash`] should not assume that they work one
273273
/// way or another. You cannot assume, for example, that a [`write_u32`] call is
274-
/// equivalent to four calls of [`write_u8`].
274+
/// equivalent to four calls of [`write_u8`]. Nor can you assume that adjacent
275+
/// `write` calls are merged, so it's possible, for example, that
276+
/// ```
277+
/// # fn foo(hasher: &mut impl std::hash::Hasher) {
278+
/// hasher.write(&[1, 2]);
279+
/// hasher.write(&[3, 4, 5, 6]);
280+
/// # }
281+
/// ```
282+
/// and
283+
/// ```
284+
/// # fn foo(hasher: &mut impl std::hash::Hasher) {
285+
/// hasher.write(&[1, 2, 3, 4]);
286+
/// hasher.write(&[5, 6]);
287+
/// # }
288+
/// ```
289+
/// end up producing different hashes.
290+
///
291+
/// Thus to produce the same hash value, [`Hash`] implementations must ensure
292+
/// for equivalent items that exactly the same sequence of calls is made -- the
293+
/// same methods with the same parameters in the same order.
275294
///
276295
/// # Examples
277296
///

src/bootstrap/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl<'a> Builder<'a> {
534534
native::Lld,
535535
native::CrtBeginEnd
536536
),
537-
Kind::Check => describe!(
537+
Kind::Check | Kind::Clippy | Kind::Fix => describe!(
538538
check::Std,
539539
check::Rustc,
540540
check::Rustdoc,
@@ -664,7 +664,7 @@ impl<'a> Builder<'a> {
664664
),
665665
Kind::Run => describe!(run::ExpandYamlAnchors, run::BuildManifest, run::BumpStage0),
666666
// These commands either don't use paths, or they're special-cased in Build::build()
667-
Kind::Clean | Kind::Clippy | Kind::Fix | Kind::Format | Kind::Setup => vec![],
667+
Kind::Clean | Kind::Format | Kind::Setup => vec![],
668668
}
669669
}
670670

src/librustdoc/html/static/.eslintrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ module.exports = {
2121
"error",
2222
"double"
2323
],
24+
"linebreak-style": [
25+
"error",
26+
"unix"
27+
],
28+
"no-trailing-spaces": "error",
2429
"no-var": ["error"],
2530
"prefer-const": ["error"],
2631
"prefer-arrow-callback": ["error"],

src/test/ui/const-generics/issues/issue-775377.stderr renamed to src/test/ui/const-generics/issues/issue-77357.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: overly complex generic constant
2-
--> $DIR/issue-775377.rs:6:46
2+
--> $DIR/issue-77357.rs:6:46
33
|
44
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constant
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// check-pass
2+
3+
struct A<const M: u32> {}
4+
5+
struct B<const M: u32> {}
6+
7+
impl<const M: u32> B<M> {
8+
const M: u32 = M;
9+
}
10+
11+
struct C<const M: u32> {
12+
a: A<{ B::<1>::M }>,
13+
}
14+
15+
fn main() {}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// edition:2018
2+
3+
async fn f() {
4+
m::f1().await; //~ ERROR `()` is not a future
5+
m::f2().await; //~ ERROR `()` is not a future
6+
m::f3().await; //~ ERROR `()` is not a future
7+
}
8+
9+
mod m {
10+
pub fn f1() {}
11+
12+
pub(crate) fn f2() {}
13+
14+
pub
15+
fn
16+
f3() {}
17+
}
18+
19+
fn main() {}
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
error[E0277]: `()` is not a future
2+
--> $DIR/issue-96555.rs:4:12
3+
|
4+
LL | m::f1().await;
5+
| -------^^^^^^ `()` is not a future
6+
| |
7+
| this call returns `()`
8+
|
9+
= help: the trait `Future` is not implemented for `()`
10+
= note: () must be a future or must implement `IntoFuture` to be awaited
11+
= note: required because of the requirements on the impl of `IntoFuture` for `()`
12+
help: remove the `.await`
13+
|
14+
LL - m::f1().await;
15+
LL + m::f1();
16+
|
17+
help: alternatively, consider making `fn f1` asynchronous
18+
|
19+
LL | pub async fn f1() {}
20+
| +++++
21+
22+
error[E0277]: `()` is not a future
23+
--> $DIR/issue-96555.rs:5:12
24+
|
25+
LL | m::f2().await;
26+
| -------^^^^^^ `()` is not a future
27+
| |
28+
| this call returns `()`
29+
|
30+
= help: the trait `Future` is not implemented for `()`
31+
= note: () must be a future or must implement `IntoFuture` to be awaited
32+
= note: required because of the requirements on the impl of `IntoFuture` for `()`
33+
help: remove the `.await`
34+
|
35+
LL - m::f2().await;
36+
LL + m::f2();
37+
|
38+
help: alternatively, consider making `fn f2` asynchronous
39+
|
40+
LL | pub(crate) async fn f2() {}
41+
| +++++
42+
43+
error[E0277]: `()` is not a future
44+
--> $DIR/issue-96555.rs:6:12
45+
|
46+
LL | m::f3().await;
47+
| -------^^^^^^ `()` is not a future
48+
| |
49+
| this call returns `()`
50+
|
51+
= help: the trait `Future` is not implemented for `()`
52+
= note: () must be a future or must implement `IntoFuture` to be awaited
53+
= note: required because of the requirements on the impl of `IntoFuture` for `()`
54+
help: remove the `.await`
55+
|
56+
LL - m::f3().await;
57+
LL + m::f3();
58+
|
59+
help: alternatively, consider making `fn f3` asynchronous
60+
|
61+
LL | pub async
62+
| +++++
63+
64+
error: aborting due to 3 previous errors
65+
66+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)