mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Merge branch 'master' into sync-from-rust
This commit is contained in:
commit
bdbd2a59b0
217 changed files with 12649 additions and 3061 deletions
|
@ -11,7 +11,7 @@ use hir_def::{
|
|||
};
|
||||
use stdx::never;
|
||||
|
||||
use crate::{db::HirDatabase, Interner, Substitution, Ty};
|
||||
use crate::{consteval::try_const_usize, db::HirDatabase, Interner, Substitution, Ty};
|
||||
|
||||
use self::adt::struct_variant_idx;
|
||||
pub use self::{
|
||||
|
@ -122,17 +122,9 @@ pub fn layout_of_ty(db: &dyn HirDatabase, ty: &Ty, krate: CrateId) -> Result<Lay
|
|||
cx.univariant(dl, &fields, &ReprOptions::default(), kind).ok_or(LayoutError::Unknown)?
|
||||
}
|
||||
TyKind::Array(element, count) => {
|
||||
let count = match count.data(Interner).value {
|
||||
chalk_ir::ConstValue::Concrete(c) => match c.interned {
|
||||
hir_def::type_ref::ConstScalar::Int(x) => x as u64,
|
||||
hir_def::type_ref::ConstScalar::UInt(x) => x as u64,
|
||||
hir_def::type_ref::ConstScalar::Unknown => {
|
||||
user_error!("unknown const generic parameter")
|
||||
}
|
||||
_ => user_error!("mismatched type of const generic parameter"),
|
||||
},
|
||||
_ => return Err(LayoutError::HasPlaceholder),
|
||||
};
|
||||
let count = try_const_usize(&count).ok_or(LayoutError::UserError(
|
||||
"mismatched type of const generic parameter".to_string(),
|
||||
))? as u64;
|
||||
let element = layout_of_ty(db, element, krate)?;
|
||||
let size = element.size.checked_mul(count, dl).ok_or(LayoutError::SizeOverflow)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue