Skip to content

Commit df55192

Browse files
author
Jonathan Turner
authored
Rollup merge of #35726 - mikhail-m1:master2, r=jonathandturner
update E0409 to new error format fixes #35699 as part of #35233. r? @jonathandturner
2 parents abb4192 + 193b9ae commit df55192

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/librustc_resolve/lib.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ enum ResolutionError<'a> {
117117
/// error E0408: variable `{}` from pattern #{} is not bound in pattern #{}
118118
VariableNotBoundInPattern(Name, usize, usize),
119119
/// error E0409: variable is bound with different mode in pattern #{} than in pattern #1
120-
VariableBoundWithDifferentMode(Name, usize),
120+
VariableBoundWithDifferentMode(Name, usize, Span),
121121
/// error E0411: use of `Self` outside of an impl or trait
122122
SelfUsedOutsideImplOrTrait,
123123
/// error E0412: use of undeclared
@@ -270,14 +270,19 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
270270
from,
271271
to)
272272
}
273-
ResolutionError::VariableBoundWithDifferentMode(variable_name, pattern_number) => {
274-
struct_span_err!(resolver.session,
273+
ResolutionError::VariableBoundWithDifferentMode(variable_name,
274+
pattern_number,
275+
first_binding_span) => {
276+
let mut err = struct_span_err!(resolver.session,
275277
span,
276278
E0409,
277279
"variable `{}` is bound with different mode in pattern #{} than in \
278280
pattern #1",
279281
variable_name,
280-
pattern_number)
282+
pattern_number);
283+
err.span_label(span, &format!("bound in different ways"));
284+
err.span_label(first_binding_span, &format!("first binding"));
285+
err
281286
}
282287
ResolutionError::SelfUsedOutsideImplOrTrait => {
283288
let mut err = struct_span_err!(resolver.session,
@@ -2046,8 +2051,10 @@ impl<'a> Resolver<'a> {
20462051
if binding_0.binding_mode != binding_i.binding_mode {
20472052
resolve_error(self,
20482053
binding_i.span,
2049-
ResolutionError::VariableBoundWithDifferentMode(key.name,
2050-
i + 1));
2054+
ResolutionError::VariableBoundWithDifferentMode(
2055+
key.name,
2056+
i + 1,
2057+
binding_0.span));
20512058
}
20522059
}
20532060
}

src/test/compile-fail/E0409.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ fn main() {
1313

1414
match x {
1515
(0, ref y) | (y, 0) => {} //~ ERROR E0409
16-
//~^ ERROR E0308
16+
//~^ NOTE bound in different ways
17+
//~| NOTE first binding
18+
//~| ERROR E0308
19+
//~| NOTE expected &{integer}, found integral variable
20+
//~| NOTE expected type `&{integer}`
21+
//~| NOTE found type `{integer}`
1722
_ => ()
1823
}
1924
}

0 commit comments

Comments
 (0)