Skip to content

Commit

Permalink
In lint, don't complain about infer mode if legacy modes aren't enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
catamorphism committed Oct 1, 2012
1 parent e480e19 commit 24fbf88
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/rustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,8 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl,
mode_to_str(arg_ast.mode));
match arg_ast.mode {
ast::expl(ast::by_copy) => {
/* always allow by-copy */
// This should warn, but we can't yet
// since it's still used. -- tjc
}

ast::expl(_) => {
Expand All @@ -694,14 +695,16 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl,
}

ast::infer(_) => {
let kind = ty::type_kind(tcx, arg_ty.ty);
if !ty::kind_is_safe_for_default_mode(kind) {
tcx.sess.span_lint(
deprecated_mode, id, id,
span,
fmt!("argument %d uses the default mode \
but shouldn't",
counter));
if tcx.legacy_modes {
let kind = ty::type_kind(tcx, arg_ty.ty);
if !ty::kind_is_safe_for_default_mode(kind) {
tcx.sess.span_lint(
deprecated_mode, id, id,
span,
fmt!("argument %d uses the default mode \
but shouldn't",
counter));
}
}
}
}
Expand Down

0 comments on commit 24fbf88

Please sign in to comment.