From 3480f6f0687267f40f1cac868c1a077d50fd01e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 19 Dec 2017 19:04:09 -0800 Subject: [PATCH] Closure type error ui tweak Do not point at the same span on all notes/help messages, and instead show them without a span. --- src/librustc/middle/entry.rs | 2 +- src/librustc/ty/error.rs | 6 ++---- src/test/ui/issue-24036.stderr | 36 ++++------------------------------ 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 31e054ec1cb9..556d32022f74 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -170,7 +170,7 @@ fn configure_main(this: &mut EntryContext) { defined at the crate level. Either move the definition or \ attach the `#[main]` attribute to override this behavior."); for &(_, span) in &this.non_main_fns { - err.span_note(span, "here is a function named 'main'"); + err.span_label(span, "here is a function named 'main'"); } err.emit(); this.session.abort_if_errors(); diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index cb68e576e5af..d2152024cff0 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -260,10 +260,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let expected_str = values.expected.sort_string(self); let found_str = values.found.sort_string(self); if expected_str == found_str && expected_str == "closure" { - db.span_note(sp, - "no two closures, even if identical, have the same type"); - db.span_help(sp, - "consider boxing your closure and/or using it as a trait object"); + db.note("no two closures, even if identical, have the same type"); + db.help("consider boxing your closure and/or using it as a trait object"); } }, TyParamDefaultMismatch(values) => { diff --git a/src/test/ui/issue-24036.stderr b/src/test/ui/issue-24036.stderr index 1a70e90c0cc1..efa02c3fc598 100644 --- a/src/test/ui/issue-24036.stderr +++ b/src/test/ui/issue-24036.stderr @@ -6,16 +6,8 @@ error[E0308]: mismatched types | = note: expected type `[closure@$DIR/issue-24036.rs:12:17: 12:26]` found type `[closure@$DIR/issue-24036.rs:13:9: 13:18]` -note: no two closures, even if identical, have the same type - --> $DIR/issue-24036.rs:13:9 - | -13 | x = |c| c + 1; - | ^^^^^^^^^ -help: consider boxing your closure and/or using it as a trait object - --> $DIR/issue-24036.rs:13:9 - | -13 | x = |c| c + 1; - | ^^^^^^^^^ + = note: no two closures, even if identical, have the same type + = help: consider boxing your closure and/or using it as a trait object error[E0308]: match arms have incompatible types --> $DIR/issue-24036.rs:18:13 @@ -31,28 +23,8 @@ error[E0308]: match arms have incompatible types | = note: expected type `[closure@$DIR/issue-24036.rs:20:14: 20:23]` found type `[closure@$DIR/issue-24036.rs:21:14: 21:23]` -note: no two closures, even if identical, have the same type - --> $DIR/issue-24036.rs:18:13 - | -18 | let x = match 1usize { - | _____________^ -19 | | //~^ ERROR match arms have incompatible types -20 | | 1 => |c| c + 1, -21 | | 2 => |c| c - 1, -22 | | _ => |c| c - 1 -23 | | }; - | |_____^ -help: consider boxing your closure and/or using it as a trait object - --> $DIR/issue-24036.rs:18:13 - | -18 | let x = match 1usize { - | _____________^ -19 | | //~^ ERROR match arms have incompatible types -20 | | 1 => |c| c + 1, -21 | | 2 => |c| c - 1, -22 | | _ => |c| c - 1 -23 | | }; - | |_____^ + = note: no two closures, even if identical, have the same type + = help: consider boxing your closure and/or using it as a trait object note: match arm with an incompatible type --> $DIR/issue-24036.rs:21:14 |