From 2389830deaf39b736e35c471e39543d30f708972 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Fri, 17 Feb 2017 14:31:59 -0800 Subject: Highlight and simplify mismatched types Shorten mismatched types errors by replacing subtypes that are not different with `_`, and highlighting only the subtypes that are different. Given a file ```rust struct X { x: T1, y: T2, } fn foo() -> X, String> { X { x: X {x: "".to_string(), y: 2}, y: "".to_string()} } fn bar() -> Option { "".to_string() } ``` provide the following output ```rust error[E0308]: mismatched types --> file.rs:6:5 | 6 | X { x: X {x: "".to_string(), y: 2}, y: "".to_string()} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::string::String`, found {integer} | = note: expected type `X, _>` ^^^^^^^^^^^^^^^^^^^ // < highlighted found type `X, _>` ^^^^^^^^^ // < highlighted error[E0308]: mismatched types --> file.rs:6:5 | 10 | "".to_string() | ^^^^^^^^^^^^^^ expected struct `std::option::Option`, found `std::string::String` | = note: expected type `Option` ^^^^^^^ ^ // < highlighted found type `std::string::String` ``` --- src/librustc_errors/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/librustc_errors/lib.rs') diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 2efdaa57fba..da29e354a70 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -203,7 +203,7 @@ impl error::Error for ExplicitBug { } } -pub use diagnostic::{Diagnostic, SubDiagnostic}; +pub use diagnostic::{Diagnostic, SubDiagnostic, DiagnosticStyledString, StringPart}; pub use diagnostic_builder::DiagnosticBuilder; /// A handler deals with errors; certain errors -- cgit 1.4.1-3-g733a5