@@ -26,6 +26,7 @@ use rustc_ast::{MetaItemKind, NestedMetaItem};
2626use rustc_attr:: { list_contains_name, InlineAttr , InstructionSetAttr , OptimizeAttr } ;
2727use rustc_data_structures:: captures:: Captures ;
2828use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexSet } ;
29+ use rustc_data_structures:: sync:: Lrc ;
2930use rustc_errors:: { struct_span_err, Applicability } ;
3031use rustc_hir as hir;
3132use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
@@ -1118,7 +1119,8 @@ fn super_predicates_that_define_assoc_type(
11181119/// Computes the def-ids of the transitive super-traits of `trait_def_id`. This (intentionally)
11191120/// does not compute the full elaborated super-predicates but just the set of def-ids. It is used
11201121/// to identify which traits may define a given associated type to help avoid cycle errors.
1121- fn super_traits_of ( tcx : TyCtxt < ' _ > , trait_def_id : DefId ) -> FxHashSet < DefId > {
1122+ /// Returns `Lrc<FxHashSet<DefId>>` so that cloning is cheaper.
1123+ fn super_traits_of ( tcx : TyCtxt < ' _ > , trait_def_id : DefId ) -> Lrc < FxHashSet < DefId > > {
11221124 let mut set = FxHashSet :: default ( ) ;
11231125 let mut stack = vec ! [ trait_def_id] ;
11241126 while let Some ( trait_did) = stack. pop ( ) {
@@ -1178,7 +1180,7 @@ fn super_traits_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> FxHashSet<DefId> {
11781180 }
11791181 }
11801182
1181- set
1183+ Lrc :: new ( set)
11821184}
11831185
11841186fn trait_def ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> ty:: TraitDef {
0 commit comments