mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-11 20:58:54 +00:00
Merge from rust-lang/rust
This commit is contained in:
commit
a2a5b72c47
3 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue