diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-04-26 03:50:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-26 03:50:21 +0200 |
| commit | 1738273ac3663263f049b65d7821928fa1330403 (patch) | |
| tree | 0856d9a3fc5b2e9138858f703a43999bd70a357d | |
| parent | 4d9d84999e6c0d97f1c445a70085e444d6f11717 (diff) | |
| parent | ef37f38726658dc51e3306171595d638eba4006d (diff) | |
Rollup merge of #60259 - sd234678:60181-derive-default-lints, r=Centril
Derive Default instead of new in applicable lint Closes #60181 As far as I can see, at least within the `src/librustc_lint` directory this is the only place this is applicable.
| -rw-r--r-- | src/librustc_lint/builtin.rs | 16 | ||||
| -rw-r--r-- | src/librustc_lint/lib.rs | 4 |
2 files changed, 4 insertions, 16 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 57bc44ee30c..47c1c16f1f8 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -542,18 +542,13 @@ declare_lint! { "detects missing implementations of fmt::Debug" } +#[derive(Default)] pub struct MissingDebugImplementations { impling_types: Option<HirIdSet>, } impl_lint_pass!(MissingDebugImplementations => [MISSING_DEBUG_IMPLEMENTATIONS]); -impl MissingDebugImplementations { - pub fn new() -> MissingDebugImplementations { - MissingDebugImplementations { impling_types: None } - } -} - impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { if !cx.access_levels.is_reachable(item.hir_id) { @@ -1285,6 +1280,7 @@ declare_lint! { "`...` range patterns are deprecated" } +#[derive(Default)] pub struct EllipsisInclusiveRangePatterns { /// If `Some(_)`, suppress all subsequent pattern /// warnings for better diagnostics. @@ -1293,14 +1289,6 @@ pub struct EllipsisInclusiveRangePatterns { impl_lint_pass!(EllipsisInclusiveRangePatterns => [ELLIPSIS_INCLUSIVE_RANGE_PATTERNS]); -impl EllipsisInclusiveRangePatterns { - pub fn new() -> Self { - Self { - node_id: None, - } - } -} - impl EarlyLintPass for EllipsisInclusiveRangePatterns { fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat) { if self.node_id.is_some() { diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 68ea2195619..7d23da857bb 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -94,7 +94,7 @@ macro_rules! early_lint_passes { UnusedImportBraces: UnusedImportBraces, UnsafeCode: UnsafeCode, AnonymousParameters: AnonymousParameters, - EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::new(), + EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(), NonCamelCaseTypes: NonCamelCaseTypes, DeprecatedAttr: DeprecatedAttr::new(), ]); @@ -132,7 +132,7 @@ macro_rules! late_lint_passes { // Depends on access levels // FIXME: Turn the computation of types which implement Debug into a query // and change this to a module lint pass - MissingDebugImplementations: MissingDebugImplementations::new(), + MissingDebugImplementations: MissingDebugImplementations::default(), ]); ) } |
