@@ -26,6 +26,7 @@ use rustc_ast::{MetaItemKind, NestedMetaItem};
26
26
use rustc_attr:: { list_contains_name, InlineAttr , InstructionSetAttr , OptimizeAttr } ;
27
27
use rustc_data_structures:: captures:: Captures ;
28
28
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexSet } ;
29
+ use rustc_data_structures:: sync:: Lrc ;
29
30
use rustc_errors:: { struct_span_err, Applicability } ;
30
31
use rustc_hir as hir;
31
32
use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
@@ -1118,7 +1119,8 @@ fn super_predicates_that_define_assoc_type(
1118
1119
/// Computes the def-ids of the transitive super-traits of `trait_def_id`. This (intentionally)
1119
1120
/// does not compute the full elaborated super-predicates but just the set of def-ids. It is used
1120
1121
/// 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 > > {
1122
1124
let mut set = FxHashSet :: default ( ) ;
1123
1125
let mut stack = vec ! [ trait_def_id] ;
1124
1126
while let Some ( trait_did) = stack. pop ( ) {
@@ -1178,7 +1180,7 @@ fn super_traits_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> FxHashSet<DefId> {
1178
1180
}
1179
1181
}
1180
1182
1181
- set
1183
+ Lrc :: new ( set)
1182
1184
}
1183
1185
1184
1186
fn trait_def ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> ty:: TraitDef {
0 commit comments