mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Rollup merge of #163810 - ShoyuVanilla:clippy-new-solver-fix, r=lcnr
Fix an issue for clippy's `search_is_some` with the next-solver r? lcnr
This commit is contained in:
@@ -794,7 +794,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
|
||||
cx.tcx
|
||||
.item_self_bounds(def_id)
|
||||
.iter_instantiated(cx.tcx, args)
|
||||
.map(Unnormalized::skip_norm_wip),
|
||||
.map(|clause| cx.tcx.normalize_erasing_regions(cx.typing_env(), clause)),
|
||||
cx.tcx.opt_parent(def_id),
|
||||
),
|
||||
ty::FnPtr(sig_tys, hdr) => Some(ExprFnSig::Sig(sig_tys.with(hdr), None)),
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//@ compile-flags: -Znext-solver=globally
|
||||
|
||||
// Regression test that ensures clippy fix won't accidently deref the argument of
|
||||
// a closure when we fix `.find(..).is_some()` into `.any(..)` due to mishandling
|
||||
// of non-rigid aliases.
|
||||
|
||||
#![warn(clippy::search_is_some)]
|
||||
#![allow(clippy::explicit_auto_deref, clippy::manual_contains)]
|
||||
#![expect(clippy::useless_vec)]
|
||||
|
||||
fn make_arg_no_deref_impl() -> impl Fn(&&u32) -> bool {
|
||||
move |x: &&u32| **x == 78
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let v = vec![3, 2, 1, 0];
|
||||
let arg_no_deref_impl = make_arg_no_deref_impl();
|
||||
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let _ = v.iter().any(|x: &u32| arg_no_deref_impl(&x));
|
||||
//~^ search_is_some
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
//@ compile-flags: -Znext-solver=globally
|
||||
|
||||
// Regression test that ensures clippy fix won't accidently deref the argument of
|
||||
// a closure when we fix `.find(..).is_some()` into `.any(..)` due to mishandling
|
||||
// of non-rigid aliases.
|
||||
|
||||
#![warn(clippy::search_is_some)]
|
||||
#![allow(clippy::explicit_auto_deref, clippy::manual_contains)]
|
||||
#![expect(clippy::useless_vec)]
|
||||
|
||||
fn make_arg_no_deref_impl() -> impl Fn(&&u32) -> bool {
|
||||
move |x: &&u32| **x == 78
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let v = vec![3, 2, 1, 0];
|
||||
let arg_no_deref_impl = make_arg_no_deref_impl();
|
||||
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let _ = v.iter().find(|x: &&u32| arg_no_deref_impl(x)).is_some();
|
||||
//~^ search_is_some
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
error: called `is_some()` after searching an `Iterator` with `find`
|
||||
--> tests/ui/search_is_some_arg_no_deref_new_solver.rs:20:22
|
||||
|
|
||||
LL | let _ = v.iter().find(|x: &&u32| arg_no_deref_impl(x)).is_some();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| arg_no_deref_impl(&x))`
|
||||
|
|
||||
= note: `-D clippy::search-is-some` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::search_is_some)]`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//@ compile-flags: -Znext-solver
|
||||
|
||||
// FIXME: The diagnostics here are suboptimal.
|
||||
// See <https://github.com/rust-lang/rust/issues/163784>.
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
//~^^^^^^ ERROR: overflow evaluating the requirement `X == _`
|
||||
|
||||
// TAIT with self-referencing bounds
|
||||
type X = impl std::ops::Add<Output = X>;
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
#[define_opaque(X)]
|
||||
pub fn new() -> X {
|
||||
//~^ ERROR: item does not constrain `X::{opaque#0}`
|
||||
0i32
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,18 @@
|
||||
error: item does not constrain `X::{opaque#0}`
|
||||
--> $DIR/overflowing-opaque-incorrectly-unconstrained.rs:16:12
|
||||
|
|
||||
LL | pub fn new() -> X {
|
||||
| ^^^
|
||||
|
|
||||
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
|
||||
note: this opaque type is supposed to be constrained
|
||||
--> $DIR/overflowing-opaque-incorrectly-unconstrained.rs:10:10
|
||||
|
|
||||
LL | type X = impl std::ops::Add<Output = X>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `X == _`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0275`.
|
||||
Reference in New Issue
Block a user