Skip to content

Commit 87282e0

Browse files
authored
Unrolled build for rust-lang#118512
Rollup merge of rust-lang#118512 - spastorino:add-implied-bounds-related-tests, r=jackh726 Add tests related to normalization in implied bounds Getting ```@aliemjay's``` tests from rust-lang#109763, so we can better track what's going on in every different example. r? ```@jackh726```
2 parents c416699 + 7079adb commit 87282e0

9 files changed

+202
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Related to Bevy regression #118553
2+
3+
pub trait WorldQuery {}
4+
impl WorldQuery for &u8 {}
5+
6+
pub struct Query<Q: WorldQuery>(Q);
7+
8+
pub trait SystemParam {
9+
type State;
10+
}
11+
impl<Q: WorldQuery + 'static> SystemParam for Query<Q> {
12+
type State = ();
13+
// `Q: 'static` is required because we need the TypeId of Q ...
14+
}
15+
16+
pub struct ParamSet<T: SystemParam>(T)
17+
where
18+
T::State: Sized;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// aux-crate:bevy_ecs=bevy_ecs.rs
2+
// check-pass
3+
// Related to Bevy regression #118553
4+
5+
extern crate bevy_ecs;
6+
7+
use bevy_ecs::*;
8+
9+
fn handler<'a>(_: ParamSet<Query<&'a u8>>) {}
10+
11+
fn main() {}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// check-pass
2+
// known-bug: #109628
3+
4+
trait Trait {
5+
type Assoc;
6+
}
7+
8+
impl<X: 'static> Trait for (X,) {
9+
type Assoc = ();
10+
}
11+
12+
struct Foo<T: Trait>(T)
13+
where
14+
T::Assoc: Clone; // any predicate using `T::Assoc` works here
15+
16+
fn func1(foo: Foo<(&str,)>) {
17+
let _: &'static str = foo.0.0;
18+
}
19+
20+
trait TestTrait {}
21+
22+
impl<X> TestTrait for [Foo<(X,)>; 1] {}
23+
24+
fn main() {}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// check-pass
2+
// Related to Bevy regression #118553
3+
4+
pub trait QueryBase {
5+
type Db;
6+
}
7+
8+
pub trait AsyncQueryFunction<'f>: // 'f is important
9+
QueryBase<Db = <Self as AsyncQueryFunction<'f>>::SendDb> // bound is important
10+
{
11+
type SendDb;
12+
}
13+
14+
pub struct QueryTable<'me, Q, DB> {
15+
_q: Option<Q>,
16+
_db: Option<DB>,
17+
_marker: Option<&'me ()>,
18+
}
19+
20+
impl<'me, Q> QueryTable<'me, Q, <Q as QueryBase>::Db>
21+
// projection is important
22+
// ^^^ removing 'me (and in QueryTable) gives a different error
23+
where
24+
Q: for<'f> AsyncQueryFunction<'f>,
25+
{
26+
pub fn get_async<'a>(&'a mut self) {
27+
panic!();
28+
}
29+
}
30+
31+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
error[E0759]: `fn` parameter has lifetime `'x` but it needs to satisfy a `'static` lifetime requirement
2-
--> $DIR/normalization-nested.rs:35:20
2+
--> $DIR/normalization-nested.rs:35:28
33
|
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
4+
LL | pub fn test_wfcheck<'x>(_: Map<Vec<&'x ()>>) {}
5+
| ^^^^^^^^^^^^^^^^
6+
| |
7+
| this data with lifetime `'x`...
8+
| ...is used and required to live as long as `'static` here
99
|
1010
note: `'static` lifetime requirement introduced by this bound
1111
--> $DIR/normalization-nested.rs:33:14
1212
|
1313
LL | I::Item: 'static;
1414
| ^^^^^^^
1515

16-
error: aborting due to 1 previous error
16+
error[E0759]: `fn` parameter has lifetime `'x` but it needs to satisfy a `'static` lifetime requirement
17+
--> $DIR/normalization-nested.rs:37:29
18+
|
19+
LL | pub fn test_borrowck<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
20+
| ^^^^^^^^^^^^^^^^
21+
| |
22+
| this data with lifetime `'x`...
23+
| ...is used and required to live as long as `'static` here
24+
|
25+
note: `'static` lifetime requirement introduced by this bound
26+
--> $DIR/normalization-nested.rs:33:14
27+
|
28+
LL | I::Item: 'static;
29+
| ^^^^^^^
30+
31+
error: aborting due to 2 previous errors
1732

