Skip to content

Commit 2880f88

Browse files
Update solver types as required by the upgrade
1 parent c7cbaa7 commit 2880f88

38 files changed

Lines changed: 416 additions & 1770 deletions

Cargo.lock

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

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8686
vfs = { path = "./crates/vfs", version = "0.0.0" }
8787
edition = { path = "./crates/edition", version = "0.0.0" }
8888

89-
ra-ap-rustc_lexer = { version = "0.159", default-features = false }
90-
ra-ap-rustc_parse_format = { version = "0.159", default-features = false }
91-
ra-ap-rustc_index = { version = "0.159", default-features = false }
92-
ra-ap-rustc_abi = { version = "0.159", default-features = false }
93-
ra-ap-rustc_pattern_analysis = { version = "0.159", default-features = false }
94-
ra-ap-rustc_ast_ir = { version = "0.159", default-features = false }
95-
ra-ap-rustc_type_ir = { version = "0.159", default-features = false }
96-
ra-ap-rustc_next_trait_solver = { version = "0.159", default-features = false }
89+
ra-ap-rustc_lexer = { version = "0.160", default-features = false }
90+
ra-ap-rustc_parse_format = { version = "0.160", default-features = false }
91+
ra-ap-rustc_index = { version = "0.160", default-features = false }
92+
ra-ap-rustc_abi = { version = "0.160", default-features = false }
93+
ra-ap-rustc_pattern_analysis = { version = "0.160", default-features = false }
94+
ra-ap-rustc_ast_ir = { version = "0.160", default-features = false }
95+
ra-ap-rustc_type_ir = { version = "0.160", default-features = false }
96+
ra-ap-rustc_next_trait_solver = { version = "0.160", default-features = false }
9797

9898
# local crates that aren't published to crates.io. These should not have versions.
9999

crates/hir-ty/src/builtin_derive.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use crate::{
2020
GenericPredicates,
2121
db::HirDatabase,
2222
next_solver::{
23-
Clause, Clauses, DbInterner, EarlyBinder, GenericArgs, ParamEnv, StoredEarlyBinder,
24-
StoredTy, TraitRef, Ty, TyKind, fold::fold_tys, generics::Generics,
23+
AliasTy, Clause, Clauses, DbInterner, EarlyBinder, GenericArgs, ParamEnv,
24+
StoredEarlyBinder, StoredTy, TraitRef, Ty, TyKind, fold::fold_tys, generics::Generics,
2525
},
2626
};
2727

@@ -342,7 +342,7 @@ fn extend_assoc_type_bounds<'db>(
342342
type Result = ();
343343

