Skip to content

Commit b7a98bf

Browse files
committed
---
yaml --- r: 95725 b: refs/heads/dist-snap c: a716657 h: refs/heads/master i: 95723: 94db7d9 v: v3
1 parent f346785 commit b7a98bf

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 01ab8542fbcfbea2cb0dcdc538e56a7167f70f51
9+
refs/heads/dist-snap: a71665798bdd629ff8d328ef325723b79a2542a7
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/typeck/check/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
20092009
}
20102010

20112011
fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
2012+
struct_ty: ty::t,
20122013
span: Span,
20132014
class_id: ast::DefId,
20142015
node_id: ast::NodeId,
@@ -2033,10 +2034,12 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
20332034
let pair = class_field_map.find(&field.ident.node.name).map(|x| *x);
20342035
match pair {
20352036
None => {
2036-
tcx.sess.span_err(
2037-
field.ident.span,
2038-
format!("structure has no field named `{}`",
2039-
tcx.sess.str_of(field.ident.node)));
2037+
fcx.type_error_message(
2038+
field.ident.span,
2039+
|actual| {
2040+
format!("structure `{}` has no field named `{}`",
2041+
actual, tcx.sess.str_of(field.ident.node))
2042+
}, struct_ty, None);
20402043
error_happened = true;
20412044
}
20422045
Some((_, true)) => {
@@ -2161,6 +2164,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
21612164
// Look up and check the fields.
21622165
let class_fields = ty::lookup_struct_fields(tcx, class_id);
21632166
check_struct_or_variant_fields(fcx,
2167+
struct_type,
21642168
span,
21652169
class_id,
21662170
id,
@@ -2248,6 +2252,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
22482252
// Look up and check the enum variant fields.
22492253
let variant_fields = ty::lookup_struct_fields(tcx, variant_id);
22502254
check_struct_or_variant_fields(fcx,
2255+
enum_type,
22512256
span,
22522257
variant_id,
22532258
id,

branches/dist-snap/src/test/compile-fail/issue-4736.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
struct NonCopyable(());
1212

1313
fn main() {
14-
let z = NonCopyable{ p: () }; //~ ERROR structure has no field named `p`
14+
let z = NonCopyable{ p: () }; //~ ERROR structure `NonCopyable` has no field named `p`
1515
}

branches/dist-snap/src/test/compile-fail/struct-fields-too-many.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ struct BuildData {
1515
fn main() {
1616
let foo = BuildData {
1717
foo: 0,
18-
bar: 0 //~ ERROR structure has no field named `bar`
18+
bar: 0 //~ ERROR structure `BuildData` has no field named `bar`
1919
};
2020
}

0 commit comments

Comments
 (0)