forked from rust-lang/rustfix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
accept multi-part solutions/substitutions
This is meant to be the resolution to rust-lang#141 (and, in a way, rust-lang/rust#53934). We add two test fixtures demonstrating usage and correctness. The JSON comes from a locally-built non-master compiler featuring the change to the JSON emitter to support this. (Actually, one is from `--error-format pretty-json` and the other is from `--error-format json` and subsequent auto-formatting, but the difference in inter-string-literal newlines doesn't seem to matter.)
- Loading branch information
1 parent
8a8f0be
commit 8e0d7c0
Showing
7 changed files
with
297 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
struct Point { x: isize, y: isize } | ||
|
||
fn main() { | ||
let p = Point { x: 1, y: 2 }; | ||
let Point { y, .. } = p; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
{ | ||
"message": "expected `}`, found `,`", | ||
"code": null, | ||
"level": "error", | ||
"spans": [ | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-parts.rs", | ||
"byte_start": 166, | ||
"byte_end": 167, | ||
"line_start": 7, | ||
"line_end": 7, | ||
"column_start": 19, | ||
"column_end": 20, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": " let Point { .., y, } = p;", | ||
"highlight_start": 19, | ||
"highlight_end": 20 | ||
} | ||
], | ||
"label": "expected `}`", | ||
"suggested_replacement": null, | ||
"suggestion_applicability": null, | ||
"expansion": null | ||
}, | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-parts.rs", | ||
"byte_start": 164, | ||
"byte_end": 167, | ||
"line_start": 7, | ||
"line_end": 7, | ||
"column_start": 17, | ||
"column_end": 20, | ||
"is_primary": false, | ||
"text": [ | ||
{ | ||
"text": " let Point { .., y, } = p;", | ||
"highlight_start": 17, | ||
"highlight_end": 20 | ||
} | ||
], | ||
"label": "`..` must be at the end and cannot have a trailing comma", | ||
"suggested_replacement": null, | ||
"suggestion_applicability": null, | ||
"expansion": null | ||
} | ||
], | ||
"children": [ | ||
{ | ||
"message": "move the `..` to the end of the field list", | ||
"code": null, | ||
"level": "help", | ||
"spans": [ | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-parts.rs", | ||
"byte_start": 164, | ||
"byte_end": 168, | ||
"line_start": 7, | ||
"line_end": 7, | ||
"column_start": 17, | ||
"column_end": 21, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": " let Point { .., y, } = p;", | ||
"highlight_start": 17, | ||
"highlight_end": 21 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": "", | ||
"suggestion_applicability": "MachineApplicable", | ||
"expansion": null | ||
}, | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-parts.rs", | ||
"byte_start": 171, | ||
"byte_end": 172, | ||
"line_start": 7, | ||
"line_end": 7, | ||
"column_start": 24, | ||
"column_end": 25, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": " let Point { .., y, } = p;", | ||
"highlight_start": 24, | ||
"highlight_end": 25 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": ".. }", | ||
"suggestion_applicability": "MachineApplicable", | ||
"expansion": null | ||
} | ||
], | ||
"children": [], | ||
"rendered": null | ||
} | ||
], | ||
"rendered": "error: expected `}`, found `,` | ||
--> $DIR/issue-53934-multiple-parts.rs:7:19 | ||
| | ||
LL | let Point { .., y, } = p; | ||
| --^ | ||
| | | | ||
| | expected `}` | ||
| `..` must be at the end and cannot have a trailing comma | ||
help: move the `..` to the end of the field list | ||
| | ||
LL | let Point { y, .. } = p; | ||
| -- ^^^^ | ||
|
||
" | ||
} | ||
{ | ||
"message": "aborting due to previous error", | ||
"code": null, | ||
"level": "error", | ||
"spans": [], | ||
"children": [], | ||
"rendered": "error: aborting due to previous error | ||
|
||
" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
struct Point { x: isize, y: isize } | ||
|
||
fn main() { | ||
let p = Point { x: 1, y: 2 }; | ||
let Point { .., y, } = p; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![allow(dead_code)] | ||
#![deny(explicit_outlives_requirements)] | ||
|
||
use std::fmt::Debug; | ||
|
||
struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T, U: Debug> { | ||
tee: &'a T, | ||
yoo: &'b U | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
"message": "outlives requirements can be inferred", | ||
"code": { | ||
"code": "explicit_outlives_requirements", | ||
"explanation": null | ||
}, | ||
"level": "error", | ||
"spans": [ | ||
{ | ||
"file_name": "/home/zmd/Code/rustfix/tests/everything/explicit-outlives-multispan.rs", | ||
"byte_start": 128, | ||
"byte_end": 132, | ||
"line_start": 6, | ||
"line_end": 6, | ||
"column_start": 44, | ||
"column_end": 48, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": "struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> {", | ||
"highlight_start": 44, | ||
"highlight_end": 48 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": null, | ||
"suggestion_applicability": null, | ||
"expansion": null | ||
}, | ||
{ | ||
"file_name": "/home/zmd/Code/rustfix/tests/everything/explicit-outlives-multispan.rs", | ||
"byte_start": 137, | ||
"byte_end": 142, | ||
"line_start": 6, | ||
"line_end": 6, | ||
"column_start": 53, | ||
"column_end": 58, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": "struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> {", | ||
"highlight_start": 53, | ||
"highlight_end": 58 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": null, | ||
"suggestion_applicability": null, | ||
"expansion": null | ||
} | ||
], | ||
"children": [ | ||
{ | ||
"message": "lint level defined here", | ||
"code": null, | ||
"level": "note", | ||
"spans": [ | ||
{ | ||
"file_name": "/home/zmd/Code/rustfix/tests/everything/explicit-outlives-multispan.rs", | ||
"byte_start": 29, | ||
"byte_end": 59, | ||
"line_start": 2, | ||
"line_end": 2, | ||
"column_start": 9, | ||
"column_end": 39, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": "#![deny(explicit_outlives_requirements)]", | ||
"highlight_start": 9, | ||
"highlight_end": 39 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": null, | ||
"suggestion_applicability": null, | ||
"expansion": null | ||
} | ||
], | ||
"children": [], | ||
"rendered": null | ||
}, | ||
{ | ||
"message": "remove these bounds", | ||
"code": null, | ||
"level": "help", | ||
"spans": [ | ||
{ | ||
"file_name": "/home/zmd/Code/rustfix/tests/everything/explicit-outlives-multispan.rs", | ||
"byte_start": 128, | ||
"byte_end": 132, | ||
"line_start": 6, | ||
"line_end": 6, | ||
"column_start": 44, | ||
"column_end": 48, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": "struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> {", | ||
"highlight_start": 44, | ||
"highlight_end": 48 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": "", | ||
"suggestion_applicability": "MachineApplicable", | ||
"expansion": null | ||
}, | ||
{ | ||
"file_name": "/home/zmd/Code/rustfix/tests/everything/explicit-outlives-multispan.rs", | ||
"byte_start": 137, | ||
"byte_end": 142, | ||
"line_start": 6, | ||
"line_end": 6, | ||
"column_start": 53, | ||
"column_end": 58, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": "struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> {", | ||
"highlight_start": 53, | ||
"highlight_end": 58 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": "", | ||
"suggestion_applicability": "MachineApplicable", | ||
"expansion": null | ||
} | ||
], | ||
"children": [], | ||
"rendered": null | ||
} | ||
], | ||
"rendered": "error: outlives requirements can be inferred\n --> /home/zmd/Code/rustfix/tests/everything/explicit-outlives-multispan.rs:6:44\n |\n6 | struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> {\n | ^^^^ ^^^^^\n |\nnote: lint level defined here\n --> /home/zmd/Code/rustfix/tests/everything/explicit-outlives-multispan.rs:2:9\n |\n2 | #![deny(explicit_outlives_requirements)]\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nhelp: remove these bounds\n |\n6 | struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T, U: Debug> {\n | -- --\n\n" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![allow(dead_code)] | ||
#![deny(explicit_outlives_requirements)] | ||
|
||
use std::fmt::Debug; | ||
|
||
struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> { | ||
tee: &'a T, | ||
yoo: &'b U | ||
} | ||
|
||
fn main() {} |