Skip to content

Commit 46809f7

Browse files
committed
Nicer quoting in "attempted access of field" message. Issue #2358.
1 parent 47b1b7a commit 46809f7

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

src/rustc/middle/typeck/check.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1551,8 +1551,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
15511551
}
15521552
none {
15531553
let t_err = fcx.infcx.resolve_type_vars_if_possible(expr_t);
1554-
let msg = #fmt["attempted access of field %s on type %s, but \
1555-
no public field or method with that name was found",
1554+
let msg = #fmt["attempted access of field `%s` on type `%s`, \
1555+
but no public field or method with that name \
1556+
was found",
15561557
*field, fcx.infcx.ty_to_str(t_err)];
15571558
tcx.sess.span_err(expr.span, msg);
15581559
// NB: Adding a bogus type to allow typechecking to continue

src/test/compile-fail/class-cast-to-iface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern: attempted access of field eat on type noisy
1+
// error-pattern: attempted access of field `eat` on type `noisy`
22
iface noisy {
33
fn speak();
44
}

src/test/compile-fail/private-method-cross-crate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:attempted access of field nap on type
1+
// error-pattern:attempted access of field `nap` on type
22
// xfail-fast
33
// aux-build:cci_class_5.rs
44
use cci_class_5;

src/test/compile-fail/unsafe-fn-autoderef.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn f(p: *rec) -> int {
1515
// are prohibited by various checks, such as that the enum is
1616
// instantiable and so forth).
1717

18-
ret p.f; //! ERROR attempted access of field f on type *rec
18+
ret p.f; //! ERROR attempted access of field `f` on type `*rec`
1919
}
2020

2121
fn main() {

src/test/compile-fail/vec-field.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:attempted access of field some_field_name on type [int]
1+
// error-pattern:attempted access of field `some_field_name` on type `[int]`
22
// issue #367
33

44
fn f() {

0 commit comments

Comments
 (0)