Skip to content

Commit 442d5d8

Browse files
committed
Adjust run pass test to stricter existential type rules
1 parent f3b4492 commit 442d5d8

File tree

3 files changed

+48
-22
lines changed

3 files changed

+48
-22
lines changed

src/test/run-pass/existential_type.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ fn my_other_iter<U>(u: U) -> MyOtherIter<U> {
7575
}
7676

7777
trait Trait {}
78-
existential type GenericBound<T: Trait>: 'static;
78+
existential type GenericBound<'a, T: Trait>: 'a;
7979

80-
fn generic_bound<T: Trait>(_: T) -> GenericBound<T> {
81-
unimplemented!()
80+
fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> {
81+
t
8282
}
8383

8484
mod pass_through {
@@ -92,22 +92,3 @@ mod pass_through {
9292
fn use_passthrough(x: pass_through::Passthrough<u32>) -> pass_through::Passthrough<u32> {
9393
x
9494
}
95-
96-
existential type PartiallyDefined<T>: 'static;
97-
98-
// doesn't declare all PartiallyDefined for all possible `T`, but since it's the only
99-
// function producing the value, noone can ever get a value that is problematic
100-
fn partially_defined<T: std::fmt::Debug>(_: T) -> PartiallyDefined<T> {
101-
4u32
102-
}
103-
104-
existential type PartiallyDefined2<T>: 'static;
105-
106-
fn partially_defined2<T: std::fmt::Debug>(_: T) -> PartiallyDefined2<T> {
107-
4u32
108-
}
109-
110-
// fully defines PartiallyDefine2
111-
fn partially_defined22<T>(_: T) -> PartiallyDefined2<T> {
112-
4u32
113-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(existential_type)]
12+
13+
fn main() {
14+
}
15+
16+
existential type PartiallyDefined<T>: 'static; //~ `T` is unused
17+
18+
fn partially_defined<T: std::fmt::Debug>(_: T) -> PartiallyDefined<T> {
19+
4u32
20+
}
21+
22+
existential type PartiallyDefined2<T>: 'static; //~ `T` is unused
23+
24+
fn partially_defined2<T: std::fmt::Debug>(_: T) -> PartiallyDefined2<T> {
25+
4u32
26+
}
27+
28+
fn partially_defined22<T>(_: T) -> PartiallyDefined2<T> {
29+
4u32
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0091]: type parameter `T` is unused
2+
--> $DIR/unused_generic_param.rs:16:35
3+
|
4+
LL | existential type PartiallyDefined<T>: 'static; //~ `T` is unused
5+
| ^ unused type parameter
6+
7+
error[E0091]: type parameter `T` is unused
8+
--> $DIR/unused_generic_param.rs:22:36
9+
|
10+
LL | existential type PartiallyDefined2<T>: 'static; //~ `T` is unused
11+
| ^ unused type parameter
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0091`.

0 commit comments

Comments
 (0)