Skip to content

Commit fbc62af

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 e20a7e3 + 193b9ae commit fbc62af

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
@@ -116,7 +116,7 @@ enum ResolutionError<'a> {
116116
/// error E0408: variable `{}` from pattern #{} is not bound in pattern #{}
117117
VariableNotBoundInPattern(Name, usize, usize),
118118
/// error E0409: variable is bound with different mode in pattern #{} than in pattern #1
119-
VariableBoundWithDifferentMode(Name, usize),
119+
VariableBoundWithDifferentMode(Name, usize, Span),
120120
/// error E0411: use of `Self` outside of an impl or trait
121121
SelfUsedOutsideImplOrTrait,
122122
/// error E0412: use of undeclared
@@ -269,14 +269,19 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
269269
from,
270270
to)
271271
}
272-
ResolutionError::VariableBoundWithDifferentMode(variable_name, pattern_number) => {
273-
struct_span_err!(resolver.session,
272+
ResolutionError::VariableBoundWithDifferentMode(variable_name,
273+
pattern_number,
274+
first_binding_span) => {
275+
let mut err = struct_span_err!(resolver.session,
274276
span,
275277
E0409,
276278
"variable `{}` is bound with different mode in pattern #{} than in \
277279
pattern #1",
278280
variable_name,
279-
pattern_number)
281+
pattern_number);
282+
err.span_label(span, &format!("bound in different ways"));
283+
err.span_label(first_binding_span, &format!("first binding"));
284+
err
280285
}
281286
ResolutionError::SelfUsedOutsideImplOrTrait => {
282287
let mut err = struct_span_err!(resolver.session,
@@ -2030,8 +2035,10 @@ impl<'a> Resolver<'a> {
20302035
if binding_0.binding_mode != binding_i.binding_mode {
20312036
resolve_error(self,
20322037
binding_i.span,
2033-
ResolutionError::VariableBoundWithDifferentMode(key.name,
2034-
i + 1));
2038+
ResolutionError::VariableBoundWithDifferentMode(
2039+
key.name,
2040+
i + 1,
2041+
binding_0.span));
20352042
}
20362043
}
20372044
}

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)