Skip to content

Commit 1a54144

Browse files
committed
add test for normalization in implied bounds query
See rust-lang#109799.
1 parent c1d3610 commit 1a54144

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0759]: `fn` parameter has lifetime `'x` but it needs to satisfy a `'static` lifetime requirement
2+
--> $DIR/normalization-nested.rs:35:20
3+
|
4+
LL | pub fn test<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
5+
| ^^^^^^^^^^^^^^^^
6+
| |
7+
| this data with lifetime `'x`...
8+
| ...is used and required to live as long as `'static` here
9+
|
10+
note: `'static` lifetime requirement introduced by this bound
11+
--> $DIR/normalization-nested.rs:33:14
12+
|
13+
LL | I::Item: 'static;
14+
| ^^^^^^^
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0759`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Test for normalization of projections that appear in the item bounds
2+
// (versus those that appear directly in the input types).
3+
// Both revisions should pass. `lifetime` revision is a bug.
4+
//
5+
// revisions: param_ty lifetime
6+
// [param_ty] check-pass
7+
// [lifetime] check-fail
8+
// [lifetime] known-bug: #109799
9+
10+
pub trait Iter {
11+
type Item;
12+
}
13+
14+
#[cfg(param_ty)]
15+
impl<X, I> Iter for I
16+
where
17+
I: IntoIterator<Item = X>,
18+
{
19+
type Item = X;
20+
}
21+
22+
#[cfg(lifetime)]
23+
impl<'x, I> Iter for I
24+
where
25+
I: IntoIterator<Item = &'x ()>,
26+
{
27+
type Item = &'x ();
28+
}
29+
30+
pub struct Map<I>(I)
31+
where
32+
I: Iter,
33+
I::Item: 'static;
34+
35+
pub fn test<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
36+
s
37+
}
38+
39+
fn main() {}

0 commit comments

Comments
 (0)