rust/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed
2018-12-25 21:08:33 -07:00

202 lines
4.9 KiB
Rust

// run-rustfix
#![allow(unused)]
#![deny(explicit_outlives_requirements)]
use std::fmt::{Debug, Display};
// Programmatically generated examples!
//
// Exercise outlives bounds for each of the following parameter/position
// combinations—
//
// • one generic parameter (T) bound inline
// • one parameter (T) with a where clause
// • two parameters (T and U), both bound inline
// • two parameters (T and U), one bound inline, one with a where clause
// • two parameters (T and U), both with where clauses
//
// —and for every permutation of 0, 1, or 2 lifetimes to outlive and 0 or 1
// trait bounds distributed among said parameters (subject to no where clause
// being empty and the struct having at least one lifetime).
struct TeeOutlivesAy<'a, T> {
//~^ ERROR outlives requirements can be inferred
tee: &'a T
}
struct TeeOutlivesAyIsDebug<'a, T: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: &'a T
}
struct TeeIsDebugOutlivesAy<'a, T: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: &'a T
}
struct TeeOutlivesAyBee<'a, 'b, T> {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T
}
struct TeeOutlivesAyBeeIsDebug<'a, 'b, T: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T
}
struct TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T
}
struct TeeWhereOutlivesAy<'a, T> {
//~^ ERROR outlives requirements can be inferred
tee: &'a T
}
struct TeeWhereOutlivesAyIsDebug<'a, T> where T: Debug {
//~^ ERROR outlives requirements can be inferred
tee: &'a T
}
struct TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug {
//~^ ERROR outlives requirements can be inferred
tee: &'a T
}
struct TeeWhereOutlivesAyBee<'a, 'b, T> {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T
}
struct TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: Debug {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T
}
struct TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T
}
struct TeeYooOutlivesAy<'a, T, U> {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a U
}
struct TeeYooOutlivesAyIsDebug<'a, T, U: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a U
}
struct TeeYooIsDebugOutlivesAy<'a, T, U: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a U
}
struct TeeOutlivesAyYooIsDebug<'a, T, U: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: &'a T,
yoo: U
}
struct TeeYooOutlivesAyBee<'a, 'b, T, U> {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a &'b U
}
struct TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a &'b U
}
struct TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a &'b U
}
struct TeeOutlivesAyBeeYooIsDebug<'a, 'b, T, U: Debug> {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T,
yoo: U
}
struct TeeYooWhereOutlivesAy<'a, T, U> {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a U
}
struct TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: Debug {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a U
}
struct TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a U
}
struct TeeOutlivesAyYooWhereIsDebug<'a, T, U> where U: Debug {
//~^ ERROR outlives requirements can be inferred
tee: &'a T,
yoo: U
}
struct TeeYooWhereOutlivesAyBee<'a, 'b, T, U> {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a &'b U
}
struct TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: Debug {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a &'b U
}
struct TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug {
//~^ ERROR outlives requirements can be inferred
tee: T,
yoo: &'a &'b U
}
struct TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where U: Debug {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T,
yoo: U
}
struct TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where U: Debug {
//~^ ERROR outlives requirements can be inferred
tee: &'a T,
yoo: U
}
struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where U: Debug {
//~^ ERROR outlives requirements can be inferred
tee: &'a &'b T,
yoo: U
}
// But outlives inference for 'static lifetimes is under a separate
// feature-gate for now
// (https://github.com/rust-lang/rust/issues/44493#issuecomment-407846046).
struct StaticRef<T: 'static> {
field: &'static T
}
fn main() {}