From cca5215060cb472902d52fba9414fdd0ea9009d9 Mon Sep 17 00:00:00 2001 From: Adrian Taylor Date: Thu, 22 Oct 2020 17:45:08 -0700 Subject: [PATCH 1/2] Diagnostic improvement. --- syntax/check.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/check.rs b/syntax/check.rs index 2f3c33483..ced15707e 100644 --- a/syntax/check.rs +++ b/syntax/check.rs @@ -67,7 +67,7 @@ fn check_type_ident(cx: &mut Check, ident: &Ident) { && !cx.types.cxx.contains(ident) && !cx.types.rust.contains(ident) { - cx.error(ident, "unsupported type"); + cx.error(ident, &format!("unsupported type: {}", ident)); } } From dbc5377e9f3c6d29cf82fcf4732005ce17872475 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 28 Oct 2020 17:28:51 -0700 Subject: [PATCH 2/2] Avoid repeating the underlined type in the label --- syntax/check.rs | 3 ++- syntax/error.rs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/syntax/check.rs b/syntax/check.rs index ced15707e..25183c990 100644 --- a/syntax/check.rs +++ b/syntax/check.rs @@ -67,7 +67,8 @@ fn check_type_ident(cx: &mut Check, ident: &Ident) { && !cx.types.cxx.contains(ident) && !cx.types.rust.contains(ident) { - cx.error(ident, &format!("unsupported type: {}", ident)); + let msg = format!("unsupported type: {}", ident); + cx.error(ident, &msg); } } diff --git a/syntax/error.rs b/syntax/error.rs index a60b7da51..274927724 100644 --- a/syntax/error.rs +++ b/syntax/error.rs @@ -21,6 +21,7 @@ pub static ERRORS: &[Error] = &[ DISCRIMINANT_OVERFLOW, DOUBLE_UNDERSCORE, RUST_TYPE_BY_VALUE, + UNSUPPORTED_TYPE, USE_NOT_ALLOWED, ]; @@ -66,6 +67,12 @@ pub static RUST_TYPE_BY_VALUE: Error = Error { note: Some("hint: wrap it in a Box<>"), }; +pub static UNSUPPORTED_TYPE: Error = Error { + msg: "unsupported type: ", + label: Some("unsupported type"), + note: None, +}; + pub static USE_NOT_ALLOWED: Error = Error { msg: "`use` items are not allowed within cxx bridge", label: Some("not allowed"),