mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 09:48:10 +00:00
Move hir_trait_id to extension trait
This commit is contained in:
parent
86feac18e8
commit
6777a4975d
11 changed files with 27 additions and 19 deletions
|
@ -59,7 +59,8 @@ use hir_ty::{
|
||||||
traits::FnTrait,
|
traits::FnTrait,
|
||||||
AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, CanonicalVarKinds, Cast,
|
AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, CanonicalVarKinds, Cast,
|
||||||
DebruijnIndex, InEnvironment, Interner, QuantifiedWhereClause, Scalar, Solution, Substitution,
|
DebruijnIndex, InEnvironment, Interner, QuantifiedWhereClause, Scalar, Solution, Substitution,
|
||||||
TraitEnvironment, Ty, TyBuilder, TyDefId, TyExt, TyKind, TyVariableKind, WhereClause,
|
TraitEnvironment, TraitRefExt, Ty, TyBuilder, TyDefId, TyExt, TyKind, TyVariableKind,
|
||||||
|
WhereClause,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
|
|
@ -260,3 +260,13 @@ impl ProjectionTyExt for ProjectionTy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait TraitRefExt {
|
||||||
|
fn hir_trait_id(&self) -> TraitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TraitRefExt for TraitRef {
|
||||||
|
fn hir_trait_id(&self) -> TraitId {
|
||||||
|
from_chalk_trait_id(self.trait_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ use crate::{
|
||||||
traits::chalk::from_chalk, utils::generics, AdtId, AliasEq, AliasTy, CallableDefId,
|
traits::chalk::from_chalk, utils::generics, AdtId, AliasEq, AliasTy, CallableDefId,
|
||||||
CallableSig, Const, ConstValue, DomainGoal, GenericArg, ImplTraitId, Interner, Lifetime,
|
CallableSig, Const, ConstValue, DomainGoal, GenericArg, ImplTraitId, Interner, Lifetime,
|
||||||
LifetimeData, LifetimeOutlives, Mutability, OpaqueTy, ProjectionTy, ProjectionTyExt,
|
LifetimeData, LifetimeOutlives, Mutability, OpaqueTy, ProjectionTy, ProjectionTyExt,
|
||||||
QuantifiedWhereClause, Scalar, TraitRef, Ty, TyExt, TyKind, WhereClause,
|
QuantifiedWhereClause, Scalar, TraitRef, TraitRefExt, Ty, TyExt, TyKind, WhereClause,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct HirFormatter<'a> {
|
pub struct HirFormatter<'a> {
|
||||||
|
|
|
@ -11,7 +11,8 @@ use hir_def::{
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
method_resolution, Interner, Substitution, Ty, TyBuilder, TyExt, TyKind, ValueTyDefId,
|
method_resolution, Interner, Substitution, TraitRefExt, Ty, TyBuilder, TyExt, TyKind,
|
||||||
|
ValueTyDefId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{ExprOrPatId, InferenceContext, TraitRef};
|
use super::{ExprOrPatId, InferenceContext, TraitRef};
|
||||||
|
|
|
@ -41,7 +41,7 @@ use crate::{db::HirDatabase, display::HirDisplay, utils::generics};
|
||||||
|
|
||||||
pub use autoderef::autoderef;
|
pub use autoderef::autoderef;
|
||||||
pub use builder::TyBuilder;
|
pub use builder::TyBuilder;
|
||||||
pub use chalk_ext::{ProjectionTyExt, TyExt};
|
pub use chalk_ext::*;
|
||||||
pub use infer::{could_unify, InferenceResult};
|
pub use infer::{could_unify, InferenceResult};
|
||||||
pub use lower::{
|
pub use lower::{
|
||||||
associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode,
|
associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode,
|
||||||
|
@ -107,12 +107,6 @@ pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TraitRef {
|
|
||||||
pub fn hir_trait_id(&self) -> TraitId {
|
|
||||||
from_chalk_trait_id(self.trait_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Canonical<T> {
|
impl<T> Canonical<T> {
|
||||||
pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self {
|
pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self {
|
||||||
let kinds = kinds.into_iter().map(|tk| {
|
let kinds = kinds.into_iter().map(|tk| {
|
||||||
|
|
|
@ -35,7 +35,7 @@ use crate::{
|
||||||
AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, DynTy, FnPointer, FnSig,
|
AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, DynTy, FnPointer, FnSig,
|
||||||
FnSubst, ImplTraitId, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause,
|
FnSubst, ImplTraitId, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause,
|
||||||
QuantifiedWhereClauses, ReturnTypeImplTrait, ReturnTypeImplTraits, Substitution,
|
QuantifiedWhereClauses, ReturnTypeImplTrait, ReturnTypeImplTraits, Substitution,
|
||||||
TraitEnvironment, TraitRef, Ty, TyBuilder, TyKind, TypeWalk, WhereClause,
|
TraitEnvironment, TraitRef, TraitRefExt, Ty, TyBuilder, TyKind, TypeWalk, WhereClause,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -22,8 +22,8 @@ use crate::{
|
||||||
static_lifetime,
|
static_lifetime,
|
||||||
utils::all_super_traits,
|
utils::all_super_traits,
|
||||||
AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId,
|
AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId,
|
||||||
InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, Ty, TyBuilder, TyExt, TyKind,
|
InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, TraitRefExt, Ty, TyBuilder,
|
||||||
TypeWalk,
|
TyExt, TyKind, TypeWalk,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This is used as a key for indexing impls.
|
/// This is used as a key for indexing impls.
|
||||||
|
|
|
@ -9,7 +9,7 @@ use stdx::panic_context;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase, AliasEq, AliasTy, Canonical, DomainGoal, Guidance, HirDisplay, InEnvironment,
|
db::HirDatabase, AliasEq, AliasTy, Canonical, DomainGoal, Guidance, HirDisplay, InEnvironment,
|
||||||
Solution, Ty, TyKind, WhereClause,
|
Solution, TraitRefExt, Ty, TyKind, WhereClause,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::chalk::{from_chalk, Interner, ToChalk};
|
use self::chalk::{from_chalk, Interner, ToChalk};
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::{
|
||||||
to_assoc_type_id, to_chalk_trait_id,
|
to_assoc_type_id, to_chalk_trait_id,
|
||||||
utils::generics,
|
utils::generics,
|
||||||
AliasEq, AliasTy, BoundVar, CallableDefId, DebruijnIndex, FnDefId, ProjectionTy, Substitution,
|
AliasEq, AliasTy, BoundVar, CallableDefId, DebruijnIndex, FnDefId, ProjectionTy, Substitution,
|
||||||
TraitRef, Ty, TyBuilder, TyExt, TyKind, WhereClause,
|
TraitRef, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, WhereClause,
|
||||||
};
|
};
|
||||||
use mapping::{
|
use mapping::{
|
||||||
convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue,
|
convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue,
|
||||||
|
|
|
@ -10,9 +10,9 @@ use base_db::salsa::InternKey;
|
||||||
use hir_def::{GenericDefId, TypeAliasId};
|
use hir_def::{GenericDefId, TypeAliasId};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
chalk_ext::ProjectionTyExt, db::HirDatabase, static_lifetime, AliasTy, CallableDefId,
|
db::HirDatabase, static_lifetime, AliasTy, CallableDefId, Canonical, ConstrainedSubst,
|
||||||
Canonical, ConstrainedSubst, DomainGoal, FnPointer, GenericArg, InEnvironment, OpaqueTy,
|
DomainGoal, FnPointer, GenericArg, InEnvironment, OpaqueTy, ProjectionTy, ProjectionTyExt,
|
||||||
ProjectionTy, QuantifiedWhereClause, Substitution, TraitRef, Ty, TypeWalk, WhereClause,
|
QuantifiedWhereClause, Substitution, TraitRef, Ty, TypeWalk, WhereClause,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::interner::*;
|
use super::interner::*;
|
||||||
|
|
|
@ -16,7 +16,9 @@ use hir_def::{
|
||||||
};
|
};
|
||||||
use hir_expand::name::{name, Name};
|
use hir_expand::name::{name, Name};
|
||||||
|
|
||||||
use crate::{db::HirDatabase, Interner, Substitution, TraitRef, TyKind, TypeWalk, WhereClause};
|
use crate::{
|
||||||
|
db::HirDatabase, Interner, Substitution, TraitRef, TraitRefExt, TyKind, TypeWalk, WhereClause,
|
||||||
|
};
|
||||||
|
|
||||||
fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec<TraitId> {
|
fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec<TraitId> {
|
||||||
let resolver = trait_.resolver(db);
|
let resolver = trait_.resolver(db);
|
||||||
|
|
Loading…
Reference in a new issue