mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
internal: Add more trivially Sized
types to is_sized
check
This commit is contained in:
parent
8dd53a3a46
commit
c11b45a6bd
1 changed files with 11 additions and 1 deletions
|
@ -917,9 +917,19 @@ impl<'a> InferenceTable<'a> {
|
||||||
/// Check if given type is `Sized` or not
|
/// Check if given type is `Sized` or not
|
||||||
pub(crate) fn is_sized(&mut self, ty: &Ty) -> bool {
|
pub(crate) fn is_sized(&mut self, ty: &Ty) -> bool {
|
||||||
// Early return for some obvious types
|
// Early return for some obvious types
|
||||||
if matches!(ty.kind(Interner), TyKind::Scalar(..) | TyKind::Ref(..) | TyKind::Raw(..)) {
|
if matches!(
|
||||||
|
ty.kind(Interner),
|
||||||
|
TyKind::Scalar(..)
|
||||||
|
| TyKind::Ref(..)
|
||||||
|
| TyKind::Raw(..)
|
||||||
|
| TyKind::Never
|
||||||
|
| TyKind::FnDef(..)
|
||||||
|
| TyKind::Array(..)
|
||||||
|
| TyKind::Function(_)
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((AdtId::StructId(id), subst)) = ty.as_adt() {
|
if let Some((AdtId::StructId(id), subst)) = ty.as_adt() {
|
||||||
let struct_data = self.db.struct_data(id);
|
let struct_data = self.db.struct_data(id);
|
||||||
if let Some((last_field, _)) = struct_data.variant_data.fields().iter().last() {
|
if let Some((last_field, _)) = struct_data.variant_data.fields().iter().last() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue