feat: Support #[rustc_must_implement_one_of] in the assists - #23042
Merged
Conversation
We still don't support it in the diagnostics for missing items, that's for later PR.
Veykril
reviewed
Aug 8, 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(()) | ||
| }) | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
I've been wondering, feels like salsa would benefit from a first class feature for this
Contributor
Author
There was a problem hiding this comment.
Maybe, although it's not clear what shape it'll take - what you query to check if we should not populate the query?
Veykril
approved these changes
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We still don't support it in the diagnostics for missing items, that's for later PR.