Skip to content

Commit 0bc0aed

Browse files
committed
use rustc crates instead of copy paste
1 parent b6d988e commit 0bc0aed

File tree

16 files changed

+270
-2063
lines changed

16 files changed

+270
-2063
lines changed

Cargo.lock

+26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exclude = ["crates/proc-macro-test/imp"]
55
[profile.dev]
66
# Disabling debug info speeds up builds a bunch,
77
# and we don't rely on it for debugging that much.
8-
debug = 0
8+
# debug = 0
99

1010
[profile.dev.package]
1111
# These speed up local tests.

crates/hir-def/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ base-db = { path = "../base-db", version = "0.0.0" }
3333
syntax = { path = "../syntax", version = "0.0.0" }
3434
profile = { path = "../profile", version = "0.0.0" }
3535
hir-expand = { path = "../hir-expand", version = "0.0.0" }
36+
rustc_abi = { version = "0.0.20221125", package = "hkalbasi-rustc-ap-rustc_abi", default-features = false }
3637
mbe = { path = "../mbe", version = "0.0.0" }
3738
cfg = { path = "../cfg", version = "0.0.0" }
3839
tt = { path = "../tt", version = "0.0.0" }

crates/hir-def/src/adt.rs

+22-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use hir_expand::{
99
HirFileId, InFile,
1010
};
1111
use la_arena::{Arena, ArenaMap};
12+
use rustc_abi::{Integer, IntegerType};
1213
use syntax::ast::{self, HasName, HasVisibility};
1314
use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree};
1415

@@ -127,15 +128,32 @@ fn parse_repr_tt(tt: &Subtree) -> Option<ReprOptions> {
127128
.map(Either::Left)
128129
.or_else(|| BuiltinUint::from_suffix(repr).map(Either::Right))
129130
{
130-
int = Some(builtin);
131+
int = Some(match builtin {
132+
Either::Left(bi) => match bi {
133+
BuiltinInt::Isize => IntegerType::Pointer(true),
134+
BuiltinInt::I8 => IntegerType::Fixed(Integer::I8, true),
135+
BuiltinInt::I16 => IntegerType::Fixed(Integer::I16, true),
136+
BuiltinInt::I32 => IntegerType::Fixed(Integer::I32, true),
137+
BuiltinInt::I64 => IntegerType::Fixed(Integer::I64, true),
138+
BuiltinInt::I128 => IntegerType::Fixed(Integer::I128, true),
139+
},
140+
Either::Right(bu) => match bu {
141+
BuiltinUint::Usize => IntegerType::Pointer(false),
142+
BuiltinUint::U8 => IntegerType::Fixed(Integer::I8, false),
143+
BuiltinUint::U16 => IntegerType::Fixed(Integer::I16, false),
144+
BuiltinUint::U32 => IntegerType::Fixed(Integer::I32, false),
145+
BuiltinUint::U64 => IntegerType::Fixed(Integer::I64, false),
146+
BuiltinUint::U128 => IntegerType::Fixed(Integer::I128, false),
147+
},
148+
});
131149
}
132150
ReprFlags::empty()
133151
}
134152
})
135153
}
136154
}
137155

138-
Some(ReprOptions { int, align: max_align, pack: min_pack, flags })
156+
Some(ReprOptions { int, align: max_align, pack: min_pack, flags, field_shuffle_seed: 0 })
139157
}
140158

141159
impl StructData {
@@ -276,10 +294,10 @@ impl EnumData {
276294
Some(id)
277295
}
278296

279-
pub fn variant_body_type(&self) -> Either<BuiltinInt, BuiltinUint> {
297+
pub fn variant_body_type(&self) -> IntegerType {
280298
match self.repr {
281299
Some(ReprOptions { int: Some(builtin), .. }) => builtin,
282-
_ => Either::Left(BuiltinInt::Isize),
300+
_ => IntegerType::Pointer(true),
283301
}
284302
}
285303
}

0 commit comments

Comments
 (0)