Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
err
}
ResolutionError::VariableNotBoundInPattern(variable_name, from, to) => {
struct_span_err!(resolver.session,
let mut err = struct_span_err!(resolver.session,
span,
E0408,
"variable `{}` from pattern #{} is not bound in pattern #{}",
variable_name,
from,
to)
to);
err.span_label(span, &format!("pattern doesn't bind `{}`", variable_name));
err
}
ResolutionError::VariableBoundWithDifferentMode(variable_name,
pattern_number,
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/E0408.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
let x = Some(0);

match x {
Some(y) | None => {} //~ ERROR E0408
_ => ()
Some(y) | None => {} //~ ERROR variable `y` from pattern #1 is not bound in pattern #2
_ => () //~| NOTE pattern doesn't bind `y`
}
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-2848.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod bar {
fn main() {
use bar::foo::{alpha, charlie};
match alpha {
alpha | beta => {} //~ ERROR variable `beta` from pattern #2 is not bound in pattern #1
charlie => {}
alpha | beta => {} //~ ERROR variable `beta` from pattern #2 is not bound in pattern #1
charlie => {} //~| NOTE pattern doesn't bind `beta`
}
}
6 changes: 4 additions & 2 deletions src/test/compile-fail/resolve-inconsistent-names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
fn main() {
let y = 1;
match y {
a | b => {} //~ ERROR variable `a` from pattern #1 is not bound in pattern #2
//~^ ERROR variable `b` from pattern #2 is not bound in pattern #1
a | b => {} //~ ERROR variable `a` from pattern #1 is not bound in pattern #2
//~^ ERROR variable `b` from pattern #2 is not bound in pattern #1
//~| NOTE pattern doesn't bind `a`
//~| NOTE pattern doesn't bind `b`
}
}