Skip to content

Commit cd0c70f

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#36307 - faebser:E0408_new_error_format, r=GuillaumeGomez
Changed error message E0408 to new format Followed your text and was able to change the ouput to the new format. I did not encounter any broken test therefore this is a really small commit. Thanks for letting me hack on the compiler :) r? @jonathandturner
2 parents 40cd1fd + 595b754 commit cd0c70f

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/librustc_resolve/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,15 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
276276
err
277277
}
278278
ResolutionError::VariableNotBoundInPattern(variable_name, from, to) => {
279-
struct_span_err!(resolver.session,
279+
let mut err = struct_span_err!(resolver.session,
280280
span,
281281
E0408,
282282
"variable `{}` from pattern #{} is not bound in pattern #{}",
283283
variable_name,
284284
from,
285-
to)
285+
to);
286+
err.span_label(span, &format!("pattern doesn't bind `{}`", variable_name));
287+
err
286288
}
287289
ResolutionError::VariableBoundWithDifferentMode(variable_name,
288290
pattern_number,

src/test/compile-fail/E0408.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
let x = Some(0);
1313

1414
match x {
15-
Some(y) | None => {} //~ ERROR E0408
16-
_ => ()
15+
Some(y) | None => {} //~ ERROR variable `y` from pattern #1 is not bound in pattern #2
16+
_ => () //~| NOTE pattern doesn't bind `y`
1717
}
1818
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod bar {
1919
fn main() {
2020
use bar::foo::{alpha, charlie};
2121
match alpha {
22-
alpha | beta => {} //~ ERROR variable `beta` from pattern #2 is not bound in pattern #1
23-
charlie => {}
22+
alpha | beta => {} //~ ERROR variable `beta` from pattern #2 is not bound in pattern #1
23+
charlie => {} //~| NOTE pattern doesn't bind `beta`
2424
}
2525
}

src/test/compile-fail/resolve-inconsistent-names.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
fn main() {
1212
let y = 1;
1313
match y {
14-
a | b => {} //~ ERROR variable `a` from pattern #1 is not bound in pattern #2
15-
//~^ ERROR variable `b` from pattern #2 is not bound in pattern #1
14+
a | b => {} //~ ERROR variable `a` from pattern #1 is not bound in pattern #2
15+
//~^ ERROR variable `b` from pattern #2 is not bound in pattern #1
16+
//~| NOTE pattern doesn't bind `a`
17+
//~| NOTE pattern doesn't bind `b`
1618
}
1719
}

0 commit comments

Comments
 (0)