mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 16:39:26 +00:00
use TyS::walk
This commit is contained in:
parent
b27cbda32b
commit
e322c773e3
2 changed files with 17 additions and 12 deletions
|
@ -1504,9 +1504,7 @@ fn is_normalizable_helper<'tcx>(
|
||||||
cache.insert(ty, false); // prevent recursive loops
|
cache.insert(ty, false); // prevent recursive loops
|
||||||
let result = cx.tcx.infer_ctxt().enter(|infcx| {
|
let result = cx.tcx.infer_ctxt().enter(|infcx| {
|
||||||
let cause = rustc_middle::traits::ObligationCause::dummy();
|
let cause = rustc_middle::traits::ObligationCause::dummy();
|
||||||
if infcx.at(&cause, param_env).normalize(ty).is_err() {
|
if infcx.at(&cause, param_env).normalize(ty).is_ok() {
|
||||||
false
|
|
||||||
} else {
|
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::Adt(def, substs) => !def.variants.iter().any(|variant| {
|
ty::Adt(def, substs) => !def.variants.iter().any(|variant| {
|
||||||
variant
|
variant
|
||||||
|
@ -1514,16 +1512,15 @@ fn is_normalizable_helper<'tcx>(
|
||||||
.iter()
|
.iter()
|
||||||
.any(|field| !is_normalizable_helper(cx, param_env, field.ty(cx.tcx, substs), cache))
|
.any(|field| !is_normalizable_helper(cx, param_env, field.ty(cx.tcx, substs), cache))
|
||||||
}),
|
}),
|
||||||
ty::Ref(_, pointee, _) | ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
_ => !ty.walk().any(|generic_arg| !match generic_arg.unpack() {
|
||||||
is_normalizable_helper(cx, param_env, pointee, cache)
|
GenericArgKind::Type(inner_ty) if inner_ty != ty => {
|
||||||
|
is_normalizable_helper(cx, param_env, inner_ty, cache)
|
||||||
},
|
},
|
||||||
ty::Array(inner_ty, _) | ty::Slice(inner_ty) => is_normalizable_helper(cx, param_env, inner_ty, cache),
|
_ => true, // if inner_ty == ty, we've already checked it
|
||||||
ty::Tuple(tys) => !tys.iter().any(|inner| match inner.unpack() {
|
|
||||||
GenericArgKind::Type(inner_ty) => !is_normalizable_helper(cx, param_env, inner_ty, cache),
|
|
||||||
_ => false,
|
|
||||||
}),
|
}),
|
||||||
_ => true,
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cache.insert(ty, result);
|
cache.insert(ty, result);
|
||||||
|
|
|
@ -13,11 +13,19 @@ pub struct RuleEdges<R: Rule> {
|
||||||
|
|
||||||
type RuleDependencyEdges<R> = HashMap<u32, RuleEdges<R>>;
|
type RuleDependencyEdges<R> = HashMap<u32, RuleEdges<R>>;
|
||||||
|
|
||||||
// and additional potential variants
|
// reproducer from the GitHub issue ends here
|
||||||
|
// but check some additional variants
|
||||||
type RuleDependencyEdgesArray<R> = HashMap<u32, [RuleEdges<R>; 8]>;
|
type RuleDependencyEdgesArray<R> = HashMap<u32, [RuleEdges<R>; 8]>;
|
||||||
type RuleDependencyEdgesSlice<R> = HashMap<u32, &'static [RuleEdges<R>]>;
|
type RuleDependencyEdgesSlice<R> = HashMap<u32, &'static [RuleEdges<R>]>;
|
||||||
type RuleDependencyEdgesRef<R> = HashMap<u32, &'static RuleEdges<R>>;
|
type RuleDependencyEdgesRef<R> = HashMap<u32, &'static RuleEdges<R>>;
|
||||||
type RuleDependencyEdgesRaw<R> = HashMap<u32, *const RuleEdges<R>>;
|
type RuleDependencyEdgesRaw<R> = HashMap<u32, *const RuleEdges<R>>;
|
||||||
type RuleDependencyEdgesTuple<R> = HashMap<u32, (RuleEdges<R>, RuleEdges<R>)>;
|
type RuleDependencyEdgesTuple<R> = HashMap<u32, (RuleEdges<R>, RuleEdges<R>)>;
|
||||||
|
|
||||||
|
// and an additional checks to make sure fix doesn't have stack-overflow issue
|
||||||
|
// on self-containing types
|
||||||
|
pub struct SelfContaining {
|
||||||
|
inner: Box<SelfContaining>,
|
||||||
|
}
|
||||||
|
type SelfContainingEdges = HashMap<u32, SelfContaining>;
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
Loading…
Reference in a new issue