fn check_field(
        &mut self,
        use_ctxt: Span,        // syntax context of the field name at the use site
        span: Span,            // span of the field pattern, e.g., `x: 0`
        def: &'tcx ty::AdtDef, // definition of the struct or enum
        field: &'tcx ty::FieldDef,
        in_update_syntax: bool,
    ) {
        // definition of the field
        let ident = Ident::new(kw::Empty, use_ctxt);
        let current_hir = self.current_item.unwrap();
        let def_id = self.tcx.adjust_ident_and_get_scope(ident, def.did, current_hir).1;
        if !def.is_enum() && !field.vis.is_accessible_from(def_id, self.tcx) {
            let label = if in_update_syntax {
                format!("field `{}` is private", field.ident)
            } else {
                "private field".to_string()
            };

            struct_span_err!(
                self.tcx.sess,
                span,
                E0451,
                "field `{}` of {} `{}` is private",
                field.ident,
                def.variant_descr(),
                self.tcx.def_path_str(def.did)
            )
            .span_label(span, label)
            .emit();
        }
    }
// Checks that a field in a struct constructor (expression or pattern) is accessible.
Checks that a field in a struct constructor (expression or pattern) is accessible.
Checks that a field in a struct constructor ( expression or pattern ) is accessible .
fn check_field(
        &mut self,
        use_ctxt: Span,        // syntax context of the field name at the use site
        span: Span,            // span of the field pattern, e.g., `x: 0`
        def: &'tcx ty::AdtDef, // definition of the struct or enum
        field: &'tcx ty::FieldDef,
        in_update_syntax: bool,
    ) {
        // definition of the field
        let ident = Ident::new(kw::Empty, use_ctxt);
        let current_hir = self.current_item.unwrap();
        let def_id = self.tcx.adjust_ident_and_get_scope(ident, def.did, current_hir).1;
        if !def.is_enum() && !field.vis.is_accessible_from(def_id, self.tcx) {
            let label = if in_update_syntax {
                format!("field `{}` is private", field.ident)
            } else {
                "private field".to_string()
            };
            struct_span_err!(
                self.tcx.sess,
                span,
                E0451,
                "field `{}` of {} `{}` is private",
                field.ident,
                def.variant_descr(),
                self.tcx.def_path_str(def.did)
            )
            .span_label(span, label)
            .emit();
        }
    }
fn check_field ( & mut self , use_ctxt : Span , // syntax context of the field name at the use site span : Span , // span of the field pattern, e.g., `x: 0` def : & ' tcx ty :: AdtDef , // definition of the struct or enum field : & ' tcx ty :: FieldDef , in_update_syntax : bool , ) { // definition of the field let ident = Ident :: new ( kw :: Empty , use_ctxt ) ; let current_hir = self . current_item . unwrap ( ) ; let def_id = self . tcx . adjust_ident_and_get_scope ( ident , def . did , current_hir ) . 1 ; if ! def . is_enum ( ) && ! field . vis . is_accessible_from ( def_id , self . tcx ) { let label = if in_update_syntax { format ! ( " " field ident ) } else { " " . to_string ( ) } ; struct_span_err ! ( self tcx sess span E0451 " " field ident def variant_descr ( ) self tcx def_path_str ( def did ) ) . span_label ( span , label ) . emit ( ) ; } }
Checks that a field in a struct constructor (expression or pattern) is accessible.
Checks that a field in a struct constructor ( expression or pattern ) is accessible .
&mut self
use_ctxt
Span
span
Span
def
&'tcx ty::AdtDef
field
&'tcx ty::FieldDef
in_update_syntax
bool
&mut self
use_ctxt
Span
span
Span
def
&'tcx ty::AdtDef
field
&'tcx ty::FieldDef
in_update_syntax
bool