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.
This commit is contained in:
Mazdak Farrokhzad 2019-04-26 03:50:21 +02:00 committed by GitHub
commit 1738273ac3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 16 deletions

View file

@ -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() {

View file

@ -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(),
]);
)
}