From 46809f7ab7e2276d004da3476074a0489de996f8 Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Fri, 22 Jun 2012 15:45:47 -0700 Subject: [PATCH] Nicer quoting in "attempted access of field" message. Issue #2358. --- src/rustc/middle/typeck/check.rs | 5 +++-- src/test/compile-fail/class-cast-to-iface.rs | 2 +- src/test/compile-fail/private-method-cross-crate.rs | 2 +- src/test/compile-fail/unsafe-fn-autoderef.rs | 2 +- src/test/compile-fail/vec-field.rs | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index e3f6ba40aefd..b8fd785f5012 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -1551,8 +1551,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } none { let t_err = fcx.infcx.resolve_type_vars_if_possible(expr_t); - let msg = #fmt["attempted access of field %s on type %s, but \ - no public field or method with that name was found", + let msg = #fmt["attempted access of field `%s` on type `%s`, \ + but no public field or method with that name \ + was found", *field, fcx.infcx.ty_to_str(t_err)]; tcx.sess.span_err(expr.span, msg); // NB: Adding a bogus type to allow typechecking to continue diff --git a/src/test/compile-fail/class-cast-to-iface.rs b/src/test/compile-fail/class-cast-to-iface.rs index faebae346943..2088d716ed72 100644 --- a/src/test/compile-fail/class-cast-to-iface.rs +++ b/src/test/compile-fail/class-cast-to-iface.rs @@ -1,4 +1,4 @@ -// error-pattern: attempted access of field eat on type noisy +// error-pattern: attempted access of field `eat` on type `noisy` iface noisy { fn speak(); } diff --git a/src/test/compile-fail/private-method-cross-crate.rs b/src/test/compile-fail/private-method-cross-crate.rs index 279c61db26c1..f54a0ffc068d 100644 --- a/src/test/compile-fail/private-method-cross-crate.rs +++ b/src/test/compile-fail/private-method-cross-crate.rs @@ -1,4 +1,4 @@ -// error-pattern:attempted access of field nap on type +// error-pattern:attempted access of field `nap` on type // xfail-fast // aux-build:cci_class_5.rs use cci_class_5; diff --git a/src/test/compile-fail/unsafe-fn-autoderef.rs b/src/test/compile-fail/unsafe-fn-autoderef.rs index 56d0f96fb3ea..cc6faa07557b 100644 --- a/src/test/compile-fail/unsafe-fn-autoderef.rs +++ b/src/test/compile-fail/unsafe-fn-autoderef.rs @@ -15,7 +15,7 @@ fn f(p: *rec) -> int { // are prohibited by various checks, such as that the enum is // instantiable and so forth). - ret p.f; //! ERROR attempted access of field f on type *rec + ret p.f; //! ERROR attempted access of field `f` on type `*rec` } fn main() { diff --git a/src/test/compile-fail/vec-field.rs b/src/test/compile-fail/vec-field.rs index 56d24a387132..18baa45feeab 100644 --- a/src/test/compile-fail/vec-field.rs +++ b/src/test/compile-fail/vec-field.rs @@ -1,4 +1,4 @@ -// error-pattern:attempted access of field some_field_name on type [int] +// error-pattern:attempted access of field `some_field_name` on type `[int]` // issue #367 fn f() {