This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -3125,6 +3125,31 @@ impl<'a> Resolver<'a> {
3125
3125
} )
3126
3126
}
3127
3127
3128
+ pub fn traits_in_scope ( & mut self , module_id : DefId ) -> Vec < TraitCandidate > {
3129
+ let module = self . get_module ( module_id) ;
3130
+ module. ensure_traits ( self ) ;
3131
+ let traits = module. traits . borrow ( ) ;
3132
+ let to_candidate =
3133
+ |this : & mut Self , & ( trait_name, binding) : & ( Ident , & NameBinding < ' _ > ) | TraitCandidate {
3134
+ def_id : binding. res ( ) . def_id ( ) ,
3135
+ import_ids : this. find_transitive_imports ( & binding. kind , trait_name) ,
3136
+ } ;
3137
+
3138
+ let mut candidates: Vec < _ > =
3139
+ traits. as_ref ( ) . unwrap ( ) . iter ( ) . map ( |x| to_candidate ( self , x) ) . collect ( ) ;
3140
+
3141
+ if let Some ( prelude) = self . prelude {
3142
+ if !module. no_implicit_prelude {
3143
+ prelude. ensure_traits ( self ) ;
3144
+ candidates. extend (
3145
+ prelude. traits . borrow ( ) . as_ref ( ) . unwrap ( ) . iter ( ) . map ( |x| to_candidate ( self , x) ) ,
3146
+ ) ;
3147
+ }
3148
+ }
3149
+
3150
+ candidates
3151
+ }
3152
+
3128
3153
/// Rustdoc uses this to resolve things in a recoverable way. `ResolutionError<'a>`
3129
3154
/// isn't something that can be returned because it can't be made to live that long,
3130
3155
/// and also it's a private type. Fortunately rustdoc doesn't need to know the error,
You can’t perform that action at this time.
0 commit comments