Skip to content

Commit 57c7b7d

Browse files
committed
Re-add set_current_program
1 parent 159a617 commit 57c7b7d

File tree

7 files changed

+101
-80
lines changed

7 files changed

+101
-80
lines changed

Cargo.lock

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

crates/hir-ty/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ rustc_apfloat = "0.2.3"
3636
query-group.workspace = true
3737
salsa.workspace = true
3838
salsa-macros.workspace = true
39-
extension-traits = "2.0.0"
4039

4140
ra-ap-rustc_abi.workspace = true
4241
ra-ap-rustc_index.workspace = true

crates/hir-ty/src/next_solver/infer/canonical/instantiate.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::next_solver::{
1515
traits::{Obligation, PredicateObligations},
1616
},
1717
};
18-
use extension_traits::extension;
1918
use rustc_type_ir::{
2019
AliasRelationDirection, AliasTyKind, BoundVar, GenericArgKind, InferTy, TypeFoldable, Upcast,
2120
Variance,
@@ -26,10 +25,23 @@ use rustc_type_ir::{
2625
},
2726
};
2827

28+
pub trait CanonicalExt<'db, V> {
29+
fn instantiate(&self, tcx: DbInterner<'db>, var_values: &CanonicalVarValues<'db>) -> V
30+
where
31+
V: TypeFoldable<DbInterner<'db>>;
32+
fn instantiate_projected<T>(
33+
&self,
34+
tcx: DbInterner<'db>,
35+
var_values: &CanonicalVarValues<'db>,
36+
projection_fn: impl FnOnce(&V) -> T,
37+
) -> T
38+
where
39+
T: TypeFoldable<DbInterner<'db>>;
40+
}
41+
2942
/// FIXME(-Znext-solver): This or public because it is shared with the
3043
/// new trait solver implementation. We should deduplicate canonicalization.
31-
#[extension(pub trait CanonicalExt)]
32-
impl<'db, V> Canonical<'db, V> {
44+
impl<'db, V> CanonicalExt<'db, V> for Canonical<'db, V> {
3345
/// Instantiate the wrapped value, replacing each canonical value
3446
/// with the value given in `var_values`.
3547
fn instantiate(&self, tcx: DbInterner<'db>, var_values: &CanonicalVarValues<'db>) -> V

crates/hir-ty/src/next_solver/infer/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub use SubregionOrigin::*;
88
pub use at::DefineOpaqueTypes;
99
use ena::undo_log::UndoLogs;
1010
use ena::unify as ut;
11-
use extension_traits::extension;
1211
use intern::Symbol;
1312
use opaque_types::{OpaqueHiddenType, OpaqueTypeStorage};
1413
use region_constraints::{
@@ -440,8 +439,11 @@ pub struct InferCtxtBuilder<'db> {
440439
interner: DbInterner<'db>,
441440
}
442441

443-
#[extension(pub trait DbInternerInferExt)]
444-
impl<'db> DbInterner<'db> {
442+
pub trait DbInternerInferExt<'db> {
443+
fn infer_ctxt(self) -> InferCtxtBuilder<'db>;
444+
}
445+
446+
impl<'db> DbInternerInferExt<'db> for DbInterner<'db> {
445447
fn infer_ctxt(self) -> InferCtxtBuilder<'db> {
446448
InferCtxtBuilder { interner: self }
447449
}

crates/hir-ty/src/next_solver/util.rs

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::iter;
22
use std::ops::{self, ControlFlow};
33

44
use base_db::Crate;
5-
use extension_traits::extension;
65
use hir_def::lang_item::LangItem;
76
use hir_def::{BlockId, HasModule, ItemContainerId, Lookup};
87
use intern::sym;
@@ -72,8 +71,17 @@ impl<'db> Discr<'db> {
7271
}
7372
}
7473

75-
#[extension(pub trait IntegerTypeExt)]
76-
impl IntegerType {
74+
pub trait IntegerTypeExt {
75+
fn to_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db>;
76+
fn initial_discriminant<'db>(&self, interner: DbInterner<'db>) -> Discr<'db>;
77+
fn disr_incr<'db>(
78+
&self,
79+
interner: DbInterner<'db>,
80+
val: Option<Discr<'db>>,
81+
) -> Option<Discr<'db>>;
82+
}
83+
84+
impl IntegerTypeExt for IntegerType {
7785
fn to_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db> {
7886
match self {
7987
IntegerType::Pointer(true) => Ty::new(interner, TyKind::Int(IntTy::Isize)),
@@ -101,8 +109,20 @@ impl IntegerType {
101109
}
102110
}
103111

104-
#[extension(pub trait IntegerExt)]
105-
impl Integer {
112+
pub trait IntegerExt {
113+
fn to_ty<'db>(&self, interner: DbInterner<'db>, signed: bool) -> Ty<'db>;
114+
fn from_int_ty<C: HasDataLayout>(cx: &C, ity: IntTy) -> Integer;
115+
fn from_uint_ty<C: HasDataLayout>(cx: &C, ity: UintTy) -> Integer;
116+
fn repr_discr<'db>(
117+
interner: DbInterner<'db>,
118+
ty: Ty<'db>,
119+
repr: &ReprOptions,
120+
min: i128,
121+
max: i128,
122+
) -> (Integer, bool);
123+
}
124+
125+
impl IntegerExt for Integer {
106126
#[inline]
107127
fn to_ty<'db>(&self, interner: DbInterner<'db>, signed: bool) -> Ty<'db> {
108128
use Integer::*;
@@ -192,8 +212,12 @@ impl Integer {
192212
}
193213
}
194214

195-
#[extension(pub trait FloatExt)]
196-
impl Float {
215+
pub trait FloatExt {
216+
fn to_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db>;
217+
fn from_float_ty(fty: FloatTy) -> Self;
218+
}
219+
220+
impl FloatExt for Float {
197221
#[inline]
198222
fn to_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db> {
199223
use Float::*;
@@ -216,8 +240,12 @@ impl Float {
216240
}
217241
}
218242

219-
#[extension(pub trait PrimitiveExt)]
220-
impl Primitive {
243+
pub trait PrimitiveExt {
244+
fn to_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db>;
245+
fn to_int_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db>;
246+
}
247+
248+
impl PrimitiveExt for Primitive {
221249
#[inline]
222250
fn to_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db> {
223251
match *self {
@@ -254,8 +282,11 @@ impl<'db> HasDataLayout for DbInterner<'db> {
254282
}
255283
}
256284

257-
#[extension(pub trait CoroutineArgsExt)]
258-
impl<'db> CoroutineArgs<DbInterner<'db>> {
285+
pub trait CoroutineArgsExt<'db> {
286+
fn discr_ty(&self, interner: DbInterner<'db>) -> Ty<'db>;
287+
}
288+
289+
impl<'db> CoroutineArgsExt<'db> for CoroutineArgs<DbInterner<'db>> {
259290
/// The type of the state discriminant used in the coroutine type.
260291
#[inline]
261292
fn discr_ty(&self, interner: DbInterner<'db>) -> Ty<'db> {

0 commit comments

Comments
 (0)