From ff44f088d7b46d1ecfc88984362140766b211d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20L=C3=B6thberg?= Date: Sat, 20 Aug 2016 02:41:51 +0200 Subject: [PATCH] Update E0424 to the new error format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #35797. Signed-off-by: Johannes Löthberg --- src/librustc_resolve/lib.rs | 8 +++++--- src/test/compile-fail/E0424.rs | 5 ++++- src/test/compile-fail/issue-2356.rs | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index b91ede5b2fa8a..655c4f1f263fe 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -344,11 +344,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>, path_name) } ResolutionError::SelfNotAvailableInStaticMethod => { - struct_span_err!(resolver.session, + let mut err = struct_span_err!(resolver.session, span, E0424, - "`self` is not available in a static method. Maybe a `self` \ - argument is missing?") + "`self` is not available in a static method"); + err.span_label(span, &format!("not available in static method")); + err.note(&format!("maybe a `self` argument is missing?")); + err } ResolutionError::UnresolvedName { path, message: msg, context, is_static_method, is_field, def } => { diff --git a/src/test/compile-fail/E0424.rs b/src/test/compile-fail/E0424.rs index 445d0c5f3edc0..911007113d3d6 100644 --- a/src/test/compile-fail/E0424.rs +++ b/src/test/compile-fail/E0424.rs @@ -14,7 +14,10 @@ impl Foo { fn bar(self) {} fn foo() { - self.bar(); //~ ERROR E0424 + self.bar(); + //~^ ERROR `self` is not available in a static method [E0424] + //~| NOTE not available in static method + //~| NOTE maybe a `self` argument is missing? } } diff --git a/src/test/compile-fail/issue-2356.rs b/src/test/compile-fail/issue-2356.rs index d7ec1ed67397f..da92161967dbd 100644 --- a/src/test/compile-fail/issue-2356.rs +++ b/src/test/compile-fail/issue-2356.rs @@ -59,7 +59,9 @@ impl cat { impl cat { fn meow() { if self.whiskers > 3 { - //~^ ERROR: `self` is not available in a static method. Maybe a `self` argument is missing? + //~^ ERROR `self` is not available in a static method [E0424] + //~| NOTE not available in static method + //~| NOTE maybe a `self` argument is missing? println!("MEOW"); } }