Skip to content

Commit 05b65ad

Browse files
authored
Rollup merge of #91915 - jackh726:issue-91899, r=Mark-Simulacrum
Add another regression test for unnormalized fn args with Self Closes #91899
2 parents b507174 + f0c0732 commit 05b65ad

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// check-fail
2+
// See issue #91899. If we treat unnormalized args as WF, `Self` can also be a
3+
// source of unsoundness.
4+
5+
pub trait Yokeable<'a>: 'static {
6+
type Output: 'a;
7+
}
8+
9+
impl<'a, T: 'static + ?Sized> Yokeable<'a> for &'static T {
10+
type Output = &'a T;
11+
}
12+
13+
pub trait ZeroCopyFrom<C: ?Sized>: for<'a> Yokeable<'a> {
14+
/// Clone the cart `C` into a [`Yokeable`] struct, which may retain references into `C`.
15+
fn zero_copy_from<'b>(cart: &'b C) -> <Self as Yokeable<'b>>::Output;
16+
}
17+
18+
impl<T> ZeroCopyFrom<[T]> for &'static [T] {
19+
fn zero_copy_from<'b>(cart: &'b [T]) -> &'b [T] {
20+
//~^ the parameter
21+
cart
22+
}
23+
}
24+
25+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0310]: the parameter type `T` may not live long enough
2+
--> $DIR/implied-bounds-unnorm-associated-type-3.rs:19:5
3+
|
4+
LL | fn zero_copy_from<'b>(cart: &'b [T]) -> &'b [T] {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: consider adding an explicit lifetime bound `T: 'static`...
8+
= note: ...so that the type `[T]` will meet its required lifetime bounds
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0310`.

0 commit comments

Comments
 (0)