Skip to content

Commit ddaf109

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 9bd2dfd + ff44f08 commit ddaf109

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
@@ -344,11 +344,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
344344
path_name)
345345
}
346346
ResolutionError::SelfNotAvailableInStaticMethod => {
347-
struct_span_err!(resolver.session,
347+
let mut err = struct_span_err!(resolver.session,
348348
span,
349349
E0424,
350-
"`self` is not available in a static method. Maybe a `self` \
351-
argument is missing?")
350+
"`self` is not available in a static method");
351+
err.span_label(span, &format!("not available in static method"));
352+
err.note(&format!("maybe a `self` argument is missing?"));
353+
err
352354
}
353355
ResolutionError::UnresolvedName { path, message: msg, context, is_static_method,
354356
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)