rust/src/test/ui/rust-2018/edition-lint-infer-outlives.stderr

189 lines
7.6 KiB
Plaintext
Raw Normal View History

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
--> $DIR/edition-lint-infer-outlives.rs:35:27
|
LL | struct TeeOutlivesAy<'a, T: 'a> {
| ^^^^ help: remove this bound
|
note: lint level defined here
--> $DIR/edition-lint-infer-outlives.rs:14:9
|
LL | #![deny(explicit_outlives_requirements)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:40:36
|
LL | struct TeeOutlivesAyIsDebug<'a, T: 'a + Debug> {
| ^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:45:41
|
LL | struct TeeIsDebugOutlivesAy<'a, T: Debug + 'a> {
| ^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:50:34
|
LL | struct TeeOutlivesAyBee<'a, 'b, T: 'a + 'b> {
| ^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:55:43
|
LL | struct TeeOutlivesAyBeeIsDebug<'a, 'b, T: 'a + 'b + Debug> {
| ^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:60:48
|
LL | struct TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug + 'a + 'b> {
| ^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:65:33
|
LL | struct TeeWhereOutlivesAy<'a, T> where T: 'a {
| ^^^^^^^^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:70:50
|
LL | struct TeeWhereOutlivesAyIsDebug<'a, T> where T: 'a + Debug {
| ^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:75:55
|
LL | struct TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug + 'a {
| ^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:80:40
|
LL | struct TeeWhereOutlivesAyBee<'a, 'b, T> where T: 'a + 'b {
| ^^^^^^^^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:85:57
|
LL | struct TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: 'a + 'b + Debug {
| ^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:90:62
|
LL | struct TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug + 'a + 'b {
| ^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:95:33
|
LL | struct TeeYooOutlivesAy<'a, T, U: 'a> {
| ^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:101:42
|
LL | struct TeeYooOutlivesAyIsDebug<'a, T, U: 'a + Debug> {
| ^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:107:47
|
LL | struct TeeYooIsDebugOutlivesAy<'a, T, U: Debug + 'a> {
| ^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:113:37
|
LL | struct TeeOutlivesAyYooIsDebug<'a, T: 'a, U: Debug> {
| ^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:119:40
|
LL | struct TeeYooOutlivesAyBee<'a, 'b, T, U: 'a + 'b> {
| ^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:125:49
|
LL | struct TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: 'a + 'b + Debug> {
| ^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:131:54
|
LL | struct TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug + 'a + 'b> {
| ^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:137:44
|
LL | struct TeeOutlivesAyBeeYooIsDebug<'a, 'b, T: 'a + 'b, U: Debug> {
| ^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:143:39
|
LL | struct TeeYooWhereOutlivesAy<'a, T, U> where U: 'a {
| ^^^^^^^^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:149:56
|
LL | struct TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: 'a + Debug {
| ^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:155:61
|
LL | struct TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug + 'a {
| ^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:161:42
|
LL | struct TeeOutlivesAyYooWhereIsDebug<'a, T: 'a, U> where U: Debug {
| ^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:167:46
|
LL | struct TeeYooWhereOutlivesAyBee<'a, 'b, T, U> where U: 'a + 'b {
| ^^^^^^^^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:173:63
|
LL | struct TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: 'a + 'b + Debug {
| ^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:179:68
|
LL | struct TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug + 'a + 'b {
| ^^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:185:49
|
LL | struct TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T: 'a + 'b, U> where U: Debug {
| ^^^^^^^^^ help: remove these bounds
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:191:58
|
LL | struct TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where T: 'a, U: Debug {
| ^^^^^^^ help: remove this bound
error: outlives requirements can be inferred
--> $DIR/edition-lint-infer-outlives.rs:197:65
|
LL | struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where T: 'a + 'b, U: Debug {
| ^^^^^^^^^^^^ help: remove these bounds
error: aborting due to 30 previous errors