From 3c103fb9531b97f37af3fe8a0bd4752786a13070 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Thu, 14 May 2026 19:55:47 +0800 Subject: [PATCH 1/5] Impl lint UNUSED_UNCONSTRUCTABLE_PUB_STRUCT --- compiler/rustc_lint_defs/src/builtin.rs | 43 +++++ compiler/rustc_middle/src/middle/dead_code.rs | 6 +- compiler/rustc_passes/src/dead.rs | 159 ++++++++++++++++-- compiler/rustc_passes/src/errors.rs | 10 ++ .../external-api-path.rs | 11 ++ .../intentional-marker-fields.rs | 26 +++ .../local-construction.rs | 29 ++++ .../name-and-reachability-exemptions.rs | 11 ++ .../private-constructor.rs | 17 ++ .../private-constructor.stderr | 31 ++++ .../receiver-methods-do-not-construct.rs | 26 +++ .../receiver-methods-do-not-construct.stderr | 15 ++ .../repr-exemptions.rs | 11 ++ 13 files changed, 377 insertions(+), 18 deletions(-) create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/external-api-path.rs create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/intentional-marker-fields.rs create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/local-construction.rs create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/name-and-reachability-exemptions.rs create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/private-constructor.rs create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/private-constructor.stderr create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/receiver-methods-do-not-construct.rs create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/receiver-methods-do-not-construct.stderr create mode 100644 tests/ui/lint/unused-unconstructable-pub-struct/repr-exemptions.rs diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index c6892419443f8..69eedba7798c7 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -150,6 +150,7 @@ declare_lint_pass! { UNUSED_MACRO_RULES, UNUSED_MUT, UNUSED_QUALIFICATIONS, + UNUSED_UNCONSTRUCTABLE_PUB_STRUCT, UNUSED_UNSAFE, UNUSED_VARIABLES, UNUSED_VISIBILITIES, @@ -821,6 +822,48 @@ declare_lint! { crate_level_only } +declare_lint! { + /// The `unused_unconstructable_pub_struct` lint detects public structs + /// with private fields that cannot be constructed or otherwise used through + /// the external API. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// #![deny(unused_unconstructable_pub_struct)] + /// + /// pub struct Foo(i32); + /// # fn main() {} + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// This lint is emitted for a `pub` struct when: + /// + /// * It has private fields and no public constructor, so downstream crates + /// cannot construct a value of the type. + /// * It is not used locally and does not appear in any reachable path from + /// external APIs other than the public struct item itself. + /// * It has no field that marks intentional unconstructability, such as a + /// field with unit or never type. + /// + /// Such structs may have been unused for a long time, but are now effectively dead code. + /// This lint helps find those items. + /// + /// To silence the warning for individual items, prefix the name with an + /// underscore such as `_Foo`. + /// + /// To indicate that the behavior is intentional, add a field with unit or + /// never type if the struct is only used at the type level. + /// + /// Otherwise, consider removing it if the struct is no longer in use. + pub UNUSED_UNCONSTRUCTABLE_PUB_STRUCT, + Allow, + "detects public structs with private fields that cannot be constructed or otherwise used through the external API" +} + declare_lint! { /// The `unused_attributes` lint detects attributes that were not used by /// the compiler. diff --git a/compiler/rustc_middle/src/middle/dead_code.rs b/compiler/rustc_middle/src/middle/dead_code.rs index 06275e1e0f3a0..4c78ba5e7e5fb 100644 --- a/compiler/rustc_middle/src/middle/dead_code.rs +++ b/compiler/rustc_middle/src/middle/dead_code.rs @@ -11,13 +11,17 @@ pub struct DeadCodeLivenessSnapshot { pub ignored_derived_traits: LocalDefIdMap>, } -/// Dead-code liveness data for both analysis phases. +/// Dead-code liveness data for different analysis phases. /// /// `pre_deferred_seeding` is computed before reachable-public and `#[allow(dead_code)]` seeding, /// and is used for lint `dead_code_pub_in_binary`. +/// `pre_unconstructable_pubs` is computed before reachable public structs that cannot be +/// directly constructed externally are seeded, and is used for lint +/// `unused_unconstructable_pub_struct`. /// `final_result` is the final liveness snapshot used for lint `dead_code`. #[derive(Clone, Debug, StableHash)] pub struct DeadCodeLivenessSummary { pub pre_deferred_seeding: DeadCodeLivenessSnapshot, + pub pre_unconstructable_pubs: DeadCodeLivenessSnapshot, pub final_result: DeadCodeLivenessSnapshot, } diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 5d3ea7e2c237c..eb2e0674bfffd 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -10,7 +10,7 @@ use hir::def_id::{LocalDefIdMap, LocalDefIdSet}; use rustc_abi::FieldIdx; use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_errors::{ErrorGuaranteed, MultiSpan}; -use rustc_hir::def::{CtorOf, DefKind, Res}; +use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId}; use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{self as hir, ForeignItemId, ItemId, Node, PatKind, QPath, find_attr}; @@ -21,13 +21,15 @@ use rustc_middle::query::Providers; use rustc_middle::ty::{self, AssocTag, TyCtxt}; use rustc_middle::{bug, span_bug}; use rustc_session::config::CrateType; -use rustc_session::lint::builtin::{DEAD_CODE, DEAD_CODE_PUB_IN_BINARY}; +use rustc_session::lint::builtin::{ + DEAD_CODE, DEAD_CODE_PUB_IN_BINARY, UNUSED_UNCONSTRUCTABLE_PUB_STRUCT, +}; use rustc_session::lint::{self, Lint, LintExpectationId}; use rustc_span::{Symbol, kw}; use crate::errors::{ ChangeFields, DeadCodePubInBinaryNote, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo, - UselessAssignment, + UnusedUnconstructablePubStructNote, UselessAssignment, }; /// Any local definition that may call something in its body block should be explored. For example, @@ -70,6 +72,42 @@ fn should_explore(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { } } +fn struct_can_be_constructed_directly(tcx: TyCtxt<'_>, id: LocalDefId) -> bool { + // Skip language items + if tcx.as_lang_item(id.to_def_id()).is_some() { + return true; + } + + let adt_def = tcx.adt_def(id.to_def_id()); + + // We only care about structs for now + if !adt_def.is_struct() { + return true; + } + + // Such types often declared in Rust but constructed by FFI, so ignore + if adt_def.repr().c() || adt_def.repr().transparent() { + return true; + } + + // Skip types contain fields of unit, never or PhantomData, + // it's usually intentional to make the type not constructible + if adt_def.all_fields().any(|field| { + let field_type = tcx.type_of(field.did).skip_binder(); + field_type.is_unit() || field_type.is_never() + }) { + return true; + } + + adt_def.all_fields().all(|field| field.vis.is_public()) + || adt_def.all_fields().all(|field| tcx.type_of(field.did).skip_binder().is_phantom_data()) +} + +fn method_has_receiver(tcx: TyCtxt<'_>, id: LocalDefId) -> bool { + tcx.hir_fn_decl_by_hir_id(tcx.local_def_id_to_hir_id(id)) + .is_some_and(|fn_decl| fn_decl.implicit_self().has_implicit_self()) +} + /// Determine if a work from the worklist is coming from a `#[allow]` /// or a `#[expect]` of `dead_code` #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] @@ -561,9 +599,12 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { (self.tcx.local_parent(local_def_id), trait_item_id) } // impl items are live if the corresponding traits are live - DefKind::Impl { of_trait: true } => { - (local_def_id, self.tcx.impl_trait_id(local_def_id).as_local()) - } + DefKind::Impl { of_trait } => ( + local_def_id, + of_trait + .then(|| self.tcx.impl_trait_id(local_def_id)) + .and_then(|did| did.as_local()), + ), _ => bug!(), }; @@ -921,12 +962,14 @@ fn maybe_record_as_seed<'tcx>( struct SeedWorklists { worklist: Vec, deferred_seeds: Vec, + deferred_unconstructable_pubs: Vec, unsolved_items: Vec, } fn create_and_seed_worklist(tcx: TyCtxt<'_>) -> SeedWorklists { let mut unsolved_items = Vec::new(); let mut deferred_seeds = Vec::new(); + let mut deferred_unconstructable_pubs = Vec::new(); let mut worklist = Vec::new(); if let Some((def_id, _)) = tcx.entry_fn(()) @@ -940,12 +983,47 @@ fn create_and_seed_worklist(tcx: TyCtxt<'_>) -> SeedWorklists { } for (id, effective_vis) in tcx.effective_visibilities(()).iter() { - if effective_vis.is_public_at_level(Level::Reachable) { - deferred_seeds.push(WorkItem { - id: *id, - propagated: ComesFromAllowExpect::No, - own: ComesFromAllowExpect::No, - }); + if !effective_vis.is_public_at_level(Level::Reachable) { + continue; + } + + let work_item = WorkItem { + id: *id, + propagated: ComesFromAllowExpect::No, + own: ComesFromAllowExpect::No, + }; + + match tcx.def_kind(*id) { + DefKind::Struct if !struct_can_be_constructed_directly(tcx, *id) => { + deferred_unconstructable_pubs.push(work_item); + } + DefKind::Ctor(CtorOf::Struct, CtorKind::Fn) + if !struct_can_be_constructed_directly(tcx, tcx.local_parent(*id)) => + { + deferred_unconstructable_pubs.push(work_item); + } + + DefKind::Impl { of_trait } => { + if !of_trait { + unsolved_items.push(*id); + } + + deferred_unconstructable_pubs.push(work_item); + } + DefKind::AssocFn + if let DefKind::Impl { of_trait } = tcx.def_kind(tcx.local_parent(*id)) + && method_has_receiver(tcx, *id) => + { + if !of_trait { + unsolved_items.push(*id); + } + + deferred_unconstructable_pubs.push(work_item); + } + + _ => { + deferred_seeds.push(work_item); + } } } @@ -958,15 +1036,19 @@ fn create_and_seed_worklist(tcx: TyCtxt<'_>) -> SeedWorklists { maybe_record_as_seed(tcx, id, &mut push_into_worklist, &mut unsolved_items); } - SeedWorklists { worklist, deferred_seeds, unsolved_items } + SeedWorklists { worklist, deferred_seeds, deferred_unconstructable_pubs, unsolved_items } } fn live_symbols_and_ignored_derived_traits( tcx: TyCtxt<'_>, (): (), ) -> Result { - let SeedWorklists { worklist, deferred_seeds, mut unsolved_items } = - create_and_seed_worklist(tcx); + let SeedWorklists { + worklist, + deferred_seeds, + deferred_unconstructable_pubs, + mut unsolved_items, + } = create_and_seed_worklist(tcx); let mut symbol_visitor = MarkSymbolVisitor { worklist, tcx, @@ -989,8 +1071,17 @@ fn live_symbols_and_ignored_derived_traits( symbol_visitor.worklist.extend(deferred_seeds); mark_live_symbols_and_ignored_derived_traits(&mut symbol_visitor, &mut unsolved_items)?; + let pre_unconstructable_pubs = DeadCodeLivenessSnapshot { + live_symbols: symbol_visitor.live_symbols.clone(), + ignored_derived_traits: symbol_visitor.ignored_derived_traits.clone(), + }; + + symbol_visitor.worklist.extend(deferred_unconstructable_pubs); + mark_live_symbols_and_ignored_derived_traits(&mut symbol_visitor, &mut unsolved_items)?; + Ok(DeadCodeLivenessSummary { pre_deferred_seeding, + pre_unconstructable_pubs, final_result: DeadCodeLivenessSnapshot { live_symbols: symbol_visitor.live_symbols, ignored_derived_traits: symbol_visitor.ignored_derived_traits, @@ -1092,6 +1183,13 @@ impl<'tcx> DeadVisitor<'tcx> { self.target_lint.name.eq(DEAD_CODE_PUB_IN_BINARY.name).then_some(DeadCodePubInBinaryNote) } + fn unused_unconstructable_pub_struct_note(&self) -> Option { + self.target_lint + .name + .eq(UNUSED_UNCONSTRUCTABLE_PUB_STRUCT.name) + .then_some(UnusedUnconstructablePubStructNote) + } + // # Panics // All `dead_codes` must have the same lint level, otherwise we will intentionally ICE. // This is because we emit a multi-spanned lint using the lint level of the `dead_codes`'s @@ -1204,6 +1302,8 @@ impl<'tcx> DeadVisitor<'tcx> { participle, name_list, dead_code_pub_in_binary_note: self.dead_code_pub_in_binary_note(), + unused_unconstructable_pub_struct_note: self + .unused_unconstructable_pub_struct_note(), change_fields_suggestion: fields_suggestion, parent_info, ignored_derived_impls, @@ -1241,6 +1341,8 @@ impl<'tcx> DeadVisitor<'tcx> { participle, name_list, dead_code_pub_in_binary_note: self.dead_code_pub_in_binary_note(), + unused_unconstructable_pub_struct_note: self + .unused_unconstructable_pub_struct_note(), parent_info, ignored_derived_impls, enum_variants_with_same_name, @@ -1317,8 +1419,11 @@ impl<'tcx> DeadVisitor<'tcx> { } fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) { - let Ok(DeadCodeLivenessSummary { pre_deferred_seeding, final_result }) = - tcx.live_symbols_and_ignored_derived_traits(()).as_ref() + let Ok(DeadCodeLivenessSummary { + pre_deferred_seeding, + pre_unconstructable_pubs, + final_result, + }) = tcx.live_symbols_and_ignored_derived_traits(()).as_ref() else { return; }; @@ -1344,6 +1449,26 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) { ); } + let is_unused_unconstructable_pub = |def_id| { + tcx.effective_visibilities(()).is_public_at_level(def_id, Level::Reachable) + && !pre_unconstructable_pubs.live_symbols.contains(&def_id) + && tcx.def_kind(def_id) == DefKind::Struct + && !struct_can_be_constructed_directly(tcx, def_id) + }; + lint_dead_codes( + tcx, + UNUSED_UNCONSTRUCTABLE_PUB_STRUCT, + module, + &pre_unconstructable_pubs.live_symbols, + &pre_unconstructable_pubs.ignored_derived_traits, + module_items + .free_items() + .filter(|free_item| is_unused_unconstructable_pub(free_item.owner_id.def_id)), + module_items + .foreign_items() + .filter(|foreign_item| is_unused_unconstructable_pub(foreign_item.owner_id.def_id)), + ); + lint_dead_codes( tcx, DEAD_CODE, diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index b87a43e9fcde0..9a03483379041 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -924,6 +924,8 @@ pub(crate) enum MultipleDeadCodes<'tcx> { #[subdiagnostic] dead_code_pub_in_binary_note: Option, #[subdiagnostic] + unused_unconstructable_pub_struct_note: Option, + #[subdiagnostic] // only on DeadCodes since it's never a problem for tuple struct fields enum_variants_with_same_name: Vec>, #[subdiagnostic] @@ -949,6 +951,8 @@ pub(crate) enum MultipleDeadCodes<'tcx> { #[subdiagnostic] dead_code_pub_in_binary_note: Option, #[subdiagnostic] + unused_unconstructable_pub_struct_note: Option, + #[subdiagnostic] change_fields_suggestion: ChangeFields, #[subdiagnostic] parent_info: Option>, @@ -963,6 +967,12 @@ pub(crate) enum MultipleDeadCodes<'tcx> { )] pub(crate) struct DeadCodePubInBinaryNote; +#[derive(Subdiagnostic)] +#[note( + "this `pub` struct has private fields, no public constructor, and is not otherwise reachable through the external API, so consider providing a public constructor or removing it" +)] +pub(crate) struct UnusedUnconstructablePubStructNote; + #[derive(Subdiagnostic)] #[note( "it is impossible to refer to the {$dead_descr} `{$dead_name}` because it is shadowed by this enum variant with the same name" diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/external-api-path.rs b/tests/ui/lint/unused-unconstructable-pub-struct/external-api-path.rs new file mode 100644 index 0000000000000..d86bae2dbbdca --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/external-api-path.rs @@ -0,0 +1,11 @@ +//@ check-pass + +#![deny(unused_unconstructable_pub_struct)] + +pub struct Foo(i32); + +pub fn foo(x: Foo) { + let _ = x; +} + +fn main() {} diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/intentional-marker-fields.rs b/tests/ui/lint/unused-unconstructable-pub-struct/intentional-marker-fields.rs new file mode 100644 index 0000000000000..2d72dd3b3df5c --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/intentional-marker-fields.rs @@ -0,0 +1,26 @@ +//@ check-pass + +#![feature(never_type)] +#![deny(unused_unconstructable_pub_struct)] + +pub struct TupleNever(!); + +pub struct TupleUnit(()); + +pub struct TuplePhantom(std::marker::PhantomData); + +pub struct NamedNever { + _never: !, + _value: T, +} + +pub struct NamedUnit { + _unit: (), + _value: T, +} + +pub struct NamedPhantom { + _marker: std::marker::PhantomData, +} + +fn main() {} diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/local-construction.rs b/tests/ui/lint/unused-unconstructable-pub-struct/local-construction.rs new file mode 100644 index 0000000000000..587a5cdec41e8 --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/local-construction.rs @@ -0,0 +1,29 @@ +//@ check-pass + +#![deny(unused_unconstructable_pub_struct)] + +pub struct Constructed(i32); + +impl Constructed { + pub fn construct_self() -> Self { + Constructed(0) + } +} + +impl Clone for Constructed { + fn clone(&self) -> Constructed { + Constructed(0) + } +} + +pub trait Trait { + fn method(&self); +} + +impl Trait for Constructed { + fn method(&self) { + self.0; + } +} + +fn main() {} diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/name-and-reachability-exemptions.rs b/tests/ui/lint/unused-unconstructable-pub-struct/name-and-reachability-exemptions.rs new file mode 100644 index 0000000000000..5ae4cdf4b57bd --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/name-and-reachability-exemptions.rs @@ -0,0 +1,11 @@ +//@ check-pass + +#![deny(unused_unconstructable_pub_struct)] + +pub struct _Prefixed(i32); + +mod private { + pub struct Unreachable(i32); +} + +fn main() {} diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/private-constructor.rs b/tests/ui/lint/unused-unconstructable-pub-struct/private-constructor.rs new file mode 100644 index 0000000000000..643c55b543bb7 --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/private-constructor.rs @@ -0,0 +1,17 @@ +#![deny(unused_unconstructable_pub_struct)] + +pub struct PrivateTuple(i32); +//~^ ERROR: struct `PrivateTuple` is never constructed + +pub struct PrivateField { +//~^ ERROR: struct `PrivateField` is never constructed + _field: i32, +} + +pub struct MixedPhantom { +//~^ ERROR: struct `MixedPhantom` is never constructed + _marker: std::marker::PhantomData, + _field: i32, +} + +fn main() {} diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/private-constructor.stderr b/tests/ui/lint/unused-unconstructable-pub-struct/private-constructor.stderr new file mode 100644 index 0000000000000..e49510e8547cb --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/private-constructor.stderr @@ -0,0 +1,31 @@ +error: struct `PrivateTuple` is never constructed + --> $DIR/private-constructor.rs:3:12 + | +LL | pub struct PrivateTuple(i32); + | ^^^^^^^^^^^^ + | + = note: this `pub` struct has private fields, no public constructor, and is not otherwise reachable through the external API, so consider providing a public constructor or removing it +note: the lint level is defined here + --> $DIR/private-constructor.rs:1:9 + | +LL | #![deny(unused_unconstructable_pub_struct)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: struct `PrivateField` is never constructed + --> $DIR/private-constructor.rs:6:12 + | +LL | pub struct PrivateField { + | ^^^^^^^^^^^^ + | + = note: this `pub` struct has private fields, no public constructor, and is not otherwise reachable through the external API, so consider providing a public constructor or removing it + +error: struct `MixedPhantom` is never constructed + --> $DIR/private-constructor.rs:11:12 + | +LL | pub struct MixedPhantom { + | ^^^^^^^^^^^^ + | + = note: this `pub` struct has private fields, no public constructor, and is not otherwise reachable through the external API, so consider providing a public constructor or removing it + +error: aborting due to 3 previous errors + diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/receiver-methods-do-not-construct.rs b/tests/ui/lint/unused-unconstructable-pub-struct/receiver-methods-do-not-construct.rs new file mode 100644 index 0000000000000..741f7dd3cdf6d --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/receiver-methods-do-not-construct.rs @@ -0,0 +1,26 @@ +#![deny(unused_unconstructable_pub_struct)] + +pub struct ReceiverOnly(i32); +//~^ ERROR: struct `ReceiverOnly` is never constructed + +impl ReceiverOnly { + pub fn method(&self) {} +} + +impl Clone for ReceiverOnly { + fn clone(&self) -> ReceiverOnly { + ReceiverOnly(0) + } +} + +pub trait Trait { + fn method(&self); +} + +impl Trait for ReceiverOnly { + fn method(&self) { + self.0; + } +} + +fn main() {} diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/receiver-methods-do-not-construct.stderr b/tests/ui/lint/unused-unconstructable-pub-struct/receiver-methods-do-not-construct.stderr new file mode 100644 index 0000000000000..8d7a7653d5ed2 --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/receiver-methods-do-not-construct.stderr @@ -0,0 +1,15 @@ +error: struct `ReceiverOnly` is never constructed + --> $DIR/receiver-methods-do-not-construct.rs:3:12 + | +LL | pub struct ReceiverOnly(i32); + | ^^^^^^^^^^^^ + | + = note: this `pub` struct has private fields, no public constructor, and is not otherwise reachable through the external API, so consider providing a public constructor or removing it +note: the lint level is defined here + --> $DIR/receiver-methods-do-not-construct.rs:1:9 + | +LL | #![deny(unused_unconstructable_pub_struct)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/unused-unconstructable-pub-struct/repr-exemptions.rs b/tests/ui/lint/unused-unconstructable-pub-struct/repr-exemptions.rs new file mode 100644 index 0000000000000..e1125f6f064d5 --- /dev/null +++ b/tests/ui/lint/unused-unconstructable-pub-struct/repr-exemptions.rs @@ -0,0 +1,11 @@ +//@ check-pass + +#![deny(unused_unconstructable_pub_struct)] + +#[repr(C)] +pub struct CRepr(i32); + +#[repr(transparent)] +pub struct Transparent(i32); + +fn main() {} From 62e367d3d6696372c5465f93e6713ca6b682bd64 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Fri, 15 May 2026 00:26:30 +0800 Subject: [PATCH 2/5] Deny-by-default for crater test --- compiler/rustc_lint_defs/src/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 69eedba7798c7..448d7a1c6859c 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -860,7 +860,7 @@ declare_lint! { /// /// Otherwise, consider removing it if the struct is no longer in use. pub UNUSED_UNCONSTRUCTABLE_PUB_STRUCT, - Allow, + Deny, "detects public structs with private fields that cannot be constructed or otherwise used through the external API" } From 71de0c9856b5fa6ba5867f301d4a53128c104ea2 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Fri, 15 May 2026 00:26:53 +0800 Subject: [PATCH 3/5] Add into unused lint group --- compiler/rustc_lint/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 10fd1d1501b3b..b67a71f536207 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -295,6 +295,7 @@ fn register_builtins(store: &mut LintStore) { UNUSED_VISIBILITIES, UNUSED_ASSIGNMENTS, DEAD_CODE, + UNUSED_UNCONSTRUCTABLE_PUB_STRUCT, UNUSED_MUT, // FIXME: add this lint when it becomes stable, // see https://github.com/rust-lang/rust/issues/115585. From bfe2b220e3fbe35dbd9ea20f00a2c62b5c736f7b Mon Sep 17 00:00:00 2001 From: mu001999 Date: Fri, 15 May 2026 00:27:08 +0800 Subject: [PATCH 4/5] Remove dead code in ra --- .../hir-ty/src/next_solver/infer/mod.rs | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/mod.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/mod.rs index 839bdf17e7589..6b6dd549b34e0 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/mod.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/mod.rs @@ -1,7 +1,6 @@ //! Infer context the next-trait-solver. use std::cell::{Cell, RefCell}; -use std::fmt; use std::ops::Range; use std::sync::Arc; @@ -308,32 +307,6 @@ pub enum BoundRegionConversionTime { AssocTypeProjection(SolverDefId), } -#[derive(Copy, Clone, Debug)] -pub struct FixupError { - unresolved: TyOrConstInferVar, -} - -impl fmt::Display for FixupError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - use TyOrConstInferVar::*; - - match self.unresolved { - TyInt(_) => write!( - f, - "cannot determine the type of this integer; \ - add a suffix to specify the type explicitly" - ), - TyFloat(_) => write!( - f, - "cannot determine the type of this number; \ - add a suffix to specify the type explicitly" - ), - Ty(_) => write!(f, "unconstrained type"), - Const(_) => write!(f, "unconstrained const value"), - } - } -} - /// See the `region_obligations` field for more information. #[derive(Clone, Debug)] pub struct TypeOutlivesConstraint<'db> { From 0a2343e1e6ba6826634976b587f678d2c97b6a4f Mon Sep 17 00:00:00 2001 From: mu001999 Date: Sat, 16 May 2026 20:22:36 +0800 Subject: [PATCH 5/5] Bless tests --- tests/assembly-llvm/asm/arm-types.rs | 2 +- tests/assembly-llvm/asm/powerpc-types.rs | 2 +- tests/assembly-llvm/asm/s390x-types.rs | 2 +- tests/assembly-llvm/simd-bitmask.rs | 2 +- tests/assembly-llvm/simd-intrinsic-select.rs | 2 +- tests/codegen-llvm/is_val_statically_known.rs | 1 + tests/codegen-llvm/simd/extract-insert-dyn.rs | 2 +- .../item-collection/generic-impl.rs | 1 + .../item-collection/overloaded-operators.rs | 1 + tests/crashes/130797.rs | 2 + tests/crashes/98322.rs | 1 + tests/incremental/auxiliary/issue-79661.rs | 1 + .../issue-79661-missing-def-path-hash.rs | 1 + .../mir-opt/pre-codegen/derived_ord_debug.rs | 1 + tests/pretty/issue-4264.pp | 1 + tests/pretty/issue-4264.rs | 1 + .../reproducible-build.rs | 2 +- .../reproducible-build/reproducible-build.rs | 2 +- .../inline_cross/auxiliary/issue-46727.rs | 2 + .../auxiliary/extern-builtin-type-impl-dep.rs | 1 + .../reexport/auxiliary/wrap-unnamable-type.rs | 2 + .../auxiliary/parent-crate-115718.rs | 2 + .../auxiliary/reexport-search_unbox.rs | 1 + .../issue-115259-suggest-iter-mut.fixed | 1 + .../borrowck/issue-115259-suggest-iter-mut.rs | 1 + .../issue-115259-suggest-iter-mut.stderr | 2 +- .../struct-with-reference-to-trait-5708.rs | 1 + .../auxiliary/coherence_copy_like_lib.rs | 1 + tests/ui/coherence/auxiliary/coherence_lib.rs | 1 + .../auxiliary/unsized_const_param.rs | 1 + .../adt_const_params/unsized_field-1.rs | 1 + .../adt_const_params/unsized_field-1.stderr | 12 +- .../auxiliary/generics_of_parent.rs | 1 + .../auxiliary/trait_object_lt_defaults_lib.rs | 1 + .../defaults/trait_object_lt_defaults.rs | 1 + .../generic_const_exprs/associated-consts.rs | 1 + .../parent_generics_of_encoding.rs | 1 + .../auxiliary/xcrate_unit_struct.rs | 1 + tests/ui/cross-crate/unit-struct.stderr | 4 +- tests/ui/extern/auxiliary/fat_drop.rs | 1 + tests/ui/extern/extern_fat_drop.rs | 1 + tests/ui/issues/auxiliary/issue-31702-2.rs | 1 + tests/ui/issues/issue-31702.rs | 1 + tests/ui/issues/issue-4875.rs | 1 + ...-dont-override-forbid-in-same-scope.stderr | 18 ++ tests/ui/lint/outer-forbid.stderr | 18 ++ tests/ui/packed/auxiliary/packed.rs | 1 + ...re-clause-before-tuple-struct-body-0.fixed | 1 + ...where-clause-before-tuple-struct-body-0.rs | 1 + ...e-clause-before-tuple-struct-body-0.stderr | 4 +- .../ui/pattern/usefulness/auxiliary/empty.rs | 1 + ...tch-check-notes.exhaustive_patterns.stderr | 14 +- .../empty-match-check-notes.normal.stderr | 14 +- .../usefulness/empty-match-check-notes.rs | 1 + tests/ui/pattern/usefulness/uninhabited.rs | 1 + .../auxiliary/non_exhaustive_with_private.rs | 1 + .../privacy/auxiliary/privacy_tuple_struct.rs | 1 + ...vate-fields-diagnostic-aux-issue-151408.rs | 1 + .../auxiliary/private-inferred-type.rs | 1 + ...n-exhaustive-with-private-fields-147513.rs | 1 + ...haustive-with-private-fields-147513.stderr | 4 +- tests/ui/privacy/privacy5.rs | 1 + tests/ui/privacy/privacy5.stderr | 240 +++++++++--------- .../private-fields-diagnostic-issue-151408.rs | 1 + ...vate-fields-diagnostic-issue-151408.stderr | 10 +- tests/ui/privacy/private-inferred-type-2.rs | 1 + .../ui/privacy/private-inferred-type-2.stderr | 6 +- tests/ui/privacy/private-inferred-type-3.rs | 1 + .../ui/privacy/private-inferred-type-3.stderr | 14 +- tests/ui/privacy/private-type-in-interface.rs | 1 + .../privacy/private-type-in-interface.stderr | 18 +- tests/ui/pub/pub-ident-struct-4.fixed | 1 + tests/ui/pub/pub-ident-struct-4.rs | 1 + tests/ui/pub/pub-ident-struct-4.stderr | 2 +- .../reachable/auxiliary/foreign-priv-aux.rs | 1 + tests/ui/reachable/foreign-priv.rs | 1 + tests/ui/regions/regions-issue-21422.rs | 1 + tests/ui/regions/regions-issue-22246.rs | 1 + .../uninhabited/auxiliary/uninhabited.rs | 1 + .../uninhabited/coercions.rs | 1 + .../uninhabited/coercions.stderr | 8 +- .../uninhabited/indirect_match.rs | 1 + .../uninhabited/indirect_match.stderr | 16 +- ...indirect_match_with_exhaustive_patterns.rs | 1 + ...rect_match_with_exhaustive_patterns.stderr | 16 +- .../issue-65157-repeated-match-arm.rs | 1 + .../issue-65157-repeated-match-arm.stderr | 2 +- .../uninhabited/match.rs | 1 + .../uninhabited/match.stderr | 8 +- .../match_with_exhaustive_patterns.rs | 1 + .../match_with_exhaustive_patterns.stderr | 4 +- .../uninhabited/patterns.rs | 1 + .../uninhabited/patterns.stderr | 8 +- .../rfcs/rfc-2093-infer-outlives/privacy.rs | 1 + tests/ui/static/auxiliary/nested_item.rs | 1 + tests/ui/static/nested_item_main.rs | 1 + .../structs/auxiliary/struct_field_privacy.rs | 1 + tests/ui/structs/struct-field-privacy.rs | 1 + tests/ui/structs/struct-field-privacy.stderr | 10 +- tests/ui/structs/suggest-private-fields.rs | 1 + .../ui/structs/suggest-private-fields.stderr | 8 +- .../auxiliary/generics_other_crate.rs | 2 + .../ui/suggestions/derive-clone-for-eq.fixed | 1 + tests/ui/suggestions/derive-clone-for-eq.rs | 1 + .../ui/suggestions/derive-clone-for-eq.stderr | 4 +- .../ui/suggestions/option-content-move.fixed | 1 + tests/ui/suggestions/option-content-move.rs | 1 + .../ui/suggestions/option-content-move.stderr | 4 +- tests/ui/traits/issue-4107.rs | 1 + tests/ui/traits/object/generics.rs | 1 + tests/ui/traits/where-clause-vs-impl.rs | 1 + .../auxiliary/drop-shim-relates-opaque-aux.rs | 1 + .../typeck/auxiliary/tdticc_coherence_lib.rs | 1 + 113 files changed, 344 insertions(+), 224 deletions(-) diff --git a/tests/assembly-llvm/asm/arm-types.rs b/tests/assembly-llvm/asm/arm-types.rs index 2022c86ef2e04..048933c8d23a6 100644 --- a/tests/assembly-llvm/asm/arm-types.rs +++ b/tests/assembly-llvm/asm/arm-types.rs @@ -12,7 +12,7 @@ #![feature(no_core, repr_simd, f16)] #![crate_type = "rlib"] #![no_core] -#![allow(asm_sub_register, non_camel_case_types)] +#![allow(asm_sub_register, non_camel_case_types, unused_unconstructable_pub_struct)] extern crate minicore; use minicore::*; diff --git a/tests/assembly-llvm/asm/powerpc-types.rs b/tests/assembly-llvm/asm/powerpc-types.rs index 076b216d019e8..1a00fcdd37ee9 100644 --- a/tests/assembly-llvm/asm/powerpc-types.rs +++ b/tests/assembly-llvm/asm/powerpc-types.rs @@ -16,7 +16,7 @@ #![feature(no_core, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] -#![allow(asm_sub_register, non_camel_case_types)] +#![allow(asm_sub_register, non_camel_case_types, unused_unconstructable_pub_struct)] extern crate minicore; use minicore::*; diff --git a/tests/assembly-llvm/asm/s390x-types.rs b/tests/assembly-llvm/asm/s390x-types.rs index 75bcfd5b026f3..a255c42eb2d0e 100644 --- a/tests/assembly-llvm/asm/s390x-types.rs +++ b/tests/assembly-llvm/asm/s390x-types.rs @@ -10,7 +10,7 @@ #![feature(no_core, repr_simd, f16, f128)] #![crate_type = "rlib"] #![no_core] -#![allow(asm_sub_register, non_camel_case_types)] +#![allow(asm_sub_register, non_camel_case_types, unused_unconstructable_pub_struct)] extern crate minicore; use minicore::*; diff --git a/tests/assembly-llvm/simd-bitmask.rs b/tests/assembly-llvm/simd-bitmask.rs index 115d76e8ba927..54a4135c654c2 100644 --- a/tests/assembly-llvm/simd-bitmask.rs +++ b/tests/assembly-llvm/simd-bitmask.rs @@ -15,7 +15,7 @@ #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] -#![allow(non_camel_case_types)] +#![allow(non_camel_case_types, unused_unconstructable_pub_struct)] extern crate minicore; use minicore::*; diff --git a/tests/assembly-llvm/simd-intrinsic-select.rs b/tests/assembly-llvm/simd-intrinsic-select.rs index 84ae6568b742a..74ee470d8c5a8 100644 --- a/tests/assembly-llvm/simd-intrinsic-select.rs +++ b/tests/assembly-llvm/simd-intrinsic-select.rs @@ -13,7 +13,7 @@ #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] -#![allow(non_camel_case_types)] +#![allow(non_camel_case_types, unused_unconstructable_pub_struct)] extern crate minicore; use minicore::*; diff --git a/tests/codegen-llvm/is_val_statically_known.rs b/tests/codegen-llvm/is_val_statically_known.rs index 8119d3a3bf678..341fd7e07db87 100644 --- a/tests/codegen-llvm/is_val_statically_known.rs +++ b/tests/codegen-llvm/is_val_statically_known.rs @@ -2,6 +2,7 @@ #![feature(core_intrinsics)] #![feature(f16, f128)] +#![allow(unused_unconstructable_pub_struct)] use std::intrinsics::is_val_statically_known; diff --git a/tests/codegen-llvm/simd/extract-insert-dyn.rs b/tests/codegen-llvm/simd/extract-insert-dyn.rs index e634841fae79d..597e23f21193a 100644 --- a/tests/codegen-llvm/simd/extract-insert-dyn.rs +++ b/tests/codegen-llvm/simd/extract-insert-dyn.rs @@ -9,7 +9,7 @@ )] #![no_std] #![crate_type = "lib"] -#![allow(non_camel_case_types)] +#![allow(non_camel_case_types, unused_unconstructable_pub_struct)] // Test that `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}` // lower to an LLVM extractelement or insertelement operation. diff --git a/tests/codegen-units/item-collection/generic-impl.rs b/tests/codegen-units/item-collection/generic-impl.rs index deebb9cd35116..282dd75d09a34 100644 --- a/tests/codegen-units/item-collection/generic-impl.rs +++ b/tests/codegen-units/item-collection/generic-impl.rs @@ -1,6 +1,7 @@ //@ compile-flags:-Clink-dead-code -Zinline-mir=no #![deny(dead_code)] +#![allow(unused_unconstructable_pub_struct)] #![crate_type = "lib"] struct Struct { diff --git a/tests/codegen-units/item-collection/overloaded-operators.rs b/tests/codegen-units/item-collection/overloaded-operators.rs index a4db80bc8fc51..bd7844270b114 100644 --- a/tests/codegen-units/item-collection/overloaded-operators.rs +++ b/tests/codegen-units/item-collection/overloaded-operators.rs @@ -1,6 +1,7 @@ //@ compile-flags:-Clink-dead-code #![deny(dead_code)] +#![allow(unused_unconstructable_pub_struct)] #![crate_type = "lib"] use std::ops::{Add, Deref, Index, IndexMut}; diff --git a/tests/crashes/130797.rs b/tests/crashes/130797.rs index e9c877d92a6e9..90f37e4bb1320 100644 --- a/tests/crashes/130797.rs +++ b/tests/crashes/130797.rs @@ -1,5 +1,7 @@ //@ known-bug: #130797 +#![allow(unused_unconstructable_pub_struct)] + trait Transform { type Output<'a>; } diff --git a/tests/crashes/98322.rs b/tests/crashes/98322.rs index 57b349160294b..b315fb0b11a86 100644 --- a/tests/crashes/98322.rs +++ b/tests/crashes/98322.rs @@ -1,6 +1,7 @@ //@ known-bug: #98322 #![feature(generic_const_exprs)] +#![allow(unused_unconstructable_pub_struct)] // Main function seems irrelevant fn main() {} diff --git a/tests/incremental/auxiliary/issue-79661.rs b/tests/incremental/auxiliary/issue-79661.rs index cd32a52ebfd21..86a441c567cda 100644 --- a/tests/incremental/auxiliary/issue-79661.rs +++ b/tests/incremental/auxiliary/issue-79661.rs @@ -1,4 +1,5 @@ #![feature(rustc_attrs)] +#![allow(unused_unconstructable_pub_struct)] #[cfg_attr(any(rpass2, rpass3), doc = "Some comment")] pub struct Foo; diff --git a/tests/incremental/issue-79661-missing-def-path-hash.rs b/tests/incremental/issue-79661-missing-def-path-hash.rs index f26f680c67e80..576e73396f3f9 100644 --- a/tests/incremental/issue-79661-missing-def-path-hash.rs +++ b/tests/incremental/issue-79661-missing-def-path-hash.rs @@ -11,5 +11,6 @@ extern crate issue_79661; use issue_79661::Wrapper; +#[allow(unused_unconstructable_pub_struct)] pub struct Outer(Wrapper); fn main() {} diff --git a/tests/mir-opt/pre-codegen/derived_ord_debug.rs b/tests/mir-opt/pre-codegen/derived_ord_debug.rs index 82851509d666f..8badd8b20af48 100644 --- a/tests/mir-opt/pre-codegen/derived_ord_debug.rs +++ b/tests/mir-opt/pre-codegen/derived_ord_debug.rs @@ -4,6 +4,7 @@ #![crate_type = "lib"] #[derive(PartialOrd, Ord, PartialEq, Eq)] +#[allow(unused_unconstructable_pub_struct)] pub struct MultiField(char, i16); // EMIT_MIR derived_ord_debug.{impl#0}-partial_cmp.runtime-optimized.after.mir diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp index d73ad35d62228..836c2f5c71804 100644 --- a/tests/pretty/issue-4264.pp +++ b/tests/pretty/issue-4264.pp @@ -41,6 +41,7 @@ struct Bar { x: [i32; (3 as usize)], } +#[allow(unused_unconstructable_pub_struct)] struct TupleBar([i32; (4 as usize)]); enum Baz { BazVariant([i32; (5 as usize)]), } fn id(x: T) -> T ({ (x as T) } as T) diff --git a/tests/pretty/issue-4264.rs b/tests/pretty/issue-4264.rs index 09840234b8c0c..8f3b420febb88 100644 --- a/tests/pretty/issue-4264.rs +++ b/tests/pretty/issue-4264.rs @@ -23,6 +23,7 @@ pub struct Bar { pub x: [i32; 3] } +#[allow(unused_unconstructable_pub_struct)] pub struct TupleBar([i32; 4]); pub enum Baz { diff --git a/tests/run-make/reproducible-build-2/reproducible-build.rs b/tests/run-make/reproducible-build-2/reproducible-build.rs index 849b3d510af81..9bb2dbbe5e33b 100644 --- a/tests/run-make/reproducible-build-2/reproducible-build.rs +++ b/tests/run-make/reproducible-build-2/reproducible-build.rs @@ -20,7 +20,7 @@ // ignore-tidy-linelength -#![allow(dead_code, warnings)] +#![allow(dead_code, warnings, unused_unconstructable_pub_struct)] extern crate reproducible_build_aux; diff --git a/tests/run-make/reproducible-build/reproducible-build.rs b/tests/run-make/reproducible-build/reproducible-build.rs index 849b3d510af81..9bb2dbbe5e33b 100644 --- a/tests/run-make/reproducible-build/reproducible-build.rs +++ b/tests/run-make/reproducible-build/reproducible-build.rs @@ -20,7 +20,7 @@ // ignore-tidy-linelength -#![allow(dead_code, warnings)] +#![allow(dead_code, warnings, unused_unconstructable_pub_struct)] extern crate reproducible_build_aux; diff --git a/tests/rustdoc-html/inline_cross/auxiliary/issue-46727.rs b/tests/rustdoc-html/inline_cross/auxiliary/issue-46727.rs index acfc418f9f1d6..50f4737abd746 100644 --- a/tests/rustdoc-html/inline_cross/auxiliary/issue-46727.rs +++ b/tests/rustdoc-html/inline_cross/auxiliary/issue-46727.rs @@ -1,5 +1,7 @@ //@ compile-flags: -Cmetadata=aux +#![allow(unused_unconstructable_pub_struct)] + pub trait Foo {} pub struct Bar { x: T } diff --git a/tests/rustdoc-html/intra-doc/auxiliary/extern-builtin-type-impl-dep.rs b/tests/rustdoc-html/intra-doc/auxiliary/extern-builtin-type-impl-dep.rs index f0662fd82f191..e89359a530068 100644 --- a/tests/rustdoc-html/intra-doc/auxiliary/extern-builtin-type-impl-dep.rs +++ b/tests/rustdoc-html/intra-doc/auxiliary/extern-builtin-type-impl-dep.rs @@ -3,6 +3,7 @@ #![feature(lang_items, rustc_attrs)] #![crate_type = "rlib"] #![no_std] +#![allow(unused_unconstructable_pub_struct)] pub struct DerefsToF64(f64); diff --git a/tests/rustdoc-html/reexport/auxiliary/wrap-unnamable-type.rs b/tests/rustdoc-html/reexport/auxiliary/wrap-unnamable-type.rs index 7f8e346c8beac..f9a09760fdf0c 100644 --- a/tests/rustdoc-html/reexport/auxiliary/wrap-unnamable-type.rs +++ b/tests/rustdoc-html/reexport/auxiliary/wrap-unnamable-type.rs @@ -1,3 +1,5 @@ +#![allow(unused_unconstructable_pub_struct)] + pub trait Assoc { type Ty; } diff --git a/tests/rustdoc-html/type-alias/auxiliary/parent-crate-115718.rs b/tests/rustdoc-html/type-alias/auxiliary/parent-crate-115718.rs index 3607612c27ae5..3c1b38bd77d3b 100644 --- a/tests/rustdoc-html/type-alias/auxiliary/parent-crate-115718.rs +++ b/tests/rustdoc-html/type-alias/auxiliary/parent-crate-115718.rs @@ -1,3 +1,5 @@ +#![allow(unused_unconstructable_pub_struct)] + pub struct MyStruct(T); pub trait MyTrait1 { diff --git a/tests/rustdoc-js/auxiliary/reexport-search_unbox.rs b/tests/rustdoc-js/auxiliary/reexport-search_unbox.rs index ee9b6acfedd5c..36cb4997b6417 100644 --- a/tests/rustdoc-js/auxiliary/reexport-search_unbox.rs +++ b/tests/rustdoc-js/auxiliary/reexport-search_unbox.rs @@ -1,4 +1,5 @@ #![feature(rustdoc_internals)] +#![allow(unused_unconstructable_pub_struct)] #[doc(search_unbox)] pub struct Inside(T); diff --git a/tests/ui/borrowck/issue-115259-suggest-iter-mut.fixed b/tests/ui/borrowck/issue-115259-suggest-iter-mut.fixed index 14ac4a9ff5d0a..977cd779e123d 100644 --- a/tests/ui/borrowck/issue-115259-suggest-iter-mut.fixed +++ b/tests/ui/borrowck/issue-115259-suggest-iter-mut.fixed @@ -1,6 +1,7 @@ //@ run-rustfix #![allow(unused_mut)] #![allow(dead_code)] +#![allow(unused_unconstructable_pub_struct)] pub trait Layer { fn process(&mut self) -> u32; diff --git a/tests/ui/borrowck/issue-115259-suggest-iter-mut.rs b/tests/ui/borrowck/issue-115259-suggest-iter-mut.rs index b0e0d8aeb5638..030b1839220bb 100644 --- a/tests/ui/borrowck/issue-115259-suggest-iter-mut.rs +++ b/tests/ui/borrowck/issue-115259-suggest-iter-mut.rs @@ -1,6 +1,7 @@ //@ run-rustfix #![allow(unused_mut)] #![allow(dead_code)] +#![allow(unused_unconstructable_pub_struct)] pub trait Layer { fn process(&mut self) -> u32; diff --git a/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr b/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr index 60ff010193fd2..9449c1ad195a3 100644 --- a/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr +++ b/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `**layer` as mutable, as it is behind a `&` reference - --> $DIR/issue-115259-suggest-iter-mut.rs:15:65 + --> $DIR/issue-115259-suggest-iter-mut.rs:16:65 | LL | self.layers.iter().fold(0, |result, mut layer| result + layer.process()) | ^^^^^ `layer` is a `&` reference, so it cannot be borrowed as mutable diff --git a/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs b/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs index 5157a3bf36b52..9ac67a0dbded5 100644 --- a/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs +++ b/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] // https://github.com/rust-lang/rust/issues/5708 //@ run-pass #![allow(unused_variables)] diff --git a/tests/ui/coherence/auxiliary/coherence_copy_like_lib.rs b/tests/ui/coherence/auxiliary/coherence_copy_like_lib.rs index b5b4802c112de..0c675c86d7f42 100644 --- a/tests/ui/coherence/auxiliary/coherence_copy_like_lib.rs +++ b/tests/ui/coherence/auxiliary/coherence_copy_like_lib.rs @@ -1,5 +1,6 @@ #![crate_type = "rlib"] #![feature(fundamental)] +#![allow(unused_unconstructable_pub_struct)] pub trait MyCopy { } impl MyCopy for i32 { } diff --git a/tests/ui/coherence/auxiliary/coherence_lib.rs b/tests/ui/coherence/auxiliary/coherence_lib.rs index c22819831ab24..5b23fe530e84a 100644 --- a/tests/ui/coherence/auxiliary/coherence_lib.rs +++ b/tests/ui/coherence/auxiliary/coherence_lib.rs @@ -1,4 +1,5 @@ #![crate_type="lib"] +#![allow(unused_unconstructable_pub_struct)] pub trait Remote { fn foo(&self) { } diff --git a/tests/ui/const-generics/adt_const_params/auxiliary/unsized_const_param.rs b/tests/ui/const-generics/adt_const_params/auxiliary/unsized_const_param.rs index 1bfd7c3465613..1eef015254e9f 100644 --- a/tests/ui/const-generics/adt_const_params/auxiliary/unsized_const_param.rs +++ b/tests/ui/const-generics/adt_const_params/auxiliary/unsized_const_param.rs @@ -1,4 +1,5 @@ #![feature(adt_const_params, unsized_const_params)] +#![allow(unused_unconstructable_pub_struct)] #[derive(std::marker::ConstParamTy, Eq, PartialEq)] pub struct Foo([u8]); diff --git a/tests/ui/const-generics/adt_const_params/unsized_field-1.rs b/tests/ui/const-generics/adt_const_params/unsized_field-1.rs index f2d972612dc64..4281624496b16 100644 --- a/tests/ui/const-generics/adt_const_params/unsized_field-1.rs +++ b/tests/ui/const-generics/adt_const_params/unsized_field-1.rs @@ -1,5 +1,6 @@ //@ aux-build:unsized_const_param.rs #![feature(adt_const_params)] +#![allow(unused_unconstructable_pub_struct)] extern crate unsized_const_param; diff --git a/tests/ui/const-generics/adt_const_params/unsized_field-1.stderr b/tests/ui/const-generics/adt_const_params/unsized_field-1.stderr index 2538b811618bb..6b9c826deb3a2 100644 --- a/tests/ui/const-generics/adt_const_params/unsized_field-1.stderr +++ b/tests/ui/const-generics/adt_const_params/unsized_field-1.stderr @@ -1,5 +1,5 @@ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/unsized_field-1.rs:9:8 + --> $DIR/unsized_field-1.rs:10:8 | LL | #[derive(ConstParamTy, Eq, PartialEq)] | ------------ in this derive macro expansion @@ -7,13 +7,13 @@ LL | struct A([u8]); | ^ ---- this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `[u8]` requires that `feature(unsized_const_params) is enabled` - --> $DIR/unsized_field-1.rs:9:10 + --> $DIR/unsized_field-1.rs:10:10 | LL | struct A([u8]); | ^^^^ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/unsized_field-1.rs:13:8 + --> $DIR/unsized_field-1.rs:14:8 | LL | #[derive(ConstParamTy, Eq, PartialEq)] | ------------ in this derive macro expansion @@ -21,13 +21,13 @@ LL | struct B(&'static [u8]); | ^ ------------- this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `&'static [u8]` requires that `feature(unsized_const_params) is enabled` - --> $DIR/unsized_field-1.rs:13:10 + --> $DIR/unsized_field-1.rs:14:10 | LL | struct B(&'static [u8]); | ^^^^^^^^^^^^^ error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type - --> $DIR/unsized_field-1.rs:20:8 + --> $DIR/unsized_field-1.rs:21:8 | LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)] | ------------------------- in this derive macro expansion @@ -35,7 +35,7 @@ LL | struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>); | ^ ---------------------------------------------------------- this field does not implement `ConstParamTy_` | note: the `ConstParamTy_` impl for `GenericNotUnsizedParam<&'static [u8]>` requires that `feature(unsized_const_params) is enabled` - --> $DIR/unsized_field-1.rs:20:10 + --> $DIR/unsized_field-1.rs:21:10 | LL | struct D(unsized_const_param::GenericNotUnsizedParam<&'static [u8]>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/auxiliary/generics_of_parent.rs b/tests/ui/const-generics/auxiliary/generics_of_parent.rs index 5009fe4698534..8d1930c5379b1 100644 --- a/tests/ui/const-generics/auxiliary/generics_of_parent.rs +++ b/tests/ui/const-generics/auxiliary/generics_of_parent.rs @@ -1,4 +1,5 @@ #![feature(generic_const_exprs)] +#![allow(unused_unconstructable_pub_struct)] // library portion of regression test for #87674 pub struct Foo([(); N + 1]) diff --git a/tests/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs b/tests/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs index 26a2c47ffb26d..0d6adca5c169d 100644 --- a/tests/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs +++ b/tests/ui/const-generics/defaults/auxiliary/trait_object_lt_defaults_lib.rs @@ -1 +1,2 @@ +#![allow(unused_unconstructable_pub_struct)] pub struct Foo<'a, const N: usize, T: 'a + ?Sized>(pub &'a T, [(); N]); diff --git a/tests/ui/const-generics/defaults/trait_object_lt_defaults.rs b/tests/ui/const-generics/defaults/trait_object_lt_defaults.rs index da25c0146c543..03d7db736b421 100644 --- a/tests/ui/const-generics/defaults/trait_object_lt_defaults.rs +++ b/tests/ui/const-generics/defaults/trait_object_lt_defaults.rs @@ -1,6 +1,7 @@ //@ aux-build:trait_object_lt_defaults_lib.rs //@ run-pass #![allow(dead_code, unused)] +#![allow(unused_unconstructable_pub_struct)] extern crate trait_object_lt_defaults_lib; // Tests that `A<'a, 3, dyn Test>` is short for `A<'a, 3, dyn Test + 'a>` diff --git a/tests/ui/const-generics/generic_const_exprs/associated-consts.rs b/tests/ui/const-generics/generic_const_exprs/associated-consts.rs index 5d2198f50ad92..2ea3ccda0c741 100644 --- a/tests/ui/const-generics/generic_const_exprs/associated-consts.rs +++ b/tests/ui/const-generics/generic_const_exprs/associated-consts.rs @@ -1,6 +1,7 @@ //@ run-pass #![feature(generic_const_exprs)] #![allow(incomplete_features)] +#![allow(unused_unconstructable_pub_struct)] pub trait BlockCipher { const BLOCK_SIZE: usize; diff --git a/tests/ui/const-generics/parent_generics_of_encoding.rs b/tests/ui/const-generics/parent_generics_of_encoding.rs index 1f9c8c5bc75a1..af150fbb428e0 100644 --- a/tests/ui/const-generics/parent_generics_of_encoding.rs +++ b/tests/ui/const-generics/parent_generics_of_encoding.rs @@ -2,6 +2,7 @@ //@ check-pass #![feature(generic_const_exprs)] #![allow(incomplete_features)] +#![allow(unused_unconstructable_pub_struct)] extern crate generics_of_parent; diff --git a/tests/ui/cross-crate/auxiliary/xcrate_unit_struct.rs b/tests/ui/cross-crate/auxiliary/xcrate_unit_struct.rs index 4f8b3508398f2..09e7dbffbd53c 100644 --- a/tests/ui/cross-crate/auxiliary/xcrate_unit_struct.rs +++ b/tests/ui/cross-crate/auxiliary/xcrate_unit_struct.rs @@ -1,4 +1,5 @@ #![crate_type = "lib"] +#![allow(unused_unconstructable_pub_struct)] // used by the rpass test diff --git a/tests/ui/cross-crate/unit-struct.stderr b/tests/ui/cross-crate/unit-struct.stderr index a7e3e4685a997..2c684381817a5 100644 --- a/tests/ui/cross-crate/unit-struct.stderr +++ b/tests/ui/cross-crate/unit-struct.stderr @@ -4,7 +4,7 @@ error[E0423]: expected value, found struct `xcrate_unit_struct::StructWithFields LL | let _ = xcrate_unit_struct::StructWithFields; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `xcrate_unit_struct::StructWithFields { foo: val }` | - ::: $DIR/auxiliary/xcrate_unit_struct.rs:20:1 + ::: $DIR/auxiliary/xcrate_unit_struct.rs:21:1 | LL | pub struct StructWithFields { | --------------------------- `xcrate_unit_struct::StructWithFields` defined here @@ -15,7 +15,7 @@ error[E0423]: expected value, found struct `xcrate_unit_struct::StructWithPrivFi LL | let _ = xcrate_unit_struct::StructWithPrivFields; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - ::: $DIR/auxiliary/xcrate_unit_struct.rs:25:1 + ::: $DIR/auxiliary/xcrate_unit_struct.rs:26:1 | LL | pub struct StructWithPrivFields { | ------------------------------- `xcrate_unit_struct::StructWithPrivFields` defined here diff --git a/tests/ui/extern/auxiliary/fat_drop.rs b/tests/ui/extern/auxiliary/fat_drop.rs index 768d29876b971..9847c25618ea5 100644 --- a/tests/ui/extern/auxiliary/fat_drop.rs +++ b/tests/ui/extern/auxiliary/fat_drop.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] pub static mut DROPPED: bool = false; pub struct S { diff --git a/tests/ui/extern/extern_fat_drop.rs b/tests/ui/extern/extern_fat_drop.rs index 9691f562d8992..6e94ecf4656c3 100644 --- a/tests/ui/extern/extern_fat_drop.rs +++ b/tests/ui/extern/extern_fat_drop.rs @@ -1,6 +1,7 @@ //@ run-pass //@ aux-build:fat_drop.rs +#![allow(unused_unconstructable_pub_struct)] extern crate fat_drop; fn main() { diff --git a/tests/ui/issues/auxiliary/issue-31702-2.rs b/tests/ui/issues/auxiliary/issue-31702-2.rs index 16300b0f5d530..3b853010b1ed2 100644 --- a/tests/ui/issues/auxiliary/issue-31702-2.rs +++ b/tests/ui/issues/auxiliary/issue-31702-2.rs @@ -1,5 +1,6 @@ //@ compile-flags: -g +#![allow(unused_unconstructable_pub_struct)] extern crate issue_31702_1; use std::collections::HashMap; diff --git a/tests/ui/issues/issue-31702.rs b/tests/ui/issues/issue-31702.rs index 1cf01f7f04ecc..b4ec4cc42d91f 100644 --- a/tests/ui/issues/issue-31702.rs +++ b/tests/ui/issues/issue-31702.rs @@ -2,6 +2,7 @@ //@ aux-build:issue-31702-1.rs //@ aux-build:issue-31702-2.rs +#![allow(unused_unconstructable_pub_struct)] // this test is actually entirely in the linked library crates extern crate issue_31702_1; diff --git a/tests/ui/issues/issue-4875.rs b/tests/ui/issues/issue-4875.rs index 5068399ff0db7..ca7de9a1fc34c 100644 --- a/tests/ui/issues/issue-4875.rs +++ b/tests/ui/issues/issue-4875.rs @@ -1,5 +1,6 @@ //@ run-pass #![allow(dead_code)] +#![allow(unused_unconstructable_pub_struct)] // regression test for issue 4875 diff --git a/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr b/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr index 506791fd17269..f40fb73acbb8b 100644 --- a/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr +++ b/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr @@ -431,3 +431,21 @@ note: the lint level is defined here LL | #![forbid(forbidden_lint_groups)] | ^^^^^^^^^^^^^^^^^^^^^ +Future breakage diagnostic: +error: warn(unused) incompatible with previous forbid + --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:22:13 + | +LL | #![forbid(unused)] + | ------ `forbid` level set here +LL | #![deny(unused)] +LL | #![warn(unused)] + | ^^^^^^ overruled by previous forbid + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #81670 +note: the lint level is defined here + --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:17:11 + | +LL | #![forbid(forbidden_lint_groups)] + | ^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/ui/lint/outer-forbid.stderr b/tests/ui/lint/outer-forbid.stderr index 7810ca223f8ad..abe5959176d4a 100644 --- a/tests/ui/lint/outer-forbid.stderr +++ b/tests/ui/lint/outer-forbid.stderr @@ -471,3 +471,21 @@ note: the lint level is defined here LL | #![forbid(forbidden_lint_groups)] | ^^^^^^^^^^^^^^^^^^^^^ +Future breakage diagnostic: +error: allow(unused) incompatible with previous forbid + --> $DIR/outer-forbid.rs:25:9 + | +LL | #![forbid(unused, non_snake_case)] + | ------ `forbid` level set here +... +LL | #[allow(unused)] + | ^^^^^^ overruled by previous forbid + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #81670 +note: the lint level is defined here + --> $DIR/outer-forbid.rs:18:11 + | +LL | #![forbid(forbidden_lint_groups)] + | ^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/ui/packed/auxiliary/packed.rs b/tests/ui/packed/auxiliary/packed.rs index cba166facf4f2..d819143c8afc9 100644 --- a/tests/ui/packed/auxiliary/packed.rs +++ b/tests/ui/packed/auxiliary/packed.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] #[repr(packed)] pub struct P1S5 { a: u8, diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed index 40028307a8cb1..d2cda04b50b23 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] // Regression test for issues #100790 and #106439. //@ run-rustfix diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs index d8dbb4238d206..56972fdd3f06e 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] // Regression test for issues #100790 and #106439. //@ run-rustfix diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr index 66dadd9fd4c24..fda6b8acdf57e 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr @@ -1,5 +1,5 @@ error: where clauses are not allowed before tuple struct bodies - --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:7:1 + --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:8:1 | LL | pub struct Example | ------- while parsing this tuple struct @@ -17,7 +17,7 @@ LL ~ (): Sized; | error: where clauses are not allowed before tuple struct bodies - --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:13:1 + --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:14:1 | LL | struct _Demo | ----- while parsing this tuple struct diff --git a/tests/ui/pattern/usefulness/auxiliary/empty.rs b/tests/ui/pattern/usefulness/auxiliary/empty.rs index 29a03c9e8b50c..c6d38404ab20f 100644 --- a/tests/ui/pattern/usefulness/auxiliary/empty.rs +++ b/tests/ui/pattern/usefulness/auxiliary/empty.rs @@ -1,4 +1,5 @@ #![crate_type = "rlib"] +#![allow(unused_unconstructable_pub_struct)] pub enum EmptyForeignEnum {} pub struct VisiblyUninhabitedForeignStruct { diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr index 4a435bcc8bad9..93e2e1d8debc0 100644 --- a/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-match-check-notes.rs:17:9 + --> $DIR/empty-match-check-notes.rs:18:9 | LL | _ => {} | ^------ @@ -9,13 +9,13 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-match-check-notes.rs:7:9 + --> $DIR/empty-match-check-notes.rs:8:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-match-check-notes.rs:22:9 + --> $DIR/empty-match-check-notes.rs:23:9 | LL | _ if false => {} | ^--------------- @@ -26,7 +26,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-match-check-notes.rs:31:9 + --> $DIR/empty-match-check-notes.rs:32:9 | LL | _ => {} | ^------ @@ -37,7 +37,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-match-check-notes.rs:36:9 + --> $DIR/empty-match-check-notes.rs:37:9 | LL | _ if false => {} | ^--------------- @@ -48,7 +48,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0005]: refutable pattern in local binding - --> $DIR/empty-match-check-notes.rs:43:9 + --> $DIR/empty-match-check-notes.rs:44:9 | LL | let None = *x; | ^^^^ pattern `Some(_)` not covered @@ -63,7 +63,7 @@ LL | if let None = *x { todo!() }; | ++ +++++++++++ error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered - --> $DIR/empty-match-check-notes.rs:53:11 + --> $DIR/empty-match-check-notes.rs:54:11 | LL | match 0u8 { | ^^^ pattern `0_u8..=u8::MAX` not covered diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr b/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr index 4a435bcc8bad9..93e2e1d8debc0 100644 --- a/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-match-check-notes.rs:17:9 + --> $DIR/empty-match-check-notes.rs:18:9 | LL | _ => {} | ^------ @@ -9,13 +9,13 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-match-check-notes.rs:7:9 + --> $DIR/empty-match-check-notes.rs:8:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-match-check-notes.rs:22:9 + --> $DIR/empty-match-check-notes.rs:23:9 | LL | _ if false => {} | ^--------------- @@ -26,7 +26,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-match-check-notes.rs:31:9 + --> $DIR/empty-match-check-notes.rs:32:9 | LL | _ => {} | ^------ @@ -37,7 +37,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-match-check-notes.rs:36:9 + --> $DIR/empty-match-check-notes.rs:37:9 | LL | _ if false => {} | ^--------------- @@ -48,7 +48,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0005]: refutable pattern in local binding - --> $DIR/empty-match-check-notes.rs:43:9 + --> $DIR/empty-match-check-notes.rs:44:9 | LL | let None = *x; | ^^^^ pattern `Some(_)` not covered @@ -63,7 +63,7 @@ LL | if let None = *x { todo!() }; | ++ +++++++++++ error[E0004]: non-exhaustive patterns: `0_u8..=u8::MAX` not covered - --> $DIR/empty-match-check-notes.rs:53:11 + --> $DIR/empty-match-check-notes.rs:54:11 | LL | match 0u8 { | ^^^ pattern `0_u8..=u8::MAX` not covered diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.rs b/tests/ui/pattern/usefulness/empty-match-check-notes.rs index 48d20fd2d5c1b..53981d3155935 100644 --- a/tests/ui/pattern/usefulness/empty-match-check-notes.rs +++ b/tests/ui/pattern/usefulness/empty-match-check-notes.rs @@ -1,5 +1,6 @@ //@ aux-build:empty.rs //@ revisions: normal exhaustive_patterns +#![allow(unused_unconstructable_pub_struct)] // // This tests a match with no arms on various types, and checks NOTEs. #![feature(never_type)] diff --git a/tests/ui/pattern/usefulness/uninhabited.rs b/tests/ui/pattern/usefulness/uninhabited.rs index 2e2c7cae65cbc..cf598146f3017 100644 --- a/tests/ui/pattern/usefulness/uninhabited.rs +++ b/tests/ui/pattern/usefulness/uninhabited.rs @@ -1,6 +1,7 @@ //@ check-pass //@ edition: 2024 //@ aux-build:empty.rs +#![allow(unused_unconstructable_pub_struct)] // // This tests plays with matching and uninhabited types. This also serves as a test for the // `Ty::is_inhabited_from` function. diff --git a/tests/ui/privacy/auxiliary/non_exhaustive_with_private.rs b/tests/ui/privacy/auxiliary/non_exhaustive_with_private.rs index 18e63db0cdd11..443a1ee50658f 100644 --- a/tests/ui/privacy/auxiliary/non_exhaustive_with_private.rs +++ b/tests/ui/privacy/auxiliary/non_exhaustive_with_private.rs @@ -1,5 +1,6 @@ // Auxiliary crate for testing non-exhaustive struct with private fields +#![allow(unused_unconstructable_pub_struct)] #[non_exhaustive] pub struct Foo { pub my_field: u32, diff --git a/tests/ui/privacy/auxiliary/privacy_tuple_struct.rs b/tests/ui/privacy/auxiliary/privacy_tuple_struct.rs index 223cda4b23628..090e7b42c6875 100644 --- a/tests/ui/privacy/auxiliary/privacy_tuple_struct.rs +++ b/tests/ui/privacy/auxiliary/privacy_tuple_struct.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] pub struct A(()); pub struct B(isize); pub struct C(pub isize, isize); diff --git a/tests/ui/privacy/auxiliary/private-fields-diagnostic-aux-issue-151408.rs b/tests/ui/privacy/auxiliary/private-fields-diagnostic-aux-issue-151408.rs index 399d45205c6ab..2239a9374b327 100644 --- a/tests/ui/privacy/auxiliary/private-fields-diagnostic-aux-issue-151408.rs +++ b/tests/ui/privacy/auxiliary/private-fields-diagnostic-aux-issue-151408.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] pub struct Named { hidden: u8, } diff --git a/tests/ui/privacy/auxiliary/private-inferred-type.rs b/tests/ui/privacy/auxiliary/private-inferred-type.rs index 7ac913f5b5bd5..7992035ec6450 100644 --- a/tests/ui/privacy/auxiliary/private-inferred-type.rs +++ b/tests/ui/privacy/auxiliary/private-inferred-type.rs @@ -1,4 +1,5 @@ #![feature(decl_macro)] +#![allow(unused_unconstructable_pub_struct)] fn priv_fn() {} static PRIV_STATIC: u8 = 0; diff --git a/tests/ui/privacy/non-exhaustive-with-private-fields-147513.rs b/tests/ui/privacy/non-exhaustive-with-private-fields-147513.rs index 0553ff6c781e9..b7bb82e34856b 100644 --- a/tests/ui/privacy/non-exhaustive-with-private-fields-147513.rs +++ b/tests/ui/privacy/non-exhaustive-with-private-fields-147513.rs @@ -1,5 +1,6 @@ //@ aux-build:non_exhaustive_with_private.rs +#![allow(unused_unconstructable_pub_struct)] extern crate non_exhaustive_with_private; use non_exhaustive_with_private::{Bar, Foo}; diff --git a/tests/ui/privacy/non-exhaustive-with-private-fields-147513.stderr b/tests/ui/privacy/non-exhaustive-with-private-fields-147513.stderr index 85bf7e4847d73..e9e3b35951d36 100644 --- a/tests/ui/privacy/non-exhaustive-with-private-fields-147513.stderr +++ b/tests/ui/privacy/non-exhaustive-with-private-fields-147513.stderr @@ -1,5 +1,5 @@ error[E0639]: cannot create non-exhaustive struct using struct expression - --> $DIR/non-exhaustive-with-private-fields-147513.rs:8:15 + --> $DIR/non-exhaustive-with-private-fields-147513.rs:9:15 | LL | let foo = Foo { | _______________^ @@ -9,7 +9,7 @@ LL | | }; | |_____^ error[E0639]: cannot create non-exhaustive struct using struct expression - --> $DIR/non-exhaustive-with-private-fields-147513.rs:13:15 + --> $DIR/non-exhaustive-with-private-fields-147513.rs:14:15 | LL | let bar = Bar { | _______________^ diff --git a/tests/ui/privacy/privacy5.rs b/tests/ui/privacy/privacy5.rs index 048189c3433da..56c9bd5120ebb 100644 --- a/tests/ui/privacy/privacy5.rs +++ b/tests/ui/privacy/privacy5.rs @@ -1,5 +1,6 @@ //@ aux-build:privacy_tuple_struct.rs +#![allow(unused_unconstructable_pub_struct)] extern crate privacy_tuple_struct as other; mod a { diff --git a/tests/ui/privacy/privacy5.stderr b/tests/ui/privacy/privacy5.stderr index ec3abe9b81629..c9b51f8be85d0 100644 --- a/tests/ui/privacy/privacy5.stderr +++ b/tests/ui/privacy/privacy5.stderr @@ -1,5 +1,5 @@ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:51:16 + --> $DIR/privacy5.rs:52:16 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private @@ -8,7 +8,7 @@ LL | let a = a::A(()); | ^ private tuple struct constructor | note: the tuple struct constructor `A` is defined here - --> $DIR/privacy5.rs:6:5 + --> $DIR/privacy5.rs:7:5 | LL | pub struct A(()); | ^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | pub struct A(pub ()); | +++ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:52:16 + --> $DIR/privacy5.rs:53:16 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private @@ -27,7 +27,7 @@ LL | let b = a::B(2); | ^ private tuple struct constructor | note: the tuple struct constructor `B` is defined here - --> $DIR/privacy5.rs:7:5 + --> $DIR/privacy5.rs:8:5 | LL | pub struct B(isize); | ^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | pub struct B(pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:53:16 + --> $DIR/privacy5.rs:54:16 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -46,7 +46,7 @@ LL | let c = a::C(2, 3); | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:56:12 + --> $DIR/privacy5.rs:57:12 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private @@ -65,7 +65,7 @@ LL | let a::A(()) = a; | ^ private tuple struct constructor | note: the tuple struct constructor `A` is defined here - --> $DIR/privacy5.rs:6:5 + --> $DIR/privacy5.rs:7:5 | LL | pub struct A(()); | ^^^^^^^^^^^^^^^^^ @@ -75,7 +75,7 @@ LL | pub struct A(pub ()); | +++ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:57:12 + --> $DIR/privacy5.rs:58:12 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private @@ -84,7 +84,7 @@ LL | let a::A(_) = a; | ^ private tuple struct constructor | note: the tuple struct constructor `A` is defined here - --> $DIR/privacy5.rs:6:5 + --> $DIR/privacy5.rs:7:5 | LL | pub struct A(()); | ^^^^^^^^^^^^^^^^^ @@ -94,7 +94,7 @@ LL | pub struct A(pub ()); | +++ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:58:18 + --> $DIR/privacy5.rs:59:18 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private @@ -103,7 +103,7 @@ LL | match a { a::A(()) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `A` is defined here - --> $DIR/privacy5.rs:6:5 + --> $DIR/privacy5.rs:7:5 | LL | pub struct A(()); | ^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | pub struct A(pub ()); | +++ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:59:18 + --> $DIR/privacy5.rs:60:18 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private @@ -122,7 +122,7 @@ LL | match a { a::A(_) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `A` is defined here - --> $DIR/privacy5.rs:6:5 + --> $DIR/privacy5.rs:7:5 | LL | pub struct A(()); | ^^^^^^^^^^^^^^^^^ @@ -132,7 +132,7 @@ LL | pub struct A(pub ()); | +++ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:61:12 + --> $DIR/privacy5.rs:62:12 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private @@ -141,7 +141,7 @@ LL | let a::B(_) = b; | ^ private tuple struct constructor | note: the tuple struct constructor `B` is defined here - --> $DIR/privacy5.rs:7:5 + --> $DIR/privacy5.rs:8:5 | LL | pub struct B(isize); | ^^^^^^^^^^^^^^^^^^^^ @@ -151,7 +151,7 @@ LL | pub struct B(pub isize); | +++ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:62:12 + --> $DIR/privacy5.rs:63:12 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private @@ -160,7 +160,7 @@ LL | let a::B(_b) = b; | ^ private tuple struct constructor | note: the tuple struct constructor `B` is defined here - --> $DIR/privacy5.rs:7:5 + --> $DIR/privacy5.rs:8:5 | LL | pub struct B(isize); | ^^^^^^^^^^^^^^^^^^^^ @@ -170,7 +170,7 @@ LL | pub struct B(pub isize); | +++ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:63:18 + --> $DIR/privacy5.rs:64:18 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private @@ -179,7 +179,7 @@ LL | match b { a::B(_) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `B` is defined here - --> $DIR/privacy5.rs:7:5 + --> $DIR/privacy5.rs:8:5 | LL | pub struct B(isize); | ^^^^^^^^^^^^^^^^^^^^ @@ -189,7 +189,7 @@ LL | pub struct B(pub isize); | +++ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:64:18 + --> $DIR/privacy5.rs:65:18 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private @@ -198,7 +198,7 @@ LL | match b { a::B(_b) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `B` is defined here - --> $DIR/privacy5.rs:7:5 + --> $DIR/privacy5.rs:8:5 | LL | pub struct B(isize); | ^^^^^^^^^^^^^^^^^^^^ @@ -208,7 +208,7 @@ LL | pub struct B(pub isize); | +++ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:65:18 + --> $DIR/privacy5.rs:66:18 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private @@ -217,7 +217,7 @@ LL | match b { a::B(1) => {} a::B(_) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `B` is defined here - --> $DIR/privacy5.rs:7:5 + --> $DIR/privacy5.rs:8:5 | LL | pub struct B(isize); | ^^^^^^^^^^^^^^^^^^^^ @@ -227,7 +227,7 @@ LL | pub struct B(pub isize); | +++ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:65:32 + --> $DIR/privacy5.rs:66:32 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private @@ -236,7 +236,7 @@ LL | match b { a::B(1) => {} a::B(_) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `B` is defined here - --> $DIR/privacy5.rs:7:5 + --> $DIR/privacy5.rs:8:5 | LL | pub struct B(isize); | ^^^^^^^^^^^^^^^^^^^^ @@ -246,7 +246,7 @@ LL | pub struct B(pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:68:12 + --> $DIR/privacy5.rs:69:12 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -255,7 +255,7 @@ LL | let a::C(_, _) = c; | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -265,7 +265,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:69:12 + --> $DIR/privacy5.rs:70:12 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -274,7 +274,7 @@ LL | let a::C(_a, _) = c; | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,7 +284,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:70:12 + --> $DIR/privacy5.rs:71:12 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -293,7 +293,7 @@ LL | let a::C(_, _b) = c; | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -303,7 +303,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:71:12 + --> $DIR/privacy5.rs:72:12 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -312,7 +312,7 @@ LL | let a::C(_a, _b) = c; | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -322,7 +322,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:72:18 + --> $DIR/privacy5.rs:73:18 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -331,7 +331,7 @@ LL | match c { a::C(_, _) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -341,7 +341,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:73:18 + --> $DIR/privacy5.rs:74:18 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -350,7 +350,7 @@ LL | match c { a::C(_a, _) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -360,7 +360,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:74:18 + --> $DIR/privacy5.rs:75:18 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -369,7 +369,7 @@ LL | match c { a::C(_, _b) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -379,7 +379,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:75:18 + --> $DIR/privacy5.rs:76:18 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -388,7 +388,7 @@ LL | match c { a::C(_a, _b) => {} } | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -398,7 +398,7 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:83:17 + --> $DIR/privacy5.rs:84:17 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private @@ -407,7 +407,7 @@ LL | let a2 = a::A; | ^ private tuple struct constructor | note: the tuple struct constructor `A` is defined here - --> $DIR/privacy5.rs:6:5 + --> $DIR/privacy5.rs:7:5 | LL | pub struct A(()); | ^^^^^^^^^^^^^^^^^ @@ -417,7 +417,7 @@ LL | pub struct A(pub ()); | +++ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:84:17 + --> $DIR/privacy5.rs:85:17 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private @@ -426,7 +426,7 @@ LL | let b2 = a::B; | ^ private tuple struct constructor | note: the tuple struct constructor `B` is defined here - --> $DIR/privacy5.rs:7:5 + --> $DIR/privacy5.rs:8:5 | LL | pub struct B(isize); | ^^^^^^^^^^^^^^^^^^^^ @@ -436,7 +436,7 @@ LL | pub struct B(pub isize); | +++ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:85:17 + --> $DIR/privacy5.rs:86:17 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private @@ -445,7 +445,7 @@ LL | let c2 = a::C; | ^ private tuple struct constructor | note: the tuple struct constructor `C` is defined here - --> $DIR/privacy5.rs:8:5 + --> $DIR/privacy5.rs:9:5 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -455,409 +455,409 @@ LL | pub struct C(pub isize, pub isize); | +++ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:90:20 + --> $DIR/privacy5.rs:91:20 | LL | let a = other::A(()); | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private | note: the tuple struct constructor `A` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 | LL | pub struct A(()); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:91:20 + --> $DIR/privacy5.rs:92:20 | LL | let b = other::B(2); | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private | note: the tuple struct constructor `B` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | LL | pub struct B(isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:92:20 + --> $DIR/privacy5.rs:93:20 | LL | let c = other::C(2, 3); | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:95:16 + --> $DIR/privacy5.rs:96:16 | LL | let other::A(()) = a; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private | note: the tuple struct constructor `A` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 | LL | pub struct A(()); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:96:16 + --> $DIR/privacy5.rs:97:16 | LL | let other::A(_) = a; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private | note: the tuple struct constructor `A` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 | LL | pub struct A(()); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:97:22 + --> $DIR/privacy5.rs:98:22 | LL | match a { other::A(()) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private | note: the tuple struct constructor `A` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 | LL | pub struct A(()); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:98:22 + --> $DIR/privacy5.rs:99:22 | LL | match a { other::A(_) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private | note: the tuple struct constructor `A` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 | LL | pub struct A(()); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:100:16 + --> $DIR/privacy5.rs:101:16 | LL | let other::B(_) = b; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private | note: the tuple struct constructor `B` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | LL | pub struct B(isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:101:16 + --> $DIR/privacy5.rs:102:16 | LL | let other::B(_b) = b; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private | note: the tuple struct constructor `B` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | LL | pub struct B(isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:102:22 + --> $DIR/privacy5.rs:103:22 | LL | match b { other::B(_) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private | note: the tuple struct constructor `B` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | LL | pub struct B(isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:103:22 + --> $DIR/privacy5.rs:104:22 | LL | match b { other::B(_b) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private | note: the tuple struct constructor `B` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | LL | pub struct B(isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:104:22 + --> $DIR/privacy5.rs:105:22 | LL | match b { other::B(1) => {} | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private | note: the tuple struct constructor `B` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | LL | pub struct B(isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:105:16 + --> $DIR/privacy5.rs:106:16 | LL | other::B(_) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private | note: the tuple struct constructor `B` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | LL | pub struct B(isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:107:16 + --> $DIR/privacy5.rs:108:16 | LL | let other::C(_, _) = c; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:108:16 + --> $DIR/privacy5.rs:109:16 | LL | let other::C(_a, _) = c; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:109:16 + --> $DIR/privacy5.rs:110:16 | LL | let other::C(_, _b) = c; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:110:16 + --> $DIR/privacy5.rs:111:16 | LL | let other::C(_a, _b) = c; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:111:22 + --> $DIR/privacy5.rs:112:22 | LL | match c { other::C(_, _) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:112:22 + --> $DIR/privacy5.rs:113:22 | LL | match c { other::C(_a, _) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:113:22 + --> $DIR/privacy5.rs:114:22 | LL | match c { other::C(_, _b) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:114:22 + --> $DIR/privacy5.rs:115:22 | LL | match c { other::C(_a, _b) => {} } | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `A` is private - --> $DIR/privacy5.rs:122:21 + --> $DIR/privacy5.rs:123:21 | LL | let a2 = other::A; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 | LL | pub struct A(()); | -- a constructor is private if any of the fields is private | note: the tuple struct constructor `A` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:1:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 | LL | pub struct A(()); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `B` is private - --> $DIR/privacy5.rs:123:21 + --> $DIR/privacy5.rs:124:21 | LL | let b2 = other::B; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 | LL | pub struct B(isize); | ----- a constructor is private if any of the fields is private | note: the tuple struct constructor `B` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:2:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 | LL | pub struct B(isize); | ^^^^^^^^^^^^ error[E0603]: tuple struct constructor `C` is private - --> $DIR/privacy5.rs:124:21 + --> $DIR/privacy5.rs:125:21 | LL | let c2 = other::C; | ^ private tuple struct constructor | - ::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14 + ::: $DIR/auxiliary/privacy_tuple_struct.rs:4:14 | LL | pub struct C(pub isize, isize); | ---------------- a constructor is private if any of the fields is private | note: the tuple struct constructor `C` is defined here - --> $DIR/auxiliary/privacy_tuple_struct.rs:3:1 + --> $DIR/auxiliary/privacy_tuple_struct.rs:4:1 | LL | pub struct C(pub isize, isize); | ^^^^^^^^^^^^ diff --git a/tests/ui/privacy/private-fields-diagnostic-issue-151408.rs b/tests/ui/privacy/private-fields-diagnostic-issue-151408.rs index 456e2d418e2d1..ef2b7319a7f42 100644 --- a/tests/ui/privacy/private-fields-diagnostic-issue-151408.rs +++ b/tests/ui/privacy/private-fields-diagnostic-issue-151408.rs @@ -1,5 +1,6 @@ //@ aux-build:private-fields-diagnostic-aux-issue-151408.rs +#![allow(unused_unconstructable_pub_struct)] extern crate private_fields_diagnostic_aux_issue_151408 as aux; use aux::{Named, NamedWithMultipleFields, PublicTuple}; diff --git a/tests/ui/privacy/private-fields-diagnostic-issue-151408.stderr b/tests/ui/privacy/private-fields-diagnostic-issue-151408.stderr index 1a49a21d6b793..b43f6d9908223 100644 --- a/tests/ui/privacy/private-fields-diagnostic-issue-151408.stderr +++ b/tests/ui/privacy/private-fields-diagnostic-issue-151408.stderr @@ -1,5 +1,5 @@ error: cannot construct `aux::Named` with struct literal syntax due to private fields - --> $DIR/private-fields-diagnostic-issue-151408.rs:8:13 + --> $DIR/private-fields-diagnostic-issue-151408.rs:9:13 | LL | let _ = Named {}; | ^^^^^ @@ -11,13 +11,13 @@ LL + let _ = Named::new(); | error[E0423]: cannot initialize a tuple struct which contains private fields - --> $DIR/private-fields-diagnostic-issue-151408.rs:11:13 + --> $DIR/private-fields-diagnostic-issue-151408.rs:12:13 | LL | let _ = PublicTuple(); | ^^^^^^^^^^^ | note: constructor is not visible here due to private fields - --> $DIR/auxiliary/private-fields-diagnostic-aux-issue-151408.rs:18:24 + --> $DIR/auxiliary/private-fields-diagnostic-aux-issue-151408.rs:19:24 | LL | pub struct PublicTuple(PrivateInner); | ^^^^^^^^^^^^ private field @@ -27,7 +27,7 @@ LL | let _ = PublicTuple::new(); | +++++ error: cannot construct `NamedWithMultipleFields` with struct literal syntax due to private fields - --> $DIR/private-fields-diagnostic-issue-151408.rs:15:13 + --> $DIR/private-fields-diagnostic-issue-151408.rs:16:13 | LL | let _ = NamedWithMultipleFields { visible: 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | let _ = NamedWithMultipleFields { visible: 1 }; = note: ...and other private field `hidden` that was not provided error: cannot construct `NamedWithMultipleFields` with struct literal syntax due to private fields - --> $DIR/private-fields-diagnostic-issue-151408.rs:18:13 + --> $DIR/private-fields-diagnostic-issue-151408.rs:19:13 | LL | let _ = NamedWithMultipleFields {}; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/privacy/private-inferred-type-2.rs b/tests/ui/privacy/private-inferred-type-2.rs index f9cdfe23cab2e..134dac178c3e4 100644 --- a/tests/ui/privacy/private-inferred-type-2.rs +++ b/tests/ui/privacy/private-inferred-type-2.rs @@ -1,5 +1,6 @@ //@ aux-build:private-inferred-type.rs #![allow(private_interfaces)] +#![allow(unused_unconstructable_pub_struct)] extern crate private_inferred_type as ext; diff --git a/tests/ui/privacy/private-inferred-type-2.stderr b/tests/ui/privacy/private-inferred-type-2.stderr index 8a905f5d88ab3..2bf7eea06d88f 100644 --- a/tests/ui/privacy/private-inferred-type-2.stderr +++ b/tests/ui/privacy/private-inferred-type-2.stderr @@ -1,17 +1,17 @@ error: type `Priv` is private - --> $DIR/private-inferred-type-2.rs:17:5 + --> $DIR/private-inferred-type-2.rs:18:5 | LL | m::Pub::get_priv; | ^^^^^^^^^^^^^^^^ private type error: type `Priv` is private - --> $DIR/private-inferred-type-2.rs:18:5 + --> $DIR/private-inferred-type-2.rs:19:5 | LL | m::Pub::static_method; | ^^^^^^^^^^^^^^^^^^^^^ private type error: type `ext::Priv` is private - --> $DIR/private-inferred-type-2.rs:19:5 + --> $DIR/private-inferred-type-2.rs:20:5 | LL | ext::Pub::static_method; | ^^^^^^^^^^^^^^^^^^^^^^^ private type diff --git a/tests/ui/privacy/private-inferred-type-3.rs b/tests/ui/privacy/private-inferred-type-3.rs index 820b0cbb30faa..34d896c4aba68 100644 --- a/tests/ui/privacy/private-inferred-type-3.rs +++ b/tests/ui/privacy/private-inferred-type-3.rs @@ -1,6 +1,7 @@ //@ aux-build:private-inferred-type.rs #![feature(decl_macro)] +#![allow(unused_unconstructable_pub_struct)] extern crate private_inferred_type as ext; diff --git a/tests/ui/privacy/private-inferred-type-3.stderr b/tests/ui/privacy/private-inferred-type-3.stderr index 0b4899c8d3d1d..d4d1e9271740a 100644 --- a/tests/ui/privacy/private-inferred-type-3.stderr +++ b/tests/ui/privacy/private-inferred-type-3.stderr @@ -1,5 +1,5 @@ error: type `fn() {ext::priv_fn}` is private - --> $DIR/private-inferred-type-3.rs:8:5 + --> $DIR/private-inferred-type-3.rs:9:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -7,7 +7,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: static `ext::PRIV_STATIC` is private - --> $DIR/private-inferred-type-3.rs:8:5 + --> $DIR/private-inferred-type-3.rs:9:5 | LL | ext::m!(); | ^^^^^^^^^ private static @@ -15,7 +15,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `ext::PrivEnum` is private - --> $DIR/private-inferred-type-3.rs:8:5 + --> $DIR/private-inferred-type-3.rs:9:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -23,7 +23,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `fn() {::method}` is private - --> $DIR/private-inferred-type-3.rs:8:5 + --> $DIR/private-inferred-type-3.rs:9:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -31,7 +31,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private - --> $DIR/private-inferred-type-3.rs:8:5 + --> $DIR/private-inferred-type-3.rs:9:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -39,7 +39,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private - --> $DIR/private-inferred-type-3.rs:8:5 + --> $DIR/private-inferred-type-3.rs:9:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -47,7 +47,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private - --> $DIR/private-inferred-type-3.rs:8:5 + --> $DIR/private-inferred-type-3.rs:9:5 | LL | ext::m!(); | ^^^^^^^^^ private type diff --git a/tests/ui/privacy/private-type-in-interface.rs b/tests/ui/privacy/private-type-in-interface.rs index 9eadd09867d41..5ca007552d347 100644 --- a/tests/ui/privacy/private-type-in-interface.rs +++ b/tests/ui/privacy/private-type-in-interface.rs @@ -2,6 +2,7 @@ #![allow(warnings)] #![allow(private_interfaces)] +#![allow(unused_unconstructable_pub_struct)] extern crate private_inferred_type as ext; diff --git a/tests/ui/privacy/private-type-in-interface.stderr b/tests/ui/privacy/private-type-in-interface.stderr index 03225d84fdb34..92b8ba70ad6be 100644 --- a/tests/ui/privacy/private-type-in-interface.stderr +++ b/tests/ui/privacy/private-type-in-interface.stderr @@ -1,53 +1,53 @@ error: type `Priv` is private - --> $DIR/private-type-in-interface.rs:16:9 + --> $DIR/private-type-in-interface.rs:17:9 | LL | fn f(_: m::Alias) {} | ^^^^^^^^ private type error: type `Priv` is private - --> $DIR/private-type-in-interface.rs:16:6 + --> $DIR/private-type-in-interface.rs:17:6 | LL | fn f(_: m::Alias) {} | ^ private type error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:18:13 + --> $DIR/private-type-in-interface.rs:19:13 | LL | fn f_ext(_: ext::Alias) {} | ^^^^^^^^^^ private type error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:18:10 + --> $DIR/private-type-in-interface.rs:19:10 | LL | fn f_ext(_: ext::Alias) {} | ^ private type error: type `Priv` is private - --> $DIR/private-type-in-interface.rs:22:6 + --> $DIR/private-type-in-interface.rs:23:6 | LL | impl m::Alias {} | ^^^^^^^^ private type error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:23:14 + --> $DIR/private-type-in-interface.rs:24:14 | LL | impl Tr1 for ext::Alias {} | ^^^^^^^^^^ private type error: type `Priv` is private - --> $DIR/private-type-in-interface.rs:24:10 + --> $DIR/private-type-in-interface.rs:25:10 | LL | type A = ::X; | ^^^^^^^^^^^^^^^^^^^^^^^^^ private type error: type `Priv` is private - --> $DIR/private-type-in-interface.rs:28:11 + --> $DIR/private-type-in-interface.rs:29:11 | LL | fn g() -> impl Tr2 { 0 } | ^^^^^^^^^^^^^^^^^^ private type error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:29:15 + --> $DIR/private-type-in-interface.rs:30:15 | LL | fn g_ext() -> impl Tr2 { 0 } | ^^^^^^^^^^^^^^^^^^^^ private type diff --git a/tests/ui/pub/pub-ident-struct-4.fixed b/tests/ui/pub/pub-ident-struct-4.fixed index 5fedbb7243749..268f2111e6144 100644 --- a/tests/ui/pub/pub-ident-struct-4.fixed +++ b/tests/ui/pub/pub-ident-struct-4.fixed @@ -1,5 +1,6 @@ //@ run-rustfix +#![allow(unused_unconstructable_pub_struct)] pub struct T(#[allow(dead_code)] String); //~^ ERROR missing `struct` for struct definition diff --git a/tests/ui/pub/pub-ident-struct-4.rs b/tests/ui/pub/pub-ident-struct-4.rs index 5c721c25a7815..a98f3b3d0b7b5 100644 --- a/tests/ui/pub/pub-ident-struct-4.rs +++ b/tests/ui/pub/pub-ident-struct-4.rs @@ -1,5 +1,6 @@ //@ run-rustfix +#![allow(unused_unconstructable_pub_struct)] pub T(#[allow(dead_code)] String); //~^ ERROR missing `struct` for struct definition diff --git a/tests/ui/pub/pub-ident-struct-4.stderr b/tests/ui/pub/pub-ident-struct-4.stderr index 04965a1a73720..b92937afafb91 100644 --- a/tests/ui/pub/pub-ident-struct-4.stderr +++ b/tests/ui/pub/pub-ident-struct-4.stderr @@ -1,5 +1,5 @@ error: missing `struct` for struct definition - --> $DIR/pub-ident-struct-4.rs:3:1 + --> $DIR/pub-ident-struct-4.rs:4:1 | LL | pub T(#[allow(dead_code)] String); | ^^^^^ diff --git a/tests/ui/reachable/auxiliary/foreign-priv-aux.rs b/tests/ui/reachable/auxiliary/foreign-priv-aux.rs index 10dc086146139..3f5181e030d94 100644 --- a/tests/ui/reachable/auxiliary/foreign-priv-aux.rs +++ b/tests/ui/reachable/auxiliary/foreign-priv-aux.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] trait PrivTrait { fn priv_fn(&self); } diff --git a/tests/ui/reachable/foreign-priv.rs b/tests/ui/reachable/foreign-priv.rs index 438d480a0b652..f1ded2a2f8cc2 100644 --- a/tests/ui/reachable/foreign-priv.rs +++ b/tests/ui/reachable/foreign-priv.rs @@ -2,6 +2,7 @@ //@ build-pass #![crate_type = "lib"] +#![allow(unused_unconstructable_pub_struct)] extern crate foreign_priv_aux; diff --git a/tests/ui/regions/regions-issue-21422.rs b/tests/ui/regions/regions-issue-21422.rs index 25f5d0f50139f..e065f05375afb 100644 --- a/tests/ui/regions/regions-issue-21422.rs +++ b/tests/ui/regions/regions-issue-21422.rs @@ -1,4 +1,5 @@ //@ run-pass +#![allow(unused_unconstructable_pub_struct)] // Regression test for issue #21422, which was related to failing to // add inference constraints that the operands of a binary operator // should outlive the binary operation itself. diff --git a/tests/ui/regions/regions-issue-22246.rs b/tests/ui/regions/regions-issue-22246.rs index c943f33150eab..15341fff5b494 100644 --- a/tests/ui/regions/regions-issue-22246.rs +++ b/tests/ui/regions/regions-issue-22246.rs @@ -1,5 +1,6 @@ //@ run-pass #![allow(unused_imports)] +#![allow(unused_unconstructable_pub_struct)] // Regression test for issue #22246 -- we should be able to deduce // that `&'a B::Owned` implies that `B::Owned : 'a`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs index e1799761b6961..90300b428fbee 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs @@ -1,5 +1,6 @@ #![crate_type = "rlib"] #![feature(never_type)] +#![allow(unused_unconstructable_pub_struct)] #[non_exhaustive] pub enum UninhabitedEnum { diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.rs index 4804d34a920ca..ac2b3d51a28d2 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.rs @@ -1,5 +1,6 @@ //@ aux-build:uninhabited.rs #![feature(never_type)] +#![allow(unused_unconstructable_pub_struct)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.stderr index c209caab5ecb6..855fa674d5444 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/coercions.rs:23:5 + --> $DIR/coercions.rs:24:5 | LL | fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { | - expected `A` because of return type @@ -7,7 +7,7 @@ LL | x | ^ expected `A`, found `UninhabitedEnum` error[E0308]: mismatched types - --> $DIR/coercions.rs:27:5 + --> $DIR/coercions.rs:28:5 | LL | fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { | - expected `A` because of return type @@ -15,7 +15,7 @@ LL | x | ^ expected `A`, found `UninhabitedTupleStruct` error[E0308]: mismatched types - --> $DIR/coercions.rs:31:5 + --> $DIR/coercions.rs:32:5 | LL | fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { | - expected `A` because of return type @@ -23,7 +23,7 @@ LL | x | ^ expected `A`, found `UninhabitedStruct` error[E0308]: mismatched types - --> $DIR/coercions.rs:35:5 + --> $DIR/coercions.rs:36:5 | LL | fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { | - expected `A` because of return type diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs index c7a7c927c0c23..5c6a7de2af3cf 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs @@ -1,5 +1,6 @@ //@ aux-build:uninhabited.rs #![feature(never_type)] +#![allow(unused_unconstructable_pub_struct)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr index f332e6deeb82c..790ced9275847 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr @@ -1,11 +1,11 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty - --> $DIR/indirect_match.rs:19:11 + --> $DIR/indirect_match.rs:20:11 | LL | match x {} | ^ | note: `IndirectUninhabitedEnum` defined here - --> $DIR/auxiliary/uninhabited.rs:32:1 + --> $DIR/auxiliary/uninhabited.rs:33:1 | LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,13 +18,13 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty - --> $DIR/indirect_match.rs:23:11 + --> $DIR/indirect_match.rs:24:11 | LL | match x {} | ^ | note: `IndirectUninhabitedStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:34:1 + --> $DIR/auxiliary/uninhabited.rs:35:1 | LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,13 +37,13 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty - --> $DIR/indirect_match.rs:27:11 + --> $DIR/indirect_match.rs:28:11 | LL | match x {} | ^ | note: `IndirectUninhabitedTupleStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:36:1 + --> $DIR/auxiliary/uninhabited.rs:37:1 | LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,13 +56,13 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty - --> $DIR/indirect_match.rs:33:11 + --> $DIR/indirect_match.rs:34:11 | LL | match x {} | ^ | note: `IndirectUninhabitedVariants` defined here - --> $DIR/auxiliary/uninhabited.rs:38:1 + --> $DIR/auxiliary/uninhabited.rs:39:1 | LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs index dd9a570522a26..4b0407ce9918e 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs @@ -1,6 +1,7 @@ //@ aux-build:uninhabited.rs #![deny(unreachable_patterns)] #![feature(never_type)] +#![allow(unused_unconstructable_pub_struct)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr index 48f3857bfa7f8..838ec08dccb54 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr @@ -1,11 +1,11 @@ error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:22:11 + --> $DIR/indirect_match_with_exhaustive_patterns.rs:23:11 | LL | match x {} | ^ | note: `IndirectUninhabitedEnum` defined here - --> $DIR/auxiliary/uninhabited.rs:32:1 + --> $DIR/auxiliary/uninhabited.rs:33:1 | LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,13 +18,13 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:26:11 + --> $DIR/indirect_match_with_exhaustive_patterns.rs:27:11 | LL | match x {} | ^ | note: `IndirectUninhabitedStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:34:1 + --> $DIR/auxiliary/uninhabited.rs:35:1 | LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,13 +37,13 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:30:11 + --> $DIR/indirect_match_with_exhaustive_patterns.rs:31:11 | LL | match x {} | ^ | note: `IndirectUninhabitedTupleStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:36:1 + --> $DIR/auxiliary/uninhabited.rs:37:1 | LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,13 +56,13 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:36:11 + --> $DIR/indirect_match_with_exhaustive_patterns.rs:37:11 | LL | match x {} | ^ | note: `IndirectUninhabitedVariants` defined here - --> $DIR/auxiliary/uninhabited.rs:38:1 + --> $DIR/auxiliary/uninhabited.rs:39:1 | LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs index ca7c528715420..a516a9b293496 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs @@ -1,6 +1,7 @@ //@ aux-build:uninhabited.rs #![deny(unreachable_patterns)] #![feature(never_type)] +#![allow(unused_unconstructable_pub_struct)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr index 86df9ef9b564c..ea16431d2f7be 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/issue-65157-repeated-match-arm.rs:15:9 + --> $DIR/issue-65157-repeated-match-arm.rs:16:9 | LL | PartiallyInhabitedVariants::Struct { .. } => {} | ----------------------------------------- matches all the relevant values diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.rs index 58d7bbd2c1730..d8867101ce38c 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.rs @@ -1,5 +1,6 @@ //@ aux-build:uninhabited.rs #![feature(never_type)] +#![allow(unused_unconstructable_pub_struct)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr index 0232e7106aab7..8277eb11d6abb 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr @@ -1,11 +1,11 @@ error[E0004]: non-exhaustive patterns: type `uninhabited::UninhabitedEnum` is non-empty - --> $DIR/match.rs:14:11 + --> $DIR/match.rs:15:11 | LL | match x {} | ^ | note: `uninhabited::UninhabitedEnum` defined here - --> $DIR/auxiliary/uninhabited.rs:5:1 + --> $DIR/auxiliary/uninhabited.rs:6:1 | LL | pub enum UninhabitedEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,13 +18,13 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `uninhabited::PrivatelyUninhabitedStruct` is non-empty - --> $DIR/match.rs:22:11 + --> $DIR/match.rs:23:11 | LL | match x {} | ^ | note: `uninhabited::PrivatelyUninhabitedStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:15:1 + --> $DIR/auxiliary/uninhabited.rs:16:1 | LL | pub struct PrivatelyUninhabitedStruct { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs index c214581549cd7..0c806c79bd2f4 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs @@ -1,6 +1,7 @@ //@ aux-build:uninhabited.rs #![deny(unreachable_patterns)] #![feature(never_type)] +#![allow(unused_unconstructable_pub_struct)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr index d6f0bc724a98d..82233124142ee 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr @@ -1,11 +1,11 @@ error[E0004]: non-exhaustive patterns: type `UninhabitedEnum` is non-empty - --> $DIR/match_with_exhaustive_patterns.rs:17:11 + --> $DIR/match_with_exhaustive_patterns.rs:18:11 | LL | match x {} | ^ | note: `UninhabitedEnum` defined here - --> $DIR/auxiliary/uninhabited.rs:5:1 + --> $DIR/auxiliary/uninhabited.rs:6:1 | LL | pub enum UninhabitedEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs index 088331b0e7f72..57ec1a552b79a 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs @@ -1,6 +1,7 @@ //@ aux-build:uninhabited.rs #![feature(exhaustive_patterns)] #![deny(unreachable_patterns)] +#![allow(unused_unconstructable_pub_struct)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr index 1bb07fd06713c..10cabf46943e4 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/patterns.rs:42:9 + --> $DIR/patterns.rs:43:9 | LL | Some(_x) => (), | ^^^^^^^^------- @@ -15,7 +15,7 @@ LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/patterns.rs:47:15 + --> $DIR/patterns.rs:48:15 | LL | while let PartiallyInhabitedVariants::Struct { x, .. } = partially_inhabited_variant() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `!` is uninhabited @@ -23,7 +23,7 @@ LL | while let PartiallyInhabitedVariants::Struct { x, .. } = partially_inha = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/patterns.rs:49:15 + --> $DIR/patterns.rs:50:15 | LL | while let Some(_x) = uninhabited_struct() { | ^^^^^^^^ matches no values because `UninhabitedStruct` is uninhabited @@ -31,7 +31,7 @@ LL | while let Some(_x) = uninhabited_struct() { = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/patterns.rs:52:15 + --> $DIR/patterns.rs:53:15 | LL | while let Some(_x) = uninhabited_tuple_struct() { | ^^^^^^^^ matches no values because `UninhabitedTupleStruct` is uninhabited diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs index c6ce001806d1b..5aa0ea468e8ec 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] // Test that we do not get a privacy error here. Initially, we did, // because we inferred an outlives predciate of ` as // Private>::Out: 'a`, but the private trait is -- well -- private, diff --git a/tests/ui/static/auxiliary/nested_item.rs b/tests/ui/static/auxiliary/nested_item.rs index 9db9d19d6f610..b22dbee411580 100644 --- a/tests/ui/static/auxiliary/nested_item.rs +++ b/tests/ui/static/auxiliary/nested_item.rs @@ -1,4 +1,5 @@ // original problem +#![allow(unused_unconstructable_pub_struct)] pub fn foo() -> isize { { static foo: isize = 2; diff --git a/tests/ui/static/nested_item_main.rs b/tests/ui/static/nested_item_main.rs index 6793d8eae1b2f..5e3bffca5e6c5 100644 --- a/tests/ui/static/nested_item_main.rs +++ b/tests/ui/static/nested_item_main.rs @@ -2,6 +2,7 @@ //@ aux-build:nested_item.rs +#![allow(unused_unconstructable_pub_struct)] extern crate nested_item; pub fn main() { diff --git a/tests/ui/structs/auxiliary/struct_field_privacy.rs b/tests/ui/structs/auxiliary/struct_field_privacy.rs index 9765af1a7f652..f0354e7d477b0 100644 --- a/tests/ui/structs/auxiliary/struct_field_privacy.rs +++ b/tests/ui/structs/auxiliary/struct_field_privacy.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] pub struct A { a: isize, pub b: isize, diff --git a/tests/ui/structs/struct-field-privacy.rs b/tests/ui/structs/struct-field-privacy.rs index d70dd5c700500..363e764ba9245 100644 --- a/tests/ui/structs/struct-field-privacy.rs +++ b/tests/ui/structs/struct-field-privacy.rs @@ -1,5 +1,6 @@ //@ aux-build:struct_field_privacy.rs +#![allow(unused_unconstructable_pub_struct)] extern crate struct_field_privacy as xc; struct A { diff --git a/tests/ui/structs/struct-field-privacy.stderr b/tests/ui/structs/struct-field-privacy.stderr index ee83e0d6c2de7..63326ff1d2a37 100644 --- a/tests/ui/structs/struct-field-privacy.stderr +++ b/tests/ui/structs/struct-field-privacy.stderr @@ -1,29 +1,29 @@ error[E0616]: field `a` of struct `inner::A` is private - --> $DIR/struct-field-privacy.rs:23:7 + --> $DIR/struct-field-privacy.rs:24:7 | LL | b.a; | ^ private field error[E0616]: field `b` of struct `inner::B` is private - --> $DIR/struct-field-privacy.rs:26:7 + --> $DIR/struct-field-privacy.rs:27:7 | LL | c.b; | ^ private field error[E0616]: field `a` of struct `xc::A` is private - --> $DIR/struct-field-privacy.rs:28:7 + --> $DIR/struct-field-privacy.rs:29:7 | LL | d.a; | ^ private field error[E0616]: field `b` of struct `xc::B` is private - --> $DIR/struct-field-privacy.rs:32:7 + --> $DIR/struct-field-privacy.rs:33:7 | LL | e.b; | ^ private field error[E0616]: field `1` of struct `Z` is private - --> $DIR/struct-field-privacy.rs:35:7 + --> $DIR/struct-field-privacy.rs:36:7 | LL | z.1; | ^ private field diff --git a/tests/ui/structs/suggest-private-fields.rs b/tests/ui/structs/suggest-private-fields.rs index b3bae58a6e413..fdde30077014f 100644 --- a/tests/ui/structs/suggest-private-fields.rs +++ b/tests/ui/structs/suggest-private-fields.rs @@ -1,5 +1,6 @@ //@ aux-build:struct_field_privacy.rs +#![allow(unused_unconstructable_pub_struct)] extern crate struct_field_privacy as xc; use xc::B; diff --git a/tests/ui/structs/suggest-private-fields.stderr b/tests/ui/structs/suggest-private-fields.stderr index adf90f0e1fd65..6275240eac4e8 100644 --- a/tests/ui/structs/suggest-private-fields.stderr +++ b/tests/ui/structs/suggest-private-fields.stderr @@ -1,5 +1,5 @@ error[E0560]: struct `B` has no field named `aa` - --> $DIR/suggest-private-fields.rs:15:9 + --> $DIR/suggest-private-fields.rs:16:9 | LL | aa: 20, | ^^ unknown field @@ -11,7 +11,7 @@ LL + a: 20, | error[E0560]: struct `B` has no field named `bb` - --> $DIR/suggest-private-fields.rs:17:9 + --> $DIR/suggest-private-fields.rs:18:9 | LL | bb: 20, | ^^ `B` does not have this field @@ -19,7 +19,7 @@ LL | bb: 20, = note: available fields are: `a` error[E0560]: struct `A` has no field named `aa` - --> $DIR/suggest-private-fields.rs:22:9 + --> $DIR/suggest-private-fields.rs:23:9 | LL | aa: 20, | ^^ unknown field @@ -31,7 +31,7 @@ LL + a: 20, | error[E0560]: struct `A` has no field named `bb` - --> $DIR/suggest-private-fields.rs:24:9 + --> $DIR/suggest-private-fields.rs:25:9 | LL | bb: 20, | ^^ unknown field diff --git a/tests/ui/suggestions/auxiliary/generics_other_crate.rs b/tests/ui/suggestions/auxiliary/generics_other_crate.rs index 2345257eddfb8..d515936b51a51 100644 --- a/tests/ui/suggestions/auxiliary/generics_other_crate.rs +++ b/tests/ui/suggestions/auxiliary/generics_other_crate.rs @@ -1,4 +1,6 @@ //! This file is used to test suggestions for generics in other crates. +#![allow(unused_unconstructable_pub_struct)] + pub struct External; pub struct ExternalGeneric(T); diff --git a/tests/ui/suggestions/derive-clone-for-eq.fixed b/tests/ui/suggestions/derive-clone-for-eq.fixed index 17259dd687c6c..d9406180727e6 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.fixed +++ b/tests/ui/suggestions/derive-clone-for-eq.fixed @@ -1,4 +1,5 @@ //@ run-rustfix +#![allow(unused_unconstructable_pub_struct)] // https://github.com/rust-lang/rust/issues/79076 #[derive(Clone, Eq)] diff --git a/tests/ui/suggestions/derive-clone-for-eq.rs b/tests/ui/suggestions/derive-clone-for-eq.rs index 3e4331745be87..5a14c623ea107 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.rs +++ b/tests/ui/suggestions/derive-clone-for-eq.rs @@ -1,4 +1,5 @@ //@ run-rustfix +#![allow(unused_unconstructable_pub_struct)] // https://github.com/rust-lang/rust/issues/79076 #[derive(Clone, Eq)] diff --git a/tests/ui/suggestions/derive-clone-for-eq.stderr b/tests/ui/suggestions/derive-clone-for-eq.stderr index bed5ff90c1949..7a36d90311cb5 100644 --- a/tests/ui/suggestions/derive-clone-for-eq.stderr +++ b/tests/ui/suggestions/derive-clone-for-eq.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/derive-clone-for-eq.rs:5:12 + --> $DIR/derive-clone-for-eq.rs:6:12 | LL | #[derive(Clone, Eq)] | -- in this derive macro expansion @@ -7,7 +7,7 @@ LL | pub struct Struct(T); | ^^^^^^ the trait `Clone` is not implemented for `T` | note: required for `Struct` to implement `PartialEq` - --> $DIR/derive-clone-for-eq.rs:7:19 + --> $DIR/derive-clone-for-eq.rs:8:19 | LL | impl PartialEq for Struct | ----- ^^^^^^^^^^^^ ^^^^^^^^^ diff --git a/tests/ui/suggestions/option-content-move.fixed b/tests/ui/suggestions/option-content-move.fixed index f36c36d7d645f..12176c5b0f44b 100644 --- a/tests/ui/suggestions/option-content-move.fixed +++ b/tests/ui/suggestions/option-content-move.fixed @@ -1,4 +1,5 @@ //@ run-rustfix +#![allow(unused_unconstructable_pub_struct)] pub struct LipogramCorpora { selections: Vec<(char, Option)>, } diff --git a/tests/ui/suggestions/option-content-move.rs b/tests/ui/suggestions/option-content-move.rs index 90d05c7439970..aad244237a838 100644 --- a/tests/ui/suggestions/option-content-move.rs +++ b/tests/ui/suggestions/option-content-move.rs @@ -1,4 +1,5 @@ //@ run-rustfix +#![allow(unused_unconstructable_pub_struct)] pub struct LipogramCorpora { selections: Vec<(char, Option)>, } diff --git a/tests/ui/suggestions/option-content-move.stderr b/tests/ui/suggestions/option-content-move.stderr index b514622699e73..33223eb6f6651 100644 --- a/tests/ui/suggestions/option-content-move.stderr +++ b/tests/ui/suggestions/option-content-move.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `selection.1` which is behind a shared reference - --> $DIR/option-content-move.rs:10:20 + --> $DIR/option-content-move.rs:11:20 | LL | if selection.1.unwrap().contains(selection.0) { | ^^^^^^^^^^^ -------- `selection.1` moved due to this method call @@ -22,7 +22,7 @@ LL | if selection.1.clone().unwrap().contains(selection.0) { | ++++++++ error[E0507]: cannot move out of `selection.1` which is behind a shared reference - --> $DIR/option-content-move.rs:28:20 + --> $DIR/option-content-move.rs:29:20 | LL | if selection.1.unwrap().contains(selection.0) { | ^^^^^^^^^^^ -------- `selection.1` moved due to this method call diff --git a/tests/ui/traits/issue-4107.rs b/tests/ui/traits/issue-4107.rs index 1a754dab5ada6..db80e2d819834 100644 --- a/tests/ui/traits/issue-4107.rs +++ b/tests/ui/traits/issue-4107.rs @@ -1,5 +1,6 @@ //@ run-pass #![allow(dead_code)] +#![allow(unused_unconstructable_pub_struct)] pub fn main() { let _id: &Mat2 = &Matrix::identity(1.0); diff --git a/tests/ui/traits/object/generics.rs b/tests/ui/traits/object/generics.rs index 462b0bc5bb77f..f6423c1a66c6c 100644 --- a/tests/ui/traits/object/generics.rs +++ b/tests/ui/traits/object/generics.rs @@ -1,4 +1,5 @@ //@ run-pass +#![allow(unused_unconstructable_pub_struct)] // test for #8664 use std::marker; diff --git a/tests/ui/traits/where-clause-vs-impl.rs b/tests/ui/traits/where-clause-vs-impl.rs index 639347b3bc36d..d27ca55679b38 100644 --- a/tests/ui/traits/where-clause-vs-impl.rs +++ b/tests/ui/traits/where-clause-vs-impl.rs @@ -1,6 +1,7 @@ //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] +#![allow(unused_unconstructable_pub_struct)] // Test that when there is a conditional (but blanket) impl and a // where clause, we don't get confused in trait resolution. // diff --git a/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs b/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs index 3c823d3e5d279..9b5acfde397dd 100644 --- a/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs +++ b/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs @@ -1,3 +1,4 @@ +#![allow(unused_unconstructable_pub_struct)] // crate foo #![feature(type_alias_impl_trait)] diff --git a/tests/ui/typeck/auxiliary/tdticc_coherence_lib.rs b/tests/ui/typeck/auxiliary/tdticc_coherence_lib.rs index ef2cd415fcaaa..7afd0e386731b 100644 --- a/tests/ui/typeck/auxiliary/tdticc_coherence_lib.rs +++ b/tests/ui/typeck/auxiliary/tdticc_coherence_lib.rs @@ -1,5 +1,6 @@ #![feature(auto_traits, core)] #![crate_type = "rlib"] +#![allow(unused_unconstructable_pub_struct)] pub auto trait DefaultedTrait { }