diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index a385bc70e359b..eecb5fb525ca4 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -2288,7 +2288,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let field_kind = if is_accessible { "field" } else { "private field" }; - err.span_label(item_name.span, format!("{field_kind}, not a method")); + err.span_label(item_name.span, format!("{field_kind}, but is used like a method")); return true; } false diff --git a/tests/ui/confuse-field-and-method/issue-18343.stderr b/tests/ui/confuse-field-and-method/issue-18343.stderr index a51fd4f02aabf..95b0565d2146f 100644 --- a/tests/ui/confuse-field-and-method/issue-18343.stderr +++ b/tests/ui/confuse-field-and-method/issue-18343.stderr @@ -5,7 +5,7 @@ LL | struct Obj where F: FnMut() -> u32 { | ------------- method `closure` not found for this struct ... LL | o.closure(); - | ^^^^^^^ field, not a method + | ^^^^^^^ field, but is used like a method | help: to call the function stored in `closure`, surround the field access with parentheses | diff --git a/tests/ui/confuse-field-and-method/issue-2392.stderr b/tests/ui/confuse-field-and-method/issue-2392.stderr index 440fbb27c0040..8121e4c9225c9 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.stderr +++ b/tests/ui/confuse-field-and-method/issue-2392.stderr @@ -5,7 +5,7 @@ LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct ... LL | o_closure.closure(); - | ^^^^^^^ field, not a method + | ^^^^^^^ field, but is used like a method | help: to call the function stored in `closure`, surround the field access with parentheses | @@ -21,7 +21,7 @@ LL | struct Obj where F: FnOnce() -> u32 { LL | o_closure.not_closure(); | ^^^^^^^^^^^-- help: remove the arguments | | - | field, not a method + | field, but is used like a method error[E0599]: no method named `closure` found for struct `Obj` in the current scope --> $DIR/issue-2392.rs:42:12 @@ -30,7 +30,7 @@ LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct ... LL | o_func.closure(); - | ^^^^^^^ field, not a method + | ^^^^^^^ field, but is used like a method | help: to call the function stored in `closure`, surround the field access with parentheses | @@ -44,7 +44,7 @@ LL | struct BoxedObj { | --------------- method `boxed_closure` not found for this struct ... LL | boxed_fn.boxed_closure(); - | ^^^^^^^^^^^^^ field, not a method + | ^^^^^^^^^^^^^ field, but is used like a method | help: to call the function stored in `boxed_closure`, surround the field access with parentheses | @@ -58,7 +58,7 @@ LL | struct BoxedObj { | --------------- method `boxed_closure` not found for this struct ... LL | boxed_closure.boxed_closure(); - | ^^^^^^^^^^^^^ field, not a method + | ^^^^^^^^^^^^^ field, but is used like a method | help: to call the function stored in `boxed_closure`, surround the field access with parentheses | @@ -72,7 +72,7 @@ LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct ... LL | w.wrap.closure(); - | ^^^^^^^ field, not a method + | ^^^^^^^ field, but is used like a method | help: to call the function stored in `closure`, surround the field access with parentheses | @@ -88,7 +88,7 @@ LL | struct Obj where F: FnOnce() -> u32 { LL | w.wrap.not_closure(); | ^^^^^^^^^^^-- help: remove the arguments | | - | field, not a method + | field, but is used like a method error[E0599]: no method named `closure` found for struct `Obj` in the current scope --> $DIR/issue-2392.rs:58:24 @@ -97,7 +97,7 @@ LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct ... LL | check_expression().closure(); - | ^^^^^^^ field, not a method + | ^^^^^^^ field, but is used like a method | help: to call the function stored in `closure`, surround the field access with parentheses | @@ -111,7 +111,7 @@ LL | struct FuncContainer { | -------------------- method `f1` not found for this struct ... LL | (*self.container).f1(1); - | ^^ field, not a method + | ^^ field, but is used like a method | help: to call the function stored in `f1`, surround the field access with parentheses | @@ -125,7 +125,7 @@ LL | struct FuncContainer { | -------------------- method `f2` not found for this struct ... LL | (*self.container).f2(1); - | ^^ field, not a method + | ^^ field, but is used like a method | help: to call the function stored in `f2`, surround the field access with parentheses | @@ -139,7 +139,7 @@ LL | struct FuncContainer { | -------------------- method `f3` not found for this struct ... LL | (*self.container).f3(1); - | ^^ field, not a method + | ^^ field, but is used like a method | help: to call the function stored in `f3`, surround the field access with parentheses | diff --git a/tests/ui/confuse-field-and-method/issue-32128.stderr b/tests/ui/confuse-field-and-method/issue-32128.stderr index 3d860d8c85a12..b6e7a8ad857ff 100644 --- a/tests/ui/confuse-field-and-method/issue-32128.stderr +++ b/tests/ui/confuse-field-and-method/issue-32128.stderr @@ -5,7 +5,7 @@ LL | struct Example { | -------------- method `example` not found for this struct ... LL | demo.example(1); - | ^^^^^^^ field, not a method + | ^^^^^^^ field, but is used like a method | help: to call the function stored in `example`, surround the field access with parentheses | diff --git a/tests/ui/confuse-field-and-method/issue-33784.stderr b/tests/ui/confuse-field-and-method/issue-33784.stderr index 8acd1f8ff1ee9..c69d720fcc459 100644 --- a/tests/ui/confuse-field-and-method/issue-33784.stderr +++ b/tests/ui/confuse-field-and-method/issue-33784.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `closure` found for reference `&Obj<{closure@$DIR/ --> $DIR/issue-33784.rs:27:7 | LL | p.closure(); - | ^^^^^^^ field, not a method + | ^^^^^^^ field, but is used like a method | help: to call the function stored in `closure`, surround the field access with parentheses | @@ -17,7 +17,7 @@ error[E0599]: no method named `fn_ptr` found for reference `&&Obj<{closure@$DIR/ --> $DIR/issue-33784.rs:29:7 | LL | q.fn_ptr(); - | ^^^^^^ field, not a method + | ^^^^^^ field, but is used like a method | help: to call the function stored in `fn_ptr`, surround the field access with parentheses | @@ -28,7 +28,7 @@ error[E0599]: no method named `c_fn_ptr` found for reference `&D` in the current --> $DIR/issue-33784.rs:32:7 | LL | s.c_fn_ptr(); - | ^^^^^^^^ field, not a method + | ^^^^^^^^ field, but is used like a method | help: to call the function stored in `c_fn_ptr`, surround the field access with parentheses | diff --git a/tests/ui/confuse-field-and-method/private-field.stderr b/tests/ui/confuse-field-and-method/private-field.stderr index 142c84504276a..844274cded264 100644 --- a/tests/ui/confuse-field-and-method/private-field.stderr +++ b/tests/ui/confuse-field-and-method/private-field.stderr @@ -5,7 +5,7 @@ LL | pub struct Dog { | -------------- method `dog_age` not found for this struct ... LL | let dog_age = dog.dog_age(); - | ^^^^^^^ private field, not a method + | ^^^^^^^ private field, but is used like a method error: aborting due to 1 previous error