Skip to content

Commit 4f6b823

Browse files
committed
rust-analyzer: repr(scalable)
Trivial changes to rust-analyzer to keep it compiling with changes to `ReprOptions`.
1 parent 51a115e commit 4f6b823

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

src/tools/rust-analyzer/crates/hir-def/src/attr.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@ use base_db::Crate;
66
use cfg::{CfgExpr, CfgOptions};
77
use either::Either;
88
use hir_expand::{
9-
HirFileId, InFile,
10-
attrs::{Attr, AttrId, RawAttrs, collect_attrs},
9+
attrs::{collect_attrs, Attr, AttrId, RawAttrs},
1110
span_map::SpanMapRef,
11+
HirFileId, InFile,
1212
};
13-
use intern::{Symbol, sym};
13+
use intern::{sym, Symbol};
1414
use la_arena::{ArenaMap, Idx, RawIdx};
1515
use mbe::DelimiterKind;
1616
use rustc_abi::ReprOptions;
1717
use span::AstIdNode;
1818
use syntax::{
19-
AstPtr,
2019
ast::{self, HasAttrs},
20+
AstPtr,
2121
};
2222
use triomphe::Arc;
2323
use tt::iter::{TtElement, TtIter};
2424

2525
use crate::{
26-
AdtId, AstIdLoc, AttrDefId, GenericParamId, HasModule, LocalFieldId, Lookup, MacroId,
27-
VariantId,
2826
db::DefDatabase,
2927
item_tree::block_item_tree_query,
3028
lang_item::LangItem,
3129
nameres::{ModuleOrigin, ModuleSource},
3230
src::{HasChildSource, HasSource},
31+
AdtId, AstIdLoc, AttrDefId, GenericParamId, HasModule, LocalFieldId, Lookup, MacroId,
32+
VariantId,
3333
};
3434

3535
/// Desugared attributes of an item post `cfg_attr` expansion.
@@ -199,7 +199,11 @@ impl Attrs {
199199
#[inline]
200200
pub(crate) fn is_cfg_enabled(&self, cfg_options: &CfgOptions) -> Result<(), CfgExpr> {
201201
self.cfgs().try_for_each(|cfg| {
202-
if cfg_options.check(&cfg) != Some(false) { Ok(()) } else { Err(cfg) }
202+
if cfg_options.check(&cfg) != Some(false) {
203+
Ok(())
204+
} else {
205+
Err(cfg)
206+
}
203207
})
204208
}
205209

@@ -331,7 +335,7 @@ fn parse_rustc_legacy_const_generics(tt: &crate::tt::TopSubtree) -> Box<[u32]> {
331335
}
332336

333337
fn merge_repr(this: &mut ReprOptions, other: ReprOptions) {
334-
let ReprOptions { int, align, pack, flags, field_shuffle_seed: _ } = this;
338+
let ReprOptions { int, align, pack, flags, scalable, field_shuffle_seed: _ } = this;
335339
flags.insert(other.flags);
336340
*align = (*align).max(other.align);
337341
*pack = match (*pack, other.pack) {
@@ -341,6 +345,9 @@ fn merge_repr(this: &mut ReprOptions, other: ReprOptions) {
341345
if other.int.is_some() {
342346
*int = other.int;
343347
}
348+
if other.scalable.is_some() {
349+
*scalable = other.scalable;
350+
}
344351
}
345352

346353
fn parse_repr_tt(tt: &crate::tt::TopSubtree) -> Option<ReprOptions> {
@@ -852,8 +859,8 @@ mod tests {
852859

853860
use hir_expand::span_map::{RealSpanMap, SpanMap};
854861
use span::FileId;
855-
use syntax::{AstNode, TextRange, ast};
856-
use syntax_bridge::{DocCommentDesugarMode, syntax_node_to_token_tree};
862+
use syntax::{ast, AstNode, TextRange};
863+
use syntax_bridge::{syntax_node_to_token_tree, DocCommentDesugarMode};
857864

858865
use crate::attr::{DocAtom, DocExpr};
859866

src/tools/rust-analyzer/crates/hir-ty/src/layout.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ use std::fmt;
44

55
use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy};
66
use hir_def::{
7-
LocalFieldId, StructId,
87
layout::{
98
Float, Integer, LayoutCalculator, LayoutCalculatorError, LayoutData, Primitive,
109
ReprOptions, Scalar, StructKind, TargetDataLayout, WrappingRange,
1110
},
11+
LocalFieldId, StructId,
1212
};
1313
use la_arena::{Idx, RawIdx};
1414
use rustc_abi::AddressSpace;
@@ -17,11 +17,11 @@ use rustc_index::IndexVec;
1717
use triomphe::Arc;
1818

1919
use crate::{
20-
Interner, ProjectionTy, Substitution, TraitEnvironment, Ty,
2120
consteval::try_const_usize,
2221
db::{HirDatabase, InternedClosure},
2322
infer::normalize,
2423
utils::ClosureSubst,
24+
Interner, ProjectionTy, Substitution, TraitEnvironment, Ty,
2525
};
2626

2727
pub(crate) use self::adt::layout_of_adt_cycle_result;
@@ -123,6 +123,7 @@ fn layout_of_simd_ty(
123123
db: &dyn HirDatabase,
124124
id: StructId,
125125
repr_packed: bool,
126+
repr_scalable: Option<u32>,
126127
subst: &Substitution,
127128
env: Arc<TraitEnvironment>,
128129
dl: &TargetDataLayout,
@@ -146,7 +147,7 @@ fn layout_of_simd_ty(
146147
let e_ly = db.layout_of_ty(e_ty, env)?;
147148

148149
let cx = LayoutCx::new(dl);
149-
Ok(Arc::new(cx.calc.simd_type(e_ly, e_len, repr_packed)?))
150+
Ok(Arc::new(cx.calc.simd_type(e_ly, e_len, repr_packed, repr_scalable)?))
150151
}
151152

152153
pub fn layout_of_ty_query(
@@ -168,7 +169,15 @@ pub fn layout_of_ty_query(
168169
let data = db.struct_signature(*s);
169170
let repr = data.repr.unwrap_or_default();
170171
if repr.simd() {
171-
return layout_of_simd_ty(db, *s, repr.packed(), subst, trait_env, &target);
172+
return layout_of_simd_ty(
173+
db,
174+
*s,
175+
repr.packed(),
176+
repr.scalable,
177+
subst,
178+
trait_env,
179+
&target,
180+
);
172181
}
173182
};
174183
return db.layout_of_adt(*def, subst.clone(), trait_env);

0 commit comments

Comments
 (0)