Skip to content

Commit 6bdb4e3

Browse files
committed
Some work
1 parent 23018a5 commit 6bdb4e3

File tree

7 files changed

+42
-19
lines changed

7 files changed

+42
-19
lines changed

compiler/rustc_errors/src/json.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ impl Emitter for JsonEmitter {
145145
}
146146
})
147147
.collect();
148+
let report = FutureIncompatReport { future_incompat_report: data };
148149
let result = if self.pretty {
149-
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
150+
writeln!(&mut self.dst, "{}", as_pretty_json(&report))
150151
} else {
151-
writeln!(&mut self.dst, "{}", as_json(&data))
152+
writeln!(&mut self.dst, "{}", as_json(&report))
152153
}
153154
.and_then(|_| self.dst.flush());
154155
if let Err(e) = result {
@@ -254,6 +255,11 @@ struct FutureBreakageItem {
254255
diagnostic: Diagnostic,
255256
}
256257

258+
#[derive(Encodable)]
259+
struct FutureIncompatReport {
260+
future_incompat_report: Vec<FutureBreakageItem>,
261+
}
262+
257263
impl Diagnostic {
258264
fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic {
259265
let sugg = diag.suggestions.iter().map(|sugg| Diagnostic {

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
893893
all `statement`s (including terminators), only `terminator` spans, or \
894894
computed `block` spans (one span encompassing a block's terminator and \
895895
all statements)."),
896-
emit_future_compat_report: bool = (false, parse_bool, [UNTRACKED],
897-
"emits a future-compatibility report for lints (RFC 2834)"),
896+
emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED],
897+
"emits a future-incompatibility report for lints (RFC 2834)"),
898898
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
899899
"emit a section containing stack size metadata (default: no)"),
900900
fewer_names: bool = (false, parse_bool, [TRACKED],

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl Session {
308308
}
309309

310310
fn emit_future_breakage(&self) {
311-
if !self.opts.debugging_opts.emit_future_compat_report {
311+
if !self.opts.debugging_opts.emit_future_incompat_report {
312312
return;
313313
}
314314

src/test/ui/iterators/into-iter-on-arrays-lint.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// run-pass
22
// run-rustfix
3+
// compiler-flags: -Z emit-future-compat-report
34

45
fn main() {
56
let small = [1, 2];

src/test/ui/iterators/into-iter-on-arrays-lint.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// run-pass
22
// run-rustfix
3+
// compile-flags: -Z emit-future-incompat-report
34

45
fn main() {
56
let small = [1, 2];

src/test/ui/iterators/into-iter-on-arrays-lint.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
2-
--> $DIR/into-iter-on-arrays-lint.rs:9:11
2+
--> $DIR/into-iter-on-arrays-lint.rs:10:11
33
|
44
LL | small.into_iter();
55
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -9,7 +9,7 @@ LL | small.into_iter();
99
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
1010

1111
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
12-
--> $DIR/into-iter-on-arrays-lint.rs:12:12
12+
--> $DIR/into-iter-on-arrays-lint.rs:13:12
1313
|
1414
LL | [1, 2].into_iter();
1515
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -18,7 +18,7 @@ LL | [1, 2].into_iter();
1818
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
1919

2020
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
21-
--> $DIR/into-iter-on-arrays-lint.rs:15:9
21+
--> $DIR/into-iter-on-arrays-lint.rs:16:9
2222
|
2323
LL | big.into_iter();
2424
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -27,7 +27,7 @@ LL | big.into_iter();
2727
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
2828

2929
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
30-
--> $DIR/into-iter-on-arrays-lint.rs:18:15
30+
--> $DIR/into-iter-on-arrays-lint.rs:19:15
3131
|
3232
LL | [0u8; 33].into_iter();
3333
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -36,7 +36,7 @@ LL | [0u8; 33].into_iter();
3636
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
3737

3838
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
39-
--> $DIR/into-iter-on-arrays-lint.rs:22:21
39+
--> $DIR/into-iter-on-arrays-lint.rs:23:21
4040
|
4141
LL | Box::new(small).into_iter();
4242
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -45,7 +45,7 @@ LL | Box::new(small).into_iter();
4545
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
4646

4747
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
48-
--> $DIR/into-iter-on-arrays-lint.rs:25:22
48+
--> $DIR/into-iter-on-arrays-lint.rs:26:22
4949
|
5050
LL | Box::new([1, 2]).into_iter();
5151
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -54,7 +54,7 @@ LL | Box::new([1, 2]).into_iter();
5454
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
5555

5656
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
57-
--> $DIR/into-iter-on-arrays-lint.rs:28:19
57+
--> $DIR/into-iter-on-arrays-lint.rs:29:19
5858
|
5959
LL | Box::new(big).into_iter();
6060
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -63,7 +63,7 @@ LL | Box::new(big).into_iter();
6363
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
6464

6565
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
66-
--> $DIR/into-iter-on-arrays-lint.rs:31:25
66+
--> $DIR/into-iter-on-arrays-lint.rs:32:25
6767
|
6868
LL | Box::new([0u8; 33]).into_iter();
6969
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -72,7 +72,7 @@ LL | Box::new([0u8; 33]).into_iter();
7272
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
7373

7474
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
75-
--> $DIR/into-iter-on-arrays-lint.rs:35:31
75+
--> $DIR/into-iter-on-arrays-lint.rs:36:31
7676
|
7777
LL | Box::new(Box::new(small)).into_iter();
7878
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -81,7 +81,7 @@ LL | Box::new(Box::new(small)).into_iter();
8181
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
8282

8383
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
84-
--> $DIR/into-iter-on-arrays-lint.rs:38:32
84+
--> $DIR/into-iter-on-arrays-lint.rs:39:32
8585
|
8686
LL | Box::new(Box::new([1, 2])).into_iter();
8787
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -90,7 +90,7 @@ LL | Box::new(Box::new([1, 2])).into_iter();
9090
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
9191

9292
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
93-
--> $DIR/into-iter-on-arrays-lint.rs:41:29
93+
--> $DIR/into-iter-on-arrays-lint.rs:42:29
9494
|
9595
LL | Box::new(Box::new(big)).into_iter();
9696
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -99,7 +99,7 @@ LL | Box::new(Box::new(big)).into_iter();
9999
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
100100

101101
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
102-
--> $DIR/into-iter-on-arrays-lint.rs:44:35
102+
--> $DIR/into-iter-on-arrays-lint.rs:45:35
103103
|
104104
LL | Box::new(Box::new([0u8; 33])).into_iter();
105105
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`

src/tools/compiletest/src/json.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ struct DiagnosticSpan {
3636
expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
3737
}
3838

39+
#[derive(Deserialize)]
40+
struct FutureIncompatReport {
41+
future_incompat_report: Vec<FutureBreakageItem>
42+
}
43+
44+
#[derive(Deserialize)]
45+
struct FutureBreakageItem {
46+
future_breakage_date: Option<String>,
47+
diagnostic: Diagnostic
48+
}
49+
3950
impl DiagnosticSpan {
4051
/// Returns the deepest source span in the macro call stack with a given file name.
4152
/// This is either the supplied span, or the span for some macro callsite that expanded to it.
@@ -94,10 +105,14 @@ pub fn extract_rendered(output: &str) -> String {
94105
}
95106

96107
pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
97-
output.lines().flat_map(|line| parse_line(file_name, line, output, proc_res)).collect()
108+
let lines = output.lines();
109+
let last_line = lines.next_back();
110+
lines.flat_map(|line| parse_line(file_name, line, output, proc_res, false)).chain(
111+
last_line.into_iter().flat_map(|line| parse_line(file_name, line, output, proc_res, true))
112+
).collect()
98113
}
99114

100-
fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
115+
fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes, last_line: bool) -> Vec<Error> {
101116
// The compiler sometimes intermingles non-JSON stuff into the
102117
// output. This hack just skips over such lines. Yuck.
103118
if line.starts_with('{') {

0 commit comments

Comments
 (0)