]> git.lizzy.rs Git - rust.git/commitdiff
suggestions no longer include private fields for structs outside local crate. closes...
authorJunseok Lee <lee.junseok@berkeley.edu>
Thu, 19 Feb 2015 00:23:13 +0000 (16:23 -0800)
committerJunseok Lee <lee.junseok@berkeley.edu>
Sat, 21 Feb 2015 00:16:09 +0000 (16:16 -0800)
src/librustc_typeck/check/mod.rs

index e443b4d0e606abd082e45a8fdd9f8b4e8efec526..9af5b85993c1c7df91e891c9f80a2ccacf24bd00 100644 (file)
 use std::slice;
 use syntax::{self, abi, attr};
 use syntax::attr::AttrMetaMethods;
-use syntax::ast::{self, ProvidedMethod, RequiredMethod, TypeTraitItem, DefId};
+use syntax::ast::{self, ProvidedMethod, RequiredMethod, TypeTraitItem, DefId, Visibility};
 use syntax::ast_util::{self, local_def, PostExpansionMethod};
 use syntax::codemap::{self, Span};
 use syntax::owned_slice::OwnedSlice;
@@ -3117,6 +3117,10 @@ fn suggest_field_names<'tcx>(id : DefId,
             if skip.iter().any(|&x| x == n) {
                 continue;
             }
+            // ignore private fields from non-local crates
+            if id.krate != ast::LOCAL_CRATE && elem.vis != Visibility::Public {
+                continue;
+            }
             let dist = lev_distance(n, name);
             if dist < best_dist {
                 best = Some(n);