diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 420427e7d0ab..396b06524d0b 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -45,6 +45,7 @@ impl LintPass for IntPlusOne { // x + 1 <= y // x <= y - 1 +#[derive(Copy, Clone)] enum Side { LHS, RHS, diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index d811de59844f..388c1ae7e346 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -6,7 +6,7 @@ use rustc::hir; use rustc::lint::{EarlyContext, LateContext, LintContext}; use rustc_errors; -use std::borrow::Cow; +use std::borrow::{Borrow, Cow}; use std::fmt::Display; use std; use syntax::codemap::{CharPos, Span}; @@ -136,8 +136,8 @@ impl<'a> Sugg<'a> { } /// Convenience method to create the ` && ` suggestion. - pub fn and(self, rhs: Self) -> Sugg<'static> { - make_binop(ast::BinOpKind::And, &self, &rhs) + pub fn and>(self, rhs: R) -> Sugg<'static> { + make_binop(ast::BinOpKind::And, &self, rhs.borrow()) } /// Convenience method to create the ` as ` suggestion. @@ -162,10 +162,10 @@ impl<'a> Sugg<'a> { /// Convenience method to create the `..` or `...` /// suggestion. - pub fn range(self, end: Self, limit: ast::RangeLimits) -> Sugg<'static> { + pub fn range>(self, end: E, limit: ast::RangeLimits) -> Sugg<'static> { match limit { - ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, &end), - ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, &end), + ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, end.borrow()), + ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, end.borrow()), } } diff --git a/tests/ui/methods.rs b/tests/ui/methods.rs index 6ecb39631546..c80f6acd06b9 100644 --- a/tests/ui/methods.rs +++ b/tests/ui/methods.rs @@ -1,9 +1,9 @@ #![feature(const_fn)] - #![warn(clippy, clippy_pedantic)] -#![allow(blacklisted_name, unused, print_stdout, non_ascii_literal, new_without_default, new_without_default_derive, missing_docs_in_private_items)] +#![allow(blacklisted_name, unused, print_stdout, non_ascii_literal, new_without_default, + new_without_default_derive, missing_docs_in_private_items, needless_pass_by_value)] use std::collections::BTreeMap; use std::collections::HashMap;