2016-06-03 14:45:07 +00:00
|
|
|
#![feature(plugin, const_fn)]
|
2016-03-01 15:25:15 +00:00
|
|
|
#![plugin(clippy)]
|
|
|
|
|
|
|
|
#![allow(dead_code)]
|
2016-05-17 06:33:57 +00:00
|
|
|
#![deny(new_without_default, new_without_default_derive)]
|
2016-03-01 15:25:15 +00:00
|
|
|
|
2016-06-01 21:35:14 +00:00
|
|
|
pub struct Foo;
|
2016-12-29 19:19:32 +00:00
|
|
|
//~^HELP try this
|
|
|
|
//~^^SUGGESTION #[derive(Default)]
|
|
|
|
//~^^SUGGESTION pub struct Foo
|
2016-03-01 15:25:15 +00:00
|
|
|
|
|
|
|
impl Foo {
|
2016-07-10 12:07:13 +00:00
|
|
|
pub fn new() -> Foo { Foo }
|
|
|
|
//~^ERROR: you should consider deriving a `Default` implementation for `Foo`
|
2016-03-01 15:25:15 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 21:35:14 +00:00
|
|
|
pub struct Bar;
|
2016-12-29 19:19:32 +00:00
|
|
|
//~^HELP try this
|
|
|
|
//~^^SUGGESTION #[derive(Default)]
|
|
|
|
//~^^SUGGESTION pub struct Bar
|
2016-03-01 15:25:15 +00:00
|
|
|
|
|
|
|
impl Bar {
|
2016-07-10 12:07:13 +00:00
|
|
|
pub fn new() -> Self { Bar }
|
|
|
|
//~^ERROR: you should consider deriving a `Default` implementation for `Bar`
|
2016-03-01 15:25:15 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 21:35:14 +00:00
|
|
|
pub struct Ok;
|
2016-03-01 15:25:15 +00:00
|
|
|
|
|
|
|
impl Ok {
|
2016-06-01 21:35:14 +00:00
|
|
|
pub fn new() -> Self { Ok }
|
2016-03-01 15:25:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Ok {
|
|
|
|
fn default() -> Self { Ok }
|
|
|
|
}
|
|
|
|
|
2016-06-01 21:35:14 +00:00
|
|
|
pub struct Params;
|
2016-03-01 15:25:15 +00:00
|
|
|
|
|
|
|
impl Params {
|
2016-06-01 21:35:14 +00:00
|
|
|
pub fn new(_: u32) -> Self { Params }
|
2016-03-01 15:25:15 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 21:35:14 +00:00
|
|
|
pub struct GenericsOk<T> {
|
2016-03-03 18:46:10 +00:00
|
|
|
bar: T,
|
|
|
|
}
|
|
|
|
|
2016-03-18 18:12:32 +00:00
|
|
|
impl<U> Default for GenericsOk<U> {
|
|
|
|
fn default() -> Self { unimplemented!(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'c, V> GenericsOk<V> {
|
2016-06-01 21:35:14 +00:00
|
|
|
pub fn new() -> GenericsOk<V> { unimplemented!() }
|
2016-03-18 18:12:32 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 21:35:14 +00:00
|
|
|
pub struct LtOk<'a> {
|
2016-03-18 18:12:32 +00:00
|
|
|
foo: &'a bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'b> Default for LtOk<'b> {
|
|
|
|
fn default() -> Self { unimplemented!(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'c> LtOk<'c> {
|
2016-06-01 21:35:14 +00:00
|
|
|
pub fn new() -> LtOk<'c> { unimplemented!() }
|
2016-03-18 18:12:32 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 21:35:14 +00:00
|
|
|
pub struct LtKo<'a> {
|
2016-03-18 18:12:32 +00:00
|
|
|
foo: &'a bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'c> LtKo<'c> {
|
2016-07-10 12:07:13 +00:00
|
|
|
pub fn new() -> LtKo<'c> { unimplemented!() }
|
|
|
|
//~^ERROR: you should consider adding a `Default` implementation for
|
|
|
|
//~^^HELP try
|
|
|
|
//~^^^SUGGESTION impl Default for LtKo<'c> {
|
|
|
|
//~^^^SUGGESTION fn default() -> Self {
|
|
|
|
//~^^^SUGGESTION Self::new()
|
|
|
|
//~^^^SUGGESTION }
|
|
|
|
//~^^^SUGGESTION }
|
|
|
|
// FIXME: that suggestion is missing lifetimes
|
2016-06-01 21:35:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Private;
|
|
|
|
|
|
|
|
impl Private {
|
|
|
|
fn new() -> Private { unimplemented!() } // We don't lint private items
|
2016-03-03 18:46:10 +00:00
|
|
|
}
|
|
|
|
|
2016-06-03 14:45:07 +00:00
|
|
|
struct Const;
|
|
|
|
|
|
|
|
impl Const {
|
|
|
|
pub const fn new() -> Const { Const } // const fns can't be implemented via Default
|
|
|
|
}
|
2016-03-01 15:25:15 +00:00
|
|
|
fn main() {}
|