.by_key("rustc_skip_array_during_method_dispatch")
.exists();
- let mut collector =
- AssocItemCollector::new(db, module_id, tree_id.file_id(), ItemContainerId::TraitId(tr));
- collector.collect(&item_tree, tree_id.tree_id(), &tr_def.items);
- let (items, attribute_calls, diagnostics) = collector.finish();
-
+ let (items, attribute_calls, diagnostics) = match &tr_def.items {
+ Some(items) => {
+ let mut collector = AssocItemCollector::new(
+ db,
+ module_id,
+ tree_id.file_id(),
+ ItemContainerId::TraitId(tr),
+ );
+ collector.collect(&item_tree, tree_id.tree_id(), items);
+ collector.finish()
+ }
+ None => Default::default(),
+ };
(
Arc::new(TraitData {
name,
pub generic_params: Interned<GenericParams>,
pub is_auto: bool,
pub is_unsafe: bool,
- pub items: Box<[AssocItem]>,
+ /// This is [`None`] if this Trait is a trait alias.
+ pub items: Option<Box<[AssocItem]>>,
pub ast_id: FileAstId<ast::Trait>,
}
.collect()
});
let ast_id = self.source_ast_id_map.ast_id(trait_def);
- let res = Trait {
- name,
- visibility,
- generic_params,
- is_auto,
- is_unsafe,
- items: items.unwrap_or_default(),
- ast_id,
- };
+ let res = Trait { name, visibility, generic_params, is_auto, is_unsafe, items, ast_id };
Some(id(self.data().traits.alloc(res)))
}
}
w!(self, "trait {}", name);
self.print_generic_params(generic_params);
- self.print_where_clause_and_opening_brace(generic_params);
- self.indented(|this| {
- for item in &**items {
- this.print_mod_item((*item).into());
+ match items {
+ Some(items) => {
+ self.print_where_clause_and_opening_brace(generic_params);
+ self.indented(|this| {
+ for item in &**items {
+ this.print_mod_item((*item).into());
+ }
+ });
}
- });
+ None => {
+ w!(self, " = ");
+ // FIXME: Print the aliased traits
+ self.print_where_clause_and_opening_brace(generic_params);
+ }
+ }
wln!(self, "}}");
}
ModItem::Impl(it) => {
Trait =
Attr* Visibility?
'unsafe'? 'auto'?
- 'trait' Name GenericParamList? (':' TypeBoundList?)? WhereClause?
- AssocItemList
+ 'trait' Name GenericParamList?
+ (
+ (':' TypeBoundList?)? WhereClause? AssocItemList
+ | '=' TypeBoundList? WhereClause? ';'
+ )
AssocItemList =
'{' Attr* AssocItem* '}'
pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
+ pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
+ pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]