Skip to content

Commit 595b754

Browse files
committed
Changed error message E0408 to new format
r? @jonathandturner
1 parent 147371f commit 595b754

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
@@ -270,13 +270,15 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
270270
err
271271
}
272272
ResolutionError::VariableNotBoundInPattern(variable_name, from, to) => {
273-
struct_span_err!(resolver.session,
273+
let mut err = struct_span_err!(resolver.session,
274274
span,
275275
E0408,
276276
"variable `{}` from pattern #{} is not bound in pattern #{}",
277277
variable_name,
278278
from,
279-
to)
279+
to);
280+
err.span_label(span, &format!("pattern doesn't bind `{}`", variable_name));
281+
err
280282
}
281283
ResolutionError::VariableBoundWithDifferentMode(variable_name,
282284
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)