Auto merge of #15417 - lowr:patch/purge-generic-arg-data-in-expr, r=HKalbasi

internal: use `Cast::cast()` instead of explicit interning

I firmly believe that we should generally use `cast()` instead of interning `GenericArgData` to construct `GenericArg` because it's less verbose and more readable.
This commit is contained in:
bors 2023-08-08 19:27:18 +00:00
commit ddbbd6a7e7
7 changed files with 45 additions and 73 deletions

View file

@ -1273,7 +1273,7 @@ impl Adt {
.fill(|x| {
let r = it.next().unwrap_or_else(|| TyKind::Error.intern(Interner));
match x {
ParamKind::Type => GenericArgData::Ty(r).intern(Interner),
ParamKind::Type => r.cast(Interner),
ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()),
}
})
@ -3716,7 +3716,7 @@ impl Type {
.fill(|x| {
let r = it.next().unwrap();
match x {
ParamKind::Type => GenericArgData::Ty(r).intern(Interner),
ParamKind::Type => r.cast(Interner),
ParamKind::Const(ty) => {
// FIXME: this code is not covered in tests.
unknown_const_as_generic(ty.clone())
@ -3749,9 +3749,7 @@ impl Type {
.fill(|it| {
// FIXME: this code is not covered in tests.
match it {
ParamKind::Type => {
GenericArgData::Ty(args.next().unwrap().ty.clone()).intern(Interner)
}
ParamKind::Type => args.next().unwrap().ty.clone().cast(Interner),
ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()),
}
})