|
5 | 5 | #![recursion_limit = "256"] |
6 | 6 | #![allow(rustc::potential_query_instability)] |
7 | 7 |
|
| 8 | +mod errors; |
| 9 | + |
8 | 10 | use rustc_ast::MacroDef; |
9 | 11 | use rustc_attr as attr; |
10 | 12 | use rustc_data_structures::fx::FxHashSet; |
@@ -34,6 +36,8 @@ use std::marker::PhantomData; |
34 | 36 | use std::ops::ControlFlow; |
35 | 37 | use std::{cmp, fmt, mem}; |
36 | 38 |
|
| 39 | +use errors::{FieldIsPrivate, FieldIsPrivateLabel}; |
| 40 | + |
37 | 41 | //////////////////////////////////////////////////////////////////////////////// |
38 | 42 | /// Generic infrastructure used to implement specific visitors below. |
39 | 43 | //////////////////////////////////////////////////////////////////////////////// |
@@ -935,23 +939,17 @@ impl<'tcx> NamePrivacyVisitor<'tcx> { |
935 | 939 | let hir_id = self.tcx.hir().local_def_id_to_hir_id(self.current_item); |
936 | 940 | let def_id = self.tcx.adjust_ident_and_get_scope(ident, def.did(), hir_id).1; |
937 | 941 | if !field.vis.is_accessible_from(def_id, self.tcx) { |
938 | | - let label = if in_update_syntax { |
939 | | - format!("field `{}` is private", field.name) |
940 | | - } else { |
941 | | - "private field".to_string() |
942 | | - }; |
943 | | - |
944 | | - struct_span_err!( |
945 | | - self.tcx.sess, |
| 942 | + self.tcx.sess.emit_err(FieldIsPrivate { |
946 | 943 | span, |
947 | | - E0451, |
948 | | - "field `{}` of {} `{}` is private", |
949 | | - field.name, |
950 | | - def.variant_descr(), |
951 | | - self.tcx.def_path_str(def.did()) |
952 | | - ) |
953 | | - .span_label(span, label) |
954 | | - .emit(); |
| 944 | + field_name: field.name, |
| 945 | + variant_descr: def.variant_descr(), |
| 946 | + def_path_str: self.tcx.def_path_str(def.did()), |
| 947 | + label: if in_update_syntax { |
| 948 | + FieldIsPrivateLabel::IsUpdateSyntax { span, field_name: field.name } |
| 949 | + } else { |
| 950 | + FieldIsPrivateLabel::Other { span } |
| 951 | + }, |
| 952 | + }); |
955 | 953 | } |
956 | 954 | } |
957 | 955 | } |
|
0 commit comments