in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
#![allow(unused)]
|
|
|
|
#![deny(explicit_outlives_requirements)]
|
|
|
|
|
|
|
|
// 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
|
2018-10-22 11:21:55 -05:00
|
|
|
// • two parameters (T and U), one bound inline, one with a where clause
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
// • two parameters (T and U), both with where clauses
|
|
|
|
//
|
2019-05-25 04:28:17 -05:00
|
|
|
// —and for every permutation of 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).
|
|
|
|
//
|
|
|
|
// —and for each of tuple structs, enums and unions.
|
|
|
|
|
|
|
|
mod structs {
|
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
struct TeeOutlivesAy<'a, T: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeOutlivesAyIsDebug<'a, T: 'a + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeIsDebugOutlivesAy<'a, T: Debug + 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeOutlivesAyBee<'a, 'b, T: 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeOutlivesAyBeeIsDebug<'a, 'b, T: 'a + 'b + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug + 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeWhereOutlivesAy<'a, T> where T: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeWhereOutlivesAyIsDebug<'a, T> where T: 'a + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug + 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeWhereOutlivesAyBee<'a, 'b, T> where T: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: 'a + 'b + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug + 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooOutlivesAy<'a, T, U: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooOutlivesAyIsDebug<'a, T, U: 'a + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooIsDebugOutlivesAy<'a, T, U: Debug + 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeOutlivesAyYooIsDebug<'a, T: 'a, U: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T,
|
|
|
|
yoo: U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooOutlivesAyBee<'a, 'b, T, U: 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: 'a + 'b + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug + 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeOutlivesAyBeeYooIsDebug<'a, 'b, T: 'a + 'b, U: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
yoo: U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooWhereOutlivesAy<'a, T, U> where U: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: 'a + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug + 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeOutlivesAyYooWhereIsDebug<'a, T: 'a, U> where U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T,
|
|
|
|
yoo: U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooWhereOutlivesAyBee<'a, 'b, T, U> where U: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: 'a + 'b + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug + 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T: 'a + 'b, U> where U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
yoo: U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where T: 'a, U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T,
|
|
|
|
yoo: U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where T: 'a + 'b, U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
yoo: U
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BeeOutlivesAy<'a, 'b: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b (),
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAy<'a, 'b> where 'b: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b (),
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BeeOutlivesAyTee<'a, 'b: 'a, T> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAyTee<'a, 'b, T> where 'b: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAyTeeWhereBee<'a, 'b, T> where 'b: 'a, T: 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAyTeeWhereAyBee<'a, 'b, T> where 'b: 'a, T: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BeeOutlivesAyTeeDebug<'a, 'b: 'a, T: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAyTeeWhereDebug<'a, 'b, T> where 'b: 'a, T: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
}
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
mod tuple_structs {
|
|
|
|
use std::fmt::Debug;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeOutlivesAy<'a, T: 'a>(&'a T);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeOutlivesAyIsDebug<'a, T: 'a + Debug>(&'a T);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeIsDebugOutlivesAy<'a, T: Debug + 'a>(&'a T);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeOutlivesAyBee<'a, 'b, T: 'a + 'b>(&'a &'b T);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeOutlivesAyBeeIsDebug<'a, 'b, T: 'a + 'b + Debug>(&'a &'b T);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug + 'a + 'b>(&'a &'b T);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeWhereOutlivesAy<'a, T>(&'a T) where T: 'a;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeWhereOutlivesAyIsDebug<'a, T>(&'a T) where T: 'a + Debug;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeWhereIsDebugOutlivesAy<'a, T>(&'a T) where T: Debug + 'a;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeWhereOutlivesAyBee<'a, 'b, T>(&'a &'b T) where T: 'a + 'b;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T>(&'a &'b T) where T: 'a + 'b + Debug;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeWhereIsDebugOutlivesAyBee<'a, 'b, T>(&'a &'b T) where T: Debug + 'a + 'b;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooOutlivesAy<'a, T, U: 'a>(T, &'a U);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooOutlivesAyIsDebug<'a, T, U: 'a + Debug>(T, &'a U);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooIsDebugOutlivesAy<'a, T, U: Debug + 'a>(T, &'a U);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeOutlivesAyYooIsDebug<'a, T: 'a, U: Debug>(&'a T, U);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooOutlivesAyBee<'a, 'b, T, U: 'a + 'b>(T, &'a &'b U);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: 'a + 'b + Debug>(T, &'a &'b U);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug + 'a + 'b>(T, &'a &'b U);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeOutlivesAyBeeYooIsDebug<'a, 'b, T: 'a + 'b, U: Debug>(&'a &'b T, U);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooWhereOutlivesAy<'a, T, U>(T, &'a U) where U: 'a;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooWhereOutlivesAyIsDebug<'a, T, U>(T, &'a U) where U: 'a + Debug;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooWhereIsDebugOutlivesAy<'a, T, U>(T, &'a U) where U: Debug + 'a;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeOutlivesAyYooWhereIsDebug<'a, T: 'a, U>(&'a T, U) where U: Debug;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooWhereOutlivesAyBee<'a, 'b, T, U>(T, &'a &'b U) where U: 'a + 'b;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U>(T, &'a &'b U) where U: 'a + 'b + Debug;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U>(T, &'a &'b U) where U: Debug + 'a + 'b;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T: 'a + 'b, U>(&'a &'b T, U) where U: Debug;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U>(&'a T, U) where T: 'a, U: Debug;
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
|
|
|
struct TeeWhereAyBeeYooWhereIsDebug<'a, 'b, T, U>(&'a &'b T, U) where T: 'a + 'b, U: Debug;
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
|
|
|
struct BeeOutlivesAy<'a, 'b: 'a>(&'a &'b ());
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAy<'a, 'b>(&'a &'b ()) where 'b: 'a;
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
|
|
|
struct BeeOutlivesAyTee<'a, 'b: 'a, T>(&'a &'b T);
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAyTee<'a, 'b, T>(&'a &'b T) where 'b: 'a;
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAyTeeWhereBee<'a, 'b, T>(&'a &'b T) where 'b: 'a, T: 'b;
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
|
|
|
struct BeeWhereOutlivesAyTeeWhereAyBee<'a, 'b, T>(&'a &'b T) where 'b: 'a, T: 'a + 'b;
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
|
2019-05-25 04:28:17 -05:00
|
|
|
struct BeeOutlivesAyTeeDebug<'a, 'b: 'a, T: Debug>(&'a &'b T);
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
//~^ ERROR outlives requirements can be inferred
|
2019-05-25 04:28:17 -05:00
|
|
|
|
|
|
|
struct BeeWhereOutlivesAyTeeWhereDebug<'a, 'b, T>(&'a &'b T) where 'b: 'a, T: Debug;
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
}
|
|
|
|
|
|
|
|
mod enums {
|
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
enum TeeOutlivesAy<'a, T: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a T },
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeOutlivesAyIsDebug<'a, T: 'a + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a T),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeIsDebugOutlivesAy<'a, T: Debug + 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a T },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeOutlivesAyBee<'a, 'b, T: 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeOutlivesAyBeeIsDebug<'a, 'b, T: 'a + 'b + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a &'b T },
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug + 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeWhereOutlivesAy<'a, T> where T: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a T },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeWhereOutlivesAyIsDebug<'a, T> where T: 'a + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a T),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug + 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a T },
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeWhereOutlivesAyBee<'a, 'b, T> where T: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: 'a + 'b + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a &'b T },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug + 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooOutlivesAy<'a, T, U: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: T },
|
|
|
|
W(&'a U),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooOutlivesAyIsDebug<'a, T, U: 'a + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: T, yoo: &'a U },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooIsDebugOutlivesAy<'a, T, U: Debug + 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(T, &'a U),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeOutlivesAyYooIsDebug<'a, T: 'a, U: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a T },
|
|
|
|
W(U),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooOutlivesAyBee<'a, 'b, T, U: 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: T, yoo: &'a &'b U },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: 'a + 'b + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(T, &'a &'b U),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug + 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: T, yoo: &'a &'b U },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeOutlivesAyBeeYooIsDebug<'a, 'b, T: 'a + 'b, U: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T, U),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooWhereOutlivesAy<'a, T, U> where U: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: T },
|
|
|
|
W(&'a U),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: 'a + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: T, yoo: &'a U },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug + 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(T, &'a U),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeOutlivesAyYooWhereIsDebug<'a, T: 'a, U> where U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a T },
|
|
|
|
W(U),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooWhereOutlivesAyBee<'a, 'b, T, U> where U: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: T, yoo: &'a &'b U },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: 'a + 'b + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(T, &'a &'b U),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug + 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: T },
|
|
|
|
W(&'a &'b U),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T: 'a + 'b, U> where U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a &'b T, yoo: U },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where T: 'a, U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a T, U),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where T: 'a + 'b, U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a &'b T },
|
|
|
|
W(U),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum BeeOutlivesAy<'a, 'b: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a &'b () },
|
|
|
|
}
|
|
|
|
|
|
|
|
enum BeeWhereOutlivesAy<'a, 'b> where 'b: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b ()),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum BeeOutlivesAyTee<'a, 'b: 'a, T> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a &'b T },
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum BeeWhereOutlivesAyTee<'a, 'b, T> where 'b: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum BeeWhereOutlivesAyTeeWhereBee<'a, 'b, T> where 'b: 'a, T: 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T),
|
|
|
|
}
|
|
|
|
|
|
|
|
enum BeeWhereOutlivesAyTeeWhereAyBee<'a, 'b, T> where 'b: 'a, T: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T),
|
|
|
|
W,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum BeeOutlivesAyTeeDebug<'a, 'b: 'a, T: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V { tee: &'a &'b T },
|
|
|
|
}
|
|
|
|
|
|
|
|
enum BeeWhereOutlivesAyTeeWhereDebug<'a, 'b, T> where 'b: 'a, T: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
V(&'a &'b T),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod unions {
|
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
union TeeOutlivesAy<'a, T: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeOutlivesAyIsDebug<'a, T: 'a + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeIsDebugOutlivesAy<'a, T: Debug + 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeOutlivesAyBee<'a, 'b, T: 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeOutlivesAyBeeIsDebug<'a, 'b, T: 'a + 'b + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug + 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeWhereOutlivesAy<'a, T> where T: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeWhereOutlivesAyIsDebug<'a, T> where T: 'a + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug + 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeWhereOutlivesAyBee<'a, 'b, T> where T: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: 'a + 'b + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug + 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooOutlivesAy<'a, T, U: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooOutlivesAyIsDebug<'a, T, U: 'a + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooIsDebugOutlivesAy<'a, T, U: Debug + 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeOutlivesAyYooIsDebug<'a, T: 'a, U: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T,
|
|
|
|
yoo: *const U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooOutlivesAyBee<'a, 'b, T, U: 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: 'a + 'b + Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug + 'a + 'b> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeOutlivesAyBeeYooIsDebug<'a, 'b, T: 'a + 'b, U: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
yoo: *const U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooWhereOutlivesAy<'a, T, U> where U: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: 'a + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug + 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeOutlivesAyYooWhereIsDebug<'a, T: 'a, U> where U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T,
|
|
|
|
yoo: *const U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooWhereOutlivesAyBee<'a, 'b, T, U> where U: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: 'a + 'b + Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug + 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: *const T,
|
|
|
|
yoo: &'a &'b U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T: 'a + 'b, U> where U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
yoo: *const U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where T: 'a, U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a T,
|
|
|
|
yoo: *const U
|
|
|
|
}
|
|
|
|
|
|
|
|
union TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where T: 'a + 'b, U: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
yoo: *const U
|
|
|
|
}
|
|
|
|
|
|
|
|
union BeeOutlivesAy<'a, 'b: 'a> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b (),
|
|
|
|
}
|
|
|
|
|
|
|
|
union BeeWhereOutlivesAy<'a, 'b> where 'b: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b (),
|
|
|
|
}
|
|
|
|
|
|
|
|
union BeeOutlivesAyTee<'a, 'b: 'a, T> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
union BeeWhereOutlivesAyTee<'a, 'b, T> where 'b: 'a {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
union BeeWhereOutlivesAyTeeWhereBee<'a, 'b, T> where 'b: 'a, T: 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
union BeeWhereOutlivesAyTeeWhereAyBee<'a, 'b, T> where 'b: 'a, T: 'a + 'b {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
union BeeOutlivesAyTeeDebug<'a, 'b: 'a, T: Debug> {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
|
|
|
|
|
|
|
union BeeWhereOutlivesAyTeeWhereDebug<'a, 'b, T> where 'b: 'a, T: Debug {
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
tee: &'a &'b T,
|
|
|
|
}
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2023-01-15 14:01:00 -06:00
|
|
|
struct TrailingCommaInWhereClause<'a, T, U>
|
|
|
|
where
|
|
|
|
T: 'a,
|
|
|
|
U: 'a,
|
|
|
|
//~^ ERROR outlives requirements can be inferred
|
|
|
|
{
|
|
|
|
tee: T,
|
|
|
|
yoo: &'a U
|
|
|
|
}
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 14:22:04 -05:00
|
|
|
|
|
|
|
fn main() {}
|