]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/exhaustive_items.rs
Auto merge of #9148 - arieluy:then_some_unwrap_or, r=Jarcho
[rust.git] / clippy_lints / src / exhaustive_items.rs
index b0f50b5c144bbe45a6487cee425aa3501258169f..173d41b4b05060b7794a9cbac5432ace09c817c0 100644 (file)
@@ -78,7 +78,10 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
             if !attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
             then {
                 let (lint, msg) = if let ItemKind::Struct(ref v, ..) = item.kind {
-                    if v.fields().iter().any(|f| !f.vis.node.is_pub()) {
+                    if v.fields().iter().any(|f| {
+                        let def_id = cx.tcx.hir().local_def_id(f.hir_id);
+                        !cx.tcx.visibility(def_id).is_public()
+                    }) {
                         // skip structs with private fields
                         return;
                     }