Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
673e443
Bump lodash from 4.17.21 to 4.17.23 in /editors/code
dependabot[bot] Jan 21, 2026
802ee01
fix: offer `toggle_macro_delimiter` in nested macro
A4-Tacks Jan 27, 2026
2755c37
Remove unncecessary `#[serde(default)]`
J3m3 Jan 28, 2026
c851897
Align with internal deserialized data structure
J3m3 Jan 28, 2026
fe9b791
feat: offer block let fallback postfix complete
A4-Tacks Feb 6, 2026
2eec617
internal: remove redundant double call in postfix
A4-Tacks Feb 7, 2026
99c45c5
fix: complete `.let` on block tail prefix expression
A4-Tacks Feb 7, 2026
0c724e5
Refactor handling of associated type shorthand for type parameters, i…
ChayimFriedman2 Feb 12, 2026
5c13e0c
Squash commits for review
tascord Feb 13, 2026
3a8a3c7
Remove resolved FIXME
tascord Feb 14, 2026
b451b42
internal: to use SmolStr in fn_param
A4-Tacks Feb 14, 2026
71e4b03
fix: no complete suggest param in complex pattern
A4-Tacks Feb 14, 2026
25a71ea
Fix predicates of builtin derive traits with two parameters defaultin…
ChayimFriedman2 Feb 15, 2026
1c462c2
fix: complete derive helpers on empty nameref
A4-Tacks Feb 15, 2026
6ac0ee9
add span_source to ProcMacroClientInterface
Shourya742 Feb 16, 2026
2541de3
update utils to include span_source in the interface
Shourya742 Feb 16, 2026
9378836
add span_source implementation in proc-macro-srv-cli
Shourya742 Feb 16, 2026
a7d65c7
add span source implementation to proc-macro-srv
Shourya742 Feb 16, 2026
7f2956e
extend span source and span source result variant in message
Shourya742 Feb 16, 2026
a9d3e24
add span source client implementation
Shourya742 Feb 16, 2026
14e6fe0
Merge pull request #21631 from ChayimFriedman2/cleanup-lowering-cycles
ShoyuVanilla Feb 16, 2026
12cacac
fix: Ensure cpu_profiler feature compiles on Rust edition 2024
Wilfred Feb 17, 2026
c22e240
Merge pull request #21659 from Wilfred/fix_profiler_build
lnicola Feb 17, 2026
3fbdb4d
Merge pull request #21652 from ChayimFriedman2/fix-builtin-derive
ShoyuVanilla Feb 17, 2026
cf246bd
Add some basic flycheck integration tests
Wilfred Feb 17, 2026
90f05e9
Merge pull request #21655 from A4-Tacks/derive-helpers-on-empty
ChayimFriedman2 Feb 18, 2026
d9a252f
Merge pull request #21650 from A4-Tacks/not-suggest-param-in-pat
ChayimFriedman2 Feb 18, 2026
e48f0fc
Merge pull request #21600 from A4-Tacks/let-in-prefix
ChayimFriedman2 Feb 18, 2026
6de75dc
Merge pull request #21598 from A4-Tacks/minor-postfix-double-call
ChayimFriedman2 Feb 18, 2026
0a6961d
fix: prevent path transformation of parameter names matching modules
raushan728 Feb 18, 2026
c48dfe0
Merge pull request #21657 from Shourya742/2026-02-16-add-span-source-…
Veykril Feb 18, 2026
cc3115d
Enable debug printing on more types
Wilfred Feb 17, 2026
e1fa34e
Merge pull request #21661 from Wilfred/initial_flycheck_tests
Veykril Feb 18, 2026
b7d95aa
internal: Add flycheck test for custom check command and debounce
Wilfred Feb 17, 2026
c992256
Only offer block let fallback in match-arm
A4-Tacks Feb 6, 2026
36f9838
Merge pull request #21594 from A4-Tacks/fallback-let-comp-block
ChayimFriedman2 Feb 18, 2026
140672a
Bump rustup-toolchain-install-master
lnicola Feb 18, 2026
ffc185a
Merge pull request #21673 from lnicola/bump-rustup-toolchain-install-…
ShoyuVanilla Feb 18, 2026
053cde5
Switch to env var CARGO_RESOLVER_LOCKFILE_PATH for copied lockfiles f…
ShoyuVanilla Feb 12, 2026
5d19cb9
Append `-Zlockfile-path`
ShoyuVanilla Feb 18, 2026
de77ad6
Merge pull request #21630 from ShoyuVanilla/cargo-lockfile
ShoyuVanilla Feb 18, 2026
1278a87
feat: offer on is_some_and for replace_is_method_with_if_let_method
A4-Tacks Feb 11, 2026
574c7b8
Add handling for cycles in `sizedness_constraint_for_ty()`
ChayimFriedman2 Feb 18, 2026
dd0c3a0
Merge pull request #21664 from ChayimFriedman2/representability
ShoyuVanilla Feb 18, 2026
69b08d5
Merge pull request #21623 from A4-Tacks/replace-is-some-and
ShoyuVanilla Feb 18, 2026
c8cf171
Merge pull request #21666 from Wilfred/flycheck_custom_check
ShoyuVanilla Feb 18, 2026
2a3d765
fix: exclude macro refs in tests when excludeTests is enabled
akashchakrabortymsc-cmd Feb 18, 2026
918214c
style: fix rustfmt formatting
akashchakrabortymsc-cmd Feb 18, 2026
9a57e95
Update vs_code.md flatpak SDK extensions to 25.08 runtime
pjhanzlik Feb 18, 2026
08a7b9a
Remove fixme
A4-Tacks Feb 19, 2026
89832e9
Add partial selection for generate_getter_or_setter
A4-Tacks Aug 1, 2025
5bb10ae
Fix some TryEnum reference assists
A4-Tacks Jan 2, 2026
94f6e7e
fix: filter non-value definitions in path transform
raushan728 Feb 19, 2026
4b02062
Merge pull request #20353 from A4-Tacks/gen-getter-range
ShoyuVanilla Feb 19, 2026
52b92ce
Merge pull request #21540 from J3m3/align-optional-fields
ShoyuVanilla Feb 19, 2026
c9a76c4
style: fix clippy collapsible_if warning
raushan728 Feb 19, 2026
f40376c
Merge pull request #21665 from raushan728/fix-param-name-bug
A4-Tacks Feb 19, 2026
0d226d1
Merge pull request #21676 from pjhanzlik/patch-1
lnicola Feb 19, 2026
348edc5
Merge pull request #21536 from A4-Tacks/toggle-nested-macro-delim
ChayimFriedman2 Feb 19, 2026
9884941
Merge pull request #21505 from rust-lang/dependabot/npm_and_yarn/edit…
ShoyuVanilla Feb 19, 2026
6d80670
test: fix exclude_tests_macro_refs test to use custom macro
akashchakrabortymsc-cmd Feb 19, 2026
5a3f581
style: fix rustfmt formatting
akashchakrabortymsc-cmd Feb 19, 2026
99b50e3
ci: rerun checks
akashchakrabortymsc-cmd Feb 19, 2026
c3dc938
Merge pull request #21675 from akashchakrabortymsc-cmd/fix/exclude-te…
ChayimFriedman2 Feb 19, 2026
102f2ec
Perf + Test Case RE: ShoyuVanilla
tascord Feb 19, 2026
c415833
Merge pull request #21635 from tascord/import-cfg-fixes
ShoyuVanilla Feb 20, 2026
b5eb4f6
Do strip references for desugar_try_expr
A4-Tacks Feb 20, 2026
c8d56aa
Merge pull request #21389 from A4-Tacks/assist-try-enum-ref
ChayimFriedman2 Feb 20, 2026
d778d12
fix: generate method assist uses enclosing impl block instead of firs…
akashchakrabortymsc-cmd Feb 20, 2026
aa2da37
style: apply rustfmt
akashchakrabortymsc-cmd Feb 20, 2026
ca3d3b7
fix: remove redundant comment
akashchakrabortymsc-cmd Feb 21, 2026
86d0e71
Merge pull request #21684 from akashchakrabortymsc-cmd/fix/generate-m…
A4-Tacks Feb 21, 2026
fba1ca8
fix: correctly parenthesize inverted condition in convert_if_to_bool_…
akashchakrabortymsc-cmd Feb 21, 2026
e883143
Merge pull request #21688 from akashchakrabortymsc-cmd/fix/convert-if…
A4-Tacks Feb 22, 2026
dbf337f
Fix another case where we forgot to put the type param for `PartialOr…
ChayimFriedman2 Feb 22, 2026
60369b2
Merge pull request #21692 from ChayimFriedman2/builtin-derive-param
ShoyuVanilla Feb 22, 2026
1b5a80c
Prepare for merging from rust-lang/rust
invalid-email-address Feb 23, 2026
419ee10
Merge ref 'c78a29473a68' from rust-lang/rust
invalid-email-address Feb 23, 2026
d8ffd91
Merge pull request #21694 from rust-lang/rustc-pull
lnicola Feb 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/tools/rust-analyzer/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install rustup-toolchain-install-master
run: cargo install rustup-toolchain-install-master@1.6.0
run: cargo install rustup-toolchain-install-master@1.11.0

# Install a pinned rustc commit to avoid surprises
- name: Install Rust toolchain
Expand Down Expand Up @@ -226,7 +226,12 @@ jobs:

strategy:
matrix:
target: [powerpc-unknown-linux-gnu, x86_64-unknown-linux-musl, wasm32-unknown-unknown]
target:
[
powerpc-unknown-linux-gnu,
x86_64-unknown-linux-musl,
wasm32-unknown-unknown,
]
include:
# The rust-analyzer binary is not expected to compile on WASM, but the IDE
# crate should
Expand Down Expand Up @@ -330,7 +335,18 @@ jobs:
run: typos

conclusion:
needs: [rust, rust-cross, typescript, typo-check, proc-macro-srv, miri, rustfmt, clippy, analysis-stats]
needs:
[
rust,
rust-cross,
typescript,
typo-check,
proc-macro-srv,
miri,
rustfmt,
clippy,
analysis-stats,
]
# We need to ensure this job does *not* get skipped if its dependencies fail,
# because a skipped job is considered a success by GitHub. So we have to
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/hir/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static EMPTY: LazyLock<Arc<GenericParams>> = LazyLock::new(|| {

impl GenericParams {
/// The index of the self param in the generic of the non-parent definition.
pub(crate) const SELF_PARAM_ID_IN_SELF: la_arena::Idx<TypeOrConstParamData> =
pub const SELF_PARAM_ID_IN_SELF: la_arena::Idx<TypeOrConstParamData> =
LocalTypeOrConstParamId::from_raw(RawIdx::from_u32(0));

pub fn new(db: &dyn DefDatabase, def: GenericDefId) -> Arc<GenericParams> {
Expand Down
16 changes: 13 additions & 3 deletions src/tools/rust-analyzer/crates/hir-def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ use crate::{
builtin_type::BuiltinType,
db::DefDatabase,
expr_store::ExpressionStoreSourceMap,
hir::generics::{LocalLifetimeParamId, LocalTypeOrConstParamId},
hir::generics::{GenericParams, LocalLifetimeParamId, LocalTypeOrConstParamId},
nameres::{
LocalDefMap,
assoc::{ImplItems, TraitItems},
Expand Down Expand Up @@ -553,15 +553,25 @@ pub struct TypeOrConstParamId {
pub struct TypeParamId(TypeOrConstParamId);

impl TypeParamId {
#[inline]
pub fn parent(&self) -> GenericDefId {
self.0.parent
}

#[inline]
pub fn local_id(&self) -> LocalTypeOrConstParamId {
self.0.local_id
}
}

impl TypeParamId {
#[inline]
pub fn trait_self(trait_: TraitId) -> TypeParamId {
TypeParamId::from_unchecked(TypeOrConstParamId {
parent: trait_.into(),
local_id: GenericParams::SELF_PARAM_ID_IN_SELF,
})
}

#[inline]
/// Caller should check if this toc id really belongs to a type
pub fn from_unchecked(it: TypeOrConstParamId) -> Self {
Self(it)
Expand Down
73 changes: 55 additions & 18 deletions src/tools/rust-analyzer/crates/hir-ty/src/builtin_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ fn coerce_pointee_new_type_param(trait_id: TraitId) -> TypeParamId {
})
}

fn trait_args(trait_: BuiltinDeriveImplTrait, self_ty: Ty<'_>) -> GenericArgs<'_> {
match trait_ {
BuiltinDeriveImplTrait::Copy
| BuiltinDeriveImplTrait::Clone
| BuiltinDeriveImplTrait::Default
| BuiltinDeriveImplTrait::Debug
| BuiltinDeriveImplTrait::Hash
| BuiltinDeriveImplTrait::Eq
| BuiltinDeriveImplTrait::Ord => GenericArgs::new_from_slice(&[self_ty.into()]),
BuiltinDeriveImplTrait::PartialOrd | BuiltinDeriveImplTrait::PartialEq => {
GenericArgs::new_from_slice(&[self_ty.into(), self_ty.into()])
}
BuiltinDeriveImplTrait::CoerceUnsized | BuiltinDeriveImplTrait::DispatchFromDyn => {
panic!("`CoerceUnsized` and `DispatchFromDyn` have special generics")
}
}
}

pub(crate) fn generics_of<'db>(interner: DbInterner<'db>, id: BuiltinDeriveImplId) -> Generics {
let db = interner.db;
let loc = id.loc(db);
Expand Down Expand Up @@ -95,21 +113,19 @@ pub fn impl_trait<'db>(
| BuiltinDeriveImplTrait::Debug
| BuiltinDeriveImplTrait::Hash
| BuiltinDeriveImplTrait::Ord
| BuiltinDeriveImplTrait::Eq => {
| BuiltinDeriveImplTrait::Eq
| BuiltinDeriveImplTrait::PartialOrd
| BuiltinDeriveImplTrait::PartialEq => {
let self_ty = Ty::new_adt(
interner,
loc.adt,
GenericArgs::identity_for_item(interner, loc.adt.into()),
);
EarlyBinder::bind(TraitRef::new(interner, trait_id.into(), [self_ty]))
}
BuiltinDeriveImplTrait::PartialOrd | BuiltinDeriveImplTrait::PartialEq => {
let self_ty = Ty::new_adt(
EarlyBinder::bind(TraitRef::new_from_args(
interner,
loc.adt,
GenericArgs::identity_for_item(interner, loc.adt.into()),
);
EarlyBinder::bind(TraitRef::new(interner, trait_id.into(), [self_ty, self_ty]))
trait_id.into(),
trait_args(loc.trait_, self_ty),
))
}
BuiltinDeriveImplTrait::CoerceUnsized | BuiltinDeriveImplTrait::DispatchFromDyn => {
let generic_params = GenericParams::new(db, loc.adt.into());
Expand Down Expand Up @@ -260,7 +276,8 @@ fn simple_trait_predicates<'db>(
let param_idx =
param_idx.into_raw().into_u32() + (generic_params.len_lifetimes() as u32);
let param_ty = Ty::new_param(interner, param_id, param_idx);
let trait_ref = TraitRef::new(interner, trait_id.into(), [param_ty]);
let trait_args = trait_args(loc.trait_, param_ty);
let trait_ref = TraitRef::new_from_args(interner, trait_id.into(), trait_args);
trait_ref.upcast(interner)
});
let mut assoc_type_bounds = Vec::new();
Expand All @@ -270,12 +287,14 @@ fn simple_trait_predicates<'db>(
&mut assoc_type_bounds,
interner.db.field_types(id.into()),
trait_id,
loc.trait_,
),
AdtId::UnionId(id) => extend_assoc_type_bounds(
interner,
&mut assoc_type_bounds,
interner.db.field_types(id.into()),
trait_id,
loc.trait_,
),
AdtId::EnumId(id) => {
for &(variant_id, _, _) in &id.enum_variants(interner.db).variants {
Expand All @@ -284,6 +303,7 @@ fn simple_trait_predicates<'db>(
&mut assoc_type_bounds,
interner.db.field_types(variant_id.into()),
trait_id,
loc.trait_,
)
}
}
Expand All @@ -305,12 +325,14 @@ fn extend_assoc_type_bounds<'db>(
interner: DbInterner<'db>,
assoc_type_bounds: &mut Vec<Clause<'db>>,
fields: &ArenaMap<LocalFieldId, StoredEarlyBinder<StoredTy>>,
trait_: TraitId,
trait_id: TraitId,
trait_: BuiltinDeriveImplTrait,
) {
struct ProjectionFinder<'a, 'db> {
interner: DbInterner<'db>,
assoc_type_bounds: &'a mut Vec<Clause<'db>>,
trait_: TraitId,
trait_id: TraitId,
trait_: BuiltinDeriveImplTrait,
}

impl<'db> TypeVisitor<DbInterner<'db>> for ProjectionFinder<'_, 'db> {
Expand All @@ -319,15 +341,20 @@ fn extend_assoc_type_bounds<'db>(
fn visit_ty(&mut self, t: Ty<'db>) -> Self::Result {
if let TyKind::Alias(AliasTyKind::Projection, _) = t.kind() {
self.assoc_type_bounds.push(
TraitRef::new(self.interner, self.trait_.into(), [t]).upcast(self.interner),
TraitRef::new_from_args(
self.interner,
self.trait_id.into(),
trait_args(self.trait_, t),
)
.upcast(self.interner),
);
}

t.super_visit_with(self)
}
}

let mut visitor = ProjectionFinder { interner, assoc_type_bounds, trait_ };
let mut visitor = ProjectionFinder { interner, assoc_type_bounds, trait_id, trait_ };
for (_, field) in fields.iter() {
field.get().instantiate_identity().visit_with(&mut visitor);
}
Expand Down Expand Up @@ -488,10 +515,12 @@ struct MultiGenericParams<'a, T, #[pointee] U: ?Sized, const N: usize>(*const U)
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
struct Simple;
trait Trait {}
trait Trait {
type Assoc;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
struct WithGenerics<'a, T: Trait, const N: usize>(&'a [T; N]);
struct WithGenerics<'a, T: Trait, const N: usize>(&'a [T; N], T::Assoc);
"#,
expect![[r#"
Expand All @@ -514,41 +543,49 @@ struct WithGenerics<'a, T: Trait, const N: usize>(&'a [T; N]);
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Debug, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Debug, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Clone, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Clone, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Copy, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Copy, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: PartialEq, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: PartialEq<[#1]>, polarity:Positive), bound_vars: [] })
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: [] })
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Eq, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Eq, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: PartialOrd, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: PartialOrd<[#1]>, polarity:Positive), bound_vars: [] })
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: [] })
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Ord, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Ord, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Trait, polarity:Positive), bound_vars: [] })
Clause(Binder { value: ConstArgHasType(#2, usize), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Sized, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(#1: Hash, polarity:Positive), bound_vars: [] })
Clause(Binder { value: TraitPredicate(Alias(Projection, AliasTy { args: [#1], def_id: TypeAliasId("Assoc"), .. }): Hash, polarity:Positive), bound_vars: [] })
"#]],
);
Expand Down
16 changes: 0 additions & 16 deletions src/tools/rust-analyzer/crates/hir-ty/src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,6 @@ impl Generics {
}
}

pub(crate) fn trait_self_param_idx(db: &dyn DefDatabase, def: GenericDefId) -> Option<usize> {
match def {
GenericDefId::TraitId(_) => {
let params = db.generic_params(def);
params.trait_self_param().map(|idx| idx.into_raw().into_u32() as usize)
}
GenericDefId::ImplId(_) => None,
_ => {
let parent_def = parent_generic_def(db, def)?;
let parent_params = db.generic_params(parent_def);
let parent_self_idx = parent_params.trait_self_param()?.into_raw().into_u32() as usize;
Some(parent_self_idx)
}
}
}

pub(crate) fn parent_generic_def(db: &dyn DefDatabase, def: GenericDefId) -> Option<GenericDefId> {
let container = match def {
GenericDefId::FunctionId(it) => it.lookup(db).container,
Expand Down
Loading
Loading