Skip to content

Commit 8acacfe

Browse files
Revert "Rollup merge of rust-lang#126302 - mu001999-contrib:ignore/default, r=michaelwoerister"
This reverts commit 58bbade, reversing changes made to c290e9d.
1 parent cfe4039 commit 8acacfe

File tree

7 files changed

+2
-78
lines changed

7 files changed

+2
-78
lines changed

Diff for: compiler/rustc_passes/src/dead.rs

-25
Original file line numberDiff line numberDiff line change
@@ -403,31 +403,6 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
403403
return false;
404404
}
405405

406-
// don't ignore impls for Enums and pub Structs whose methods don't have self receiver,
407-
// cause external crate may call such methods to construct values of these types
408-
if let Some(local_impl_of) = impl_of.as_local()
409-
&& let Some(local_def_id) = def_id.as_local()
410-
&& let Some(fn_sig) =
411-
self.tcx.hir().fn_sig_by_hir_id(self.tcx.local_def_id_to_hir_id(local_def_id))
412-
&& matches!(fn_sig.decl.implicit_self, hir::ImplicitSelfKind::None)
413-
&& let TyKind::Path(hir::QPath::Resolved(_, path)) =
414-
self.tcx.hir().expect_item(local_impl_of).expect_impl().self_ty.kind
415-
&& let Res::Def(def_kind, did) = path.res
416-
{
417-
match def_kind {
418-
// for example, #[derive(Default)] pub struct T(i32);
419-
// external crate can call T::default() to construct T,
420-
// so that don't ignore impl Default for pub Enum and Structs
421-
DefKind::Struct | DefKind::Union if self.tcx.visibility(did).is_public() => {
422-
return false;
423-
}
424-
// don't ignore impl Default for Enums,
425-
// cause we don't know which variant is constructed
426-
DefKind::Enum => return false,
427-
_ => (),
428-
};
429-
}
430-
431406
if let Some(trait_of) = self.tcx.trait_id_of_impl(impl_of)
432407
&& self.tcx.has_attr(trait_of, sym::rustc_trivial_field_reads)
433408
{

Diff for: library/alloc/src/sync/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ fn show_arc() {
396396

397397
// Make sure deriving works with Arc<T>
398398
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Default)]
399-
struct _Foo {
399+
struct Foo {
400400
inner: Arc<i32>,
401401
}
402402

Diff for: library/core/src/default.rs

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ use crate::ascii::Char as AsciiChar;
103103
/// ```
104104
#[cfg_attr(not(test), rustc_diagnostic_item = "Default")]
105105
#[stable(feature = "rust1", since = "1.0.0")]
106-
#[cfg_attr(not(bootstrap), rustc_trivial_field_reads)]
107106
pub trait Default: Sized {
108107
/// Returns the "default value" for a type.
109108
///

Diff for: tests/ui/deriving/deriving-default-enum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ enum MyOption<T> {
2222
}
2323

2424
fn main() {
25-
assert!(matches!(Foo::default(), Foo::Alpha));
25+
assert_eq!(Foo::default(), Foo::Alpha);
2626
assert!(matches!(MyOption::<NotDefault>::default(), MyOption::None));
2727
}

Diff for: tests/ui/issues/issue-68696-catch-during-unwind.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use std::panic::catch_unwind;
99

10-
#[allow(dead_code)]
1110
#[derive(Default)]
1211
struct Guard;
1312

Diff for: tests/ui/lint/dead-code/unused-struct-derive-default.rs

-25
This file was deleted.

Diff for: tests/ui/lint/dead-code/unused-struct-derive-default.stderr

-24
This file was deleted.

0 commit comments

Comments
 (0)