Skip to content

Commit 838595a

Browse files
author
Junseok Lee
committed
suggestions no longer include private fields for structs outside local crate. closes #22421
1 parent 522d09d commit 838595a

File tree

1 file changed

+5
-1
lines changed
  • src/librustc_typeck/check

1 file changed

+5
-1
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ use std::iter::repeat;
117117
use std::slice;
118118
use syntax::{self, abi, attr};
119119
use syntax::attr::AttrMetaMethods;
120-
use syntax::ast::{self, ProvidedMethod, RequiredMethod, TypeTraitItem, DefId};
120+
use syntax::ast::{self, ProvidedMethod, RequiredMethod, TypeTraitItem, DefId, Visibility};
121121
use syntax::ast_util::{self, local_def, PostExpansionMethod};
122122
use syntax::codemap::{self, Span};
123123
use syntax::owned_slice::OwnedSlice;
@@ -3117,6 +3117,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
31173117
if skip.iter().any(|&x| x == n) {
31183118
continue;
31193119
}
3120+
// ignore private fields from non-local crates
3121+
if id.krate != ast::LOCAL_CRATE && elem.vis != Visibility::Public {
3122+
continue;
3123+
}
31203124
let dist = lev_distance(n, name);
31213125
if dist < best_dist {
31223126
best = Some(n);

0 commit comments

Comments
 (0)