comment return sites
This commit is contained in:
parent
5a5017ec63
commit
ea47fdf785
@ -149,19 +149,19 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
|
|||||||
}
|
}
|
||||||
ty::Foreign(_) => {
|
ty::Foreign(_) => {
|
||||||
self.found = Some(NonStructuralMatchTy::Foreign);
|
self.found = Some(NonStructuralMatchTy::Foreign);
|
||||||
return true; // Stop visiting
|
return true; // Stop visiting.
|
||||||
}
|
}
|
||||||
ty::Opaque(..) => {
|
ty::Opaque(..) => {
|
||||||
self.found = Some(NonStructuralMatchTy::Opaque);
|
self.found = Some(NonStructuralMatchTy::Opaque);
|
||||||
return true;
|
return true; // Stop visiting.
|
||||||
}
|
}
|
||||||
ty::Projection(..) => {
|
ty::Projection(..) => {
|
||||||
self.found = Some(NonStructuralMatchTy::Projection);
|
self.found = Some(NonStructuralMatchTy::Projection);
|
||||||
return true;
|
return true; // Stop visiting.
|
||||||
}
|
}
|
||||||
ty::Generator(..) | ty::GeneratorWitness(..) => {
|
ty::Generator(..) | ty::GeneratorWitness(..) => {
|
||||||
self.found = Some(NonStructuralMatchTy::Generator);
|
self.found = Some(NonStructuralMatchTy::Generator);
|
||||||
return true;
|
return true; // Stop visiting.
|
||||||
}
|
}
|
||||||
ty::RawPtr(..) => {
|
ty::RawPtr(..) => {
|
||||||
// structural-match ignores substructure of
|
// structural-match ignores substructure of
|
||||||
@ -179,14 +179,14 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
|
|||||||
// structural equality on `T` does not recur into the raw
|
// structural equality on `T` does not recur into the raw
|
||||||
// pointer. Therefore, one can still use `C` in a pattern.
|
// pointer. Therefore, one can still use `C` in a pattern.
|
||||||
|
|
||||||
// (But still tell caller to continue search.)
|
// (But still tell the caller to continue search.)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ty::FnDef(..) | ty::FnPtr(..) => {
|
ty::FnDef(..) | ty::FnPtr(..) => {
|
||||||
// Types of formals and return in `fn(_) -> _` are also irrelevant;
|
// Types of formals and return in `fn(_) -> _` are also irrelevant;
|
||||||
// so we do not recur into them via `super_visit_with`
|
// so we do not recur into them via `super_visit_with`
|
||||||
//
|
//
|
||||||
// (But still tell caller to continue search.)
|
// (But still tell the caller to continue search.)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ty::Array(_, n)
|
ty::Array(_, n)
|
||||||
@ -194,16 +194,21 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
|
|||||||
{
|
{
|
||||||
// rust-lang/rust#62336: ignore type of contents
|
// rust-lang/rust#62336: ignore type of contents
|
||||||
// for empty array.
|
// for empty array.
|
||||||
|
//
|
||||||
|
// (But still tell the caller to continue search.)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => {
|
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => {
|
||||||
// These primitive types are always structural match.
|
// These primitive types are always structural match.
|
||||||
//
|
//
|
||||||
// `Never` is kind of special here, but as it is not inhabitable, this should be fine.
|
// `Never` is kind of special here, but as it is not inhabitable, this should be fine.
|
||||||
|
//
|
||||||
|
// (But still tell the caller to continue search.)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Array(..) | ty::Slice(_) | ty::Ref(..) | ty::Tuple(..) => {
|
ty::Array(..) | ty::Slice(_) | ty::Ref(..) | ty::Tuple(..) => {
|
||||||
|
// First check all contained types and then tell the caller to continue searching.
|
||||||
ty.super_visit_with(self);
|
ty.super_visit_with(self);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -214,13 +219,15 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
|
|||||||
self.tcx().sess.delay_span_bug(self.span, "ty::Error in structural-match check");
|
self.tcx().sess.delay_span_bug(self.span, "ty::Error in structural-match check");
|
||||||
// We still want to check other types after encountering an error,
|
// We still want to check other types after encountering an error,
|
||||||
// as this may still emit relevant errors.
|
// as this may still emit relevant errors.
|
||||||
|
//
|
||||||
|
// So we continue searching here.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !self.seen.insert(adt_def.did) {
|
if !self.seen.insert(adt_def.did) {
|
||||||
debug!("Search already seen adt_def: {:?}", adt_def);
|
debug!("Search already seen adt_def: {:?}", adt_def);
|
||||||
// let caller continue its search
|
// Let caller continue its search.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user