Rustup to 1.9.0-nightly (c9629d61c 2016-03-10)

This commit is contained in:
mcarton 2016-03-10 18:13:49 +01:00
parent 233000da3d
commit c6316df19f
5 changed files with 40 additions and 30 deletions

View file

@ -124,13 +124,14 @@ impl<'a, 'b, 'tcx> Visitor<'a> for CCHelper<'b, 'tcx> {
ExprCall(ref callee, _) => {
walk_expr(self, e);
let ty = self.tcx.node_id_to_type(callee.id);
if let ty::TyBareFn(_, ty) = ty.sty {
if ty.sig.skip_binder().output.diverges() {
match ty.sty {
ty::TyFnDef(_, _, ty) | ty::TyFnPtr(ty) if ty.sig.skip_binder().output.diverges() => {
self.divergence += 1;
}
_ => (),
}
}
ExprClosure(..) => {}
ExprClosure(..) => (),
ExprBinary(op, _, _) => {
walk_expr(self, e);
match op.node {

View file

@ -155,7 +155,7 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref
TypeVariants::TyArray(_, size) if size > 32 => {
return;
}
TypeVariants::TyBareFn(..) => {
TypeVariants::TyFnPtr(..) => {
return;
}
TypeVariants::TyTuple(ref tys) if tys.len() > 12 => {

View file

@ -58,12 +58,15 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
return;
}
let fn_ty = cx.tcx.expr_ty(caller);
if let ty::TyBareFn(_, fn_ty) = fn_ty.sty {
match fn_ty.sty {
// Is it an unsafe function? They don't implement the closure traits
ty::TyFnDef(_, _, fn_ty) | ty::TyFnPtr(fn_ty) => {
if fn_ty.unsafety == Unsafety::Unsafe {
return;
}
}
_ => (),
}
for (ref a1, ref a2) in decl.inputs.iter().zip(args) {
if let PatKind::Ident(_, ident, _) = a1.pat.node {
// XXXManishearth Should I be checking the binding mode here?

View file

@ -53,7 +53,8 @@ impl LateLintPass for UnnecessaryMutPassed {
}
fn check_arguments(cx: &LateContext, arguments: &[P<Expr>], type_definition: &TyS, name: &str) {
if let TypeVariants::TyBareFn(_, ref fn_type) = type_definition.sty {
match type_definition.sty {
TypeVariants::TyFnDef(_, _, ref fn_type) | TypeVariants::TyFnPtr(ref fn_type) => {
let parameters = &fn_type.sig.skip_binder().inputs;
for (argument, parameter) in arguments.iter().zip(parameters.iter()) {
match parameter.sty {
@ -70,4 +71,6 @@ fn check_arguments(cx: &LateContext, arguments: &[P<Expr>], type_definition: &Ty
}
}
}
_ => (),
}
}

View file

@ -3,12 +3,8 @@
#![allow(unused_variables)]
fn takes_an_immutable_reference(a: &i32) {
}
fn takes_a_mutable_reference(a: &mut i32) {
}
fn takes_an_immutable_reference(a: &i32) {}
fn takes_a_mutable_reference(a: &mut i32) {}
struct MyStruct;
@ -24,6 +20,8 @@ impl MyStruct {
fn main() {
// Functions
takes_an_immutable_reference(&mut 42); //~ERROR The function/method "takes_an_immutable_reference" doesn't need a mutable reference
let foo: fn(&i32) = takes_an_immutable_reference;
foo(&mut 42); //~ERROR The function/method "foo" doesn't need a mutable reference
// Methods
let my_struct = MyStruct;
@ -34,7 +32,13 @@ fn main() {
// Functions
takes_an_immutable_reference(&42);
let foo: fn(&i32) = takes_an_immutable_reference;
foo(&42);
takes_a_mutable_reference(&mut 42);
let foo: fn(&mut i32) = takes_a_mutable_reference;
foo(&mut 42);
let a = &mut 42;
takes_an_immutable_reference(a);
@ -42,5 +46,4 @@ fn main() {
my_struct.takes_an_immutable_reference(&42);
my_struct.takes_a_mutable_reference(&mut 42);
my_struct.takes_an_immutable_reference(a);
}