privacy: port "item is private" diag

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood
2022-06-22 13:31:24 +01:00
parent be9ebfdbce
commit cb90a4f30c
3 changed files with 19 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ use std::marker::PhantomData;
use std::ops::ControlFlow;
use std::{cmp, fmt, mem};
use errors::{FieldIsPrivate, FieldIsPrivateLabel};
use errors::{FieldIsPrivate, FieldIsPrivateLabel, ItemIsPrivate};
////////////////////////////////////////////////////////////////////////////////
/// Generic infrastructure used to implement specific visitors below.
@@ -1073,11 +1073,11 @@ impl<'tcx> TypePrivacyVisitor<'tcx> {
fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool {
let is_error = !self.item_is_accessible(def_id);
if is_error {
self.tcx
.sess
.struct_span_err(self.span, &format!("{} `{}` is private", kind, descr))
.span_label(self.span, &format!("private {}", kind))
.emit();
self.tcx.sess.emit_err(ItemIsPrivate {
span: self.span,
kind,
descr: descr.to_string(),
});
}
is_error
}