Skip to content

Commit 4cb250b

Browse files
Merge pull request rust-lang#20834 from ChayimFriedman2/hir-ns
Migrate `hir` types to next solver
2 parents bfb0892 + 9170a7d commit 4cb250b

File tree

28 files changed

+1272
-1921
lines changed

28 files changed

+1272
-1921
lines changed

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@
55
66
use std::fmt;
77

8-
use hir_def::TraitId;
9-
use hir_def::{TypeAliasId, lang_item::LangItem};
8+
use hir_def::{TraitId, TypeAliasId, lang_item::LangItem};
109
use rustc_type_ir::inherent::{IntoKind, Ty as _};
1110
use tracing::debug;
1211
use triomphe::Arc;
1312

14-
use crate::next_solver::TraitRef;
15-
use crate::next_solver::infer::InferOk;
16-
use crate::next_solver::infer::traits::Obligation;
1713
use crate::{
1814
TraitEnvironment,
1915
db::HirDatabase,
2016
infer::unify::InferenceTable,
2117
next_solver::{
22-
Ty, TyKind,
23-
infer::traits::{ObligationCause, PredicateObligations},
24-
mapping::{ChalkToNextSolver, NextSolverToChalk},
18+
Canonical, TraitRef, Ty, TyKind,
19+
infer::{
20+
InferOk,
21+
traits::{Obligation, ObligationCause, PredicateObligations},
22+
},
2523
obligation_ctxt::ObligationCtxt,
2624
},
2725
};
@@ -38,17 +36,16 @@ const AUTODEREF_RECURSION_LIMIT: usize = 20;
3836
pub fn autoderef<'db>(
3937
db: &'db dyn HirDatabase,
4038
env: Arc<TraitEnvironment<'db>>,
41-
ty: crate::Canonical<crate::Ty>,
42-
) -> impl Iterator<Item = crate::Ty> + use<> {
39+
ty: Canonical<'db, Ty<'db>>,
40+
) -> impl Iterator<Item = Ty<'db>> + use<'db> {
4341
let mut table = InferenceTable::new(db, env);
44-
let interner = table.interner();
45-
let ty = table.instantiate_canonical(ty.to_nextsolver(interner));
42+
let ty = table.instantiate_canonical(ty);
4643
let mut autoderef = Autoderef::new_no_tracking(&mut table, ty);
4744
let mut v = Vec::new();
4845
while let Some((ty, _steps)) = autoderef.next() {
4946
// `ty` may contain unresolved inference variables. Since there's no chance they would be
5047
// resolved, just replace with fallback type.
51-
let resolved = autoderef.table.resolve_completely(ty).to_chalk(interner);
48+
let resolved = autoderef.table.resolve_completely(ty);
5249

5350
// If the deref chain contains a cycle (e.g. `A` derefs to `B` and `B` derefs to `A`), we
5451
// would revisit some already visited types. Stop here to avoid duplication.

0 commit comments

Comments
 (0)