2016-06-03 16:45:07 +02:00
|
|
|
#![feature(plugin, const_fn)]
|
2017-09-18 12:47:33 +02:00
|
|
|
|
2016-03-01 16:25:15 +01:00
|
|
|
|
|
|
|
#![allow(dead_code)]
|
2017-05-17 14:19:44 +02:00
|
|
|
#![warn(new_without_default, new_without_default_derive)]
|
2016-03-01 16:25:15 +01:00
|
|
|
|
2016-06-01 23:35:14 +02:00
|
|
|
pub struct Foo;
|
2017-02-08 14:58:07 +01:00
|
|
|
|
2016-03-01 16:25:15 +01:00
|
|
|
impl Foo {
|
2016-07-10 14:07:13 +02:00
|
|
|
pub fn new() -> Foo { Foo }
|
2016-03-01 16:25:15 +01:00
|
|
|
}
|
|
|
|
|
2016-06-01 23:35:14 +02:00
|
|
|
pub struct Bar;
|
2017-02-08 14:58:07 +01:00
|
|
|
|
2016-03-01 16:25:15 +01:00
|
|
|
impl Bar {
|
2016-07-10 14:07:13 +02:00
|
|
|
pub fn new() -> Self { Bar }
|
2016-03-01 16:25:15 +01:00
|
|
|
}
|
|
|
|
|
2016-06-01 23:35:14 +02:00
|
|
|
pub struct Ok;
|
2016-03-01 16:25:15 +01:00
|
|
|
|
|
|
|
impl Ok {
|
2016-06-01 23:35:14 +02:00
|
|
|
pub fn new() -> Self { Ok }
|
2016-03-01 16:25:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Ok {
|
|
|
|
fn default() -> Self { Ok }
|
|
|
|
}
|
|
|
|
|
2016-06-01 23:35:14 +02:00
|
|
|
pub struct Params;
|
2016-03-01 16:25:15 +01:00
|
|
|
|
|
|
|
impl Params {
|
2016-06-01 23:35:14 +02:00
|
|
|
pub fn new(_: u32) -> Self { Params }
|
2016-03-01 16:25:15 +01:00
|
|
|
}
|
|
|
|
|
2016-06-01 23:35:14 +02:00
|
|
|
pub struct GenericsOk<T> {
|
2016-03-03 19:46:10 +01:00
|
|
|
bar: T,
|
|
|
|
}
|
|
|
|
|
2016-03-18 19:12:32 +01:00
|
|
|
impl<U> Default for GenericsOk<U> {
|
|
|
|
fn default() -> Self { unimplemented!(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'c, V> GenericsOk<V> {
|
2016-06-01 23:35:14 +02:00
|
|
|
pub fn new() -> GenericsOk<V> { unimplemented!() }
|
2016-03-18 19:12:32 +01:00
|
|
|
}
|
|
|
|
|
2016-06-01 23:35:14 +02:00
|
|
|
pub struct LtOk<'a> {
|
2016-03-18 19:12:32 +01:00
|
|
|
foo: &'a bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'b> Default for LtOk<'b> {
|
|
|
|
fn default() -> Self { unimplemented!(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'c> LtOk<'c> {
|
2016-06-01 23:35:14 +02:00
|
|
|
pub fn new() -> LtOk<'c> { unimplemented!() }
|
2016-03-18 19:12:32 +01:00
|
|
|
}
|
|
|
|
|
2016-06-01 23:35:14 +02:00
|
|
|
pub struct LtKo<'a> {
|
2016-03-18 19:12:32 +01:00
|
|
|
foo: &'a bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'c> LtKo<'c> {
|
2016-07-10 14:07:13 +02:00
|
|
|
pub fn new() -> LtKo<'c> { unimplemented!() }
|
|
|
|
// FIXME: that suggestion is missing lifetimes
|
2016-06-01 23:35:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Private;
|
|
|
|
|
|
|
|
impl Private {
|
|
|
|
fn new() -> Private { unimplemented!() } // We don't lint private items
|
2016-03-03 19:46:10 +01:00
|
|
|
}
|
|
|
|
|
2016-06-03 16:45:07 +02:00
|
|
|
struct Const;
|
|
|
|
|
|
|
|
impl Const {
|
|
|
|
pub const fn new() -> Const { Const } // const fns can't be implemented via Default
|
|
|
|
}
|
2017-06-14 18:50:19 +02:00
|
|
|
|
|
|
|
pub struct IgnoreGenericNew;
|
|
|
|
|
|
|
|
impl IgnoreGenericNew {
|
|
|
|
pub fn new<T>() -> Self { IgnoreGenericNew } // the derived Default does not make sense here as the result depends on T
|
|
|
|
}
|
|
|
|
|
2016-03-01 16:25:15 +01:00
|
|
|
fn main() {}
|