From 7ce29fae59599a3d198851f7e348e26a7dce466b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 4 Feb 2019 15:53:41 -0800 Subject: [PATCH] Change privacy checks, particularly for tuple structs Move tuple struct privacy checks away from `resolve` in order to evaluate more explicitely point at private tuple struct fields when they are the cause of the tuple struct being inaccessible. For structs that are inaccessible, point at the definition span. Reword privacy messages to be more specific about the ADT kind name. Group private field errors per struct. --- src/librustc/ty/mod.rs | 15 +- src/librustc_privacy/lib.rs | 204 ++++- src/librustc_resolve/lib.rs | 20 +- src/librustc_resolve/resolve_imports.rs | 6 +- src/test/ui/error-codes/E0451.stderr | 26 +- ...onal-struct-update-respects-privacy.stderr | 8 +- src/test/ui/hygiene/fields.rs | 12 +- src/test/ui/hygiene/fields.stderr | 30 +- src/test/ui/hygiene/impl_items.rs | 3 +- src/test/ui/hygiene/impl_items.stderr | 6 +- src/test/ui/hygiene/intercrate.rs | 2 +- src/test/ui/hygiene/intercrate.stderr | 4 +- .../associated-item-privacy-inherent.rs | 40 +- .../associated-item-privacy-inherent.stderr | 82 +- .../privacy/associated-item-privacy-trait.rs | 58 +- .../associated-item-privacy-trait.stderr | 128 +-- .../associated-item-privacy-type-binding.rs | 16 +- ...ssociated-item-privacy-type-binding.stderr | 48 +- .../ui/privacy/multiple-private-fields.rs | 17 + .../ui/privacy/multiple-private-fields.stderr | 34 + src/test/ui/privacy/privacy5.rs | 150 ++-- src/test/ui/privacy/privacy5.stderr | 828 ++++++++++++------ .../private-in-public-non-principal-2.stderr | 2 +- .../ui/privacy/private-inferred-type-1.rs | 4 +- .../ui/privacy/private-inferred-type-1.stderr | 12 +- .../ui/privacy/private-inferred-type-2.rs | 6 +- .../ui/privacy/private-inferred-type-2.stderr | 18 +- .../ui/privacy/private-inferred-type-3.rs | 12 +- .../ui/privacy/private-inferred-type-3.stderr | 26 +- .../ui/privacy/private-inferred-type-4.rs | 17 + .../ui/privacy/private-inferred-type-4.stderr | 11 + src/test/ui/privacy/private-inferred-type.rs | 63 +- .../ui/privacy/private-inferred-type.stderr | 239 +++-- .../privacy/private-struct-field-ctor.stderr | 12 +- .../private-struct-field-pattern.stderr | 12 +- .../ui/privacy/private-type-in-interface.rs | 25 +- .../privacy/private-type-in-interface.stderr | 68 +- .../restricted/struct-literal-field.stderr | 12 +- .../ui/privacy/union-field-privacy-1.stderr | 28 +- src/test/ui/resolve/privacy-struct-ctor-2.rs | 38 + .../ui/resolve/privacy-struct-ctor-2.stderr | 44 + src/test/ui/resolve/privacy-struct-ctor.rs | 12 - .../ui/resolve/privacy-struct-ctor.stderr | 49 +- .../ui/rfc-2008-non-exhaustive/structs-2.rs | 9 + .../rfc-2008-non-exhaustive/structs-2.stderr | 8 + .../ui/rfc-2008-non-exhaustive/structs.rs | 3 - .../ui/rfc-2008-non-exhaustive/structs.stderr | 16 +- 47 files changed, 1598 insertions(+), 885 deletions(-) create mode 100644 src/test/ui/privacy/multiple-private-fields.rs create mode 100644 src/test/ui/privacy/multiple-private-fields.stderr create mode 100644 src/test/ui/privacy/private-inferred-type-4.rs create mode 100644 src/test/ui/privacy/private-inferred-type-4.stderr create mode 100644 src/test/ui/resolve/privacy-struct-ctor-2.rs create mode 100644 src/test/ui/resolve/privacy-struct-ctor-2.stderr create mode 100644 src/test/ui/rfc-2008-non-exhaustive/structs-2.rs create mode 100644 src/test/ui/rfc-2008-non-exhaustive/structs-2.stderr diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index c9089428b2324..669cd79e3aa8f 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2242,13 +2242,20 @@ impl<'a, 'gcx, 'tcx> AdtDef { .0 } - pub fn variant_of_def(&self, def: Def) -> &VariantDef { + pub fn opt_variant_of_def(&self, def: Def) -> Option<&VariantDef> { match def { - Def::Variant(vid) | Def::VariantCtor(vid, ..) => self.variant_with_id(vid), + Def::Variant(vid) | Def::VariantCtor(vid, ..) => Some(self.variant_with_id(vid)), Def::Struct(..) | Def::StructCtor(..) | Def::Union(..) | Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) | - Def::SelfCtor(..) => self.non_enum_variant(), - _ => bug!("unexpected def {:?} in variant_of_def", def) + Def::SelfCtor(..) => Some(self.non_enum_variant()), + _ => None, + } + } + + pub fn variant_of_def(&self, def: Def) -> &VariantDef { + match self.opt_variant_of_def(def) { + Some(vd) => vd, + None => bug!("unexpected def {:?} in variant_of_def", def), } } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 05d20562d34e7..c048a7d700404 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -222,8 +222,10 @@ impl<'a, 'tcx, V> TypeVisitor<'tcx> for DefIdVisitorSkeleton<'_, 'a, 'tcx, V> } } -fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> (ty::Visibility, Span, &'static str) { +fn def_id_visibility<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, +) -> (ty::Visibility, Span, &'static str) { match tcx.hir().as_local_node_id(def_id) { Some(node_id) => { let vis = match tcx.hir().get(node_id) { @@ -799,22 +801,71 @@ struct NamePrivacyVisitor<'a, 'tcx: 'a> { tables: &'a ty::TypeckTables<'tcx>, current_item: ast::NodeId, empty_tables: &'a ty::TypeckTables<'tcx>, + reported_tuple_structs: FxHashSet, } impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> { // 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) { // definition of the field + 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, // definition of the field + ) -> Option<(String /* field name */, Span)> { let ident = Ident::new(keywords::Invalid.name(), use_ctxt); let def_id = self.tcx.adjust_ident(ident, def.did, self.current_item).1; if !def.is_enum() && !field.vis.is_accessible_from(def_id, self.tcx) { - struct_span_err!(self.tcx.sess, span, E0451, "field `{}` of {} `{}` is private", - field.ident, def.variant_descr(), self.tcx.item_path_str(def.did)) - .span_label(span, format!("field `{}` is private", field.ident)) - .emit(); + return Some((field.ident.to_string(), span)); + } + None + } + + /// If appropriate, construct a privacy error pointing at all the fields of a literal struct + /// that are private both when constructing an instance or destructuring a pattern. + fn emit_field_checks( + &mut self, + // d: Def, + def: &'tcx ty::AdtDef, // definition of the struct or enum + span: Span, // struct span at use site + fields: Vec<(String, Span)>, // inaccessible ADT fields + action: &str, // "built" or "destructured" depending of where this happened + ) { + let item_path = self.tcx.item_path_str(def.did); + + if !fields.is_empty() { + self.reported_tuple_structs.insert(span); + let mut err = struct_span_err!( + self.tcx.sess, + fields.iter().map(|(_, sp)| *sp).collect::>(), + E0451, + "field{} of {} `{}` {} private", + if fields.len() == 1 { + format!(" `{}`", fields[0].0) + } else { + "s".to_owned() + }, + def.variant_descr(), + item_path, + if fields.len() == 1 { + "is" + } else { + "are" + }, + ); + err.span_label(span, format!( + "`{}` cannot be {} due to private field{}", + item_path, + action, + if fields.len() == 1 { "" } else { "s" }, + )); + for (_field_name, field) in fields { + err.span_label(field, "private field"); + } + + // Point at definition + err.span_label(self.tcx.def_span(def.did), format!("`{}` defined here", item_path)); + err.emit(); } } } @@ -867,6 +918,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { let def = self.tables.qpath_def(qpath, expr.hir_id); let adt = self.tables.expr_ty(expr).ty_adt_def().unwrap(); let variant = adt.variant_of_def(def); + let mut field_errors = vec![]; if let Some(ref base) = *base { // If the expression uses FRU we need to make sure all the unmentioned fields // are checked for privacy (RFC 736). Rather than computing the set of @@ -879,13 +931,48 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { Some(field) => (field.ident.span, field.span), None => (base.span, base.span), }; - self.check_field(use_ctxt, span, adt, variant_field); + if let Some(err) = self.check_field(use_ctxt, span, adt, variant_field) { + field_errors.push(err); + } } } else { for field in fields { let use_ctxt = field.ident.span; let index = self.tcx.field_index(field.id, self.tables); - self.check_field(use_ctxt, field.span, adt, &variant.fields[index]); + if let Some(err) = self.check_field( + use_ctxt, + field.span, + adt, + &variant.fields[index], + ) { + field_errors.push(err); + } + } + } + self.emit_field_checks(adt, expr.span, field_errors, "built"); + } + hir::ExprKind::Call(ref path, ref fields) => { + if let hir::ExprKind::Path(qpath) = &path.node { + let def = self.tables.qpath_def(qpath, path.hir_id); + if let Some(_) = def.opt_def_id() { + if let Some(adt) = self.tables.expr_ty(expr).ty_adt_def() { + if let Some(variant) = adt.opt_variant_of_def(def) { + let mut field_errors = vec![]; + for (idx, field) in variant.fields.iter().enumerate() { + let use_ctxt = fields.get(idx).map(|f| f.span) + .unwrap_or(path.span); + if let Some(err) = self.check_field( + use_ctxt, + use_ctxt, + adt, + &field, + ) { + field_errors.push(err); + } + } + self.emit_field_checks(adt, path.span, field_errors, "built"); + } + } } } } @@ -901,11 +988,39 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { let def = self.tables.qpath_def(qpath, pat.hir_id); let adt = self.tables.pat_ty(pat).ty_adt_def().unwrap(); let variant = adt.variant_of_def(def); + let mut field_errors = vec![]; for field in fields { let use_ctxt = field.node.ident.span; let index = self.tcx.field_index(field.node.id, self.tables); - self.check_field(use_ctxt, field.span, adt, &variant.fields[index]); + if let Some(err) = self.check_field( + use_ctxt, + field.span, + adt, + &variant.fields[index], + ) { + field_errors.push(err); + } + } + self.emit_field_checks(adt, pat.span, field_errors, "destructured"); + } + PatKind::TupleStruct(ref qpath, ref patterns, ..) => { + let def = self.tables.qpath_def(qpath, pat.hir_id); + let adt = self.tables.pat_ty(pat).ty_adt_def().unwrap(); + let variant = adt.variant_of_def(def); + let mut field_errors = vec![]; + for (vf_index, variant_field) in variant.fields.iter().enumerate() { + if let Some(pat) = patterns.get(vf_index) { + if let Some(err) = self.check_field( + pat.span, + pat.span, + adt, + variant_field, + ) { + field_errors.push(err); + } + } } + self.emit_field_checks(adt, pat.span, field_errors, "destructured"); } _ => {} } @@ -927,11 +1042,13 @@ struct TypePrivacyVisitor<'a, 'tcx: 'a> { in_body: bool, span: Span, empty_tables: &'a ty::TypeckTables<'tcx>, + reported_tuple_structs: FxHashSet, } impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> { fn item_is_accessible(&self, did: DefId) -> bool { - def_id_visibility(self.tcx, did).0.is_accessible_from(self.current_item, self.tcx) + let (a, ..) = def_id_visibility(self.tcx, did); + a.is_accessible_from(self.current_item, self.tcx) } // Take node-id of an expression or pattern and check its type for privacy. @@ -951,11 +1068,33 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, '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.span_err(self.span, &format!("{} `{}` is private", kind, descr)); + let is_ok = self.item_is_accessible(def_id); + if !is_ok { + match self.tcx.hir().as_local_node_id(def_id) { + Some(node_id) => { + match self.tcx.hir().get(node_id) { + Node::StructCtor(hir::VariantData::Tuple(..)) => { + // Ignore tuple structs, as they are handled in `visit_path` + return false; + } + _ => {} + } + } + _ => {} + } + let msg = if let Some(def) = self.tcx.describe_def(def_id) { + format!("{} `{}` is private", def.kind_name(), self.tcx.item_path_str(def_id)) + } else { + format!("{} `{}` is private", kind, descr) + }; + if !self.reported_tuple_structs.iter().any(|sp| sp.overlaps(self.span)) { + self.tcx.sess + .struct_span_err(self.span, &msg) + .span_label(self.span, "private") + .emit(); + } } - is_error + !is_ok } } @@ -1079,7 +1218,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { hir::QPath::TypeRelative(_, ref segment) => segment.ident.to_string(), }; let msg = format!("{} `{}` is private", def.kind_name(), name); - self.tcx.sess.span_err(span, &msg); + let label = format!("{} not accessible from here", def.kind_name()); + self.tcx.sess.struct_span_err(span, &msg) + .span_label(span, label) + .emit(); return; } } @@ -1087,6 +1229,26 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { intravisit::walk_qpath(self, qpath, id, span); } + // Prohibit access to tuple structs that are either unreachable *or* have private fields. + fn visit_path(&mut self, path: &'tcx hir::Path, _id: hir::HirId) { + // We handle tuple struct visibility here to only complain about bare paths referencing an + // unreachable tuple struct or one that has private fields. + if let Def::StructCtor(def_id, hir::def::CtorKind::Fn) = path.def { + if !self.item_is_accessible(def_id) && + // only report if this is a bare path, not part of a tuple struct literal + !self.reported_tuple_structs.iter().any(|sp| sp.overlaps(path.span)) + { + let kind_name = path.def.kind_name(); + let sp = path.span; + let msg = format!("{} `{}` is private", kind_name, path); + let label = format!("{} not accesssible from here", kind_name); + self.tcx.sess.struct_span_err(sp, &msg) + .span_label(sp, label) + .emit(); + } + } + } + // Check types of patterns. fn visit_pat(&mut self, pattern: &'tcx hir::Pat) { if self.check_expr_pat_type(pattern.hir_id, pattern.span) { @@ -1770,6 +1932,7 @@ fn check_mod_privacy<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) { tables: &empty_tables, current_item: DUMMY_NODE_ID, empty_tables: &empty_tables, + reported_tuple_structs: FxHashSet::default(), }; let (module, span, node_id) = tcx.hir().get_module(module_def_id); intravisit::walk_mod(&mut visitor, module, node_id); @@ -1783,6 +1946,7 @@ fn check_mod_privacy<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) { in_body: false, span, empty_tables: &empty_tables, + reported_tuple_structs: visitor.reported_tuple_structs, }; intravisit::walk_mod(&mut visitor, module, node_id); } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 55d5cdedd6ddd..cf3c848e61224 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -5046,8 +5046,24 @@ impl<'a> Resolver<'a> { let mut reported_spans = FxHashSet::default(); for &PrivacyError(dedup_span, ident, binding) in &self.privacy_errors { if reported_spans.insert(dedup_span) { - span_err!(self.session, ident.span, E0603, "{} `{}` is private", - binding.descr(), ident.name); + if let NameBindingKind::Def( + Def::StructCtor(_def_id, CtorKind::Fn), false, + ) = binding.kind { + // For tuple structs we want to be clearer about the reason for the ctor being + // private, as we'd want to identify whether the visibility failure is due to a + // non-accessible field. Because of this, ignore them at the resolve time and + // defer to privacy checking step. + } else { + let mut err = struct_span_err!( + self.session, + ident.span, + E0603, + "{} `{}` is private", + binding.descr(), + ident.name, + ); + err.emit(); + } } } } diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 9a04c9d60b868..4b3adbb460f47 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -268,9 +268,11 @@ impl<'a> Resolver<'a> { } } - if !self.is_accessible(binding.vis) && + let is_accessible = self.is_accessible(binding.vis); + if !is_accessible && // Remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE` - !(self.last_import_segment && binding.is_extern_crate()) { + !(self.last_import_segment && binding.is_extern_crate()) + { self.privacy_errors.push(PrivacyError(path_span, ident, binding)); } diff --git a/src/test/ui/error-codes/E0451.stderr b/src/test/ui/error-codes/E0451.stderr index 11bc7e31803a7..2aa7c1c083451 100644 --- a/src/test/ui/error-codes/E0451.stderr +++ b/src/test/ui/error-codes/E0451.stderr @@ -1,14 +1,32 @@ error[E0451]: field `b` of struct `Bar::Foo` is private --> $DIR/E0451.rs:14:23 | -LL | let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451 - | ^^^ field `b` is private +LL | / pub struct Foo { +LL | | pub a: isize, +LL | | b: isize, +LL | | } + | |_____- `Bar::Foo` defined here +... +LL | let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451 + | --------------^^^- + | | | + | | private field + | `Bar::Foo` cannot be destructured due to private field error[E0451]: field `b` of struct `Bar::Foo` is private --> $DIR/E0451.rs:18:29 | -LL | let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451 - | ^^^^ field `b` is private +LL | / pub struct Foo { +LL | | pub a: isize, +LL | | b: isize, +LL | | } + | |_____- `Bar::Foo` defined here +... +LL | let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451 + | ----------------^^^^-- + | | | + | | private field + | `Bar::Foo` cannot be built due to private field error: aborting due to 2 previous errors diff --git a/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.stderr b/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.stderr index 2aeffc3e5e457..4ce15c5287e8c 100644 --- a/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.stderr +++ b/src/test/ui/functional-struct-update/functional-struct-update-respects-privacy.stderr @@ -1,8 +1,14 @@ error[E0451]: field `secret_uid` of struct `foo::S` is private --> $DIR/functional-struct-update-respects-privacy.rs:28:49 | +LL | pub struct S { pub a: u8, pub b: String, secret_uid: u64 } + | ---------------------------------------------------------- `foo::S` defined here +... LL | let s_2 = foo::S { b: format!("ess two"), ..s_1 }; // FRU ... - | ^^^ field `secret_uid` is private + | ----------------------------------^^^-- + | | | + | | private field + | `foo::S` cannot be built due to private field error: aborting due to previous error diff --git a/src/test/ui/hygiene/fields.rs b/src/test/ui/hygiene/fields.rs index 597019cb1ee2d..45ea15b256b3b 100644 --- a/src/test/ui/hygiene/fields.rs +++ b/src/test/ui/hygiene/fields.rs @@ -12,11 +12,15 @@ mod foo { x: i32, } - let s = S { x: 0 }; //~ ERROR type `foo::S` is private - let _ = s.x; //~ ERROR type `foo::S` is private + let s = S { x: 0 }; + //~^ ERROR struct `foo::S` is private + let _ = s.x; + //~^ ERROR struct `foo::S` is private - let t = T(0); //~ ERROR type `foo::T` is private - let _ = t.0; //~ ERROR type `foo::T` is private + let t = T(0); + //~^ ERROR struct `foo::T` is private + let _ = t.0; + //~^ ERROR struct `foo::T` is private let s = $S { $x: 0, x: 1 }; assert_eq!((s.$x, s.x), (0, 1)); diff --git a/src/test/ui/hygiene/fields.stderr b/src/test/ui/hygiene/fields.stderr index 6d5b60fcb5b7f..dc841c01b1abe 100644 --- a/src/test/ui/hygiene/fields.stderr +++ b/src/test/ui/hygiene/fields.stderr @@ -1,35 +1,35 @@ -error: type `foo::S` is private +error: struct `foo::S` is private --> $DIR/fields.rs:15:17 | -LL | let s = S { x: 0 }; //~ ERROR type `foo::S` is private - | ^^^^^^^^^^ +LL | let s = S { x: 0 }; + | ^^^^^^^^^^ private ... LL | let s = foo::m!(S, x); | ------------- in this macro invocation -error: type `foo::S` is private - --> $DIR/fields.rs:16:17 +error: struct `foo::S` is private + --> $DIR/fields.rs:17:17 | -LL | let _ = s.x; //~ ERROR type `foo::S` is private - | ^ +LL | let _ = s.x; + | ^ private ... LL | let s = foo::m!(S, x); | ------------- in this macro invocation -error: type `foo::T` is private - --> $DIR/fields.rs:18:17 +error: struct `foo::T` is private + --> $DIR/fields.rs:20:17 | -LL | let t = T(0); //~ ERROR type `foo::T` is private - | ^^^^ +LL | let t = T(0); + | ^^^^ private ... LL | let s = foo::m!(S, x); | ------------- in this macro invocation -error: type `foo::T` is private - --> $DIR/fields.rs:19:17 +error: struct `foo::T` is private + --> $DIR/fields.rs:22:17 | -LL | let _ = t.0; //~ ERROR type `foo::T` is private - | ^ +LL | let _ = t.0; + | ^ private ... LL | let s = foo::m!(S, x); | ------------- in this macro invocation diff --git a/src/test/ui/hygiene/impl_items.rs b/src/test/ui/hygiene/impl_items.rs index 37794c6e0773c..50cca671b6656 100644 --- a/src/test/ui/hygiene/impl_items.rs +++ b/src/test/ui/hygiene/impl_items.rs @@ -9,7 +9,8 @@ mod foo { } pub macro m() { - let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private + let _: () = S.f(); + //~^ ERROR method `foo::S::f` is private } } diff --git a/src/test/ui/hygiene/impl_items.stderr b/src/test/ui/hygiene/impl_items.stderr index cb3705e5513cc..fda4ea655f589 100644 --- a/src/test/ui/hygiene/impl_items.stderr +++ b/src/test/ui/hygiene/impl_items.stderr @@ -1,8 +1,8 @@ -error: type `for<'r> fn(&'r foo::S) {foo::S::f}` is private +error: method `foo::S::f` is private --> $DIR/impl_items.rs:12:23 | -LL | let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private - | ^ +LL | let _: () = S.f(); + | ^ private ... LL | foo::m!(); | ---------- in this macro invocation diff --git a/src/test/ui/hygiene/intercrate.rs b/src/test/ui/hygiene/intercrate.rs index 2acbc893cf5fa..3cc96c929485f 100644 --- a/src/test/ui/hygiene/intercrate.rs +++ b/src/test/ui/hygiene/intercrate.rs @@ -8,5 +8,5 @@ extern crate intercrate; fn main() { assert_eq!(intercrate::foo::m!(), 1); - //~^ ERROR type `fn() -> u32 {intercrate::foo::bar::f}` is private + //~^ ERROR function `intercrate::foo::bar::f` is private } diff --git a/src/test/ui/hygiene/intercrate.stderr b/src/test/ui/hygiene/intercrate.stderr index 30a5570b2ad0e..ec18471fde882 100644 --- a/src/test/ui/hygiene/intercrate.stderr +++ b/src/test/ui/hygiene/intercrate.stderr @@ -1,8 +1,8 @@ -error: type `fn() -> u32 {intercrate::foo::bar::f}` is private +error: function `intercrate::foo::bar::f` is private --> $DIR/intercrate.rs:10:16 | LL | assert_eq!(intercrate::foo::m!(), 1); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ private | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) diff --git a/src/test/ui/privacy/associated-item-privacy-inherent.rs b/src/test/ui/privacy/associated-item-privacy-inherent.rs index c3ae920238f18..f00e6e3c40b29 100644 --- a/src/test/ui/privacy/associated-item-privacy-inherent.rs +++ b/src/test/ui/privacy/associated-item-privacy-inherent.rs @@ -11,11 +11,11 @@ mod priv_nominal { pub macro mac() { let value = Pub::method; - //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR method `priv_nominal::Pub::method` is private value; - //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR method `priv_nominal::Pub::method` is private Pub.method(); - //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR method `priv_nominal::Pub::method` is private Pub::CONST; //~^ ERROR associated constant `CONST` is private // let _: Pub::AssocTy; @@ -35,11 +35,11 @@ mod priv_signature { pub macro mac() { let value = Pub::method; - //~^ ERROR type `priv_signature::Priv` is private + //~^ ERROR struct `priv_signature::Priv` is private value; - //~^ ERROR type `priv_signature::Priv` is private + //~^ ERROR struct `priv_signature::Priv` is private Pub.method(loop {}); - //~^ ERROR type `priv_signature::Priv` is private + //~^ ERROR struct `priv_signature::Priv` is private } } fn priv_signature() { @@ -55,11 +55,11 @@ mod priv_substs { pub macro mac() { let value = Pub::method::; - //~^ ERROR type `priv_substs::Priv` is private + //~^ ERROR struct `priv_substs::Priv` is private value; - //~^ ERROR type `priv_substs::Priv` is private + //~^ ERROR struct `priv_substs::Priv` is private Pub.method::(); - //~^ ERROR type `priv_substs::Priv` is private + //~^ ERROR struct `priv_substs::Priv` is private } } fn priv_substs() { @@ -78,28 +78,28 @@ mod priv_parent_substs { pub macro mac() { let value = ::method; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private value; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private let value = Pub::method; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private value; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private let value = ::static_method; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private value; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private let value = Pub::static_method; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private value; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private Pub(Priv).method(); - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private ::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private Pub::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private // let _: Pub::AssocTy; // pub type InSignatureTy = Pub::AssocTy; diff --git a/src/test/ui/privacy/associated-item-privacy-inherent.stderr b/src/test/ui/privacy/associated-item-privacy-inherent.stderr index 6471a7914e103..1339b42c0c769 100644 --- a/src/test/ui/privacy/associated-item-privacy-inherent.stderr +++ b/src/test/ui/privacy/associated-item-privacy-inherent.stderr @@ -1,26 +1,26 @@ -error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: method `priv_nominal::Pub::method` is private --> $DIR/associated-item-privacy-inherent.rs:13:21 | LL | let value = Pub::method; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ private ... LL | priv_nominal::mac!(); | --------------------- in this macro invocation -error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: method `priv_nominal::Pub::method` is private --> $DIR/associated-item-privacy-inherent.rs:15:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_nominal::mac!(); | --------------------- in this macro invocation -error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: method `priv_nominal::Pub::method` is private --> $DIR/associated-item-privacy-inherent.rs:17:13 | LL | Pub.method(); - | ^^^^^^ + | ^^^^^^ private ... LL | priv_nominal::mac!(); | --------------------- in this macro invocation @@ -29,160 +29,160 @@ error: associated constant `CONST` is private --> $DIR/associated-item-privacy-inherent.rs:19:9 | LL | Pub::CONST; - | ^^^^^^^^^^ + | ^^^^^^^^^^ associated constant not accessible from here ... LL | priv_nominal::mac!(); | --------------------- in this macro invocation -error: type `priv_signature::Priv` is private +error: struct `priv_signature::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:37:21 | LL | let value = Pub::method; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ private ... LL | priv_signature::mac!(); | ----------------------- in this macro invocation -error: type `priv_signature::Priv` is private +error: struct `priv_signature::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:39:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_signature::mac!(); | ----------------------- in this macro invocation -error: type `priv_signature::Priv` is private +error: struct `priv_signature::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:41:13 | LL | Pub.method(loop {}); - | ^^^^^^ + | ^^^^^^ private ... LL | priv_signature::mac!(); | ----------------------- in this macro invocation -error: type `priv_substs::Priv` is private +error: struct `priv_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:57:21 | LL | let value = Pub::method::; - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ private ... LL | priv_substs::mac!(); | -------------------- in this macro invocation -error: type `priv_substs::Priv` is private +error: struct `priv_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:59:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_substs::mac!(); | -------------------- in this macro invocation -error: type `priv_substs::Priv` is private +error: struct `priv_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:61:9 | LL | Pub.method::(); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_substs::mac!(); | -------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:80:21 | LL | let value = ::method; - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:82:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:84:21 | LL | let value = Pub::method; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:86:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:88:21 | LL | let value = ::static_method; - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:90:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:92:21 | LL | let value = Pub::static_method; - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:94:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:96:19 | LL | Pub(Priv).method(); - | ^^^^^^ + | ^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:99:10 | LL | ::CONST; - | ^^^ + | ^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-inherent.rs:101:9 | LL | Pub::CONST; - | ^^^^^^^^^^ + | ^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation diff --git a/src/test/ui/privacy/associated-item-privacy-trait.rs b/src/test/ui/privacy/associated-item-privacy-trait.rs index b3d42f0959627..5d34b96075c2b 100644 --- a/src/test/ui/privacy/associated-item-privacy-trait.rs +++ b/src/test/ui/privacy/associated-item-privacy-trait.rs @@ -15,11 +15,11 @@ mod priv_trait { pub macro mac() { let value = ::method; - //~^ ERROR type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private + //~^ ERROR method `priv_trait::PrivTr::method` is private value; - //~^ ERROR type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private + //~^ ERROR method `priv_trait::PrivTr::method` is private Pub.method(); - //~^ ERROR type `for<'r> fn(&'r Self) {::method}` is private + //~^ ERROR method `priv_trait::PrivTr::method` is private ::CONST; //~^ ERROR associated constant `PrivTr::CONST` is private let _: ::AssocTy; @@ -47,11 +47,11 @@ mod priv_signature { pub macro mac() { let value = ::method; - //~^ ERROR type `priv_signature::Priv` is private + //~^ ERROR struct `priv_signature::Priv` is private value; - //~^ ERROR type `priv_signature::Priv` is private + //~^ ERROR struct `priv_signature::Priv` is private Pub.method(loop {}); - //~^ ERROR type `priv_signature::Priv` is private + //~^ ERROR struct `priv_signature::Priv` is private } } fn priv_signature() { @@ -68,11 +68,11 @@ mod priv_substs { pub macro mac() { let value = ::method::; - //~^ ERROR type `priv_substs::Priv` is private + //~^ ERROR struct `priv_substs::Priv` is private value; - //~^ ERROR type `priv_substs::Priv` is private + //~^ ERROR struct `priv_substs::Priv` is private Pub.method::(); - //~^ ERROR type `priv_substs::Priv` is private + //~^ ERROR struct `priv_substs::Priv` is private } } fn priv_substs() { @@ -92,46 +92,46 @@ mod priv_parent_substs { pub macro mac() { let value = ::method; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private value; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private let value = >::method; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private value; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private Pub.method(); - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private let value = >::method; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private value; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private Priv.method(); - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private ::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private >::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private >::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private let _: ::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private + //~| ERROR struct `priv_parent_substs::Priv` is private let _: >::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private + //~| ERROR struct `priv_parent_substs::Priv` is private let _: >::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private + //~| ERROR struct `priv_parent_substs::Priv` is private pub type InSignatureTy1 = ::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private pub type InSignatureTy2 = >::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private impl PubTr for u8 {} - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private } } fn priv_parent_substs() { diff --git a/src/test/ui/privacy/associated-item-privacy-trait.stderr b/src/test/ui/privacy/associated-item-privacy-trait.stderr index 5cf1be82937f8..fbeb0921ce023 100644 --- a/src/test/ui/privacy/associated-item-privacy-trait.stderr +++ b/src/test/ui/privacy/associated-item-privacy-trait.stderr @@ -1,26 +1,26 @@ -error: type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private +error: method `priv_trait::PrivTr::method` is private --> $DIR/associated-item-privacy-trait.rs:17:21 | LL | let value = ::method; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac!(); | ------------------- in this macro invocation -error: type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private +error: method `priv_trait::PrivTr::method` is private --> $DIR/associated-item-privacy-trait.rs:19:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_trait::mac!(); | ------------------- in this macro invocation -error: type `for<'r> fn(&'r Self) {::method}` is private +error: method `priv_trait::PrivTr::method` is private --> $DIR/associated-item-privacy-trait.rs:21:13 | LL | Pub.method(); - | ^^^^^^ + | ^^^^^^ private ... LL | priv_trait::mac!(); | ------------------- in this macro invocation @@ -29,7 +29,7 @@ error: associated constant `PrivTr::CONST` is private --> $DIR/associated-item-privacy-trait.rs:23:9 | LL | ::CONST; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ associated constant not accessible from here ... LL | priv_trait::mac!(); | ------------------- in this macro invocation @@ -38,7 +38,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-trait.rs:25:13 | LL | let _: ::AssocTy; - | ^ + | ^ private ... LL | priv_trait::mac!(); | ------------------- in this macro invocation @@ -47,7 +47,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-trait.rs:25:16 | LL | let _: ::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac!(); | ------------------- in this macro invocation @@ -56,7 +56,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-trait.rs:28:34 | LL | pub type InSignatureTy = ::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac!(); | ------------------- in this macro invocation @@ -65,7 +65,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-trait.rs:30:34 | LL | pub trait InSignatureTr: PrivTr {} - | ^^^^^^ + | ^^^^^^ private ... LL | priv_trait::mac!(); | ------------------- in this macro invocation @@ -74,241 +74,241 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-trait.rs:32:14 | LL | impl PrivTr for u8 {} - | ^^^^^^ + | ^^^^^^ private ... LL | priv_trait::mac!(); | ------------------- in this macro invocation -error: type `priv_signature::Priv` is private +error: struct `priv_signature::Priv` is private --> $DIR/associated-item-privacy-trait.rs:49:21 | LL | let value = ::method; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_signature::mac!(); | ----------------------- in this macro invocation -error: type `priv_signature::Priv` is private +error: struct `priv_signature::Priv` is private --> $DIR/associated-item-privacy-trait.rs:51:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_signature::mac!(); | ----------------------- in this macro invocation -error: type `priv_signature::Priv` is private +error: struct `priv_signature::Priv` is private --> $DIR/associated-item-privacy-trait.rs:53:13 | LL | Pub.method(loop {}); - | ^^^^^^ + | ^^^^^^ private ... LL | priv_signature::mac!(); | ----------------------- in this macro invocation -error: type `priv_substs::Priv` is private +error: struct `priv_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:70:21 | LL | let value = ::method::; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_substs::mac!(); | -------------------- in this macro invocation -error: type `priv_substs::Priv` is private +error: struct `priv_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:72:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_substs::mac!(); | -------------------- in this macro invocation -error: type `priv_substs::Priv` is private +error: struct `priv_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:74:9 | LL | Pub.method::(); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_substs::mac!(); | -------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:94:21 | LL | let value = ::method; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:96:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:98:21 | LL | let value = >::method; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:100:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:102:9 | LL | Pub.method(); - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:105:21 | LL | let value = >::method; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:107:9 | LL | value; - | ^^^^^ + | ^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:109:9 | LL | Priv.method(); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:112:9 | LL | ::CONST; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:114:9 | LL | >::CONST; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:116:9 | LL | >::CONST; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:119:13 | LL | let _: ::AssocTy; - | ^ + | ^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:119:16 | LL | let _: ::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:122:13 | LL | let _: >::AssocTy; - | ^ + | ^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:122:16 | LL | let _: >::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:125:13 | LL | let _: >::AssocTy; - | ^ + | ^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:125:16 | LL | let _: >::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:129:35 | LL | pub type InSignatureTy1 = ::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:131:35 | LL | pub type InSignatureTy2 = >::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-trait.rs:133:14 | LL | impl PubTr for u8 {} - | ^^^^^ + | ^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation diff --git a/src/test/ui/privacy/associated-item-privacy-type-binding.rs b/src/test/ui/privacy/associated-item-privacy-type-binding.rs index 591e9df81eb0b..392e0b547894e 100644 --- a/src/test/ui/privacy/associated-item-privacy-type-binding.rs +++ b/src/test/ui/privacy/associated-item-privacy-type-binding.rs @@ -42,19 +42,19 @@ mod priv_parent_substs { pub macro mac() { let _: Box>; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private + //~| ERROR struct `priv_parent_substs::Priv` is private let _: Box>; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private + //~| ERROR struct `priv_parent_substs::Priv` is private pub type InSignatureTy1 = Box>; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private pub type InSignatureTy2 = Box>; - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private trait InSignatureTr1: PubTrWithParam {} - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private trait InSignatureTr2: PubTr {} - //~^ ERROR type `priv_parent_substs::Priv` is private + //~^ ERROR struct `priv_parent_substs::Priv` is private } } fn priv_parent_substs() { diff --git a/src/test/ui/privacy/associated-item-privacy-type-binding.stderr b/src/test/ui/privacy/associated-item-privacy-type-binding.stderr index 7f6886d7f9ad4..b00c85edda7da 100644 --- a/src/test/ui/privacy/associated-item-privacy-type-binding.stderr +++ b/src/test/ui/privacy/associated-item-privacy-type-binding.stderr @@ -2,7 +2,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-type-binding.rs:11:13 | LL | let _: Box>; - | ^ + | ^ private ... LL | priv_trait::mac1!(); | -------------------- in this macro invocation @@ -11,7 +11,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-type-binding.rs:11:16 | LL | let _: Box>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac1!(); | -------------------- in this macro invocation @@ -20,7 +20,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-type-binding.rs:14:31 | LL | type InSignatureTy2 = Box>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac1!(); | -------------------- in this macro invocation @@ -29,7 +29,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-type-binding.rs:16:31 | LL | trait InSignatureTr2: PubTr {} - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac1!(); | -------------------- in this macro invocation @@ -38,7 +38,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-type-binding.rs:20:13 | LL | let _: Box>; - | ^ + | ^ private ... LL | priv_trait::mac2!(); | -------------------- in this macro invocation @@ -47,7 +47,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-type-binding.rs:20:16 | LL | let _: Box>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac2!(); | -------------------- in this macro invocation @@ -56,7 +56,7 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-type-binding.rs:23:31 | LL | type InSignatureTy1 = Box>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac2!(); | -------------------- in this macro invocation @@ -65,79 +65,79 @@ error: trait `priv_trait::PrivTr` is private --> $DIR/associated-item-privacy-type-binding.rs:25:31 | LL | trait InSignatureTr1: PrivTr {} - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_trait::mac2!(); | -------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-type-binding.rs:44:13 | LL | let _: Box>; - | ^ + | ^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-type-binding.rs:44:16 | LL | let _: Box>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-type-binding.rs:47:13 | LL | let _: Box>; - | ^ + | ^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-type-binding.rs:47:16 | LL | let _: Box>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-type-binding.rs:50:35 | LL | pub type InSignatureTy1 = Box>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-type-binding.rs:52:35 | LL | pub type InSignatureTy2 = Box>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-type-binding.rs:54:31 | LL | trait InSignatureTr1: PubTrWithParam {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation -error: type `priv_parent_substs::Priv` is private +error: struct `priv_parent_substs::Priv` is private --> $DIR/associated-item-privacy-type-binding.rs:56:31 | LL | trait InSignatureTr2: PubTr {} - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ private ... LL | priv_parent_substs::mac!(); | --------------------------- in this macro invocation diff --git a/src/test/ui/privacy/multiple-private-fields.rs b/src/test/ui/privacy/multiple-private-fields.rs new file mode 100644 index 0000000000000..e1a63a8dbb14d --- /dev/null +++ b/src/test/ui/privacy/multiple-private-fields.rs @@ -0,0 +1,17 @@ +mod a { + pub struct A(usize, usize); + pub struct B {a: usize, b: usize} + +} + +fn main(){ + let x = a::A(3, 4); + //~^ ERROR fields of struct `a::A` are private + let x = a::A; + //~^ ERROR tuple struct `a::A` is private + let x = a::B {a:1, b:2}; + //~^ ERROR fields of struct `a::B` are private +} + +fn foo(_x: a::A) {} // ok +fn bar(_x: a::B) {} // ok diff --git a/src/test/ui/privacy/multiple-private-fields.stderr b/src/test/ui/privacy/multiple-private-fields.stderr new file mode 100644 index 0000000000000..8c2b97ccbd616 --- /dev/null +++ b/src/test/ui/privacy/multiple-private-fields.stderr @@ -0,0 +1,34 @@ +error[E0451]: fields of struct `a::A` are private + --> $DIR/multiple-private-fields.rs:8:18 + | +LL | pub struct A(usize, usize); + | --------------------------- `a::A` defined here +... +LL | let x = a::A(3, 4); + | ---- ^ ^ private field + | | | + | | private field + | `a::A` cannot be built due to private fields + +error[E0451]: fields of struct `a::B` are private + --> $DIR/multiple-private-fields.rs:12:19 + | +LL | pub struct B {a: usize, b: usize} + | --------------------------------- `a::B` defined here +... +LL | let x = a::B {a:1, b:2}; + | ------^^^--^^^- + | | | | + | | | private field + | | private field + | `a::B` cannot be built due to private fields + +error: tuple struct `a::A` is private + --> $DIR/multiple-private-fields.rs:10:13 + | +LL | let x = a::A; + | ^^^^ tuple struct not accesssible from here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/privacy/privacy5.rs b/src/test/ui/privacy/privacy5.rs index 741ba0be2c2b6..d29cb73ff6e81 100644 --- a/src/test/ui/privacy/privacy5.rs +++ b/src/test/ui/privacy/privacy5.rs @@ -48,31 +48,51 @@ mod a { } fn this_crate() { - let a = a::A(()); //~ ERROR tuple struct `A` is private - let b = a::B(2); //~ ERROR tuple struct `B` is private - let c = a::C(2, 3); //~ ERROR tuple struct `C` is private + let a = a::A(()); + //~^ ERROR field `0` of struct `a::A` is private + let b = a::B(2); + //~^ ERROR field `0` of struct `a::B` is private + let c = a::C(2, 3); + //~^ ERROR field `1` of struct `a::C` is private let d = a::D(4); - let a::A(()) = a; //~ ERROR tuple struct `A` is private - let a::A(_) = a; //~ ERROR tuple struct `A` is private - match a { a::A(()) => {} } //~ ERROR tuple struct `A` is private - match a { a::A(_) => {} } //~ ERROR tuple struct `A` is private - - let a::B(_) = b; //~ ERROR tuple struct `B` is private - let a::B(_b) = b; //~ ERROR tuple struct `B` is private - match b { a::B(_) => {} } //~ ERROR tuple struct `B` is private - match b { a::B(_b) => {} } //~ ERROR tuple struct `B` is private - match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private - //~^ ERROR tuple struct `B` is private - - let a::C(_, _) = c; //~ ERROR tuple struct `C` is private - let a::C(_a, _) = c; //~ ERROR tuple struct `C` is private - let a::C(_, _b) = c; //~ ERROR tuple struct `C` is private - let a::C(_a, _b) = c; //~ ERROR tuple struct `C` is private - match c { a::C(_, _) => {} } //~ ERROR tuple struct `C` is private - match c { a::C(_a, _) => {} } //~ ERROR tuple struct `C` is private - match c { a::C(_, _b) => {} } //~ ERROR tuple struct `C` is private - match c { a::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private + let a::A(()) = a; + //~^ ERROR field `0` of struct `a::A` is private + let a::A(_) = a; + //~^ ERROR field `0` of struct `a::A` is private + match a { a::A(()) => {} } + //~^ ERROR field `0` of struct `a::A` is private + match a { a::A(_) => {} } + //~^ ERROR field `0` of struct `a::A` is private + + let a::B(_) = b; + //~^ ERROR field `0` of struct `a::B` is private + let a::B(_b) = b; + //~^ ERROR field `0` of struct `a::B` is private + match b { a::B(_) => {} } + //~^ ERROR field `0` of struct `a::B` is private + match b { a::B(_b) => {} } + //~^ ERROR field `0` of struct `a::B` is private + match b { a::B(1) => {} a::B(_) => {} } + //~^ ERROR field `0` of struct `a::B` is private + //~| ERROR field `0` of struct `a::B` is private + + let a::C(_, _) = c; + //~^ ERROR field `1` of struct `a::C` is private + let a::C(_a, _) = c; + //~^ ERROR field `1` of struct `a::C` is private + let a::C(_, _b) = c; + //~^ ERROR field `1` of struct `a::C` is private + let a::C(_a, _b) = c; + //~^ ERROR field `1` of struct `a::C` is private + match c { a::C(_, _) => {} } + //~^ ERROR field `1` of struct `a::C` is private + match c { a::C(_a, _) => {} } + //~^ ERROR field `1` of struct `a::C` is private + match c { a::C(_, _b) => {} } + //~^ ERROR field `1` of struct `a::C` is private + match c { a::C(_a, _b) => {} } + //~^ ERROR field `1` of struct `a::C` is private let a::D(_) = d; let a::D(_d) = d; @@ -80,38 +100,61 @@ fn this_crate() { match d { a::D(_d) => {} } match d { a::D(1) => {} a::D(_) => {} } - let a2 = a::A; //~ ERROR tuple struct `A` is private - let b2 = a::B; //~ ERROR tuple struct `B` is private - let c2 = a::C; //~ ERROR tuple struct `C` is private + let a2 = a::A; + //~^ ERROR tuple struct `a::A` is private + let b2 = a::B; + //~^ ERROR tuple struct `a::B` is private + let c2 = a::C; + //~^ ERROR tuple struct `a::C` is private let d2 = a::D; } fn xcrate() { - let a = other::A(()); //~ ERROR tuple struct `A` is private - let b = other::B(2); //~ ERROR tuple struct `B` is private - let c = other::C(2, 3); //~ ERROR tuple struct `C` is private + let a = other::A(()); + //~^ ERROR field `0` of struct `other::A` is private + let b = other::B(2); + //~^ ERROR field `0` of struct `other::B` is private + let c = other::C(2, 3); + //~^ ERROR field `1` of struct `other::C` is private let d = other::D(4); - let other::A(()) = a; //~ ERROR tuple struct `A` is private - let other::A(_) = a; //~ ERROR tuple struct `A` is private - match a { other::A(()) => {} } //~ ERROR tuple struct `A` is private - match a { other::A(_) => {} } //~ ERROR tuple struct `A` is private - - let other::B(_) = b; //~ ERROR tuple struct `B` is private - let other::B(_b) = b; //~ ERROR tuple struct `B` is private - match b { other::B(_) => {} } //~ ERROR tuple struct `B` is private - match b { other::B(_b) => {} } //~ ERROR tuple struct `B` is private - match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private - //~^ ERROR tuple struct `B` is private - - let other::C(_, _) = c; //~ ERROR tuple struct `C` is private - let other::C(_a, _) = c; //~ ERROR tuple struct `C` is private - let other::C(_, _b) = c; //~ ERROR tuple struct `C` is private - let other::C(_a, _b) = c; //~ ERROR tuple struct `C` is private - match c { other::C(_, _) => {} } //~ ERROR tuple struct `C` is private - match c { other::C(_a, _) => {} } //~ ERROR tuple struct `C` is private - match c { other::C(_, _b) => {} } //~ ERROR tuple struct `C` is private - match c { other::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private + let other::A(()) = a; + //~^ ERROR field `0` of struct `other::A` is private + let other::A(_) = a; + //~^ ERROR field `0` of struct `other::A` is private + match a { other::A(()) => {} } + //~^ ERROR field `0` of struct `other::A` is private + match a { other::A(_) => {} } + //~^ ERROR field `0` of struct `other::A` is private + + let other::B(_) = b; + //~^ ERROR field `0` of struct `other::B` is private + let other::B(_b) = b; + //~^ ERROR field `0` of struct `other::B` is private + match b { other::B(_) => {} } + //~^ ERROR field `0` of struct `other::B` is private + match b { other::B(_b) => {} } + //~^ ERROR field `0` of struct `other::B` is private + match b { other::B(1) => {} other::B(_) => {} } + //~^ ERROR field `0` of struct `other::B` is private + //~| ERROR field `0` of struct `other::B` is private + + let other::C(_, _) = c; + //~^ ERROR field `1` of struct `other::C` is private + let other::C(_a, _) = c; + //~^ ERROR field `1` of struct `other::C` is private + let other::C(_, _b) = c; + //~^ ERROR field `1` of struct `other::C` is private + let other::C(_a, _b) = c; + //~^ ERROR field `1` of struct `other::C` is private + match c { other::C(_, _) => {} } + //~^ ERROR field `1` of struct `other::C` is private + match c { other::C(_a, _) => {} } + //~^ ERROR field `1` of struct `other::C` is private + match c { other::C(_, _b) => {} } + //~^ ERROR field `1` of struct `other::C` is private + match c { other::C(_a, _b) => {} } + //~^ ERROR field `1` of struct `other::C` is private let other::D(_) = d; let other::D(_d) = d; @@ -119,9 +162,12 @@ fn xcrate() { match d { other::D(_d) => {} } match d { other::D(1) => {} other::D(_) => {} } - let a2 = other::A; //~ ERROR tuple struct `A` is private - let b2 = other::B; //~ ERROR tuple struct `B` is private - let c2 = other::C; //~ ERROR tuple struct `C` is private + let a2 = other::A; + //~^ ERROR struct `other::A` is private + let b2 = other::B; + //~^ ERROR struct `other::B` is private + let c2 = other::C; + //~^ ERROR struct `other::C` is private let d2 = other::D; } diff --git a/src/test/ui/privacy/privacy5.stderr b/src/test/ui/privacy/privacy5.stderr index cdd9b2cefbba7..d9d2f2ea2dda7 100644 --- a/src/test/ui/privacy/privacy5.stderr +++ b/src/test/ui/privacy/privacy5.stderr @@ -1,291 +1,579 @@ -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:51:16 - | -LL | let a = a::A(()); //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:52:16 - | -LL | let b = a::B(2); //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:53:16 - | -LL | let c = a::C(2, 3); //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:56:12 - | -LL | let a::A(()) = a; //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:57:12 - | -LL | let a::A(_) = a; //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:58:18 - | -LL | match a { a::A(()) => {} } //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:59:18 - | -LL | match a { a::A(_) => {} } //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:61:12 - | -LL | let a::B(_) = b; //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:62:12 - | -LL | let a::B(_b) = b; //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:63:18 - | -LL | match b { a::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:64:18 - | -LL | match b { a::B(_b) => {} } //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:65:18 - | -LL | match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:65:32 - | -LL | match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:68:12 - | -LL | let a::C(_, _) = c; //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:69:12 - | -LL | let a::C(_a, _) = c; //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:70:12 - | -LL | let a::C(_, _b) = c; //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:71:12 - | -LL | let a::C(_a, _b) = c; //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:72:18 - | -LL | match c { a::C(_, _) => {} } //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:73:18 - | -LL | match c { a::C(_a, _) => {} } //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:74:18 - | -LL | match c { a::C(_, _b) => {} } //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:75:18 - | -LL | match c { a::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:83:17 - | -LL | let a2 = a::A; //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `B` is private +error[E0451]: field `0` of struct `a::A` is private + --> $DIR/privacy5.rs:51:18 + | +LL | pub struct A(()); + | ----------------- `a::A` defined here +... +LL | let a = a::A(()); + | ---- ^^ private field + | | + | `a::A` cannot be built due to private field + +error[E0451]: field `0` of struct `a::B` is private + --> $DIR/privacy5.rs:53:18 + | +LL | pub struct B(isize); + | -------------------- `a::B` defined here +... +LL | let b = a::B(2); + | ---- ^ private field + | | + | `a::B` cannot be built due to private field + +error[E0451]: field `1` of struct `a::C` is private + --> $DIR/privacy5.rs:55:21 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | let c = a::C(2, 3); + | ---- ^ private field + | | + | `a::C` cannot be built due to private field + +error[E0451]: field `0` of struct `a::A` is private + --> $DIR/privacy5.rs:59:14 + | +LL | pub struct A(()); + | ----------------- `a::A` defined here +... +LL | let a::A(()) = a; + | -----^^- + | | | + | | private field + | `a::A` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::A` is private + --> $DIR/privacy5.rs:61:14 + | +LL | pub struct A(()); + | ----------------- `a::A` defined here +... +LL | let a::A(_) = a; + | -----^- + | | | + | | private field + | `a::A` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::A` is private + --> $DIR/privacy5.rs:63:20 + | +LL | pub struct A(()); + | ----------------- `a::A` defined here +... +LL | match a { a::A(()) => {} } + | -----^^- + | | | + | | private field + | `a::A` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::A` is private + --> $DIR/privacy5.rs:65:20 + | +LL | pub struct A(()); + | ----------------- `a::A` defined here +... +LL | match a { a::A(_) => {} } + | -----^- + | | | + | | private field + | `a::A` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::B` is private + --> $DIR/privacy5.rs:68:14 + | +LL | pub struct B(isize); + | -------------------- `a::B` defined here +... +LL | let a::B(_) = b; + | -----^- + | | | + | | private field + | `a::B` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::B` is private + --> $DIR/privacy5.rs:70:14 + | +LL | pub struct B(isize); + | -------------------- `a::B` defined here +... +LL | let a::B(_b) = b; + | -----^^- + | | | + | | private field + | `a::B` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::B` is private + --> $DIR/privacy5.rs:72:20 + | +LL | pub struct B(isize); + | -------------------- `a::B` defined here +... +LL | match b { a::B(_) => {} } + | -----^- + | | | + | | private field + | `a::B` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::B` is private + --> $DIR/privacy5.rs:74:20 + | +LL | pub struct B(isize); + | -------------------- `a::B` defined here +... +LL | match b { a::B(_b) => {} } + | -----^^- + | | | + | | private field + | `a::B` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::B` is private + --> $DIR/privacy5.rs:76:20 + | +LL | pub struct B(isize); + | -------------------- `a::B` defined here +... +LL | match b { a::B(1) => {} a::B(_) => {} } + | -----^- + | | | + | | private field + | `a::B` cannot be destructured due to private field + +error[E0451]: field `0` of struct `a::B` is private + --> $DIR/privacy5.rs:76:34 + | +LL | pub struct B(isize); + | -------------------- `a::B` defined here +... +LL | match b { a::B(1) => {} a::B(_) => {} } + | -----^- + | | | + | | private field + | `a::B` cannot be destructured due to private field + +error[E0451]: field `1` of struct `a::C` is private + --> $DIR/privacy5.rs:80:17 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | let a::C(_, _) = c; + | --------^- + | | | + | | private field + | `a::C` cannot be destructured due to private field + +error[E0451]: field `1` of struct `a::C` is private + --> $DIR/privacy5.rs:82:18 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | let a::C(_a, _) = c; + | ---------^- + | | | + | | private field + | `a::C` cannot be destructured due to private field + +error[E0451]: field `1` of struct `a::C` is private --> $DIR/privacy5.rs:84:17 | -LL | let b2 = a::B; //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:85:17 - | -LL | let c2 = a::C; //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:90:20 - | -LL | let a = other::A(()); //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:91:20 - | -LL | let b = other::B(2); //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:92:20 - | -LL | let c = other::C(2, 3); //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:95:16 - | -LL | let other::A(()) = a; //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:96:16 - | -LL | let other::A(_) = a; //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:97:22 - | -LL | match a { other::A(()) => {} } //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:98:22 - | -LL | match a { other::A(_) => {} } //~ ERROR tuple struct `A` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:100:16 - | -LL | let other::B(_) = b; //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:101:16 - | -LL | let other::B(_b) = b; //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:102:22 - | -LL | match b { other::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:103:22 - | -LL | match b { other::B(_b) => {} } //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:104:22 - | -LL | match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:104:40 - | -LL | match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:107:16 - | -LL | let other::C(_, _) = c; //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:108:16 +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | let a::C(_, _b) = c; + | --------^^- + | | | + | | private field + | `a::C` cannot be destructured due to private field + +error[E0451]: field `1` of struct `a::C` is private + --> $DIR/privacy5.rs:86:18 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | let a::C(_a, _b) = c; + | ---------^^- + | | | + | | private field + | `a::C` cannot be destructured due to private field + +error[E0451]: field `1` of struct `a::C` is private + --> $DIR/privacy5.rs:88:23 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | match c { a::C(_, _) => {} } + | --------^- + | | | + | | private field + | `a::C` cannot be destructured due to private field + +error[E0451]: field `1` of struct `a::C` is private + --> $DIR/privacy5.rs:90:24 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | match c { a::C(_a, _) => {} } + | ---------^- + | | | + | | private field + | `a::C` cannot be destructured due to private field + +error[E0451]: field `1` of struct `a::C` is private + --> $DIR/privacy5.rs:92:23 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | match c { a::C(_, _b) => {} } + | --------^^- + | | | + | | private field + | `a::C` cannot be destructured due to private field + +error[E0451]: field `1` of struct `a::C` is private + --> $DIR/privacy5.rs:94:24 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `a::C` defined here +... +LL | match c { a::C(_a, _b) => {} } + | ---------^^- + | | | + | | private field + | `a::C` cannot be destructured due to private field + +error[E0451]: field `0` of struct `other::A` is private + --> $DIR/privacy5.rs:113:22 | -LL | let other::C(_a, _) = c; //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:109:16 +LL | let a = other::A(()); + | -------- ^^ private field + | | + | `other::A` cannot be built due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + | +LL | pub struct A(()); + | ----------------- `other::A` defined here + +error[E0451]: field `0` of struct `other::B` is private + --> $DIR/privacy5.rs:115:22 + | +LL | let b = other::B(2); + | -------- ^ private field + | | + | `other::B` cannot be built due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + | +LL | pub struct B(isize); + | -------------------- `other::B` defined here + +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:117:25 + | +LL | let c = other::C(2, 3); + | -------- ^ private field + | | + | `other::C` cannot be built due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here + +error[E0451]: field `0` of struct `other::A` is private + --> $DIR/privacy5.rs:121:18 + | +LL | let other::A(()) = a; + | ---------^^- + | | | + | | private field + | `other::A` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + | +LL | pub struct A(()); + | ----------------- `other::A` defined here + +error[E0451]: field `0` of struct `other::A` is private + --> $DIR/privacy5.rs:123:18 + | +LL | let other::A(_) = a; + | ---------^- + | | | + | | private field + | `other::A` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + | +LL | pub struct A(()); + | ----------------- `other::A` defined here + +error[E0451]: field `0` of struct `other::A` is private + --> $DIR/privacy5.rs:125:24 + | +LL | match a { other::A(()) => {} } + | ---------^^- + | | | + | | private field + | `other::A` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + | +LL | pub struct A(()); + | ----------------- `other::A` defined here + +error[E0451]: field `0` of struct `other::A` is private + --> $DIR/privacy5.rs:127:24 + | +LL | match a { other::A(_) => {} } + | ---------^- + | | | + | | private field + | `other::A` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + | +LL | pub struct A(()); + | ----------------- `other::A` defined here + +error[E0451]: field `0` of struct `other::B` is private + --> $DIR/privacy5.rs:130:18 + | +LL | let other::B(_) = b; + | ---------^- + | | | + | | private field + | `other::B` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + | +LL | pub struct B(isize); + | -------------------- `other::B` defined here + +error[E0451]: field `0` of struct `other::B` is private + --> $DIR/privacy5.rs:132:18 + | +LL | let other::B(_b) = b; + | ---------^^- + | | | + | | private field + | `other::B` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + | +LL | pub struct B(isize); + | -------------------- `other::B` defined here + +error[E0451]: field `0` of struct `other::B` is private + --> $DIR/privacy5.rs:134:24 + | +LL | match b { other::B(_) => {} } + | ---------^- + | | | + | | private field + | `other::B` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + | +LL | pub struct B(isize); + | -------------------- `other::B` defined here + +error[E0451]: field `0` of struct `other::B` is private + --> $DIR/privacy5.rs:136:24 + | +LL | match b { other::B(_b) => {} } + | ---------^^- + | | | + | | private field + | `other::B` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + | +LL | pub struct B(isize); + | -------------------- `other::B` defined here + +error[E0451]: field `0` of struct `other::B` is private + --> $DIR/privacy5.rs:138:24 + | +LL | match b { other::B(1) => {} other::B(_) => {} } + | ---------^- + | | | + | | private field + | `other::B` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + | +LL | pub struct B(isize); + | -------------------- `other::B` defined here + +error[E0451]: field `0` of struct `other::B` is private + --> $DIR/privacy5.rs:138:42 + | +LL | match b { other::B(1) => {} other::B(_) => {} } + | ---------^- + | | | + | | private field + | `other::B` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + | +LL | pub struct B(isize); + | -------------------- `other::B` defined here + +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:142:21 + | +LL | let other::C(_, _) = c; + | ------------^- + | | | + | | private field + | `other::C` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here + +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:144:22 + | +LL | let other::C(_a, _) = c; + | -------------^- + | | | + | | private field + | `other::C` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here + +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:146:21 + | +LL | let other::C(_, _b) = c; + | ------------^^- + | | | + | | private field + | `other::C` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here + +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:148:22 + | +LL | let other::C(_a, _b) = c; + | -------------^^- + | | | + | | private field + | `other::C` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here + +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:150:27 + | +LL | match c { other::C(_, _) => {} } + | ------------^- + | | | + | | private field + | `other::C` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here + +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:152:28 + | +LL | match c { other::C(_a, _) => {} } + | -------------^- + | | | + | | private field + | `other::C` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + | +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here + +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:154:27 + | +LL | match c { other::C(_, _b) => {} } + | ------------^^- + | | | + | | private field + | `other::C` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | -LL | let other::C(_, _b) = c; //~ ERROR tuple struct `C` is private - | ^ +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:110:16 +error[E0451]: field `1` of struct `other::C` is private + --> $DIR/privacy5.rs:156:28 + | +LL | match c { other::C(_a, _b) => {} } + | -------------^^- + | | | + | | private field + | `other::C` cannot be destructured due to private field + | + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | -LL | let other::C(_a, _b) = c; //~ ERROR tuple struct `C` is private - | ^ +LL | pub struct C(pub isize, isize); + | ------------------------------- `other::C` defined here -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:111:22 +error: tuple struct `a::A` is private + --> $DIR/privacy5.rs:103:14 | -LL | match c { other::C(_, _) => {} } //~ ERROR tuple struct `C` is private - | ^ +LL | let a2 = a::A; + | ^^^^ tuple struct not accesssible from here -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:112:22 - | -LL | match c { other::C(_a, _) => {} } //~ ERROR tuple struct `C` is private - | ^ - -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:113:22 +error: tuple struct `a::B` is private + --> $DIR/privacy5.rs:105:14 | -LL | match c { other::C(_, _b) => {} } //~ ERROR tuple struct `C` is private - | ^ +LL | let b2 = a::B; + | ^^^^ tuple struct not accesssible from here -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:114:22 +error: tuple struct `a::C` is private + --> $DIR/privacy5.rs:107:14 | -LL | match c { other::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private - | ^ +LL | let c2 = a::C; + | ^^^^ tuple struct not accesssible from here -error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:122:21 +error: struct `other::A` is private + --> $DIR/privacy5.rs:165:14 | -LL | let a2 = other::A; //~ ERROR tuple struct `A` is private - | ^ +LL | let a2 = other::A; + | ^^^^^^^^ private -error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:123:21 +error: struct `other::B` is private + --> $DIR/privacy5.rs:167:14 | -LL | let b2 = other::B; //~ ERROR tuple struct `B` is private - | ^ +LL | let b2 = other::B; + | ^^^^^^^^ private -error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:124:21 +error: struct `other::C` is private + --> $DIR/privacy5.rs:169:14 | -LL | let c2 = other::C; //~ ERROR tuple struct `C` is private - | ^ +LL | let c2 = other::C; + | ^^^^^^^^ private error: aborting due to 48 previous errors -For more information about this error, try `rustc --explain E0603`. +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/privacy/private-in-public-non-principal-2.stderr b/src/test/ui/privacy/private-in-public-non-principal-2.stderr index 2db4925722642..3a411a8982ae6 100644 --- a/src/test/ui/privacy/private-in-public-non-principal-2.stderr +++ b/src/test/ui/privacy/private-in-public-non-principal-2.stderr @@ -2,7 +2,7 @@ error: trait `m::PrivNonPrincipal` is private --> $DIR/private-in-public-non-principal-2.rs:11:5 | LL | m::leak_dyn_nonprincipal(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ private error: aborting due to previous error diff --git a/src/test/ui/privacy/private-inferred-type-1.rs b/src/test/ui/privacy/private-inferred-type-1.rs index 69eeb2a26e643..aa74050a15252 100644 --- a/src/test/ui/privacy/private-inferred-type-1.rs +++ b/src/test/ui/privacy/private-inferred-type-1.rs @@ -13,6 +13,6 @@ mod m { } fn main() { - [].arr0_secret(); //~ ERROR type `m::Priv` is private - None.ty_param_secret(); //~ ERROR type `m::Priv` is private + [].arr0_secret(); //~ ERROR struct `m::Priv` is private + None.ty_param_secret(); //~ ERROR struct `m::Priv` is private } diff --git a/src/test/ui/privacy/private-inferred-type-1.stderr b/src/test/ui/privacy/private-inferred-type-1.stderr index 06df7e8478370..e46c5c85e7cb9 100644 --- a/src/test/ui/privacy/private-inferred-type-1.stderr +++ b/src/test/ui/privacy/private-inferred-type-1.stderr @@ -1,14 +1,14 @@ -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-inferred-type-1.rs:16:5 | -LL | [].arr0_secret(); //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^ +LL | [].arr0_secret(); //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-inferred-type-1.rs:17:5 | -LL | None.ty_param_secret(); //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | None.ty_param_secret(); //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^ private error: aborting due to 2 previous errors diff --git a/src/test/ui/privacy/private-inferred-type-2.rs b/src/test/ui/privacy/private-inferred-type-2.rs index 28b47606d157a..4b9cbd5ed3b36 100644 --- a/src/test/ui/privacy/private-inferred-type-2.rs +++ b/src/test/ui/privacy/private-inferred-type-2.rs @@ -13,7 +13,7 @@ mod m { } fn main() { - m::Pub::get_priv; //~ ERROR type `m::Priv` is private - m::Pub::static_method; //~ ERROR type `m::Priv` is private - ext::Pub::static_method; //~ ERROR type `ext::Priv` is private + m::Pub::get_priv; //~ ERROR struct `m::Priv` is private + m::Pub::static_method; //~ ERROR struct `m::Priv` is private + ext::Pub::static_method; //~ ERROR struct `ext::Priv` is private } diff --git a/src/test/ui/privacy/private-inferred-type-2.stderr b/src/test/ui/privacy/private-inferred-type-2.stderr index 7a3f52fa05df7..2482d886ce720 100644 --- a/src/test/ui/privacy/private-inferred-type-2.stderr +++ b/src/test/ui/privacy/private-inferred-type-2.stderr @@ -1,20 +1,20 @@ -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-inferred-type-2.rs:16:5 | -LL | m::Pub::get_priv; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^ +LL | m::Pub::get_priv; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-inferred-type-2.rs:17:5 | -LL | m::Pub::static_method; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^ +LL | m::Pub::static_method; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^ private -error: type `ext::Priv` is private +error: struct `ext::Priv` is private --> $DIR/private-inferred-type-2.rs:18:5 | -LL | ext::Pub::static_method; //~ ERROR type `ext::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | ext::Pub::static_method; //~ ERROR struct `ext::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^ private error: aborting due to 3 previous errors diff --git a/src/test/ui/privacy/private-inferred-type-3.rs b/src/test/ui/privacy/private-inferred-type-3.rs index d885407a1cd37..707673482baa9 100644 --- a/src/test/ui/privacy/private-inferred-type-3.rs +++ b/src/test/ui/privacy/private-inferred-type-3.rs @@ -1,12 +1,12 @@ // aux-build:private-inferred-type.rs -// error-pattern:type `fn() {ext::priv_fn}` is private +// error-pattern:function `ext::priv_fn` is private // error-pattern:static `PRIV_STATIC` is private -// error-pattern:type `ext::PrivEnum` is private -// error-pattern:type `fn() {::method}` is private -// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private -// error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct}` is private -// error-pattern:type `for<'r> fn(&'r ext::Pub) {>::priv_method}` is private +// error-pattern:enum `ext::PrivEnum` is private +// error-pattern:method `ext::PrivTrait::method` is private +// error-pattern:struct `ext::PrivTupleStruct` is private +// error-pattern:struct `ext::PubTupleStruct` is private +// error-pattern:method `>::priv_method` is private #![feature(decl_macro)] diff --git a/src/test/ui/privacy/private-inferred-type-3.stderr b/src/test/ui/privacy/private-inferred-type-3.stderr index f8b757ea09820..7fe2f0e0e170d 100644 --- a/src/test/ui/privacy/private-inferred-type-3.stderr +++ b/src/test/ui/privacy/private-inferred-type-3.stderr @@ -1,8 +1,8 @@ -error: type `fn() {ext::priv_fn}` is private +error: function `ext::priv_fn` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ private | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) @@ -10,47 +10,47 @@ error: static `PRIV_STATIC` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ static not accessible from here | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: type `ext::PrivEnum` is private +error: enum `ext::PrivEnum` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ private | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: type `fn() {::method}` is private +error: method `ext::PrivTrait::method` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ private | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private +error: struct `ext::PrivTupleStruct` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ private | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct}` is private +error: struct `ext::PubTupleStruct` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ private | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: type `for<'r> fn(&'r ext::Pub) {>::priv_method}` is private +error: method `>::priv_method` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ private | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) diff --git a/src/test/ui/privacy/private-inferred-type-4.rs b/src/test/ui/privacy/private-inferred-type-4.rs new file mode 100644 index 0000000000000..45a12bd61b60a --- /dev/null +++ b/src/test/ui/privacy/private-inferred-type-4.rs @@ -0,0 +1,17 @@ +#![feature(associated_consts)] +#![feature(decl_macro)] +#![allow(private_in_public)] + +mod m { + pub struct PubTupleStruct(u8); + impl PubTupleStruct { fn method() {} } + + pub macro m() { + PubTupleStruct; + //~^ ERROR tuple struct `PubTupleStruct` is private + } +} + +fn main() { + m::m!(); +} diff --git a/src/test/ui/privacy/private-inferred-type-4.stderr b/src/test/ui/privacy/private-inferred-type-4.stderr new file mode 100644 index 0000000000000..e961bb140c078 --- /dev/null +++ b/src/test/ui/privacy/private-inferred-type-4.stderr @@ -0,0 +1,11 @@ +error: tuple struct `PubTupleStruct` is private + --> $DIR/private-inferred-type-4.rs:10:9 + | +LL | PubTupleStruct; + | ^^^^^^^^^^^^^^ tuple struct not accesssible from here +... +LL | m::m!(); + | -------- in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/ui/privacy/private-inferred-type.rs b/src/test/ui/privacy/private-inferred-type.rs index 69b60a56c67f1..58e6fd8218212 100644 --- a/src/test/ui/privacy/private-inferred-type.rs +++ b/src/test/ui/privacy/private-inferred-type.rs @@ -12,8 +12,6 @@ mod m { pub trait PubTrait { fn method() {} } impl PubTrait for u8 {} struct PrivTupleStruct(u8); - pub struct PubTupleStruct(u8); - impl PubTupleStruct { fn method() {} } struct Priv; pub type Alias = Priv; @@ -36,18 +34,16 @@ mod m { impl TraitWithAssocTy for Priv { type AssocTy = u8; } pub macro m() { - priv_fn; //~ ERROR type `fn() {m::priv_fn}` is private + priv_fn; //~ ERROR function `m::priv_fn` is private PRIV_STATIC; // OK, not cross-crate - PrivEnum::Variant; //~ ERROR type `m::PrivEnum` is private + PrivEnum::Variant; //~ ERROR enum `m::PrivEnum` is private PubEnum::Variant; // OK - ::method; //~ ERROR type `fn() {::method}` is private + ::method; //~ ERROR method `m::PrivTrait::method` is private ::method; // OK PrivTupleStruct; - //~^ ERROR type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct}` is private - PubTupleStruct; - //~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct}` is private + //~^ ERROR struct `m::PrivTupleStruct` is private Pub(0u8).priv_method(); - //~^ ERROR type `for<'r> fn(&'r m::Pub) {>::priv_method}` is private + //~^ ERROR method `>::priv_method` is private } trait Trait {} @@ -94,40 +90,43 @@ mod adjust { } fn main() { - let _: m::Alias; //~ ERROR type `m::Priv` is private - //~^ ERROR type `m::Priv` is private - let _: ::AssocTy; //~ ERROR type `m::Priv` is private - m::Alias {}; //~ ERROR type `m::Priv` is private - m::Pub { 0: m::Alias {} }; //~ ERROR type `m::Priv` is private + let _: m::Alias; + //~^ ERROR struct `m::Priv` is private + //~| ERROR struct `m::Priv` is private + let _: ::AssocTy; + //~^ ERROR struct `m::Priv` is private + m::Alias {}; + //~^ ERROR struct `m::Priv` is private + m::Pub { 0: m::Alias {} }; //~ ERROR struct `m::Priv` is private m::Pub { 0: loop {} }; // OK, `m::Pub` is in value context, so it means Pub<_>, not Pub - m::Pub::static_method; //~ ERROR type `m::Priv` is private - m::Pub::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - m::Pub(0u8).method_with_substs::(); //~ ERROR type `m::Priv` is private - m::Pub(0u8).method_with_priv_params(loop{}); //~ ERROR type `m::Priv` is private - ::TRAIT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - >::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - >::INHERENT_ASSOC_CONST_GENERIC_SELF; //~ ERROR type `m::Priv` is private - >::static_method_generic_self; //~ ERROR type `m::Priv` is private + m::Pub::static_method; //~ ERROR struct `m::Priv` is private + m::Pub::INHERENT_ASSOC_CONST; //~ ERROR struct `m::Priv` is private + m::Pub(0u8).method_with_substs::(); //~ ERROR struct `m::Priv` is private + m::Pub(0u8).method_with_priv_params(loop{}); //~ ERROR struct `m::Priv` is private + ::TRAIT_ASSOC_CONST; //~ ERROR struct `m::Priv` is private + >::INHERENT_ASSOC_CONST; //~ ERROR struct `m::Priv` is private + >::INHERENT_ASSOC_CONST_GENERIC_SELF; //~ ERROR struct `m::Priv` is private + >::static_method_generic_self; //~ ERROR struct `m::Priv` is private use m::TraitWithTyParam2; - u8::pub_method; //~ ERROR type `m::Priv` is private + u8::pub_method; //~ ERROR struct `m::Priv` is private - adjust::S1.method_s3(); //~ ERROR type `adjust::S2` is private + adjust::S1.method_s3(); //~ ERROR struct `adjust::S2` is private m::m!(); m::leak_anon1(); //~ ERROR trait `m::Trait` is private - m::leak_anon2(); //~ ERROR type `m::Priv` is private - m::leak_anon3(); //~ ERROR type `m::Priv` is private + m::leak_anon2(); //~ ERROR struct `m::Priv` is private + m::leak_anon3(); //~ ERROR struct `m::Priv` is private m::leak_dyn1(); //~ ERROR trait `m::Trait` is private - m::leak_dyn2(); //~ ERROR type `m::Priv` is private - m::leak_dyn3(); //~ ERROR type `m::Priv` is private + m::leak_dyn2(); //~ ERROR struct `m::Priv` is private + m::leak_dyn3(); //~ ERROR struct `m::Priv` is private // Check that messages are not duplicated for various kinds of assignments - let a = m::Alias {}; //~ ERROR type `m::Priv` is private - let mut b = a; //~ ERROR type `m::Priv` is private - b = a; //~ ERROR type `m::Priv` is private - match a { //~ ERROR type `m::Priv` is private + let a = m::Alias {}; //~ ERROR struct `m::Priv` is private + let mut b = a; //~ ERROR struct `m::Priv` is private + b = a; //~ ERROR struct `m::Priv` is private + match a { //~ ERROR struct `m::Priv` is private _ => {} } } diff --git a/src/test/ui/privacy/private-inferred-type.stderr b/src/test/ui/privacy/private-inferred-type.stderr index 80a475f7dceea..c1e61d85188dc 100644 --- a/src/test/ui/privacy/private-inferred-type.stderr +++ b/src/test/ui/privacy/private-inferred-type.stderr @@ -1,209 +1,200 @@ -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:97:9 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:93:9 | -LL | let _: m::Alias; //~ ERROR type `m::Priv` is private - | ^ +LL | let _: m::Alias; + | ^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:97:12 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:93:12 | -LL | let _: m::Alias; //~ ERROR type `m::Priv` is private - | ^^^^^^^^ +LL | let _: m::Alias; + | ^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:99:13 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:96:13 | -LL | let _: ::AssocTy; //~ ERROR type `m::Priv` is private - | ^^^^^^^^ +LL | let _: ::AssocTy; + | ^^^^^^^^ private -error: type `m::Priv` is private +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:98:5 + | +LL | m::Alias {}; + | ^^^^^^^^^^^ private + +error: struct `m::Priv` is private --> $DIR/private-inferred-type.rs:100:5 | -LL | m::Alias {}; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^ +LL | m::Pub { 0: m::Alias {} }; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:101:5 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:102:5 | -LL | m::Pub { 0: m::Alias {} }; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | m::Pub::static_method; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-inferred-type.rs:103:5 | -LL | m::Pub::static_method; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^ +LL | m::Pub::INHERENT_ASSOC_CONST; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-inferred-type.rs:104:5 | -LL | m::Pub::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | m::Pub(0u8).method_with_substs::(); //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:105:5 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:105:17 | -LL | m::Pub(0u8).method_with_substs::(); //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | m::Pub(0u8).method_with_priv_params(loop{}); //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:106:17 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:106:5 | -LL | m::Pub(0u8).method_with_priv_params(loop{}); //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | ::TRAIT_ASSOC_CONST; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:107:5 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:107:6 | -LL | ::TRAIT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | >::INHERENT_ASSOC_CONST; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:108:6 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:108:5 | -LL | >::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^ +LL | >::INHERENT_ASSOC_CONST_GENERIC_SELF; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-inferred-type.rs:109:5 | -LL | >::INHERENT_ASSOC_CONST_GENERIC_SELF; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:110:5 - | -LL | >::static_method_generic_self; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | >::static_method_generic_self; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:112:5 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:111:5 | -LL | u8::pub_method; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^ +LL | u8::pub_method; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^ private -error: type `adjust::S2` is private - --> $DIR/private-inferred-type.rs:114:5 +error: struct `adjust::S2` is private + --> $DIR/private-inferred-type.rs:113:5 | -LL | adjust::S1.method_s3(); //~ ERROR type `adjust::S2` is private - | ^^^^^^^^^^ +LL | adjust::S1.method_s3(); //~ ERROR struct `adjust::S2` is private + | ^^^^^^^^^^ private -error: type `fn() {m::priv_fn}` is private - --> $DIR/private-inferred-type.rs:39:9 +error: function `m::priv_fn` is private + --> $DIR/private-inferred-type.rs:37:9 | -LL | priv_fn; //~ ERROR type `fn() {m::priv_fn}` is private - | ^^^^^^^ +LL | priv_fn; //~ ERROR function `m::priv_fn` is private + | ^^^^^^^ private ... LL | m::m!(); | -------- in this macro invocation -error: type `m::PrivEnum` is private - --> $DIR/private-inferred-type.rs:41:9 +error: enum `m::PrivEnum` is private + --> $DIR/private-inferred-type.rs:39:9 | -LL | PrivEnum::Variant; //~ ERROR type `m::PrivEnum` is private - | ^^^^^^^^^^^^^^^^^ +LL | PrivEnum::Variant; //~ ERROR enum `m::PrivEnum` is private + | ^^^^^^^^^^^^^^^^^ private ... LL | m::m!(); | -------- in this macro invocation -error: type `fn() {::method}` is private - --> $DIR/private-inferred-type.rs:43:9 +error: method `m::PrivTrait::method` is private + --> $DIR/private-inferred-type.rs:41:9 | -LL | ::method; //~ ERROR type `fn() {::method}` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | ::method; //~ ERROR method `m::PrivTrait::method` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^ private ... LL | m::m!(); | -------- in this macro invocation -error: type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct}` is private - --> $DIR/private-inferred-type.rs:45:9 +error: struct `m::PrivTupleStruct` is private + --> $DIR/private-inferred-type.rs:43:9 | LL | PrivTupleStruct; - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ private ... LL | m::m!(); | -------- in this macro invocation -error: type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct}` is private - --> $DIR/private-inferred-type.rs:47:9 - | -LL | PubTupleStruct; - | ^^^^^^^^^^^^^^ -... -LL | m::m!(); - | -------- in this macro invocation - -error: type `for<'r> fn(&'r m::Pub) {>::priv_method}` is private - --> $DIR/private-inferred-type.rs:49:18 +error: method `>::priv_method` is private + --> $DIR/private-inferred-type.rs:45:18 | LL | Pub(0u8).priv_method(); - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ private ... LL | m::m!(); | -------- in this macro invocation error: trait `m::Trait` is private - --> $DIR/private-inferred-type.rs:118:5 + --> $DIR/private-inferred-type.rs:117:5 | LL | m::leak_anon1(); //~ ERROR trait `m::Trait` is private - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:119:5 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:118:5 | -LL | m::leak_anon2(); //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^ +LL | m::leak_anon2(); //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:120:5 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:119:5 | -LL | m::leak_anon3(); //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^ +LL | m::leak_anon3(); //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^^ private error: trait `m::Trait` is private - --> $DIR/private-inferred-type.rs:122:5 + --> $DIR/private-inferred-type.rs:121:5 | LL | m::leak_dyn1(); //~ ERROR trait `m::Trait` is private - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:123:5 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:122:5 | -LL | m::leak_dyn2(); //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^ +LL | m::leak_dyn2(); //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:124:5 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:123:5 | -LL | m::leak_dyn3(); //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^ +LL | m::leak_dyn3(); //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:127:13 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:126:13 | -LL | let a = m::Alias {}; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^ +LL | let a = m::Alias {}; //~ ERROR struct `m::Priv` is private + | ^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:128:17 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:127:17 | -LL | let mut b = a; //~ ERROR type `m::Priv` is private - | ^ +LL | let mut b = a; //~ ERROR struct `m::Priv` is private + | ^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:129:9 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:128:9 | -LL | b = a; //~ ERROR type `m::Priv` is private - | ^ +LL | b = a; //~ ERROR struct `m::Priv` is private + | ^ private -error: type `m::Priv` is private - --> $DIR/private-inferred-type.rs:130:11 +error: struct `m::Priv` is private + --> $DIR/private-inferred-type.rs:129:11 | -LL | match a { //~ ERROR type `m::Priv` is private - | ^ +LL | match a { //~ ERROR struct `m::Priv` is private + | ^ private error[E0446]: private type `m::Priv` in public interface - --> $DIR/private-inferred-type.rs:61:36 + --> $DIR/private-inferred-type.rs:57:36 | LL | struct Priv; | - `m::Priv` declared as private @@ -212,7 +203,7 @@ LL | impl TraitWithAssocTy for u8 { type AssocTy = Priv; } | ^^^^^^^^^^^^^^^^^^^^ can't leak private type error[E0446]: private type `adjust::S2` in public interface - --> $DIR/private-inferred-type.rs:83:9 + --> $DIR/private-inferred-type.rs:79:9 | LL | struct S2; | - `adjust::S2` declared as private @@ -220,6 +211,6 @@ LL | struct S2; LL | type Target = S2Alias; //~ ERROR private type `adjust::S2` in public interface | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type -error: aborting due to 33 previous errors +error: aborting due to 32 previous errors For more information about this error, try `rustc --explain E0446`. diff --git a/src/test/ui/privacy/private-struct-field-ctor.stderr b/src/test/ui/privacy/private-struct-field-ctor.stderr index 943abeed114c8..902ffd951dc15 100644 --- a/src/test/ui/privacy/private-struct-field-ctor.stderr +++ b/src/test/ui/privacy/private-struct-field-ctor.stderr @@ -1,8 +1,16 @@ error[E0451]: field `x` of struct `a::Foo` is private --> $DIR/private-struct-field-ctor.rs:8:22 | -LL | let s = a::Foo { x: 1 }; //~ ERROR field `x` of struct `a::Foo` is private - | ^^^^ field `x` is private +LL | / pub struct Foo { +LL | | x: isize +LL | | } + | |_____- `a::Foo` defined here +... +LL | let s = a::Foo { x: 1 }; //~ ERROR field `x` of struct `a::Foo` is private + | ---------^^^^-- + | | | + | | private field + | `a::Foo` cannot be built due to private field error: aborting due to previous error diff --git a/src/test/ui/privacy/private-struct-field-pattern.stderr b/src/test/ui/privacy/private-struct-field-pattern.stderr index 05e6d3d724313..679b1818626c8 100644 --- a/src/test/ui/privacy/private-struct-field-pattern.stderr +++ b/src/test/ui/privacy/private-struct-field-pattern.stderr @@ -1,8 +1,16 @@ error[E0451]: field `x` of struct `a::Foo` is private --> $DIR/private-struct-field-pattern.rs:15:15 | -LL | Foo { x: _ } => {} //~ ERROR field `x` of struct `a::Foo` is private - | ^^^^ field `x` is private +LL | / pub struct Foo { +LL | | x: isize +LL | | } + | |_____- `a::Foo` defined here +... +LL | Foo { x: _ } => {} //~ ERROR field `x` of struct `a::Foo` is private + | ------^^^^-- + | | | + | | private field + | `a::Foo` cannot be destructured due to private field error: aborting due to previous error diff --git a/src/test/ui/privacy/private-type-in-interface.rs b/src/test/ui/privacy/private-type-in-interface.rs index 359b6da1d799e..2da474db98afc 100644 --- a/src/test/ui/privacy/private-type-in-interface.rs +++ b/src/test/ui/privacy/private-type-in-interface.rs @@ -12,19 +12,26 @@ mod m { impl Trait for Priv { type X = u8; } } -fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private - //~^ ERROR type `m::Priv` is private -fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private - //~^ ERROR type `ext::Priv` is private +fn f(_: m::Alias) {} +//~^ ERROR struct `m::Priv` is private +//~| ERROR struct `m::Priv` is private +fn f_ext(_: ext::Alias) {} +//~^ ERROR struct `ext::Priv` is private +//~| ERROR struct `ext::Priv` is private trait Tr1 {} -impl m::Alias {} //~ ERROR type `m::Priv` is private -impl Tr1 for ext::Alias {} //~ ERROR type `ext::Priv` is private -type A = ::X; //~ ERROR type `m::Priv` is private +impl m::Alias {} +//~^ ERROR struct `m::Priv` is private +impl Tr1 for ext::Alias {} +//~^ ERROR struct `ext::Priv` is private +type A = ::X; +//~^ ERROR struct `m::Priv` is private trait Tr2 {} impl Tr2 for u8 {} -fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private -fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private +fn g() -> impl Tr2 { 0 } +//~^ ERROR struct `m::Priv` is private +fn g_ext() -> impl Tr2 { 0 } +//~^ ERROR struct `ext::Priv` is private fn main() {} diff --git a/src/test/ui/privacy/private-type-in-interface.stderr b/src/test/ui/privacy/private-type-in-interface.stderr index b436f20fce981..dc35e5553b69b 100644 --- a/src/test/ui/privacy/private-type-in-interface.stderr +++ b/src/test/ui/privacy/private-type-in-interface.stderr @@ -1,56 +1,56 @@ -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-type-in-interface.rs:15:9 | -LL | fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private - | ^^^^^^^^ +LL | fn f(_: m::Alias) {} + | ^^^^^^^^ private -error: type `m::Priv` is private +error: struct `m::Priv` is private --> $DIR/private-type-in-interface.rs:15:6 | -LL | fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private - | ^ +LL | fn f(_: m::Alias) {} + | ^ private -error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:17:13 +error: struct `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:18:13 | -LL | fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private - | ^^^^^^^^^^ +LL | fn f_ext(_: ext::Alias) {} + | ^^^^^^^^^^ private -error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:17:10 +error: struct `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:18:10 | -LL | fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private - | ^ +LL | fn f_ext(_: ext::Alias) {} + | ^ private -error: type `m::Priv` is private - --> $DIR/private-type-in-interface.rs:21:6 +error: struct `m::Priv` is private + --> $DIR/private-type-in-interface.rs:23:6 | -LL | impl m::Alias {} //~ ERROR type `m::Priv` is private - | ^^^^^^^^ +LL | impl m::Alias {} + | ^^^^^^^^ private -error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:22:14 +error: struct `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:25:14 | -LL | impl Tr1 for ext::Alias {} //~ ERROR type `ext::Priv` is private - | ^^^^^^^^^^ +LL | impl Tr1 for ext::Alias {} + | ^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-type-in-interface.rs:23:10 +error: struct `m::Priv` is private + --> $DIR/private-type-in-interface.rs:27:10 | -LL | type A = ::X; //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type A = ::X; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ private -error: type `m::Priv` is private - --> $DIR/private-type-in-interface.rs:27:11 +error: struct `m::Priv` is private + --> $DIR/private-type-in-interface.rs:32:11 | -LL | fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^^^^^^ +LL | fn g() -> impl Tr2 { 0 } + | ^^^^^^^^^^^^^^^^^^ private -error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:28:15 +error: struct `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:34:15 | -LL | fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private - | ^^^^^^^^^^^^^^^^^^^^ +LL | fn g_ext() -> impl Tr2 { 0 } + | ^^^^^^^^^^^^^^^^^^^^ private error: aborting due to 9 previous errors diff --git a/src/test/ui/privacy/restricted/struct-literal-field.stderr b/src/test/ui/privacy/restricted/struct-literal-field.stderr index 0109cae91a0c8..1f32d39a51c5c 100644 --- a/src/test/ui/privacy/restricted/struct-literal-field.stderr +++ b/src/test/ui/privacy/restricted/struct-literal-field.stderr @@ -1,8 +1,16 @@ error[E0451]: field `x` of struct `foo::bar::S` is private --> $DIR/struct-literal-field.rs:18:9 | -LL | S { x: 0 }; //~ ERROR private - | ^^^^ field `x` is private +LL | / pub struct S { +LL | | pub(in foo) x: i32, +LL | | } + | |_________- `foo::bar::S` defined here +... +LL | S { x: 0 }; //~ ERROR private + | ----^^^^-- + | | | + | | private field + | `foo::bar::S` cannot be built due to private field error: aborting due to previous error diff --git a/src/test/ui/privacy/union-field-privacy-1.stderr b/src/test/ui/privacy/union-field-privacy-1.stderr index d31360dbe6511..95ae59f742098 100644 --- a/src/test/ui/privacy/union-field-privacy-1.stderr +++ b/src/test/ui/privacy/union-field-privacy-1.stderr @@ -1,14 +1,34 @@ error[E0451]: field `c` of union `m::U` is private --> $DIR/union-field-privacy-1.rs:12:20 | -LL | let u = m::U { c: 0 }; //~ ERROR field `c` of union `m::U` is private - | ^^^^ field `c` is private +LL | / pub union U { +LL | | pub a: u8, +LL | | pub(super) b: u8, +LL | | c: u8, +LL | | } + | |_____- `m::U` defined here +... +LL | let u = m::U { c: 0 }; //~ ERROR field `c` of union `m::U` is private + | -------^^^^-- + | | | + | | private field + | `m::U` cannot be built due to private field error[E0451]: field `c` of union `m::U` is private --> $DIR/union-field-privacy-1.rs:16:16 | -LL | let m::U { c } = u; //~ ERROR field `c` of union `m::U` is private - | ^ field `c` is private +LL | / pub union U { +LL | | pub a: u8, +LL | | pub(super) b: u8, +LL | | c: u8, +LL | | } + | |_____- `m::U` defined here +... +LL | let m::U { c } = u; //~ ERROR field `c` of union `m::U` is private + | -------^-- + | | | + | | private field + | `m::U` cannot be destructured due to private field error: aborting due to 2 previous errors diff --git a/src/test/ui/resolve/privacy-struct-ctor-2.rs b/src/test/ui/resolve/privacy-struct-ctor-2.rs new file mode 100644 index 0000000000000..55645673a7bff --- /dev/null +++ b/src/test/ui/resolve/privacy-struct-ctor-2.rs @@ -0,0 +1,38 @@ +// aux-build:privacy-struct-ctor.rs + +extern crate privacy_struct_ctor as xcrate; + +mod m { + pub struct S(u8); + pub struct S2 { + s: u8 + } + + pub mod n { + pub(in m) struct Z(pub(in m::n) u8); + } + + use m::n::Z; // OK, only the type is imported + + fn f() { + n::Z; + //~^ ERROR tuple struct `n::Z` is private + } +} + +use m::S; // OK, only the type is imported +use m::S2; // OK, only the type is imported + +fn main() { + m::S; + //~^ ERROR tuple struct `m::S` is private + let _: S = m::S(2); + //~^ ERROR field `0` of struct `m::S` is private + m::n::Z; + //~^ ERROR struct `m::n::Z` is private + + xcrate::m::S; + //~^ ERROR struct `xcrate::S` is private + xcrate::m::n::Z; + //~^ ERROR struct `xcrate::m::n::Z` is private +} diff --git a/src/test/ui/resolve/privacy-struct-ctor-2.stderr b/src/test/ui/resolve/privacy-struct-ctor-2.stderr new file mode 100644 index 0000000000000..bce593dd4c4c7 --- /dev/null +++ b/src/test/ui/resolve/privacy-struct-ctor-2.stderr @@ -0,0 +1,44 @@ +error[E0451]: field `0` of struct `m::S` is private + --> $DIR/privacy-struct-ctor-2.rs:29:21 + | +LL | pub struct S(u8); + | ----------------- `m::S` defined here +... +LL | let _: S = m::S(2); + | ---- ^ private field + | | + | `m::S` cannot be built due to private field + +error: tuple struct `m::S` is private + --> $DIR/privacy-struct-ctor-2.rs:27:5 + | +LL | m::S; + | ^^^^ tuple struct not accesssible from here + +error: struct `m::n::Z` is private + --> $DIR/privacy-struct-ctor-2.rs:31:5 + | +LL | m::n::Z; + | ^^^^^^^ private + +error: struct `xcrate::S` is private + --> $DIR/privacy-struct-ctor-2.rs:34:5 + | +LL | xcrate::m::S; + | ^^^^^^^^^^^^ private + +error: struct `xcrate::m::n::Z` is private + --> $DIR/privacy-struct-ctor-2.rs:36:5 + | +LL | xcrate::m::n::Z; + | ^^^^^^^^^^^^^^^ private + +error: tuple struct `n::Z` is private + --> $DIR/privacy-struct-ctor-2.rs:18:9 + | +LL | n::Z; + | ^^^^ tuple struct not accesssible from here + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/resolve/privacy-struct-ctor.rs b/src/test/ui/resolve/privacy-struct-ctor.rs index 0b389acf75d8b..2f41282777b40 100644 --- a/src/test/ui/resolve/privacy-struct-ctor.rs +++ b/src/test/ui/resolve/privacy-struct-ctor.rs @@ -15,8 +15,6 @@ mod m { use m::n::Z; // OK, only the type is imported fn f() { - n::Z; - //~^ ERROR tuple struct `Z` is private Z; //~^ ERROR expected value, found struct `Z` } @@ -26,22 +24,12 @@ use m::S; // OK, only the type is imported use m::S2; // OK, only the type is imported fn main() { - m::S; - //~^ ERROR tuple struct `S` is private - let _: S = m::S(2); - //~^ ERROR tuple struct `S` is private S; //~^ ERROR expected value, found struct `S` - m::n::Z; - //~^ ERROR tuple struct `Z` is private S2; //~^ ERROR expected value, found struct `S2` - xcrate::m::S; - //~^ ERROR tuple struct `S` is private xcrate::S; //~^ ERROR expected value, found struct `xcrate::S` - xcrate::m::n::Z; - //~^ ERROR tuple struct `Z` is private } diff --git a/src/test/ui/resolve/privacy-struct-ctor.stderr b/src/test/ui/resolve/privacy-struct-ctor.stderr index 44ecf6b97bf50..9347c3d73569f 100644 --- a/src/test/ui/resolve/privacy-struct-ctor.stderr +++ b/src/test/ui/resolve/privacy-struct-ctor.stderr @@ -1,5 +1,5 @@ error[E0423]: expected value, found struct `Z` - --> $DIR/privacy-struct-ctor.rs:20:9 + --> $DIR/privacy-struct-ctor.rs:18:9 | LL | Z; | ^ constructor is not visible here due to private fields @@ -13,7 +13,7 @@ LL | use m::n::Z; | error[E0423]: expected value, found struct `S` - --> $DIR/privacy-struct-ctor.rs:33:5 + --> $DIR/privacy-struct-ctor.rs:27:5 | LL | S; | ^ constructor is not visible here due to private fields @@ -23,13 +23,13 @@ LL | use m::S; | error[E0423]: expected value, found struct `S2` - --> $DIR/privacy-struct-ctor.rs:38:5 + --> $DIR/privacy-struct-ctor.rs:30:5 | LL | S2; | ^^ did you mean `S2 { /* fields */ }`? error[E0423]: expected value, found struct `xcrate::S` - --> $DIR/privacy-struct-ctor.rs:43:5 + --> $DIR/privacy-struct-ctor.rs:33:5 | LL | xcrate::S; | ^^^^^^^^^ constructor is not visible here due to private fields @@ -38,43 +38,6 @@ help: possible better candidate is found in another module, you can import it in LL | use m::S; | -error[E0603]: tuple struct `Z` is private - --> $DIR/privacy-struct-ctor.rs:18:12 - | -LL | n::Z; - | ^ - -error[E0603]: tuple struct `S` is private - --> $DIR/privacy-struct-ctor.rs:29:8 - | -LL | m::S; - | ^ - -error[E0603]: tuple struct `S` is private - --> $DIR/privacy-struct-ctor.rs:31:19 - | -LL | let _: S = m::S(2); - | ^ - -error[E0603]: tuple struct `Z` is private - --> $DIR/privacy-struct-ctor.rs:35:11 - | -LL | m::n::Z; - | ^ - -error[E0603]: tuple struct `S` is private - --> $DIR/privacy-struct-ctor.rs:41:16 - | -LL | xcrate::m::S; - | ^ - -error[E0603]: tuple struct `Z` is private - --> $DIR/privacy-struct-ctor.rs:45:19 - | -LL | xcrate::m::n::Z; - | ^ - -error: aborting due to 10 previous errors +error: aborting due to 4 previous errors -Some errors occurred: E0423, E0603. -For more information about an error, try `rustc --explain E0423`. +For more information about this error, try `rustc --explain E0423`. diff --git a/src/test/ui/rfc-2008-non-exhaustive/structs-2.rs b/src/test/ui/rfc-2008-non-exhaustive/structs-2.rs new file mode 100644 index 0000000000000..994b56b0fe5be --- /dev/null +++ b/src/test/ui/rfc-2008-non-exhaustive/structs-2.rs @@ -0,0 +1,9 @@ +// aux-build:structs.rs +extern crate structs; + +use structs::{NormalStruct, UnitStruct, TupleStruct, FunctionalRecord}; + +fn main() { + let ts_explicit = structs::TupleStruct(640, 480); + //~^ ERROR struct `structs::TupleStruct` is private +} diff --git a/src/test/ui/rfc-2008-non-exhaustive/structs-2.stderr b/src/test/ui/rfc-2008-non-exhaustive/structs-2.stderr new file mode 100644 index 0000000000000..569b80dcb6996 --- /dev/null +++ b/src/test/ui/rfc-2008-non-exhaustive/structs-2.stderr @@ -0,0 +1,8 @@ +error: struct `structs::TupleStruct` is private + --> $DIR/structs-2.rs:7:23 + | +LL | let ts_explicit = structs::TupleStruct(640, 480); + | ^^^^^^^^^^^^^^^^^^^^ private + +error: aborting due to previous error + diff --git a/src/test/ui/rfc-2008-non-exhaustive/structs.rs b/src/test/ui/rfc-2008-non-exhaustive/structs.rs index 303d71d12df33..e1dffd4527f44 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/structs.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/structs.rs @@ -20,9 +20,6 @@ fn main() { let ts = TupleStruct(640, 480); //~^ ERROR expected function, found struct `TupleStruct` [E0423] - let ts_explicit = structs::TupleStruct(640, 480); - //~^ ERROR tuple struct `TupleStruct` is private [E0603] - let TupleStruct { 0: first_field, 1: second_field } = ts; //~^ ERROR `..` required with struct marked as non-exhaustive diff --git a/src/test/ui/rfc-2008-non-exhaustive/structs.stderr b/src/test/ui/rfc-2008-non-exhaustive/structs.stderr index 4532b5c34cc0f..02e626760c382 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/structs.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/structs.stderr @@ -5,19 +5,13 @@ LL | let ts = TupleStruct(640, 480); | ^^^^^^^^^^^ constructor is not visible here due to private fields error[E0423]: expected value, found struct `UnitStruct` - --> $DIR/structs.rs:29:14 + --> $DIR/structs.rs:26:14 | LL | let us = UnitStruct; | ^^^^^^^^^^ constructor is not visible here due to private fields -error[E0603]: tuple struct `TupleStruct` is private - --> $DIR/structs.rs:23:32 - | -LL | let ts_explicit = structs::TupleStruct(640, 480); - | ^^^^^^^^^^^ - error[E0603]: unit struct `UnitStruct` is private - --> $DIR/structs.rs:32:32 + --> $DIR/structs.rs:29:32 | LL | let us_explicit = structs::UnitStruct; | ^^^^^^^^^^ @@ -47,18 +41,18 @@ LL | let NormalStruct { first_field, second_field } = ns; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0638]: `..` required with struct marked as non-exhaustive - --> $DIR/structs.rs:26:9 + --> $DIR/structs.rs:23:9 | LL | let TupleStruct { 0: first_field, 1: second_field } = ts; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0638]: `..` required with struct marked as non-exhaustive - --> $DIR/structs.rs:35:9 + --> $DIR/structs.rs:32:9 | LL | let UnitStruct { } = us; | ^^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +error: aborting due to 8 previous errors Some errors occurred: E0423, E0603, E0638, E0639. For more information about an error, try `rustc --explain E0423`.