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
This commit is contained in:
commit
cb12198715
9 changed files with 148 additions and 14 deletions
|
@ -1085,18 +1085,28 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
self.in_progress_typeck_results.map(|t| t.borrow())
|
self.in_progress_typeck_results.map(|t| t.borrow())
|
||||||
&& let ty = typeck_results.expr_ty_adjusted(base)
|
&& let ty = typeck_results.expr_ty_adjusted(base)
|
||||||
&& let ty::FnDef(def_id, _substs) = ty.kind()
|
&& let ty::FnDef(def_id, _substs) = ty.kind()
|
||||||
&& let Some(hir::Node::Item(hir::Item { span, ident, .. })) =
|
&& let Some(hir::Node::Item(hir::Item { ident, span, vis_span, .. })) =
|
||||||
hir.get_if_local(*def_id)
|
hir.get_if_local(*def_id)
|
||||||
{
|
{
|
||||||
err.span_suggestion_verbose(
|
let msg = format!(
|
||||||
span.shrink_to_lo(),
|
"alternatively, consider making `fn {}` asynchronous",
|
||||||
&format!(
|
ident
|
||||||
"alternatively, consider making `fn {}` asynchronous",
|
|
||||||
ident
|
|
||||||
),
|
|
||||||
"async ".to_string(),
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
);
|
);
|
||||||
|
if vis_span.is_empty() {
|
||||||
|
err.span_suggestion_verbose(
|
||||||
|
span.shrink_to_lo(),
|
||||||
|
&msg,
|
||||||
|
"async ".to_string(),
|
||||||
|
Applicability::MaybeIncorrect,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
err.span_suggestion_verbose(
|
||||||
|
vis_span.shrink_to_hi(),
|
||||||
|
&msg,
|
||||||
|
" async".to_string(),
|
||||||
|
Applicability::MaybeIncorrect,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,10 +268,29 @@ pub use macros::Hash;
|
||||||
/// instance (with [`write`] and [`write_u8`] etc.). Most of the time, `Hasher`
|
/// instance (with [`write`] and [`write_u8`] etc.). Most of the time, `Hasher`
|
||||||
/// instances are used in conjunction with the [`Hash`] trait.
|
/// instances are used in conjunction with the [`Hash`] trait.
|
||||||
///
|
///
|
||||||
/// This trait makes no assumptions about how the various `write_*` methods are
|
/// This trait provides no guarantees about how the various `write_*` methods are
|
||||||
/// defined and implementations of [`Hash`] should not assume that they work one
|
/// defined and implementations of [`Hash`] should not assume that they work one
|
||||||
/// way or another. You cannot assume, for example, that a [`write_u32`] call is
|
/// way or another. You cannot assume, for example, that a [`write_u32`] call is
|
||||||
/// equivalent to four calls of [`write_u8`].
|
/// equivalent to four calls of [`write_u8`]. Nor can you assume that adjacent
|
||||||
|
/// `write` calls are merged, so it's possible, for example, that
|
||||||
|
/// ```
|
||||||
|
/// # fn foo(hasher: &mut impl std::hash::Hasher) {
|
||||||
|
/// hasher.write(&[1, 2]);
|
||||||
|
/// hasher.write(&[3, 4, 5, 6]);
|
||||||
|
/// # }
|
||||||
|
/// ```
|
||||||
|
/// and
|
||||||
|
/// ```
|
||||||
|
/// # fn foo(hasher: &mut impl std::hash::Hasher) {
|
||||||
|
/// hasher.write(&[1, 2, 3, 4]);
|
||||||
|
/// hasher.write(&[5, 6]);
|
||||||
|
/// # }
|
||||||
|
/// ```
|
||||||
|
/// end up producing different hashes.
|
||||||
|
///
|
||||||
|
/// Thus to produce the same hash value, [`Hash`] implementations must ensure
|
||||||
|
/// for equivalent items that exactly the same sequence of calls is made -- the
|
||||||
|
/// same methods with the same parameters in the same order.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
|
@ -534,7 +534,7 @@ impl<'a> Builder<'a> {
|
||||||
native::Lld,
|
native::Lld,
|
||||||
native::CrtBeginEnd
|
native::CrtBeginEnd
|
||||||
),
|
),
|
||||||
Kind::Check => describe!(
|
Kind::Check | Kind::Clippy | Kind::Fix => describe!(
|
||||||
check::Std,
|
check::Std,
|
||||||
check::Rustc,
|
check::Rustc,
|
||||||
check::Rustdoc,
|
check::Rustdoc,
|
||||||
|
@ -664,7 +664,7 @@ impl<'a> Builder<'a> {
|
||||||
),
|
),
|
||||||
Kind::Run => describe!(run::ExpandYamlAnchors, run::BuildManifest, run::BumpStage0),
|
Kind::Run => describe!(run::ExpandYamlAnchors, run::BuildManifest, run::BumpStage0),
|
||||||
// These commands either don't use paths, or they're special-cased in Build::build()
|
// These commands either don't use paths, or they're special-cased in Build::build()
|
||||||
Kind::Clean | Kind::Clippy | Kind::Fix | Kind::Format | Kind::Setup => vec![],
|
Kind::Clean | Kind::Format | Kind::Setup => vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,11 @@ module.exports = {
|
||||||
"error",
|
"error",
|
||||||
"double"
|
"double"
|
||||||
],
|
],
|
||||||
|
"linebreak-style": [
|
||||||
|
"error",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"no-trailing-spaces": "error",
|
||||||
"no-var": ["error"],
|
"no-var": ["error"],
|
||||||
"prefer-const": ["error"],
|
"prefer-const": ["error"],
|
||||||
"prefer-arrow-callback": ["error"],
|
"prefer-arrow-callback": ["error"],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error: overly complex generic constant
|
error: overly complex generic constant
|
||||||
--> $DIR/issue-775377.rs:6:46
|
--> $DIR/issue-77357.rs:6:46
|
||||||
|
|
|
|
||||||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constant
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constant
|
15
src/test/ui/const-generics/issues/issue-96654.rs
Normal file
15
src/test/ui/const-generics/issues/issue-96654.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
struct A<const M: u32> {}
|
||||||
|
|
||||||
|
struct B<const M: u32> {}
|
||||||
|
|
||||||
|
impl<const M: u32> B<M> {
|
||||||
|
const M: u32 = M;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct C<const M: u32> {
|
||||||
|
a: A<{ B::<1>::M }>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
19
src/test/ui/suggestions/issue-96555.rs
Normal file
19
src/test/ui/suggestions/issue-96555.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// edition:2018
|
||||||
|
|
||||||
|
async fn f() {
|
||||||
|
m::f1().await; //~ ERROR `()` is not a future
|
||||||
|
m::f2().await; //~ ERROR `()` is not a future
|
||||||
|
m::f3().await; //~ ERROR `()` is not a future
|
||||||
|
}
|
||||||
|
|
||||||
|
mod m {
|
||||||
|
pub fn f1() {}
|
||||||
|
|
||||||
|
pub(crate) fn f2() {}
|
||||||
|
|
||||||
|
pub
|
||||||
|
fn
|
||||||
|
f3() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
66
src/test/ui/suggestions/issue-96555.stderr
Normal file
66
src/test/ui/suggestions/issue-96555.stderr
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
error[E0277]: `()` is not a future
|
||||||
|
--> $DIR/issue-96555.rs:4:12
|
||||||
|
|
|
||||||
|
LL | m::f1().await;
|
||||||
|
| -------^^^^^^ `()` is not a future
|
||||||
|
| |
|
||||||
|
| this call returns `()`
|
||||||
|
|
|
||||||
|
= help: the trait `Future` is not implemented for `()`
|
||||||
|
= note: () must be a future or must implement `IntoFuture` to be awaited
|
||||||
|
= note: required because of the requirements on the impl of `IntoFuture` for `()`
|
||||||
|
help: remove the `.await`
|
||||||
|
|
|
||||||
|
LL - m::f1().await;
|
||||||
|
LL + m::f1();
|
||||||
|
|
|
||||||
|
help: alternatively, consider making `fn f1` asynchronous
|
||||||
|
|
|
||||||
|
LL | pub async fn f1() {}
|
||||||
|
| +++++
|
||||||
|
|
||||||
|
error[E0277]: `()` is not a future
|
||||||
|
--> $DIR/issue-96555.rs:5:12
|
||||||
|
|
|
||||||
|
LL | m::f2().await;
|
||||||
|
| -------^^^^^^ `()` is not a future
|
||||||
|
| |
|
||||||
|
| this call returns `()`
|
||||||
|
|
|
||||||
|
= help: the trait `Future` is not implemented for `()`
|
||||||
|
= note: () must be a future or must implement `IntoFuture` to be awaited
|
||||||
|
= note: required because of the requirements on the impl of `IntoFuture` for `()`
|
||||||
|
help: remove the `.await`
|
||||||
|
|
|
||||||
|
LL - m::f2().await;
|
||||||
|
LL + m::f2();
|
||||||
|
|
|
||||||
|
help: alternatively, consider making `fn f2` asynchronous
|
||||||
|
|
|
||||||
|
LL | pub(crate) async fn f2() {}
|
||||||
|
| +++++
|
||||||
|
|
||||||
|
error[E0277]: `()` is not a future
|
||||||
|
--> $DIR/issue-96555.rs:6:12
|
||||||
|
|
|
||||||
|
LL | m::f3().await;
|
||||||
|
| -------^^^^^^ `()` is not a future
|
||||||
|
| |
|
||||||
|
| this call returns `()`
|
||||||
|
|
|
||||||
|
= help: the trait `Future` is not implemented for `()`
|
||||||
|
= note: () must be a future or must implement `IntoFuture` to be awaited
|
||||||
|
= note: required because of the requirements on the impl of `IntoFuture` for `()`
|
||||||
|
help: remove the `.await`
|
||||||
|
|
|
||||||
|
LL - m::f3().await;
|
||||||
|
LL + m::f3();
|
||||||
|
|
|
||||||
|
help: alternatively, consider making `fn f3` asynchronous
|
||||||
|
|
|
||||||
|
LL | pub async
|
||||||
|
| +++++
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Add table
Add a link
Reference in a new issue