344344
fn visit_ty(&mut self, t: Ty<'db>) -> Self::Result {
345-
if let TyKind::Alias(AliasTyKind::Projection, _) = t.kind() {
345+
if let TyKind::Alias(AliasTy { kind: AliasTyKind::Projection { .. }, .. }) = t.kind() {
346346
self.assoc_type_bounds.push(
347347
TraitRef::new_from_args(
348348
self.interner,
@@ -546,49 +546,49 @@ struct WithGenerics<'a, T: Trait, const N: usize>(&'a [T; N], T::Assoc);
546546
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
547547
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
548548
Clause(Binder { value: TraitPredicate(#1: Debug, polarity:Positive), bound_vars: [] })
549-
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Debug, polarity:Positive), bound_vars: [] })
549+
Clause(Binder { value: TraitPredicate(Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. }): Debug, polarity:Positive), bound_vars: [] })
550550
551551
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
552552
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
553553
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
554554
Clause(Binder { value: TraitPredicate(#1: Clone, polarity:Positive), bound_vars: [] })
555-
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Clone, polarity:Positive), bound_vars: [] })
555+
Clause(Binder { value: TraitPredicate(Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. }): Clone, polarity:Positive), bound_vars: [] })
556556
557557
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
558558
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
559559
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
560560
Clause(Binder { value: TraitPredicate(#1: Copy, polarity:Positive), bound_vars: [] })
561-
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Copy, polarity:Positive), bound_vars: [] })
561+
Clause(Binder { value: TraitPredicate(Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. }): Copy, polarity:Positive), bound_vars: [] })
562562
563563
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
564564
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
565565
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
566566
Clause(Binder { value: TraitPredicate(#1: PartialEq<[#1]>, polarity:Positive), bound_vars: [] })
567-
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): PartialEq<[Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. })]>, polarity:Positive), bound_vars: [] })
567+
Clause(Binder { value: TraitPredicate(Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. }): PartialEq<[Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. })]>, polarity:Positive), bound_vars: [] })
568568
569569
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
570570
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
571571
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
572572
Clause(Binder { value: TraitPredicate(#1: Eq, polarity:Positive), bound_vars: [] })
573-
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Eq, polarity:Positive), bound_vars: [] })
573+
Clause(Binder { value: TraitPredicate(Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. }): Eq, polarity:Positive), bound_vars: [] })
574574
575575
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
576576
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
577577
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
578578
Clause(Binder { value: TraitPredicate(#1: PartialOrd<[#1]>, polarity:Positive), bound_vars: [] })
579-
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): PartialOrd<[Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. })]>, polarity:Positive), bound_vars: [] })
579+
Clause(Binder { value: TraitPredicate(Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. }): PartialOrd<[Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. })]>, polarity:Positive), bound_vars: [] })
580580
581581
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
582582
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
583583
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
584584
Clause(Binder { value: TraitPredicate(#1: Ord, polarity:Positive), bound_vars: [] })
585-
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Ord, polarity:Positive), bound_vars: [] })
585+
Clause(Binder { value: TraitPredicate(Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. }): Ord, polarity:Positive), bound_vars: [] })
586586
587587
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
588588
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
589589
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
590590
Clause(Binder { value: TraitPredicate(#1: Hash, polarity:Positive), bound_vars: [] })
591-
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Hash, polarity:Positive), bound_vars: [] })
591+
Clause(Binder { value: TraitPredicate(Alias(AliasTy { args: [#1], kind: Projection { def_id: TypeAliasId("Assoc") }, .. }): Hash, polarity:Positive), bound_vars: [] })
592592
593593
"#]],
594594
);

crates/hir-ty/src/display.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ fn write_projection<'db>(
646646
ClauseKind::TypeOutlives(t) => t.0,
647647
_ => return false,
648648
};
649-
let TyKind::Alias(AliasTyKind::Projection, a) = ty.kind() else {
649+
let TyKind::Alias(a) = ty.kind() else {
650650
return false;
651651
};
652652
a == *alias
@@ -657,7 +657,7 @@ fn write_projection<'db>(
657657
write_bounds_like_dyn_trait_with_prefix(
658658
f,
659659
"impl",
660-
Either::Left(Ty::new_alias(f.interner, AliasTyKind::Projection, *alias)),
660+
Either::Left(Ty::new_alias(f.interner, *alias)),
661661
&bounds,
662662
SizedByDefault::NotSized,
663663
needs_parens_if_multi,
@@ -673,7 +673,7 @@ fn write_projection<'db>(
673673
write!(
674674
f,
675675
">::{}",
676-
TypeAliasSignature::of(f.db, alias.def_id.expect_type_alias())
676+
TypeAliasSignature::of(f.db, alias.kind.def_id().expect_type_alias())
677677
.name
678678
.display(f.db, f.edition())
679679
)?;
@@ -1005,7 +1005,7 @@ fn render_const_scalar_inner<'db>(
10051005
TyKind::Pat(_, _) => f.write_str("<pat>"),
10061006
TyKind::Error(..)
10071007
| TyKind::Placeholder(_)
1008-
| TyKind::Alias(_, _)
1008+
| TyKind::Alias(..)
10091009
| TyKind::Param(_)
10101010
| TyKind::Bound(_, _)
10111011
| TyKind::Infer(_) => f.write_str("<placeholder-or-unknown-type>"),
@@ -1280,7 +1280,7 @@ impl<'db> HirDisplay<'db> for Ty<'db> {
12801280

12811281
hir_fmt_generics(f, parameters.as_slice(), Some(def.def_id().0.into()), None)?;
12821282
}
1283-
TyKind::Alias(AliasTyKind::Projection, alias_ty) => {
1283+
TyKind::Alias(alias_ty @ AliasTy { kind: AliasTyKind::Projection { .. }, .. }) => {
12841284
write_projection(f, &alias_ty, trait_bounds_need_parens)?
12851285
}
12861286
TyKind::Foreign(alias) => {
@@ -1289,8 +1289,8 @@ impl<'db> HirDisplay<'db> for Ty<'db> {
12891289
write!(f, "{}", type_alias.name.display(f.db, f.edition()))?;
12901290
f.end_location_link();
12911291
}
1292-
TyKind::Alias(AliasTyKind::Opaque, alias_ty) => {
1293-
let opaque_ty_id = match alias_ty.def_id {
1292+
TyKind::Alias(alias_ty @ AliasTy { kind: AliasTyKind::Opaque { def_id }, .. }) => {
1293+
let opaque_ty_id = match def_id {
12941294
SolverDefId::InternedOpaqueTyId(id) => id,
12951295
_ => unreachable!(),
12961296
};
@@ -1585,7 +1585,7 @@ impl<'db> HirDisplay<'db> for Ty<'db> {
15851585
TyKind::CoroutineWitness(..) => write!(f, "{{coroutine witness}}")?,
15861586
TyKind::Pat(_, _) => write!(f, "{{pat}}")?,
15871587
TyKind::UnsafeBinder(_) => write!(f, "{{unsafe binder}}")?,
1588-
TyKind::Alias(_, _) => write!(f, "{{alias}}")?,
1588+
TyKind::Alias(..) => write!(f, "{{alias}}")?,
15891589
}
15901590
Ok(())
15911591
}

crates/hir-ty/src/dyn_compatibility.rs

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ use crate::{
2121
db::{HirDatabase, InternedOpaqueTyId},
2222
lower::{GenericPredicates, associated_ty_item_bounds},
2323
next_solver::{
24-
Binder, Clause, Clauses, DbInterner, EarlyBinder, GenericArgs, Goal, ParamEnv, ParamTy,
25-
SolverDefId, TraitPredicate, TraitRef, Ty, TypingMode, infer::DbInternerInferExt, mk_param,
24+
AliasTy, Binder, Clause, Clauses, DbInterner, EarlyBinder, GenericArgs, Goal, ParamEnv,
25+
ParamTy, SolverDefId, TraitPredicate, TraitRef, Ty, TypingMode, infer::DbInternerInferExt,
26+
mk_param,
2627
},
2728
traits::next_trait_solve_in_ctxt,
2829
};
@@ -239,30 +240,30 @@ fn contains_illegal_self_type_reference<'db, T: rustc_type_ir::TypeVisitable<DbI
239240
match ty.kind() {
240241
rustc_type_ir::TyKind::Param(param) if param.index == 0 => ControlFlow::Break(()),
241242
rustc_type_ir::TyKind::Param(_) => ControlFlow::Continue(()),
242-
rustc_type_ir::TyKind::Alias(AliasTyKind::Projection, proj) => {
243-
match self.allow_self_projection {
244-
AllowSelfProjection::Yes => {
245-
let trait_ = proj.trait_def_id(interner);
246-
let trait_ = match trait_ {
247-
SolverDefId::TraitId(id) => id,
248-
_ => unreachable!(),
249-
};
250-
if self.super_traits.is_none() {
251-
self.super_traits = Some(
252-
elaborate::supertrait_def_ids(interner, self.trait_.into())
253-
.map(|super_trait| super_trait.0)
254-
.collect(),
255-
)
256-
}
257-
if self.super_traits.as_ref().is_some_and(|s| s.contains(&trait_)) {
258-
ControlFlow::Continue(())
259-
} else {
260-
ty.super_visit_with(self)
261-
}
243+
rustc_type_ir::TyKind::Alias(
244+
proj @ AliasTy { kind: AliasTyKind::Projection { .. }, .. },
245+
) => match self.allow_self_projection {
246+
AllowSelfProjection::Yes => {
247+
let trait_ = proj.trait_def_id(interner);
248+
let trait_ = match trait_ {
249+
SolverDefId::TraitId(id) => id,
250+
_ => unreachable!(),
251+
};
252+
if self.super_traits.is_none() {
253+
self.super_traits = Some(
254+
elaborate::supertrait_def_ids(interner, self.trait_.into())
255+
.map(|super_trait| super_trait.0)
256+
.collect(),
257+
)
258+
}
259+
if self.super_traits.as_ref().is_some_and(|s| s.contains(&trait_)) {
260+
ControlFlow::Continue(())
261+
} else {
262+
ty.super_visit_with(self)
262263
}
263-
AllowSelfProjection::No => ty.super_visit_with(self),
264264
}
265-
}
265+
AllowSelfProjection::No => ty.super_visit_with(self),
266+
},
266267
_ => ty.super_visit_with(self),
267268
}
268269
}
@@ -503,8 +504,12 @@ fn contains_illegal_impl_trait_in_trait<'db>(
503504
&mut self,
504505
ty: <DbInterner<'db> as rustc_type_ir::Interner>::Ty,
505506
) -> Self::Result {
506-
if let rustc_type_ir::TyKind::Alias(AliasTyKind::Opaque, op) = ty.kind() {
507-
let id = match op.def_id {
507+
if let rustc_type_ir::TyKind::Alias(AliasTy {
508+
kind: AliasTyKind::Opaque { def_id },
509+
..
510+
}) = ty.kind()
511+
{
512+
let id = match def_id {
508513
SolverDefId::InternedOpaqueTyId(id) => id,
509514
_ => unreachable!(),
510515
};

0 commit comments

Comments
 (0)