@@ -3078,17 +3078,25 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
3078
3078
binding = self . r . resolution ( module, key) . try_borrow ( ) . ok ( ) . and_then ( |r| r. binding ) ;
3079
3079
debug ! ( ?binding) ;
3080
3080
}
3081
+
3082
+ let feed_visibility = |this : & mut Self , def_id| {
3083
+ let vis = this. r . tcx . visibility ( def_id) . expect_local ( ) ;
3084
+ this. r . feed_visibility ( this. r . local_def_id ( id) , vis) ;
3085
+ } ;
3086
+
3081
3087
let Some ( binding) = binding else {
3082
3088
// We could not find the method: report an error.
3083
3089
let candidate = self . find_similarly_named_assoc_item ( ident. name , kind) ;
3084
3090
let path = & self . current_trait_ref . as_ref ( ) . unwrap ( ) . 1 . path ;
3085
3091
let path_names = path_names_to_string ( path) ;
3086
3092
self . report_error ( span, err ( ident, path_names, candidate) ) ;
3093
+ feed_visibility ( self , module. def_id ( ) ) ;
3087
3094
return ;
3088
3095
} ;
3089
3096
3090
3097
let res = binding. res ( ) ;
3091
3098
let Res :: Def ( def_kind, id_in_trait) = res else { bug ! ( ) } ;
3099
+ feed_visibility ( self , id_in_trait) ;
3092
3100
3093
3101
match seen_trait_items. entry ( id_in_trait) {
3094
3102
Entry :: Occupied ( entry) => {
@@ -3112,8 +3120,6 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
3112
3120
| ( DefKind :: AssocFn , AssocItemKind :: Fn ( ..) )
3113
3121
| ( DefKind :: AssocConst , AssocItemKind :: Const ( ..) ) => {
3114
3122
self . r . record_partial_res ( id, PartialRes :: new ( res) ) ;
3115
- let vis = self . r . tcx . visibility ( id_in_trait) . expect_local ( ) ;
3116
- self . r . feed_visibility ( self . r . local_def_id ( id) , vis) ;
3117
3123
return ;
3118
3124
}
3119
3125
_ => { }
0 commit comments