Skip to content

Commit

Permalink
fix dogfood tests
Browse files Browse the repository at this point in the history
remove unnecessary clone in parse_attrs
  • Loading branch information
suyashb95 committed Nov 3, 2020
1 parent 6d22f60 commit b0c826f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(|| box implicit_return::ImplicitReturn);
store.register_late_pass(|| box implicit_saturating_sub::ImplicitSaturatingSub);
let msrv = conf.msrv.clone();
store.register_late_pass(move || box methods::Methods::new(String::from(msrv.clone())));
store.register_late_pass(move || box methods::Methods::new(msrv.clone()));
store.register_late_pass(|| box map_clone::MapClone);
store.register_late_pass(|| box map_err_ignore::MapErrIgnore);
store.register_late_pass(|| box shadow::Shadow);
Expand All @@ -971,7 +971,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
let type_complexity_threshold = conf.type_complexity_threshold;
store.register_late_pass(move || box types::TypeComplexity::new(type_complexity_threshold));
let msrv = conf.msrv.clone();
store.register_late_pass(move || box matches::Matches::new(String::from(msrv.clone())));
store.register_late_pass(move || box matches::Matches::new(msrv.clone()));
store.register_late_pass(|| box minmax::MinMaxPass);
store.register_late_pass(|| box open_options::OpenOptions);
store.register_late_pass(|| box zero_div_zero::ZeroDiv);
Expand Down Expand Up @@ -1131,7 +1131,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(|| box mut_mutex_lock::MutMutexLock);
store.register_late_pass(|| box match_on_vec_items::MatchOnVecItems);
let msrv = conf.msrv.clone();
store.register_early_pass(move || box manual_non_exhaustive::ManualNonExhaustive::new(String::from(msrv.clone())));
store.register_early_pass(move || box manual_non_exhaustive::ManualNonExhaustive::new(msrv.clone()));
store.register_late_pass(|| box manual_async_fn::ManualAsyncFn);
store.register_early_pass(|| box redundant_field_names::RedundantFieldNames);
store.register_late_pass(|| box vec_resize_to_zero::VecResizeToZero);
Expand All @@ -1153,7 +1153,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(|| box float_equality_without_abs::FloatEqualityWithoutAbs);
store.register_late_pass(|| box async_yields_async::AsyncYieldsAsync);
let msrv = conf.msrv.clone();
store.register_late_pass(move || box manual_strip::ManualStrip::new(String::from(msrv.clone())));
store.register_late_pass(move || box manual_strip::ManualStrip::new(msrv.clone()));
store.register_late_pass(|| box utils::internal_lints::MatchTypeOnDiagItem);
let disallowed_methods = conf.disallowed_methods.iter().cloned().collect::<FxHashSet<_>>();
store.register_late_pass(move || box disallowed_method::DisallowedMethod::new(&disallowed_methods));
Expand Down
11 changes: 3 additions & 8 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,7 @@ pub struct Matches {
impl Matches {
#[must_use]
pub fn new(msrv: String) -> Self {
Self {
msrv_stack: LimitStack::new(msrv),
..Default::default()
}
Self { msrv_stack: LimitStack::new(msrv), ..Default::default()}
}
}

Expand Down Expand Up @@ -565,10 +562,8 @@ impl<'tcx> LateLintPass<'tcx> for Matches {

redundant_pattern_match::check(cx, expr);

if Version::parse(&self.msrv_stack.limit()) >= Version::parse(MATCH_LIKE_MATCHES_MACRO_MSRV) {
if !check_match_like_matches(cx, expr) {
lint_match_arms(cx, expr);
}
if Version::parse(&self.msrv_stack.limit()) >= Version::parse(MATCH_LIKE_MATCHES_MACRO_MSRV) && !check_match_like_matches(cx, expr) {
lint_match_arms(cx, expr);
}

if let ExprKind::Match(ref ex, ref arms, MatchSource::Normal) = expr.kind {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ impl Methods {
#[must_use]
pub fn new(msrv: String) -> Self {
Self {
msrv_stack: LimitStack::new(msrv.clone()),
msrv_stack: LimitStack::new(msrv),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/utils/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ pub struct LimitStack<T> {
stack: Vec<T>,
}

impl<T> Drop for LimitStack<T> {
fn drop(&mut self) {
assert_eq!(1, 1);
}
}
// impl<T> Drop for LimitStack<T> {
// fn drop(&mut self) {
// assert_eq!(1, 1);
// }
// }

impl<T: std::cmp::PartialEq + std::fmt::Debug + FromStr + Clone> LimitStack<T> {
#[must_use]
Expand Down Expand Up @@ -118,7 +118,7 @@ fn parse_attrs<T: std::clone::Clone + FromStr, F: FnMut(T)>(
mut f: F,
) {
for attr in get_attr(sess, attrs, name) {
if let Some(ref value) = attr.value_str().clone() {
if let Some(ref value) = attr.value_str() {
if let Ok(value) = FromStr::from_str(&value.as_str()) {
f(value)
} else {
Expand Down

0 comments on commit b0c826f

Please sign in to comment.