Skip to content

Commit 6fcd20b

Browse files
authored
Merge pull request #20814 from ChayimFriedman2/mir-ns
internal: Migrate MIR to next solver
2 parents edaeac1 + e6857aa commit 6fcd20b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2493
-2504
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ debug = 2
5252

5353
[workspace.dependencies]
5454
# local crates
55+
macros = { path = "./crates/macros", version = "0.0.0" }
5556
base-db = { path = "./crates/base-db", version = "0.0.0" }
5657
cfg = { path = "./crates/cfg", version = "0.0.0", features = ["tt"] }
5758
hir = { path = "./crates/hir", version = "0.0.0" }

crates/hir-def/src/signatures.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ bitflags::bitflags! {
349349
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
350350
pub struct ImplFlags: u8 {
351351
const NEGATIVE = 1 << 1;
352+
const DEFAULT = 1 << 2;
352353
const UNSAFE = 1 << 3;
353354
}
354355
}
@@ -374,6 +375,9 @@ impl ImplSignature {
374375
if src.value.excl_token().is_some() {
375376
flags.insert(ImplFlags::NEGATIVE);
376377
}
378+
if src.value.default_token().is_some() {
379+
flags.insert(ImplFlags::DEFAULT);
380+
}
377381

378382
let (store, source_map, self_ty, target_trait, generic_params) =
379383
crate::expr_store::lower::lower_impl(db, loc.container, src, id);
@@ -389,6 +393,16 @@ impl ImplSignature {
389393
Arc::new(source_map),
390394
)
391395
}
396+
397+
#[inline]
398+
pub fn is_negative(&self) -> bool {
399+
self.flags.contains(ImplFlags::NEGATIVE)
400+
}
401+
402+
#[inline]
403+
pub fn is_default(&self) -> bool {
404+
self.flags.contains(ImplFlags::DEFAULT)
405+
}
392406
}
393407

394408
bitflags::bitflags! {

crates/hir-ty/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ tracing-tree.workspace = true
5050

5151
# local deps
5252
stdx.workspace = true
53+
macros.workspace = true
5354
intern.workspace = true
5455
hir-def.workspace = true
5556
hir-expand.workspace = true

crates/hir-ty/src/builder.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,14 @@ impl<D> TyBuilder<D> {
130130
}
131131

132132
pub fn fill_with_unknown(self) -> Self {
133+
let interner = DbInterner::conjure();
133134
// self.fill is inlined to make borrow checker happy
134135
let mut this = self;
135136
let filler = this.param_kinds[this.vec.len()..].iter().map(|x| match x {
136137
ParamKind::Type => TyKind::Error.intern(Interner).cast(Interner),
137-
ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()),
138+
ParamKind::Const(ty) => {
139+
unknown_const_as_generic(ty.to_nextsolver(interner)).to_chalk(interner)
140+
}
138141
ParamKind::Lifetime => error_lifetime().cast(Interner),
139142
});
140143
this.vec.extend(filler.casted(Interner));
@@ -219,13 +222,16 @@ impl TyBuilder<()> {
219222
}
220223

221224
pub fn unknown_subst(db: &dyn HirDatabase, def: impl Into<GenericDefId>) -> Substitution {
225+
let interner = DbInterner::conjure();
222226
let params = generics(db, def.into());
223227
Substitution::from_iter(
224228
Interner,
225229
params.iter_id().map(|id| match id {
226230
GenericParamId::TypeParamId(_) => TyKind::Error.intern(Interner).cast(Interner),
227231
GenericParamId::ConstParamId(id) => {
228-
unknown_const_as_generic(db.const_param_ty(id)).cast(Interner)
232+
unknown_const_as_generic(db.const_param_ty_ns(id))
233+
.to_chalk(interner)
234+
.cast(Interner)
229235
}
230236
GenericParamId::LifetimeParamId(_) => error_lifetime().cast(Interner),
231237
}),
@@ -267,6 +273,7 @@ impl TyBuilder<hir_def::AdtId> {
267273
db: &dyn HirDatabase,
268274
mut fallback: impl FnMut() -> Ty,
269275
) -> Self {
276+
let interner = DbInterner::conjure();
270277
// Note that we're building ADT, so we never have parent generic parameters.
271278
let defaults = db.generic_defaults(self.data.into());
272279

@@ -287,7 +294,9 @@ impl TyBuilder<hir_def::AdtId> {
287294
// The defaults may be missing if no param has default, so fill that.
288295
let filler = self.param_kinds[self.vec.len()..].iter().map(|x| match x {
289296
ParamKind::Type => fallback().cast(Interner),
290-
ParamKind::Const(ty) => unknown_const_as_generic(ty.clone()),
297+
ParamKind::Const(ty) => {
298+
unknown_const_as_generic(ty.to_nextsolver(interner)).to_chalk(interner)
299+
}
291300
ParamKind::Lifetime => error_lifetime().cast(Interner),
292301
});
293302
self.vec.extend(filler.casted(Interner));

0 commit comments

Comments
 (0)