-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
GenericArgs::types triage + possible fixes
#159899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ enum RepeatKind { | |
|
|
||
| fn get_ty_param(ty: Ty<'_>) -> Option<Ty<'_>> { | ||
| if let ty::Adt(_, subs) = ty.kind() { | ||
| subs.types().next() | ||
| subs.iter().filter_map(ty::GenericArg::as_type).nth(0) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so |
||
| } else { | ||
| None | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -323,12 +323,16 @@ fn is_size_pair(ty: Ty<'_>) -> bool { | |
| } | ||
|
|
||
| fn same_except_params<'tcx>(subs1: GenericArgsRef<'tcx>, subs2: GenericArgsRef<'tcx>) -> bool { | ||
| // TODO: check const parameters as well. Currently this will consider `Array<5>` the same as | ||
| // `Array<6>` | ||
| for (ty1, ty2) in subs1.types().zip(subs2.types()).filter(|(ty1, ty2)| ty1 != ty2) { | ||
| match (ty1.kind(), ty2.kind()) { | ||
| (ty::Param(_), _) | (_, ty::Param(_)) => (), | ||
| (ty::Adt(adt1, subs1), ty::Adt(adt2, subs2)) if adt1 == adt2 && same_except_params(subs1, subs2) => (), | ||
| for (t1, t2) in subs1.terms().zip(subs2.terms()).filter(|(t1, t2)| t1 != t2) { | ||
| match (t1.kind(), t2.kind()) { | ||
| (ty::TermKind::Ty(ty1), ty::TermKind::Ty(ty2)) => match (ty1.kind(), ty2.kind()) { | ||
| (ty::Param(_), _) | (_, ty::Param(_)) => (), | ||
| (ty::Adt(adt1, subs1), ty::Adt(adt2, subs2)) if adt1 == adt2 && same_except_params(subs1, subs2) => (), | ||
| _ => return false, | ||
| }, | ||
| // FIXME: check const parameters better as well. Currently this will consider `Array<5>` the same as | ||
| // `Array<6>` | ||
| (ty::TermKind::Const(c1), ty::TermKind::Const(c2)) if c1 == c2 => todo!(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a (today I learned that tidy doesn't run on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I meant to ask a follow up question on this. Consts are interned as well, right? But are there cases where they are not the same "const" but are still the same? Otherwise this can just return true indeed.
Yeah me to :D.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For purposes of this real wonky function, yeah, consts can contain params. IMO, drop the guard, just have (Also, shouldn't |
||
| _ => return false, | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From @lcnr in the zulip discussion:
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that can just be
next().as_type()🤔