Skip to content

Commit cc51d1c

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35841 - kyrias:new-error-E0424, r=GuillaumeGomez
Update E0424 to the new error format Fixes rust-lang#35797. Part of rust-lang#35233. r? @GuillaumeGomez
2 parents ae83225 + ff44f08 commit cc51d1c

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/librustc_resolve/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
346346
err
347347
}
348348
ResolutionError::SelfNotAvailableInStaticMethod => {
349-
struct_span_err!(resolver.session,
349+
let mut err = struct_span_err!(resolver.session,
350350
span,
351351
E0424,
352-
"`self` is not available in a static method. Maybe a `self` \
353-
argument is missing?")
352+
"`self` is not available in a static method");
353+
err.span_label(span, &format!("not available in static method"));
354+
err.note(&format!("maybe a `self` argument is missing?"));
355+
err
354356
}
355357
ResolutionError::UnresolvedName { path, message: msg, context, is_static_method,
356358
is_field, def } => {

src/test/compile-fail/E0424.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ impl Foo {
1414
fn bar(self) {}
1515

1616
fn foo() {
17-
self.bar(); //~ ERROR E0424
17+
self.bar();
18+
//~^ ERROR `self` is not available in a static method [E0424]
19+
//~| NOTE not available in static method
20+
//~| NOTE maybe a `self` argument is missing?
1821
}
1922
}
2023

src/test/compile-fail/issue-2356.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ impl cat {
5959
impl cat {
6060
fn meow() {
6161
if self.whiskers > 3 {
62-
//~^ ERROR: `self` is not available in a static method. Maybe a `self` argument is missing?
62+
//~^ ERROR `self` is not available in a static method [E0424]
63+
//~| NOTE not available in static method
64+
//~| NOTE maybe a `self` argument is missing?
6365
println!("MEOW");
6466
}
6567
}

0 commit comments

Comments
 (0)