@@ -62,14 +62,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
62
62
// It might seem that we can use `predicate_must_hold_modulo_regions`,
63
63
// but since a Dummy binder is used to fill in the FnOnce trait's arguments,
64
64
// type resolution always gives a "maybe" here.
65
- if self . autoderef ( span, ty) . any ( |( ty, _) | {
65
+ if self . autoderef ( span, ty) . silence_errors ( ) . any ( |( ty, _) | {
66
66
info ! ( "check deref {:?} error" , ty) ;
67
67
matches ! ( ty. kind( ) , ty:: Error ( _) | ty:: Infer ( _) )
68
68
} ) {
69
69
return false ;
70
70
}
71
71
72
- self . autoderef ( span, ty) . any ( |( ty, _) | {
72
+ self . autoderef ( span, ty) . silence_errors ( ) . any ( |( ty, _) | {
73
73
info ! ( "check deref {:?} impl FnOnce" , ty) ;
74
74
self . probe ( |_| {
75
75
let trait_ref =
@@ -90,7 +90,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
90
90
}
91
91
92
92
fn is_slice_ty ( & self , ty : Ty < ' tcx > , span : Span ) -> bool {
93
- self . autoderef ( span, ty) . any ( |( ty, _) | matches ! ( ty. kind( ) , ty:: Slice ( ..) | ty:: Array ( ..) ) )
93
+ self . autoderef ( span, ty)
94
+ . silence_errors ( )
95
+ . any ( |( ty, _) | matches ! ( ty. kind( ) , ty:: Slice ( ..) | ty:: Array ( ..) ) )
94
96
}
95
97
96
98
fn impl_into_iterator_should_be_iterator (
@@ -672,7 +674,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
672
674
let mut ty_str_reported = ty_str. clone ( ) ;
673
675
if let ty:: Adt ( _, generics) = rcvr_ty. kind ( ) {
674
676
if generics. len ( ) > 0 {
675
- let mut autoderef = self . autoderef ( span, rcvr_ty) ;
677
+ let mut autoderef = self . autoderef ( span, rcvr_ty) . silence_errors ( ) ;
676
678
let candidate_found = autoderef. any ( |( ty, _) | {
677
679
if let ty:: Adt ( adt_def, _) = ty. kind ( ) {
678
680
self . tcx
@@ -2237,6 +2239,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2237
2239
let impl_ty = self . tcx . type_of ( * impl_did) . instantiate_identity ( ) ;
2238
2240
let target_ty = self
2239
2241
. autoderef ( sugg_span, rcvr_ty)
2242
+ . silence_errors ( )
2240
2243
. find ( |( rcvr_ty, _) | {
2241
2244
DeepRejectCtxt :: relate_rigid_infer ( self . tcx ) . types_may_unify ( * rcvr_ty, impl_ty)
2242
2245
} )
@@ -2352,17 +2355,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2352
2355
err : & mut Diag < ' _ > ,
2353
2356
) -> bool {
2354
2357
let tcx = self . tcx ;
2355
- let field_receiver = self . autoderef ( span, rcvr_ty) . find_map ( |( ty, _) | match ty. kind ( ) {
2356
- ty:: Adt ( def, args) if !def. is_enum ( ) => {
2357
- let variant = & def. non_enum_variant ( ) ;
2358
- tcx. find_field_index ( item_name, variant) . map ( |index| {
2359
- let field = & variant. fields [ index] ;
2360
- let field_ty = field. ty ( tcx, args) ;
2361
- ( field, field_ty)
2362
- } )
2363
- }
2364
- _ => None ,
2365
- } ) ;
2358
+ let field_receiver =
2359
+ self . autoderef ( span, rcvr_ty) . silence_errors ( ) . find_map ( |( ty, _) | match ty. kind ( ) {
2360
+ ty:: Adt ( def, args) if !def. is_enum ( ) => {
2361
+ let variant = & def. non_enum_variant ( ) ;
2362
+ tcx. find_field_index ( item_name, variant) . map ( |index| {
2363
+ let field = & variant. fields [ index] ;
2364
+ let field_ty = field. ty ( tcx, args) ;
2365
+ ( field, field_ty)
2366
+ } )
2367
+ }
2368
+ _ => None ,
2369
+ } ) ;
2366
2370
if let Some ( ( field, field_ty) ) = field_receiver {
2367
2371
let scope = tcx. parent_module_from_def_id ( self . body_id ) ;
2368
2372
let is_accessible = field. vis . is_accessible_from ( scope, tcx) ;
@@ -2675,9 +2679,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2675
2679
) {
2676
2680
if let SelfSource :: MethodCall ( expr) = source {
2677
2681
let mod_id = self . tcx . parent_module ( expr. hir_id ) . to_def_id ( ) ;
2678
- for ( fields, args) in
2679
- self . get_field_candidates_considering_privacy ( span, actual, mod_id, expr. hir_id )
2680
- {
2682
+ for ( fields, args) in self . get_field_candidates_considering_privacy_for_diag (
2683
+ span,
2684
+ actual,
2685
+ mod_id,
2686
+ expr. hir_id ,
2687
+ ) {
2681
2688
let call_expr = self . tcx . hir ( ) . expect_expr ( self . tcx . parent_hir_id ( expr. hir_id ) ) ;
2682
2689
2683
2690
let lang_items = self . tcx . lang_items ( ) ;
@@ -2693,7 +2700,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2693
2700
let mut candidate_fields: Vec < _ > = fields
2694
2701
. into_iter ( )
2695
2702
. filter_map ( |candidate_field| {
2696
- self . check_for_nested_field_satisfying (
2703
+ self . check_for_nested_field_satisfying_condition_for_diag (
2697
2704
span,
2698
2705
& |_, field_ty| {
2699
2706
self . lookup_probe_for_diagnostic (
@@ -3195,7 +3202,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3195
3202
let SelfSource :: QPath ( ty) = self_source else {
3196
3203
return ;
3197
3204
} ;
3198
- for ( deref_ty, _) in self . autoderef ( DUMMY_SP , rcvr_ty) . skip ( 1 ) {
3205
+ for ( deref_ty, _) in self . autoderef ( DUMMY_SP , rcvr_ty) . silence_errors ( ) . skip ( 1 ) {
3199
3206
if let Ok ( pick) = self . probe_for_name (
3200
3207
Mode :: Path ,
3201
3208
item_name,
@@ -4221,7 +4228,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4221
4228
return is_local ( rcvr_ty) ;
4222
4229
}
4223
4230
4224
- self . autoderef ( span, rcvr_ty) . any ( |( ty, _) | is_local ( ty) )
4231
+ self . autoderef ( span, rcvr_ty) . silence_errors ( ) . any ( |( ty, _) | is_local ( ty) )
4225
4232
}
4226
4233
}
4227
4234
0 commit comments