Merge from rust-lang/rust

This commit is contained in:
Laurențiu Nicola 2024-12-23 11:27:07 +02:00
commit a2a5b72c47
3 changed files with 5 additions and 3 deletions

View file

@ -237,7 +237,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
experimental!(no_sanitize)
),
gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)),
ungated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing),
ungated!(
doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk

View file

@ -813,7 +813,7 @@ impl Evaluator<'_> {
ProjectionElem::Field(Either::Left(f)) => {
let layout = self.layout(&prev_ty)?;
let variant_layout = match &layout.variants {
Variants::Single { .. } => &layout,
Variants::Single { .. } | Variants::Empty => &layout,
Variants::Multiple { variants, .. } => {
&variants[match f.parent {
hir_def::VariantId::EnumVariantId(it) => {
@ -1638,6 +1638,7 @@ impl Evaluator<'_> {
return Ok(0);
};
match &layout.variants {
Variants::Empty => unreachable!(),
Variants::Single { index } => {
let r = self.const_eval_discriminant(self.db.enum_data(e).variants[index.0].0)?;
Ok(r)
@ -1800,7 +1801,7 @@ impl Evaluator<'_> {
}
let layout = self.layout_adt(adt, subst)?;
Ok(match &layout.variants {
Variants::Single { .. } => (layout.size.bytes_usize(), layout, None),
Variants::Single { .. } | Variants::Empty => (layout.size.bytes_usize(), layout, None),
Variants::Multiple { variants, tag, tag_encoding, .. } => {
let enum_variant_id = match it {
VariantId::EnumVariantId(it) => it,

View file

@ -334,6 +334,7 @@ pub(crate) fn detect_variant_from_bytes<'a>(
e: EnumId,
) -> Option<(EnumVariantId, &'a Layout)> {
let (var_id, var_layout) = match &layout.variants {
hir_def::layout::Variants::Empty => unreachable!(),
hir_def::layout::Variants::Single { index } => {
(db.enum_data(e).variants[index.0].0, layout)
}