Skip to content

Commit ae5100e

Browse files
authored
Rollup merge of rust-lang#60259 - sd234678:60181-derive-default-lints, r=Centril
Derive Default instead of new in applicable lint Closes rust-lang#60181 As far as I can see, at least within the `src/librustc_lint` directory this is the only place this is applicable.
2 parents 4eca7c5 + ef37f38 commit ae5100e

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/librustc_lint/builtin.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -542,18 +542,13 @@ declare_lint! {
542542
"detects missing implementations of fmt::Debug"
543543
}
544544

545+
#[derive(Default)]
545546
pub struct MissingDebugImplementations {
546547
impling_types: Option<HirIdSet>,
547548
}
548549

549550
impl_lint_pass!(MissingDebugImplementations => [MISSING_DEBUG_IMPLEMENTATIONS]);
550551

551-
impl MissingDebugImplementations {
552-
pub fn new() -> MissingDebugImplementations {
553-
MissingDebugImplementations { impling_types: None }
554-
}
555-
}
556-
557552
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
558553
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
559554
if !cx.access_levels.is_reachable(item.hir_id) {
@@ -1285,6 +1280,7 @@ declare_lint! {
12851280
"`...` range patterns are deprecated"
12861281
}
12871282

1283+
#[derive(Default)]
12881284
pub struct EllipsisInclusiveRangePatterns {
12891285
/// If `Some(_)`, suppress all subsequent pattern
12901286
/// warnings for better diagnostics.
@@ -1293,14 +1289,6 @@ pub struct EllipsisInclusiveRangePatterns {
12931289

12941290
impl_lint_pass!(EllipsisInclusiveRangePatterns => [ELLIPSIS_INCLUSIVE_RANGE_PATTERNS]);
12951291

1296-
impl EllipsisInclusiveRangePatterns {
1297-
pub fn new() -> Self {
1298-
Self {
1299-
node_id: None,
1300-
}
1301-
}
1302-
}
1303-
13041292
impl EarlyLintPass for EllipsisInclusiveRangePatterns {
13051293
fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat) {
13061294
if self.node_id.is_some() {

src/librustc_lint/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ macro_rules! early_lint_passes {
9494
UnusedImportBraces: UnusedImportBraces,
9595
UnsafeCode: UnsafeCode,
9696
AnonymousParameters: AnonymousParameters,
97-
EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::new(),
97+
EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(),
9898
NonCamelCaseTypes: NonCamelCaseTypes,
9999
DeprecatedAttr: DeprecatedAttr::new(),
100100
]);
@@ -132,7 +132,7 @@ macro_rules! late_lint_passes {
132132
// Depends on access levels
133133
// FIXME: Turn the computation of types which implement Debug into a query
134134
// and change this to a module lint pass
135-
MissingDebugImplementations: MissingDebugImplementations::new(),
135+
MissingDebugImplementations: MissingDebugImplementations::default(),
136136
]);
137137
)
138138
}

0 commit comments

Comments
 (0)