1833
For more information about this error, try `rustc --explain E0759`.

tests/ui/implied-bounds/normalization-nested.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ where
3232
I: Iter,
3333
I::Item: 'static;
3434

35-
pub fn test<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
35+
pub fn test_wfcheck<'x>(_: Map<Vec<&'x ()>>) {}
36+
37+
pub fn test_borrowck<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str {
3638
s
3739
}
3840

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/normalization-preserve-equality.rs:24:1
3+
|
4+
LL | fn test_borrowck<'a, 'b>(_: (<Equal<'a, 'b> as Trait>::Ty, Equal<'a, 'b>)) {
5+
| ^^^^^^^^^^^^^^^^^--^^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| | | |
7+
| | | lifetime `'b` defined here
8+
| | lifetime `'a` defined here
9+
| requires that `'a` must outlive `'b`
10+
|
11+
= help: consider adding the following bound: `'a: 'b`
12+
13+
error: lifetime may not live long enough
14+
--> $DIR/normalization-preserve-equality.rs:24:1
15+
|
16+
LL | fn test_borrowck<'a, 'b>(_: (<Equal<'a, 'b> as Trait>::Ty, Equal<'a, 'b>)) {
17+
| ^^^^^^^^^^^^^^^^^--^^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
| | | |
19+
| | | lifetime `'b` defined here
20+
| | lifetime `'a` defined here
21+
| requires that `'b` must outlive `'a`
22+
|
23+
= help: consider adding the following bound: `'b: 'a`
24+
25+
help: `'a` and `'b` must be the same: replace one with the other
26+
27+
error: aborting due to 2 previous errors
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Both revisions should pass. `borrowck` revision is a bug!
2+
//
3+
// revisions: wfcheck borrowck
4+
// [wfcheck] check-pass
5+
// [borrowck] check-fail
6+
// [borrowck] known-bug: #106569
7+
8+
struct Equal<'a, 'b>(&'a &'b (), &'b &'a ()); // implies 'a == 'b
9+
10+
trait Trait {
11+
type Ty;
12+
}
13+
14+
impl<'x> Trait for Equal<'x, 'x> {
15+
type Ty = ();
16+
}
17+
18+
trait WfCheckTrait {}
19+
20+
#[cfg(wfcheck)]
21+
impl<'a, 'b> WfCheckTrait for (<Equal<'a, 'b> as Trait>::Ty, Equal<'a, 'b>) {}
22+
23+
#[cfg(borrowck)]
24+
fn test_borrowck<'a, 'b>(_: (<Equal<'a, 'b> as Trait>::Ty, Equal<'a, 'b>)) {
25+
let _ = None::<Equal<'a, 'b>>;
26+
}
27+
28+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// check-pass
2+
// Related to crater regressions on #118553
3+
4+
pub trait Debug {}
5+
6+
pub trait Service {
7+
type Input;
8+
type Output;
9+
type Error;
10+
}
11+
12+
pub struct ServiceChain<P, S> {
13+
prev: P,
14+
service: S,
15+
}
16+
impl<P: Service, S: Service<Input = P::Output>> Service for ServiceChain<P, S>
17+
where
18+
P::Error: 'static,
19+
S::Error: 'static,
20+
{
21+
type Input = P::Input;
22+
type Output = S::Output;
23+
type Error = ();
24+
}
25+
26+
pub struct ServiceChainBuilder<P: Service, S: Service<Input = P::Output>> {
27+
chain: ServiceChain<P, S>,
28+
}
29+
impl<P: Service, S: Service<Input = P::Output>> ServiceChainBuilder<P, S> {
30+
pub fn next<NS: Service<Input = S::Output>>(
31+
self,
32+
) -> ServiceChainBuilder<ServiceChain<P, S>, NS> {
33+
panic!();
34+
}
35+
}
36+
37+
fn main() {}

0 commit comments

Comments
 (0)