mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
add known-bug tests
This commit is contained in:
parent
13471d3b20
commit
20b20b23ea
@ -0,0 +1,19 @@
|
||||
// chek-fail
|
||||
// known-bug: #108639
|
||||
|
||||
trait Trait {
|
||||
type Item<'a>: 'a;
|
||||
}
|
||||
|
||||
fn assert_static<T: 'static>(_: T) {}
|
||||
fn relate<T>(_: T, _: T) {}
|
||||
|
||||
fn test_args<I: Trait>() {
|
||||
let closure = |a, b| {
|
||||
relate(&a, b);
|
||||
assert_static(a);
|
||||
};
|
||||
closure(None::<I::Item<'_>>, &None::<I::Item<'_>>);
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,12 @@
|
||||
error[E0310]: the associated type `<I as Trait>::Item<'_>` may not live long enough
|
||||
--> $DIR/type-test-subject-non-trivial-region.rs:14:9
|
||||
|
|
||||
LL | assert_static(a);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<I as Trait>::Item<'_>: 'static`...
|
||||
= note: ...so that the type `<I as Trait>::Item<'_>` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
@ -0,0 +1,18 @@
|
||||
// check-fail
|
||||
// known-bug: #107426
|
||||
|
||||
use std::marker::PhantomData;
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Scope<'a>(&'a PhantomData<&'a mut &'a ()>);
|
||||
fn event<'a, F: FnMut() + 'a>(_: Scope<'a>, _: F) {}
|
||||
fn make_fn<'a>(_: Scope<'a>) -> impl Fn() + Copy + 'a {
|
||||
|| {}
|
||||
}
|
||||
|
||||
fn foo(cx: Scope) {
|
||||
let open_toggle = make_fn(cx);
|
||||
|
||||
|| event(cx, open_toggle);
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,8 @@
|
||||
error: `make_fn::{opaque#0}<'_>` does not live long enough
|
||||
--> $DIR/type-test-subject-opaque-1.rs:15:8
|
||||
|
|
||||
LL | || event(cx, open_toggle);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -0,0 +1,17 @@
|
||||
// check-fail
|
||||
// known-bug: #107516
|
||||
|
||||
fn iter1<'a: 'a>() -> impl Iterator<Item = &'static str> {
|
||||
None.into_iter()
|
||||
}
|
||||
|
||||
fn iter2<'a>() -> impl Iterator<Item = &'a str> {
|
||||
None.into_iter()
|
||||
}
|
||||
|
||||
struct Bivar<'a, I: Iterator<Item = &'a str> + 'a>(I);
|
||||
|
||||
fn main() {
|
||||
let _ = || Bivar(iter1());
|
||||
let _ = || Bivar(iter2());
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
error[E0310]: the opaque type `iter1<'_>::{opaque#0}` may not live long enough
|
||||
--> $DIR/type-test-subject-opaque-2.rs:15:16
|
||||
|
|
||||
LL | let _ = || Bivar(iter1());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `iter1<'_>::{opaque#0}: 'static`...
|
||||
= note: ...so that the type `impl Iterator<Item = &'static str>` will meet its required lifetime bounds
|
||||
|
||||
error: `iter2<'_>::{opaque#0}<'_>` does not live long enough
|
||||
--> $DIR/type-test-subject-opaque-2.rs:16:16
|
||||
|
|
||||
LL | let _ = || Bivar(iter2());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
@ -0,0 +1,24 @@
|
||||
// check-fail
|
||||
// known-bug: #108635
|
||||
|
||||
trait Trait {
|
||||
type Item<'a>: 'a;
|
||||
}
|
||||
|
||||
fn assert_static<T: 'static>(_: T) {}
|
||||
|
||||
fn test_args<I: Trait>() {
|
||||
let closure = |a, _b| assert_static(a);
|
||||
|
||||
closure(None::<I::Item<'_>>, &None::<I::Item<'_>>);
|
||||
}
|
||||
|
||||
fn test_upvars<I: Trait>() {
|
||||
let upvars = (None::<I::Item<'_>>, &None::<I::Item<'_>>);
|
||||
let _closure = || {
|
||||
let (a, _b) = upvars;
|
||||
assert_static(a);
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,21 @@
|
||||
error[E0310]: the associated type `<I as Trait>::Item<'_>` may not live long enough
|
||||
--> $DIR/type-test-subject-unnamed-region.rs:11:27
|
||||
|
|
||||
LL | let closure = |a, _b| assert_static(a);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<I as Trait>::Item<'_>: 'static`...
|
||||
= note: ...so that the type `<I as Trait>::Item<'_>` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the associated type `<I as Trait>::Item<'_>` may not live long enough
|
||||
--> $DIR/type-test-subject-unnamed-region.rs:20:9
|
||||
|
|
||||
LL | assert_static(a);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `<I as Trait>::Item<'_>: 'static`...
|
||||
= note: ...so that the type `<I as Trait>::Item<'_>` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
Loading…
Reference in New Issue
Block a user