Skip to content

Commit

Permalink
Rollup merge of rust-lang#60259 - sd234678:60181-derive-default-lints…
Browse files Browse the repository at this point in the history
…, 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.
  • Loading branch information
Centril authored Apr 25, 2019
2 parents 4eca7c5 + ef37f38 commit ae5100e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
16 changes: 2 additions & 14 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
Expand Down Expand Up @@ -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(),
]);
)
}
Expand Down

0 comments on commit ae5100e

Please sign in to comment.