Skip to content

feat: Support #[rustc_must_implement_one_of] in the assists - #23042

Merged
Veykril merged 1 commit into
rust-lang:masterfrom
ChayimFriedman2:must-impl-one-of
Aug 8, 2026
Merged

feat: Support #[rustc_must_implement_one_of] in the assists#23042
Veykril merged 1 commit into
rust-lang:masterfrom
ChayimFriedman2:must-impl-one-of

Conversation

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

We still don't support it in the diagnostics for missing items, that's for later PR.

We still don't support it in the diagnostics for missing items, that's for later PR.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 5, 2026
Comment on lines +1225 to +1253
pub fn must_implement_one_of(db: &dyn SourceDatabase, owner: TraitId) -> Option<&[Name]> {
if !AttrFlags::query(db, owner.into()).contains(AttrFlags::HAS_RUSTC_MUST_IMPLEMENT_ONE_OF)
{
return None;
}
return must_implement_one_of(db, owner);

#[salsa::tracked(returns(as_deref))]
pub fn must_implement_one_of(
db: &dyn SourceDatabase,
owner: TraitId,
) -> Option<Box<[Name]>> {
collect_attrs(db, owner.into(), |attr| {
if let ast::Meta::TokenTreeMeta(attr) = attr
&& attr.path().is1("rustc_must_implement_one_of")
&& let Some(tt) = attr.token_tree()
&& let names = tt
.token_trees_and_tokens()
.filter_map(|it| ast::Ident::cast(it.into_token()?))
.map(|name| Name::new_symbol_root(Symbol::intern(name.text())))
.collect::<Box<[_]>>()
&& !names.is_empty()
{
return ControlFlow::Break(names);
}
ControlFlow::Continue(())
})
}
}

@Veykril Veykril Aug 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been wondering, feels like salsa would benefit from a first class feature for this

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, although it's not clear what shape it'll take - what you query to check if we should not populate the query?

@Veykril
Veykril added this pull request to the merge queue Aug 8, 2026
Merged via the queue into rust-lang:master with commit ec186b5 Aug 8, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 8, 2026
@ChayimFriedman2
ChayimFriedman2 deleted the must-impl-one-of branch August 8, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants