remove nondeterminism by adjusting thresholds
This commit is contained in:
parent
299d7be132
commit
ed9d71f2c9
30 changed files with 157 additions and 133 deletions
|
@ -107,9 +107,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an option containing a tuple with the start and end (exclusive) of the range.
|
/// Returns an option containing a tuple with the start and end (exclusive) of the range.
|
||||||
fn to_const_range(start: Option<Option<ConstVal>>, end: Option<Option<ConstVal>>, limits: RangeLimits,
|
fn to_const_range(start: Option<Option<ConstVal>>, end: Option<Option<ConstVal>>, limits: RangeLimits, array_size: ConstInt)
|
||||||
array_size: ConstInt)
|
-> Option<(ConstInt, ConstInt)> {
|
||||||
-> Option<(ConstInt, ConstInt)> {
|
|
||||||
let start = match start {
|
let start = match start {
|
||||||
Some(Some(ConstVal::Integral(x))) => x,
|
Some(Some(ConstVal::Integral(x))) => x,
|
||||||
Some(_) => return None,
|
Some(_) => return None,
|
||||||
|
|
|
@ -36,9 +36,11 @@ declare_lint! {
|
||||||
|
|
||||||
/// **What it does:** Checks for `extern crate` and `use` items annotated with lint attributes
|
/// **What it does:** Checks for `extern crate` and `use` items annotated with lint attributes
|
||||||
///
|
///
|
||||||
/// **Why is this bad?** Lint attributes have no effect on crate imports. Most likely a `!` was forgotten
|
/// **Why is this bad?** Lint attributes have no effect on crate imports. Most likely a `!` was
|
||||||
|
/// forgotten
|
||||||
///
|
///
|
||||||
/// **Known problems:** Technically one might allow `unused_import` on a `use` item, but it's easier to remove the unused item.
|
/// **Known problems:** Technically one might allow `unused_import` on a `use` item,
|
||||||
|
/// but it's easier to remove the unused item.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
@ -125,11 +127,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
||||||
attr.span,
|
attr.span,
|
||||||
"useless lint attribute",
|
"useless lint attribute",
|
||||||
|db| {
|
|db| {
|
||||||
sugg.insert(1, '!');
|
sugg.insert(1, '!');
|
||||||
db.span_suggestion(attr.span,
|
db.span_suggestion(attr.span, "if you just forgot a `!`, use", sugg);
|
||||||
"if you just forgot a `!`, use",
|
});
|
||||||
sugg);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -204,7 +204,8 @@ fn lint_match_arms(cx: &LateContext, expr: &Expr) {
|
||||||
|
|
||||||
if let PatKind::Wild = j.pats[0].node {
|
if let PatKind::Wild = j.pats[0].node {
|
||||||
// if the last arm is _, then i could be integrated into _
|
// if the last arm is _, then i could be integrated into _
|
||||||
// note that i.pats[0] cannot be _, because that would mean that we're hiding all the subsequent arms, and rust won't compile
|
// note that i.pats[0] cannot be _, because that would mean that we're
|
||||||
|
// hiding all the subsequent arms, and rust won't compile
|
||||||
db.span_note(i.body.span,
|
db.span_note(i.body.span,
|
||||||
&format!("`{}` has the same arm body as the `_` wildcard, consider removing it`",
|
&format!("`{}` has the same arm body as the `_` wildcard, consider removing it`",
|
||||||
lhs));
|
lhs));
|
||||||
|
|
|
@ -169,7 +169,7 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
|
||||||
item.span,
|
item.span,
|
||||||
"you are implementing `Clone` explicitly on a `Copy` type",
|
"you are implementing `Clone` explicitly on a `Copy` type",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_note(item.span, "consider deriving `Clone` or removing `Copy`");
|
db.span_note(item.span, "consider deriving `Clone` or removing `Copy`");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,9 @@ fn check_doc(cx: &EarlyContext, valid_idents: &[String], docs: &[(String, Span)]
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup_parser = parser.clone();
|
lookup_parser = parser.clone();
|
||||||
if let (Some((false, $c)), Some((false, $c))) = (lookup_parser.next(), lookup_parser.next()) {
|
let a = lookup_parser.next();
|
||||||
|
let b = lookup_parser.next();
|
||||||
|
if let (Some((false, $c)), Some((false, $c))) = (a, b) {
|
||||||
let mut close_count = 3;
|
let mut close_count = 3;
|
||||||
while let Some((false, $c)) = lookup_parser.next() {
|
while let Some((false, $c)) = lookup_parser.next() {
|
||||||
close_count += 1;
|
close_count += 1;
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HashMapLint {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_cond<'a, 'tcx, 'b>(cx: &'a LateContext<'a, 'tcx>, check: &'b Expr)
|
fn check_cond<'a, 'tcx, 'b>(cx: &'a LateContext<'a, 'tcx>, check: &'b Expr)
|
||||||
-> Option<(&'static str, &'b Expr, &'b Expr)> {
|
-> Option<(&'static str, &'b Expr, &'b Expr)> {
|
||||||
if_let_chain! {[
|
if_let_chain! {[
|
||||||
let ExprMethodCall(ref name, _, ref params) = check.node,
|
let ExprMethodCall(ref name, _, ref params) = check.node,
|
||||||
params.len() >= 2,
|
params.len() >= 2,
|
||||||
|
|
|
@ -49,10 +49,13 @@ declare_lint! {
|
||||||
|
|
||||||
/// **What it does:** Checks for modules that have the same name as their parent module
|
/// **What it does:** Checks for modules that have the same name as their parent module
|
||||||
///
|
///
|
||||||
/// **Why is this bad?** A typical beginner mistake is to have `mod foo;` and again `mod foo { .. }` in `foo.rs`.
|
/// **Why is this bad?** A typical beginner mistake is to have `mod foo;` and again `mod foo { ..
|
||||||
/// The expectation is that items inside the inner `mod foo { .. }` are then available
|
/// }` in `foo.rs`.
|
||||||
|
/// The expectation is that items inside the inner `mod foo { .. }` are then
|
||||||
|
/// available
|
||||||
/// through `foo::x`, but they are only available through `foo::foo::x`.
|
/// through `foo::x`, but they are only available through `foo::foo::x`.
|
||||||
/// If this is done on purpose, it would be better to choose a more representative module name.
|
/// If this is done on purpose, it would be better to choose a more
|
||||||
|
/// representative module name.
|
||||||
///
|
///
|
||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
|
@ -111,8 +114,7 @@ fn partial_rmatch(post: &str, name: &str) -> usize {
|
||||||
|
|
||||||
// FIXME: #600
|
// FIXME: #600
|
||||||
#[allow(while_let_on_iterator)]
|
#[allow(while_let_on_iterator)]
|
||||||
fn check_variant(cx: &EarlyContext, threshold: u64, def: &EnumDef, item_name: &str, item_name_chars: usize,
|
fn check_variant(cx: &EarlyContext, threshold: u64, def: &EnumDef, item_name: &str, item_name_chars: usize, span: Span) {
|
||||||
span: Span) {
|
|
||||||
if (def.variants.len() as u64) < threshold {
|
if (def.variants.len() as u64) < threshold {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,10 @@ impl LintPass for Pass {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, _: visit::FnKind<'tcx>, decl: &'tcx FnDecl, body: &'tcx Expr,
|
fn check_fn(
|
||||||
_: Span, id: NodeId) {
|
&mut self, cx: &LateContext<'a, 'tcx>, _: visit::FnKind<'tcx>, decl: &'tcx FnDecl, body: &'tcx Expr, _: Span,
|
||||||
|
id: NodeId
|
||||||
|
) {
|
||||||
let param_env = ty::ParameterEnvironment::for_item(cx.tcx, id);
|
let param_env = ty::ParameterEnvironment::for_item(cx.tcx, id);
|
||||||
|
|
||||||
let infcx = cx.tcx.borrowck_fake_infer_ctxt(param_env);
|
let infcx = cx.tcx.borrowck_fake_infer_ctxt(param_env);
|
||||||
|
|
|
@ -146,7 +146,8 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
// do not lint expressions referencing objects of type `!`, as that required a diverging expression to begin with
|
// do not lint expressions referencing objects of type `!`, as that required a diverging expression
|
||||||
|
// to begin with
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
self.maybe_walk_expr(e);
|
self.maybe_walk_expr(e);
|
||||||
|
|
|
@ -69,8 +69,10 @@ impl LintPass for Functions {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
|
||||||
fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, kind: intravisit::FnKind<'tcx>, decl: &'tcx hir::FnDecl,
|
fn check_fn(
|
||||||
expr: &'tcx hir::Expr, span: Span, nodeid: ast::NodeId) {
|
&mut self, cx: &LateContext<'a, 'tcx>, kind: intravisit::FnKind<'tcx>, decl: &'tcx hir::FnDecl,
|
||||||
|
expr: &'tcx hir::Expr, span: Span, nodeid: ast::NodeId
|
||||||
|
) {
|
||||||
use rustc::hir::map::Node::*;
|
use rustc::hir::map::Node::*;
|
||||||
|
|
||||||
let is_impl = if let Some(NodeItem(item)) = cx.tcx.map.find(cx.tcx.map.get_parent_node(nodeid)) {
|
let is_impl = if let Some(NodeItem(item)) = cx.tcx.map.find(cx.tcx.map.get_parent_node(nodeid)) {
|
||||||
|
@ -124,8 +126,10 @@ impl<'a, 'tcx> Functions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_raw_ptr(&self, cx: &LateContext<'a, 'tcx>, unsafety: hir::Unsafety, decl: &'tcx hir::FnDecl,
|
fn check_raw_ptr(
|
||||||
expr: &'tcx hir::Expr, nodeid: ast::NodeId) {
|
&self, cx: &LateContext<'a, 'tcx>, unsafety: hir::Unsafety, decl: &'tcx hir::FnDecl, expr: &'tcx hir::Expr,
|
||||||
|
nodeid: ast::NodeId
|
||||||
|
) {
|
||||||
if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(nodeid) {
|
if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(nodeid) {
|
||||||
let raw_ptrs = decl.inputs.iter().filter_map(|arg| raw_ptr_arg(cx, arg)).collect::<HashSet<_>>();
|
let raw_ptrs = decl.inputs.iter().filter_map(|arg| raw_ptr_arg(cx, arg)).collect::<HashSet<_>>();
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_assign<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: hir::def_id::DefId, block: &'tcx hir::Block)
|
fn check_assign<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: hir::def_id::DefId, block: &'tcx hir::Block)
|
||||||
-> Option<&'tcx hir::Expr> {
|
-> Option<&'tcx hir::Expr> {
|
||||||
if_let_chain! {[
|
if_let_chain! {[
|
||||||
block.expr.is_none(),
|
block.expr.is_none(),
|
||||||
let Some(expr) = block.stmts.iter().last(),
|
let Some(expr) = block.stmts.iter().last(),
|
||||||
|
|
|
@ -116,10 +116,8 @@ fn check_fn_inner<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, gene
|
||||||
report_extra_lifetimes(cx, decl, generics);
|
report_extra_lifetimes(cx, decl, generics);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn could_use_elision<'a, 'tcx: 'a, T: Iterator<Item = &'tcx Lifetime>>(cx: &LateContext<'a, 'tcx>,
|
fn could_use_elision<'a, 'tcx: 'a, T: Iterator<Item = &'tcx Lifetime>>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, named_lts: &'tcx [LifetimeDef], bounds_lts: T)
|
||||||
func: &'tcx FnDecl,
|
-> bool {
|
||||||
named_lts: &'tcx [LifetimeDef], bounds_lts: T)
|
|
||||||
-> bool {
|
|
||||||
// There are two scenarios where elision works:
|
// There are two scenarios where elision works:
|
||||||
// * no output references, all input references have different LT
|
// * no output references, all input references have different LT
|
||||||
// * output references, exactly one input reference with same LT
|
// * output references, exactly one input reference with same LT
|
||||||
|
|
|
@ -351,11 +351,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
expr.span,
|
expr.span,
|
||||||
"this loop could be written as a `while let` loop",
|
"this loop could be written as a `while let` loop",
|
||||||
|db| {
|
|db| {
|
||||||
let sug = format!("while let {} = {} {{ .. }}",
|
let sug = format!("while let {} = {} {{ .. }}",
|
||||||
snippet(cx, arms[0].pats[0].span, ".."),
|
snippet(cx, arms[0].pats[0].span, ".."),
|
||||||
snippet(cx, matchexpr.span, ".."));
|
snippet(cx, matchexpr.span, ".."));
|
||||||
db.span_suggestion(expr.span, "try", sug);
|
db.span_suggestion(expr.span, "try", sug);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -379,10 +379,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
expr.span,
|
expr.span,
|
||||||
"this loop could be written as a `for` loop",
|
"this loop could be written as a `for` loop",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(expr.span,
|
db.span_suggestion(expr.span, "try", format!("for {} in {} {{ .. }}", loop_var, iterator));
|
||||||
"try",
|
});
|
||||||
format!("for {} in {} {{ .. }}", loop_var, iterator));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,11 +471,11 @@ fn check_for_loop_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat, ar
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("the loop variable `{}` is used to index `{}`", ident.node, indexed),
|
&format!("the loop variable `{}` is used to index `{}`", ident.node, indexed),
|
||||||
|db| {
|
|db| {
|
||||||
multispan_sugg(db,
|
multispan_sugg(db,
|
||||||
"consider using an iterator".to_string(),
|
"consider using an iterator".to_string(),
|
||||||
&[(pat.span, &format!("({}, <item>)", ident.node)),
|
&[(pat.span, &format!("({}, <item>)", ident.node)),
|
||||||
(arg.span, &format!("{}.iter().enumerate(){}{}", indexed, take, skip))]);
|
(arg.span, &format!("{}.iter().enumerate(){}{}", indexed, take, skip))]);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let repl = if starts_at_zero && take.is_empty() {
|
let repl = if starts_at_zero && take.is_empty() {
|
||||||
format!("&{}", indexed)
|
format!("&{}", indexed)
|
||||||
|
@ -492,10 +490,10 @@ fn check_for_loop_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat, ar
|
||||||
ident.node,
|
ident.node,
|
||||||
indexed),
|
indexed),
|
||||||
|db| {
|
|db| {
|
||||||
multispan_sugg(db,
|
multispan_sugg(db,
|
||||||
"consider using an iterator".to_string(),
|
"consider using an iterator".to_string(),
|
||||||
&[(pat.span, "<item>"), (arg.span, &repl)]);
|
&[(pat.span, "<item>"), (arg.span, &repl)]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,10 +322,10 @@ fn check_match_ref_pats(cx: &LateContext, ex: &Expr, arms: &[Arm], source: Match
|
||||||
expr.span,
|
expr.span,
|
||||||
"you don't need to add `&` to both the expression and the patterns",
|
"you don't need to add `&` to both the expression and the patterns",
|
||||||
|db| {
|
|db| {
|
||||||
let inner = Sugg::hir(cx, inner, "..");
|
let inner = Sugg::hir(cx, inner, "..");
|
||||||
let template = match_template(expr.span, source, inner);
|
let template = match_template(expr.span, source, inner);
|
||||||
db.span_suggestion(expr.span, "try", template);
|
db.span_suggestion(expr.span, "try", template);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
span_lint_and_then(cx,
|
span_lint_and_then(cx,
|
||||||
MATCH_REF_PATS,
|
MATCH_REF_PATS,
|
||||||
|
@ -335,8 +335,7 @@ fn check_match_ref_pats(cx: &LateContext, ex: &Expr, arms: &[Arm], source: Match
|
||||||
let ex = Sugg::hir(cx, ex, "..");
|
let ex = Sugg::hir(cx, ex, "..");
|
||||||
let template = match_template(expr.span, source, ex.deref());
|
let template = match_template(expr.span, source, ex.deref());
|
||||||
db.span_suggestion(expr.span,
|
db.span_suggestion(expr.span,
|
||||||
"instead of prefixing all patterns with `&`, you can \
|
"instead of prefixing all patterns with `&`, you can dereference the expression",
|
||||||
dereference the expression",
|
|
||||||
template);
|
template);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,9 +695,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
/// Checks for the `OR_FUN_CALL` lint.
|
/// Checks for the `OR_FUN_CALL` lint.
|
||||||
fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir::Expr]) {
|
fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir::Expr]) {
|
||||||
/// Check for `unwrap_or(T::new())` or `unwrap_or(T::default())`.
|
/// Check for `unwrap_or(T::new())` or `unwrap_or(T::default())`.
|
||||||
fn check_unwrap_or_default(cx: &LateContext, name: &str, fun: &hir::Expr, self_expr: &hir::Expr, arg: &hir::Expr,
|
fn check_unwrap_or_default(
|
||||||
or_has_args: bool, span: Span)
|
cx: &LateContext, name: &str, fun: &hir::Expr, self_expr: &hir::Expr, arg: &hir::Expr, or_has_args: bool,
|
||||||
-> bool {
|
span: Span
|
||||||
|
) -> bool {
|
||||||
if or_has_args {
|
if or_has_args {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -721,11 +722,10 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir:
|
||||||
span,
|
span,
|
||||||
&format!("use of `{}` followed by a call to `{}`", name, path),
|
&format!("use of `{}` followed by a call to `{}`", name, path),
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(span,
|
db.span_suggestion(span,
|
||||||
"try this",
|
"try this",
|
||||||
format!("{}.unwrap_or_default()",
|
format!("{}.unwrap_or_default()", snippet(cx, self_expr.span, "_")));
|
||||||
snippet(cx, self_expr.span, "_")));
|
});
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -736,8 +736,10 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check for `*or(foo())`.
|
/// Check for `*or(foo())`.
|
||||||
fn check_general_case(cx: &LateContext, name: &str, fun: &hir::Expr, self_expr: &hir::Expr, arg: &hir::Expr,
|
fn check_general_case(
|
||||||
or_has_args: bool, span: Span) {
|
cx: &LateContext, name: &str, fun: &hir::Expr, self_expr: &hir::Expr, arg: &hir::Expr, or_has_args: bool,
|
||||||
|
span: Span
|
||||||
|
) {
|
||||||
// don't lint for constant values
|
// don't lint for constant values
|
||||||
// FIXME: can we `expect` here instead of match?
|
// FIXME: can we `expect` here instead of match?
|
||||||
if let Some(qualif) = cx.tcx.const_qualif_map.borrow().get(&arg.id) {
|
if let Some(qualif) = cx.tcx.const_qualif_map.borrow().get(&arg.id) {
|
||||||
|
@ -776,10 +778,10 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir:
|
||||||
span,
|
span,
|
||||||
&format!("use of `{}` followed by a function call", name),
|
&format!("use of `{}` followed by a function call", name),
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(span,
|
db.span_suggestion(span,
|
||||||
"try this",
|
"try this",
|
||||||
format!("{}.{}_{}({})", snippet(cx, self_expr.span, "_"), name, suffix, sugg));
|
format!("{}.{}_{}({})", snippet(cx, self_expr.span, "_"), name, suffix, sugg));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.len() == 2 {
|
if args.len() == 2 {
|
||||||
|
@ -836,10 +838,10 @@ fn lint_vec_extend(cx: &LateContext, expr: &hir::Expr, args: &[hir::Expr]) {
|
||||||
expr.span,
|
expr.span,
|
||||||
"use of `extend` to extend a Vec by a slice",
|
"use of `extend` to extend a Vec by a slice",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(expr.span,
|
db.span_suggestion(expr.span,
|
||||||
"try this",
|
"try this",
|
||||||
format!("{}.extend_from_slice({})", snippet(cx, args[0].span, "_"), slice));
|
format!("{}.extend_from_slice({})", snippet(cx, args[0].span, "_"), slice));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1223,8 +1225,8 @@ fn lint_single_char_pattern(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr)
|
||||||
arg.span,
|
arg.span,
|
||||||
"single-character string constant used as pattern",
|
"single-character string constant used as pattern",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(expr.span, "try using a char instead:", hint);
|
db.span_suggestion(expr.span, "try using a char instead:", hint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,11 +277,11 @@ impl EarlyLintPass for MiscEarly {
|
||||||
expr.span,
|
expr.span,
|
||||||
"Try not to call a closure in the expression where it is declared.",
|
"Try not to call a closure in the expression where it is declared.",
|
||||||
|db| {
|
|db| {
|
||||||
if decl.inputs.is_empty() {
|
if decl.inputs.is_empty() {
|
||||||
let hint = snippet(cx, block.span, "..").into_owned();
|
let hint = snippet(cx, block.span, "..").into_owned();
|
||||||
db.span_suggestion(expr.span, "Try doing something like: ", hint);
|
db.span_suggestion(expr.span, "Try doing something like: ", hint);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,10 @@
|
||||||
// Note: More specifically this lint is largely inspired (aka copied) from *rustc*'s
|
// Note: More specifically this lint is largely inspired (aka copied) from *rustc*'s
|
||||||
// [`missing_doc`].
|
// [`missing_doc`].
|
||||||
//
|
//
|
||||||
// [`missing_doc`]: https://github.com/rust-lang/rust/blob/d6d05904697d89099b55da3331155392f1db9c00/src/librustc_lint/builtin.rs#L246
|
// [`missing_doc`]:
|
||||||
|
// https://github.
|
||||||
|
// com/rust-lang/rust/blob/d6d05904697d89099b55da3331155392f1db9c00/src/librustc_lint/builtin.
|
||||||
|
// rs#L246
|
||||||
//
|
//
|
||||||
|
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
|
|
|
@ -75,8 +75,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
|
||||||
e.span,
|
e.span,
|
||||||
"this if-then-else expression returns a bool literal",
|
"this if-then-else expression returns a bool literal",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(e.span, "you can reduce it to", hint);
|
db.span_suggestion(e.span, "you can reduce it to", hint);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
|
match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
|
||||||
(RetBool(true), RetBool(true)) |
|
(RetBool(true), RetBool(true)) |
|
||||||
|
@ -124,8 +124,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||||
e.span,
|
e.span,
|
||||||
"equality checks against true are unnecessary",
|
"equality checks against true are unnecessary",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(e.span, "try simplifying it as shown:", hint);
|
db.span_suggestion(e.span, "try simplifying it as shown:", hint);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(Other, Bool(true)) => {
|
(Other, Bool(true)) => {
|
||||||
let hint = snippet(cx, left_side.span, "..").into_owned();
|
let hint = snippet(cx, left_side.span, "..").into_owned();
|
||||||
|
@ -134,8 +134,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||||
e.span,
|
e.span,
|
||||||
"equality checks against true are unnecessary",
|
"equality checks against true are unnecessary",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(e.span, "try simplifying it as shown:", hint);
|
db.span_suggestion(e.span, "try simplifying it as shown:", hint);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(Bool(false), Other) => {
|
(Bool(false), Other) => {
|
||||||
let hint = Sugg::hir(cx, right_side, "..");
|
let hint = Sugg::hir(cx, right_side, "..");
|
||||||
|
@ -144,10 +144,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||||
e.span,
|
e.span,
|
||||||
"equality checks against false can be replaced by a negation",
|
"equality checks against false can be replaced by a negation",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(e.span,
|
db.span_suggestion(e.span, "try simplifying it as shown:", (!hint).to_string());
|
||||||
"try simplifying it as shown:",
|
});
|
||||||
(!hint).to_string());
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
(Other, Bool(false)) => {
|
(Other, Bool(false)) => {
|
||||||
let hint = Sugg::hir(cx, left_side, "..");
|
let hint = Sugg::hir(cx, left_side, "..");
|
||||||
|
@ -156,10 +154,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||||
e.span,
|
e.span,
|
||||||
"equality checks against false can be replaced by a negation",
|
"equality checks against false can be replaced by a negation",
|
||||||
|db| {
|
|db| {
|
||||||
db.span_suggestion(e.span,
|
db.span_suggestion(e.span, "try simplifying it as shown:", (!hint).to_string());
|
||||||
"try simplifying it as shown:",
|
});
|
||||||
(!hint).to_string());
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,8 +90,10 @@ impl LintPass for NewWithoutDefault {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
||||||
fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, kind: FnKind<'tcx>, decl: &'tcx hir::FnDecl,
|
fn check_fn(
|
||||||
_: &'tcx hir::Expr, span: Span, id: ast::NodeId) {
|
&mut self, cx: &LateContext<'a, 'tcx>, kind: FnKind<'tcx>, decl: &'tcx hir::FnDecl, _: &'tcx hir::Expr,
|
||||||
|
span: Span, id: ast::NodeId
|
||||||
|
) {
|
||||||
if in_external_macro(cx, span) {
|
if in_external_macro(cx, span) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,8 @@ impl<'a, 'tcx> Visitor<'tcx> for SimilarNamesLocalVisitor<'a, 'tcx> {
|
||||||
if let Some(ref init) = local.init {
|
if let Some(ref init) = local.init {
|
||||||
self.apply(|this| walk_expr(this, &**init));
|
self.apply(|this| walk_expr(this, &**init));
|
||||||
}
|
}
|
||||||
// add the pattern after the expression because the bindings aren't available yet in the init expression
|
// add the pattern after the expression because the bindings aren't available yet in the init
|
||||||
|
// expression
|
||||||
SimilarNamesNameVisitor(self).visit_pat(&*local.pat);
|
SimilarNamesNameVisitor(self).visit_pat(&*local.pat);
|
||||||
}
|
}
|
||||||
fn visit_block(&mut self, blk: &'tcx Block) {
|
fn visit_block(&mut self, blk: &'tcx Block) {
|
||||||
|
@ -249,7 +250,8 @@ impl<'a, 'tcx> Visitor<'tcx> for SimilarNamesLocalVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
fn visit_arm(&mut self, arm: &'tcx Arm) {
|
fn visit_arm(&mut self, arm: &'tcx Arm) {
|
||||||
self.apply(|this| {
|
self.apply(|this| {
|
||||||
// just go through the first pattern, as either all patterns bind the same bindings or rustc would have errored much earlier
|
// just go through the first pattern, as either all patterns
|
||||||
|
// bind the same bindings or rustc would have errored much earlier
|
||||||
SimilarNamesNameVisitor(this).visit_pat(&arm.pats[0]);
|
SimilarNamesNameVisitor(this).visit_pat(&arm.pats[0]);
|
||||||
this.apply(|this| walk_expr(this, &arm.body));
|
this.apply(|this| walk_expr(this, &arm.body));
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,12 +44,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional {
|
||||||
], {
|
], {
|
||||||
if let BinOp_::BiLt = op.node {
|
if let BinOp_::BiLt = op.node {
|
||||||
if let BinOp_::BiAdd = op2.node {
|
if let BinOp_::BiAdd = op2.node {
|
||||||
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C overflow conditions that will fail in Rust.");
|
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
|
||||||
|
"You are trying to use classic C overflow conditions that will fail in Rust.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let BinOp_::BiGt = op.node {
|
if let BinOp_::BiGt = op.node {
|
||||||
if let BinOp_::BiSub = op2.node {
|
if let BinOp_::BiSub = op2.node {
|
||||||
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C underflow conditions that will fail in Rust.");
|
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
|
||||||
|
"You are trying to use classic C underflow conditions that will fail in Rust.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -66,12 +68,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional {
|
||||||
], {
|
], {
|
||||||
if let BinOp_::BiGt = op.node {
|
if let BinOp_::BiGt = op.node {
|
||||||
if let BinOp_::BiAdd = op2.node {
|
if let BinOp_::BiAdd = op2.node {
|
||||||
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C overflow conditions that will fail in Rust.");
|
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
|
||||||
|
"You are trying to use classic C overflow conditions that will fail in Rust.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let BinOp_::BiLt = op.node {
|
if let BinOp_::BiLt = op.node {
|
||||||
if let BinOp_::BiSub = op2.node {
|
if let BinOp_::BiSub = op2.node {
|
||||||
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span, "You are trying to use classic C underflow conditions that will fail in Rust.");
|
span_lint(cx, OVERFLOW_CHECK_CONDITIONAL, expr.span,
|
||||||
|
"You are trying to use classic C underflow conditions that will fail in Rust.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -233,8 +233,8 @@ fn lint_shadow<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, name: Name, span: Span,
|
||||||
snippet(cx, pattern_span, "_"),
|
snippet(cx, pattern_span, "_"),
|
||||||
snippet(cx, expr.span, "..")),
|
snippet(cx, expr.span, "..")),
|
||||||
|db| {
|
|db| {
|
||||||
db.span_note(prev_span, "previous binding is here");
|
db.span_note(prev_span, "previous binding is here");
|
||||||
});
|
});
|
||||||
} else if contains_self(cx, name, expr) {
|
} else if contains_self(cx, name, expr) {
|
||||||
span_lint_and_then(cx,
|
span_lint_and_then(cx,
|
||||||
SHADOW_REUSE,
|
SHADOW_REUSE,
|
||||||
|
@ -243,9 +243,9 @@ fn lint_shadow<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, name: Name, span: Span,
|
||||||
snippet(cx, pattern_span, "_"),
|
snippet(cx, pattern_span, "_"),
|
||||||
snippet(cx, expr.span, "..")),
|
snippet(cx, expr.span, "..")),
|
||||||
|db| {
|
|db| {
|
||||||
db.span_note(expr.span, "initialization happens here");
|
db.span_note(expr.span, "initialization happens here");
|
||||||
db.span_note(prev_span, "previous binding is here");
|
db.span_note(prev_span, "previous binding is here");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
span_lint_and_then(cx,
|
span_lint_and_then(cx,
|
||||||
SHADOW_UNRELATED,
|
SHADOW_UNRELATED,
|
||||||
|
@ -254,9 +254,9 @@ fn lint_shadow<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, name: Name, span: Span,
|
||||||
snippet(cx, pattern_span, "_"),
|
snippet(cx, pattern_span, "_"),
|
||||||
snippet(cx, expr.span, "..")),
|
snippet(cx, expr.span, "..")),
|
||||||
|db| {
|
|db| {
|
||||||
db.span_note(expr.span, "initialization happens here");
|
db.span_note(expr.span, "initialization happens here");
|
||||||
db.span_note(prev_span, "previous binding is here");
|
db.span_note(prev_span, "previous binding is here");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -265,8 +265,8 @@ fn lint_shadow<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, name: Name, span: Span,
|
||||||
span,
|
span,
|
||||||
&format!("`{}` shadows a previous declaration", snippet(cx, pattern_span, "_")),
|
&format!("`{}` shadows a previous declaration", snippet(cx, pattern_span, "_")),
|
||||||
|db| {
|
|db| {
|
||||||
db.span_note(prev_span, "previous binding is here");
|
db.span_note(prev_span, "previous binding is here");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,11 +152,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
|
||||||
e.span,
|
e.span,
|
||||||
"calling `as_bytes()` on a string literal",
|
"calling `as_bytes()` on a string literal",
|
||||||
|db| {
|
|db| {
|
||||||
let sugg = format!("b{}", snippet(cx, args[0].span, r#""foo""#));
|
let sugg = format!("b{}", snippet(cx, args[0].span, r#""foo""#));
|
||||||
db.span_suggestion(e.span,
|
db.span_suggestion(e.span, "consider using a byte string literal instead", sugg);
|
||||||
"consider using a byte string literal instead",
|
});
|
||||||
sugg);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -741,7 +741,7 @@ enum AbsurdComparisonResult {
|
||||||
|
|
||||||
|
|
||||||
fn detect_absurd_comparison<'a>(cx: &LateContext, op: BinOp_, lhs: &'a Expr, rhs: &'a Expr)
|
fn detect_absurd_comparison<'a>(cx: &LateContext, op: BinOp_, lhs: &'a Expr, rhs: &'a Expr)
|
||||||
-> Option<(ExtremeExpr<'a>, AbsurdComparisonResult)> {
|
-> Option<(ExtremeExpr<'a>, AbsurdComparisonResult)> {
|
||||||
use types::ExtremeType::*;
|
use types::ExtremeType::*;
|
||||||
use types::AbsurdComparisonResult::*;
|
use types::AbsurdComparisonResult::*;
|
||||||
use utils::comparisons::*;
|
use utils::comparisons::*;
|
||||||
|
@ -1007,8 +1007,10 @@ fn err_upcast_comparison(cx: &LateContext, span: &Span, expr: &Expr, always: boo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upcast_comparison_bounds_err(cx: &LateContext, span: &Span, rel: comparisons::Rel,
|
fn upcast_comparison_bounds_err(
|
||||||
lhs_bounds: Option<(FullInt, FullInt)>, lhs: &Expr, rhs: &Expr, invert: bool) {
|
cx: &LateContext, span: &Span, rel: comparisons::Rel, lhs_bounds: Option<(FullInt, FullInt)>, lhs: &Expr,
|
||||||
|
rhs: &Expr, invert: bool
|
||||||
|
) {
|
||||||
use utils::comparisons::*;
|
use utils::comparisons::*;
|
||||||
|
|
||||||
if let Some((lb, ub)) = lhs_bounds {
|
if let Some((lb, ub)) = lhs_bounds {
|
||||||
|
|
|
@ -41,8 +41,10 @@ impl LintPass for UnusedLabel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedLabel {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedLabel {
|
||||||
fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, kind: FnKind<'tcx>, decl: &'tcx hir::FnDecl,
|
fn check_fn(
|
||||||
body: &'tcx hir::Expr, span: Span, fn_id: ast::NodeId) {
|
&mut self, cx: &LateContext<'a, 'tcx>, kind: FnKind<'tcx>, decl: &'tcx hir::FnDecl, body: &'tcx hir::Expr,
|
||||||
|
span: Span, fn_id: ast::NodeId
|
||||||
|
) {
|
||||||
if in_macro(cx, span) {
|
if in_macro(cx, span) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use toml;
|
||||||
|
|
||||||
/// Get the configuration file from arguments.
|
/// Get the configuration file from arguments.
|
||||||
pub fn file_from_args(args: &[codemap::Spanned<ast::NestedMetaItemKind>])
|
pub fn file_from_args(args: &[codemap::Spanned<ast::NestedMetaItemKind>])
|
||||||
-> Result<Option<path::PathBuf>, (&'static str, codemap::Span)> {
|
-> Result<Option<path::PathBuf>, (&'static str, codemap::Span)> {
|
||||||
for arg in args.iter().filter_map(|a| a.meta_item()) {
|
for arg in args.iter().filter_map(|a| a.meta_item()) {
|
||||||
if arg.name() == "conf_file" {
|
if arg.name() == "conf_file" {
|
||||||
return match arg.node {
|
return match arg.node {
|
||||||
|
|
|
@ -73,7 +73,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, var: &'tcx hir::Variant, _: &hir::Generics) {
|
// fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, var: &'tcx hir::Variant, _:
|
||||||
|
// &hir::Generics) {
|
||||||
// if !has_attr(&var.node.attrs) {
|
// if !has_attr(&var.node.attrs) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -317,9 +317,8 @@ pub fn get_trait_def_id(cx: &LateContext, path: &[&str]) -> Option<DefId> {
|
||||||
|
|
||||||
/// Check whether a type implements a trait.
|
/// Check whether a type implements a trait.
|
||||||
/// See also `get_trait_def_id`.
|
/// See also `get_trait_def_id`.
|
||||||
pub fn implements_trait<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>, trait_id: DefId,
|
pub fn implements_trait<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>, trait_id: DefId, ty_params: Vec<ty::Ty<'tcx>>)
|
||||||
ty_params: Vec<ty::Ty<'tcx>>)
|
-> bool {
|
||||||
-> bool {
|
|
||||||
cx.tcx.populate_implementations_for_trait_if_necessary(trait_id);
|
cx.tcx.populate_implementations_for_trait_if_necessary(trait_id);
|
||||||
|
|
||||||
let ty = cx.tcx.erase_regions(&ty);
|
let ty = cx.tcx.erase_regions(&ty);
|
||||||
|
@ -403,7 +402,7 @@ pub fn snippet_block<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'
|
||||||
/// Like `snippet_block`, but add braces if the expr is not an `ExprBlock`.
|
/// Like `snippet_block`, but add braces if the expr is not an `ExprBlock`.
|
||||||
/// Also takes an `Option<String>` which can be put inside the braces.
|
/// Also takes an `Option<String>` which can be put inside the braces.
|
||||||
pub fn expr_block<'a, 'b, T: LintContext<'b>>(cx: &T, expr: &Expr, option: Option<String>, default: &'a str)
|
pub fn expr_block<'a, 'b, T: LintContext<'b>>(cx: &T, expr: &Expr, option: Option<String>, default: &'a str)
|
||||||
-> Cow<'a, str> {
|
-> Cow<'a, str> {
|
||||||
let code = snippet_block(cx, expr.span, default);
|
let code = snippet_block(cx, expr.span, default);
|
||||||
let string = option.unwrap_or_default();
|
let string = option.unwrap_or_default();
|
||||||
if let ExprBlock(_) = expr.node {
|
if let ExprBlock(_) = expr.node {
|
||||||
|
@ -758,7 +757,7 @@ pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> ty::T
|
||||||
// FIXME: this works correctly for lifetimes bounds (`for <'a> Foo<'a>` == `for <'b> Foo<'b>` but
|
// FIXME: this works correctly for lifetimes bounds (`for <'a> Foo<'a>` == `for <'b> Foo<'b>` but
|
||||||
// not for type parameters.
|
// not for type parameters.
|
||||||
pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: ty::Ty<'tcx>, b: ty::Ty<'tcx>, parameter_item: NodeId)
|
pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: ty::Ty<'tcx>, b: ty::Ty<'tcx>, parameter_item: NodeId)
|
||||||
-> bool {
|
-> bool {
|
||||||
let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, parameter_item);
|
let parameter_env = ty::ParameterEnvironment::for_item(cx.tcx, parameter_item);
|
||||||
cx.tcx.infer_ctxt(None, Some(parameter_env), Reveal::All).enter(|infcx| {
|
cx.tcx.infer_ctxt(None, Some(parameter_env), Reveal::All).enter(|infcx| {
|
||||||
let new_a = a.subst(infcx.tcx, infcx.parameter_environment.free_substs);
|
let new_a = a.subst(infcx.tcx, infcx.parameter_environment.free_substs);
|
||||||
|
|
|
@ -4,3 +4,7 @@ fn_args_density = "Compressed"
|
||||||
fn_call_width = 80
|
fn_call_width = 80
|
||||||
fn_args_paren_newline = false
|
fn_args_paren_newline = false
|
||||||
match_block_trailing_comma = true
|
match_block_trailing_comma = true
|
||||||
|
fn_args_layout = "Block"
|
||||||
|
closure_block_indent_threshold = 0
|
||||||
|
fn_return_indent = "WithWhereClause"
|
||||||
|
wrap_comments = true
|
||||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -38,19 +38,22 @@ impl ClippyCompilerCalls {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
|
impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
|
||||||
fn early_callback(&mut self, matches: &getopts::Matches, sopts: &config::Options, cfg: &ast::CrateConfig,
|
fn early_callback(
|
||||||
descriptions: &rustc_errors::registry::Registry, output: ErrorOutputType)
|
&mut self, matches: &getopts::Matches, sopts: &config::Options, cfg: &ast::CrateConfig,
|
||||||
-> Compilation {
|
descriptions: &rustc_errors::registry::Registry, output: ErrorOutputType
|
||||||
|
) -> Compilation {
|
||||||
self.default.early_callback(matches, sopts, cfg, descriptions, output)
|
self.default.early_callback(matches, sopts, cfg, descriptions, output)
|
||||||
}
|
}
|
||||||
fn no_input(&mut self, matches: &getopts::Matches, sopts: &config::Options, cfg: &ast::CrateConfig,
|
fn no_input(
|
||||||
odir: &Option<PathBuf>, ofile: &Option<PathBuf>, descriptions: &rustc_errors::registry::Registry)
|
&mut self, matches: &getopts::Matches, sopts: &config::Options, cfg: &ast::CrateConfig, odir: &Option<PathBuf>,
|
||||||
-> Option<(Input, Option<PathBuf>)> {
|
ofile: &Option<PathBuf>, descriptions: &rustc_errors::registry::Registry
|
||||||
|
) -> Option<(Input, Option<PathBuf>)> {
|
||||||
self.default.no_input(matches, sopts, cfg, odir, ofile, descriptions)
|
self.default.no_input(matches, sopts, cfg, odir, ofile, descriptions)
|
||||||
}
|
}
|
||||||
fn late_callback(&mut self, matches: &getopts::Matches, sess: &Session, input: &Input, odir: &Option<PathBuf>,
|
fn late_callback(
|
||||||
ofile: &Option<PathBuf>)
|
&mut self, matches: &getopts::Matches, sess: &Session, input: &Input, odir: &Option<PathBuf>,
|
||||||
-> Compilation {
|
ofile: &Option<PathBuf>
|
||||||
|
) -> Compilation {
|
||||||
self.default.late_callback(matches, sess, input, odir, ofile)
|
self.default.late_callback(matches, sess, input, odir, ofile)
|
||||||
}
|
}
|
||||||
fn build_controller(&mut self, sess: &Session, matches: &getopts::Matches) -> driver::CompileController<'a> {
|
fn build_controller(&mut self, sess: &Session, matches: &getopts::Matches) -> driver::CompileController<'a> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue