diff --git a/src/test/run-pass/existential_type.rs b/src/test/run-pass/existential_type.rs index d2cecd83036e..e63d5c2293a8 100644 --- a/src/test/run-pass/existential_type.rs +++ b/src/test/run-pass/existential_type.rs @@ -75,10 +75,10 @@ fn my_other_iter(u: U) -> MyOtherIter { } trait Trait {} -existential type GenericBound: 'static; +existential type GenericBound<'a, T: Trait>: 'a; -fn generic_bound(_: T) -> GenericBound { - unimplemented!() +fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> { + t } mod pass_through { @@ -92,22 +92,3 @@ mod pass_through { fn use_passthrough(x: pass_through::Passthrough) -> pass_through::Passthrough { x } - -existential type PartiallyDefined: 'static; - -// doesn't declare all PartiallyDefined for all possible `T`, but since it's the only -// function producing the value, noone can ever get a value that is problematic -fn partially_defined(_: T) -> PartiallyDefined { - 4u32 -} - -existential type PartiallyDefined2: 'static; - -fn partially_defined2(_: T) -> PartiallyDefined2 { - 4u32 -} - -// fully defines PartiallyDefine2 -fn partially_defined22(_: T) -> PartiallyDefined2 { - 4u32 -} diff --git a/src/test/ui/existential_types/unused_generic_param.rs b/src/test/ui/existential_types/unused_generic_param.rs new file mode 100644 index 000000000000..420ce89cc37c --- /dev/null +++ b/src/test/ui/existential_types/unused_generic_param.rs @@ -0,0 +1,30 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(existential_type)] + +fn main() { +} + +existential type PartiallyDefined: 'static; //~ `T` is unused + +fn partially_defined(_: T) -> PartiallyDefined { + 4u32 +} + +existential type PartiallyDefined2: 'static; //~ `T` is unused + +fn partially_defined2(_: T) -> PartiallyDefined2 { + 4u32 +} + +fn partially_defined22(_: T) -> PartiallyDefined2 { + 4u32 +} diff --git a/src/test/ui/existential_types/unused_generic_param.stderr b/src/test/ui/existential_types/unused_generic_param.stderr new file mode 100644 index 000000000000..7ad5eab0b0a6 --- /dev/null +++ b/src/test/ui/existential_types/unused_generic_param.stderr @@ -0,0 +1,15 @@ +error[E0091]: type parameter `T` is unused + --> $DIR/unused_generic_param.rs:16:35 + | +LL | existential type PartiallyDefined: 'static; //~ `T` is unused + | ^ unused type parameter + +error[E0091]: type parameter `T` is unused + --> $DIR/unused_generic_param.rs:22:36 + | +LL | existential type PartiallyDefined2: 'static; //~ `T` is unused + | ^ unused type parameter + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0091`.