diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2020-10-18 15:28:23 -0400 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2020-10-30 20:02:14 -0400 |
| commit | 6bdb4e32067a37b339d77f7788a772356d486f72 (patch) | |
| tree | 6d8df8adc0d41c747e5967f3dcc0adbe588640a6 | |
| parent | 23018a55d9735afbefb19fcec91db4b53fe917d8 (diff) | |
| download | rust-6bdb4e32067a37b339d77f7788a772356d486f72.tar.gz rust-6bdb4e32067a37b339d77f7788a772356d486f72.zip | |
Some work
| -rw-r--r-- | compiler/rustc_errors/src/json.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/iterators/into-iter-on-arrays-lint.fixed | 1 | ||||
| -rw-r--r-- | src/test/ui/iterators/into-iter-on-arrays-lint.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/iterators/into-iter-on-arrays-lint.stderr | 24 | ||||
| -rw-r--r-- | src/tools/compiletest/src/json.rs | 19 |
7 files changed, 42 insertions, 19 deletions
diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index ddffa64f222..d57beb1148a 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -145,10 +145,11 @@ impl Emitter for JsonEmitter { } }) .collect(); + let report = FutureIncompatReport { future_incompat_report: data }; let result = if self.pretty { - writeln!(&mut self.dst, "{}", as_pretty_json(&data)) + writeln!(&mut self.dst, "{}", as_pretty_json(&report)) } else { - writeln!(&mut self.dst, "{}", as_json(&data)) + writeln!(&mut self.dst, "{}", as_json(&report)) } .and_then(|_| self.dst.flush()); if let Err(e) = result { @@ -254,6 +255,11 @@ struct FutureBreakageItem { diagnostic: Diagnostic, } +#[derive(Encodable)] +struct FutureIncompatReport { + future_incompat_report: Vec<FutureBreakageItem>, +} + impl Diagnostic { fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic { let sugg = diag.suggestions.iter().map(|sugg| Diagnostic { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index aaed8488c92..578caf2192d 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -893,8 +893,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, all `statement`s (including terminators), only `terminator` spans, or \ computed `block` spans (one span encompassing a block's terminator and \ all statements)."), - emit_future_compat_report: bool = (false, parse_bool, [UNTRACKED], - "emits a future-compatibility report for lints (RFC 2834)"), + emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED], + "emits a future-incompatibility report for lints (RFC 2834)"), emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], "emit a section containing stack size metadata (default: no)"), fewer_names: bool = (false, parse_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 5ef4883c99b..0b7c35a8afd 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -308,7 +308,7 @@ impl Session { } fn emit_future_breakage(&self) { - if !self.opts.debugging_opts.emit_future_compat_report { + if !self.opts.debugging_opts.emit_future_incompat_report { return; } diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed index 561376c8f05..1e473a2b720 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed @@ -1,5 +1,6 @@ // run-pass // run-rustfix +// compiler-flags: -Z emit-future-compat-report fn main() { let small = [1, 2]; diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.rs b/src/test/ui/iterators/into-iter-on-arrays-lint.rs index cc310191f0c..8e441ed56a1 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.rs @@ -1,5 +1,6 @@ // run-pass // run-rustfix +// compile-flags: -Z emit-future-incompat-report fn main() { let small = [1, 2]; diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr index b31f444b36e..89e5881b955 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr @@ -1,5 +1,5 @@ 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. - --> $DIR/into-iter-on-arrays-lint.rs:9:11 + --> $DIR/into-iter-on-arrays-lint.rs:10:11 | LL | small.into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -9,7 +9,7 @@ LL | small.into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:12:12 + --> $DIR/into-iter-on-arrays-lint.rs:13:12 | LL | [1, 2].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -18,7 +18,7 @@ LL | [1, 2].into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:15:9 + --> $DIR/into-iter-on-arrays-lint.rs:16:9 | LL | big.into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -27,7 +27,7 @@ LL | big.into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:18:15 + --> $DIR/into-iter-on-arrays-lint.rs:19:15 | LL | [0u8; 33].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -36,7 +36,7 @@ LL | [0u8; 33].into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:22:21 + --> $DIR/into-iter-on-arrays-lint.rs:23:21 | LL | Box::new(small).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -45,7 +45,7 @@ LL | Box::new(small).into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:25:22 + --> $DIR/into-iter-on-arrays-lint.rs:26:22 | LL | Box::new([1, 2]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -54,7 +54,7 @@ LL | Box::new([1, 2]).into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:28:19 + --> $DIR/into-iter-on-arrays-lint.rs:29:19 | LL | Box::new(big).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -63,7 +63,7 @@ LL | Box::new(big).into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:31:25 + --> $DIR/into-iter-on-arrays-lint.rs:32:25 | LL | Box::new([0u8; 33]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -72,7 +72,7 @@ LL | Box::new([0u8; 33]).into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:35:31 + --> $DIR/into-iter-on-arrays-lint.rs:36:31 | LL | Box::new(Box::new(small)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -81,7 +81,7 @@ LL | Box::new(Box::new(small)).into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:38:32 + --> $DIR/into-iter-on-arrays-lint.rs:39:32 | LL | Box::new(Box::new([1, 2])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -90,7 +90,7 @@ LL | Box::new(Box::new([1, 2])).into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:41:29 + --> $DIR/into-iter-on-arrays-lint.rs:42:29 | LL | Box::new(Box::new(big)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -99,7 +99,7 @@ LL | Box::new(Box::new(big)).into_iter(); = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145> 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. - --> $DIR/into-iter-on-arrays-lint.rs:44:35 + --> $DIR/into-iter-on-arrays-lint.rs:45:35 | LL | Box::new(Box::new([0u8; 33])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 6a03a76c566..643475dc539 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -36,6 +36,17 @@ struct DiagnosticSpan { expansion: Option<Box<DiagnosticSpanMacroExpansion>>, } +#[derive(Deserialize)] +struct FutureIncompatReport { + future_incompat_report: Vec<FutureBreakageItem> +} + +#[derive(Deserialize)] +struct FutureBreakageItem { + future_breakage_date: Option<String>, + diagnostic: Diagnostic +} + impl DiagnosticSpan { /// Returns the deepest source span in the macro call stack with a given file name. /// 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 { } pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> { - output.lines().flat_map(|line| parse_line(file_name, line, output, proc_res)).collect() + let lines = output.lines(); + let last_line = lines.next_back(); + lines.flat_map(|line| parse_line(file_name, line, output, proc_res, false)).chain( + last_line.into_iter().flat_map(|line| parse_line(file_name, line, output, proc_res, true)) + ).collect() } -fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> { +fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes, last_line: bool) -> Vec<Error> { // The compiler sometimes intermingles non-JSON stuff into the // output. This hack just skips over such lines. Yuck. if line.starts_with('{') { |
