2016-03-08 23:48:10 +00:00
|
|
|
|
#![feature(plugin)]
|
|
|
|
|
#![plugin(clippy)]
|
|
|
|
|
|
|
|
|
|
#![deny(clippy)]
|
|
|
|
|
#![allow(dead_code)]
|
2016-06-07 14:55:55 +00:00
|
|
|
|
#![allow(unused_unsafe)]
|
2016-03-08 23:48:10 +00:00
|
|
|
|
|
2016-06-07 14:55:55 +00:00
|
|
|
|
// TOO_MANY_ARGUMENTS
|
2016-03-08 23:48:10 +00:00
|
|
|
|
fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {}
|
|
|
|
|
|
|
|
|
|
fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {
|
2016-05-12 15:52:51 +00:00
|
|
|
|
//~^ ERROR: this function has too many arguments (8/7)
|
2016-03-08 23:48:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 15:21:47 +00:00
|
|
|
|
// don't lint extern fns
|
|
|
|
|
extern fn extern_fn(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
|
|
|
|
|
|
2016-06-07 14:55:55 +00:00
|
|
|
|
pub trait Foo {
|
2016-03-08 23:48:10 +00:00
|
|
|
|
fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool);
|
|
|
|
|
fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ());
|
2016-05-12 15:52:51 +00:00
|
|
|
|
//~^ ERROR: this function has too many arguments (8/7)
|
2016-06-07 14:55:55 +00:00
|
|
|
|
|
|
|
|
|
fn ptr(p: *const u8);
|
2016-03-08 23:48:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-07 14:55:55 +00:00
|
|
|
|
pub struct Bar;
|
2016-03-08 23:48:10 +00:00
|
|
|
|
|
|
|
|
|
impl Bar {
|
|
|
|
|
fn good_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {}
|
|
|
|
|
fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
|
2016-05-12 15:52:51 +00:00
|
|
|
|
//~^ ERROR: this function has too many arguments (8/7)
|
2016-03-08 23:48:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ok, we don’t want to warn implementations
|
|
|
|
|
impl Foo for Bar {
|
|
|
|
|
fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {}
|
|
|
|
|
fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
|
2016-06-07 14:55:55 +00:00
|
|
|
|
|
|
|
|
|
fn ptr(p: *const u8) {
|
|
|
|
|
println!("{}", unsafe { *p });
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
2016-06-07 15:29:22 +00:00
|
|
|
|
println!("{:?}", unsafe { p.as_ref() });
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
|
|
|
|
unsafe { std::ptr::read(p) };
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
2016-06-07 14:55:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NOT_UNSAFE_PTR_ARG_DEREF
|
|
|
|
|
|
|
|
|
|
fn private(p: *const u8) {
|
|
|
|
|
println!("{}", unsafe { *p });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn public(p: *const u8) {
|
|
|
|
|
println!("{}", unsafe { *p });
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
|
|
|
|
println!("{:?}", unsafe { p.as_ref() });
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
2016-06-07 15:29:22 +00:00
|
|
|
|
unsafe { std::ptr::read(p) };
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
2016-06-07 14:55:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Bar {
|
|
|
|
|
fn private(self, p: *const u8) {
|
|
|
|
|
println!("{}", unsafe { *p });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn public(self, p: *const u8) {
|
|
|
|
|
println!("{}", unsafe { *p });
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
|
|
|
|
println!("{:?}", unsafe { p.as_ref() });
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
2016-06-07 15:29:22 +00:00
|
|
|
|
unsafe { std::ptr::read(p) };
|
|
|
|
|
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
2016-06-07 14:55:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn public_ok(self, p: *const u8) {
|
|
|
|
|
if !p.is_null() {
|
|
|
|
|
println!("{:p}", p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub unsafe fn public_unsafe(self, p: *const u8) {
|
|
|
|
|
println!("{}", unsafe { *p });
|
|
|
|
|
println!("{:?}", unsafe { p.as_ref() });
|
|
|
|
|
}
|
2016-03-08 23:48:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {}
|