Some work

This commit is contained in:
Aaron Hill 2020-10-18 15:28:23 -04:00
parent 23018a55d9
commit 6bdb4e3206
No known key found for this signature in database
GPG key ID: B4087E510E98B164
7 changed files with 42 additions and 19 deletions

View file

@ -145,10 +145,11 @@ impl Emitter for JsonEmitter {
} }
}) })
.collect(); .collect();
let report = FutureIncompatReport { future_incompat_report: data };
let result = if self.pretty { let result = if self.pretty {
writeln!(&mut self.dst, "{}", as_pretty_json(&data)) writeln!(&mut self.dst, "{}", as_pretty_json(&report))
} else { } else {
writeln!(&mut self.dst, "{}", as_json(&data)) writeln!(&mut self.dst, "{}", as_json(&report))
} }
.and_then(|_| self.dst.flush()); .and_then(|_| self.dst.flush());
if let Err(e) = result { if let Err(e) = result {
@ -254,6 +255,11 @@ struct FutureBreakageItem {
diagnostic: Diagnostic, diagnostic: Diagnostic,
} }
#[derive(Encodable)]
struct FutureIncompatReport {
future_incompat_report: Vec<FutureBreakageItem>,
}
impl Diagnostic { impl Diagnostic {
fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic { fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic {
let sugg = diag.suggestions.iter().map(|sugg| Diagnostic { let sugg = diag.suggestions.iter().map(|sugg| Diagnostic {

View file

@ -893,8 +893,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
all `statement`s (including terminators), only `terminator` spans, or \ all `statement`s (including terminators), only `terminator` spans, or \
computed `block` spans (one span encompassing a block's terminator and \ computed `block` spans (one span encompassing a block's terminator and \
all statements)."), all statements)."),
emit_future_compat_report: bool = (false, parse_bool, [UNTRACKED], emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED],
"emits a future-compatibility report for lints (RFC 2834)"), "emits a future-incompatibility report for lints (RFC 2834)"),
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
"emit a section containing stack size metadata (default: no)"), "emit a section containing stack size metadata (default: no)"),
fewer_names: bool = (false, parse_bool, [TRACKED], fewer_names: bool = (false, parse_bool, [TRACKED],

View file

@ -308,7 +308,7 @@ impl Session {
} }
fn emit_future_breakage(&self) { fn emit_future_breakage(&self) {
if !self.opts.debugging_opts.emit_future_compat_report { if !self.opts.debugging_opts.emit_future_incompat_report {
return; return;
} }

View file

@ -1,5 +1,6 @@
// run-pass // run-pass
// run-rustfix // run-rustfix
// compiler-flags: -Z emit-future-compat-report
fn main() { fn main() {
let small = [1, 2]; let small = [1, 2];

View file

@ -1,5 +1,6 @@
// run-pass // run-pass
// run-rustfix // run-rustfix
// compile-flags: -Z emit-future-incompat-report
fn main() { fn main() {
let small = [1, 2]; let small = [1, 2];

View file

@ -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. 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(); LL | small.into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | [1, 2].into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | big.into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | [0u8; 33].into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | Box::new(small).into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | Box::new([1, 2]).into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | Box::new(big).into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | Box::new([0u8; 33]).into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | Box::new(Box::new(small)).into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | Box::new(Box::new([1, 2])).into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | Box::new(Box::new(big)).into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `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> = 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. 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(); LL | Box::new(Box::new([0u8; 33])).into_iter();
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`

View file

@ -36,6 +36,17 @@ struct DiagnosticSpan {
expansion: Option<Box<DiagnosticSpanMacroExpansion>>, 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 { impl DiagnosticSpan {
/// Returns the deepest source span in the macro call stack with a given file name. /// 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. /// 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> { 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 // The compiler sometimes intermingles non-JSON stuff into the
// output. This hack just skips over such lines. Yuck. // output. This hack just skips over such lines. Yuck.
if line.starts_with('{') { if line.starts_with('{') {