Skip to content

Commit

Permalink
Applying PR suggestions (mostly typos)
Browse files Browse the repository at this point in the history
Co-authored-by: flip1995 <[email protected]>
Co-authored-by: phansch <[email protected]>
  • Loading branch information
xFrednet committed Mar 31, 2021
1 parent 243848d commit 9e076d9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
1 change: 0 additions & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
&utils::internal_lints::PRODUCE_ICE,
#[cfg(feature = "internal-lints")]
&utils::internal_lints::UNNECESSARY_SYMBOL_STR,

&absurd_extreme_comparisons::ABSURD_EXTREME_COMPARISONS,
&approx_const::APPROX_CONSTANT,
&arithmetic::FLOAT_ARITHMETIC,
Expand Down
19 changes: 10 additions & 9 deletions clippy_lints/src/utils/internal_lints/metadata_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ use std::io::prelude::*;
use std::path::Path;

use crate::utils::internal_lints::is_lint_ref_type;
use crate::utils::{
last_path_segment, match_function_call, match_path, match_type, paths, span_lint, walk_ptrs_ty_depth,
use clippy_utils::{
diagnostics::span_lint, last_path_segment, match_function_call, match_path, paths, ty::match_type,
ty::walk_ptrs_ty_depth,
};

/// This is the output file of the lint collector.
Expand Down Expand Up @@ -107,7 +108,7 @@ pub struct MetadataCollector {
///
/// We use a Heap here to have the lints added in alphabetic order in the export
lints: BinaryHeap<LintMetadata>,
applicability_into: FxHashMap<String, ApplicabilityInfo>,
applicability_info: FxHashMap<String, ApplicabilityInfo>,
}

impl Drop for MetadataCollector {
Expand All @@ -120,7 +121,7 @@ impl Drop for MetadataCollector {
return;
}

let mut applicability_info = std::mem::take(&mut self.applicability_into);
let mut applicability_info = std::mem::take(&mut self.applicability_info);

// Mapping the final data
let mut lints = std::mem::take(&mut self.lints).into_sorted_vec();
Expand Down Expand Up @@ -272,7 +273,7 @@ impl<'hir> LateLintPass<'hir> for MetadataCollector {
}

for (lint_name, applicability, is_multi_part) in emission_info.drain(..) {
let app_info = self.applicability_into.entry(lint_name).or_default();
let app_info = self.applicability_info.entry(lint_name).or_default();
app_info.applicability = applicability;
app_info.is_multi_part_suggestion = is_multi_part;
}
Expand Down Expand Up @@ -354,7 +355,7 @@ fn lint_collection_error_item(cx: &LateContext<'_>, item: &Item<'_>, message: &s
cx,
INTERNAL_METADATA_COLLECTOR,
item.ident.span,
&format!("Metadata collection error for `{}`: {}", item.ident.name, message),
&format!("metadata collection error for `{}`: {}", item.ident.name, message),
);
}

Expand Down Expand Up @@ -569,7 +570,7 @@ impl<'a, 'hir> IsMultiSpanScanner<'a, 'hir> {
}

/// Add a new single expression suggestion to the counter
fn add_singe_span_suggestion(&mut self) {
fn add_single_span_suggestion(&mut self) {
self.suggestion_count += 1;
}

Expand Down Expand Up @@ -604,7 +605,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for IsMultiSpanScanner<'a, 'hir> {
.any(|func_path| match_function_call(self.cx, fn_expr, func_path).is_some());
if found_function {
// These functions are all multi part suggestions
self.add_singe_span_suggestion()
self.add_single_span_suggestion()
}
},
ExprKind::MethodCall(path, _path_span, arg, _arg_span) => {
Expand All @@ -616,7 +617,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for IsMultiSpanScanner<'a, 'hir> {
if *is_multi_part {
self.add_multi_part_suggestion();
} else {
self.add_singe_span_suggestion();
self.add_single_span_suggestion();
}
break;
}
Expand Down
8 changes: 8 additions & 0 deletions clippy_utils/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
//! Clippy wrappers around rustc's diagnostic functions.
//!
//! These functions are used by the `INTERNAL_METADATA_COLLECTOR` lint to collect the corresponding
//! lint applicability. Please make sure that you update the `LINT_EMISSION_FUNCTIONS` variable in
//! `clippy_lints::utils::internal_lints::metadata_collector` when a new function is added
//! or renamed.
//!
//! Thank you!
//! ~The `INTERNAL_METADATA_COLLECTOR` lint

use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir::HirId;
Expand Down

0 comments on commit 9e076d9

Please sign in to comment.