Skip to content

Commit 7a9b4fb

Browse files
committed
remove unused parameters
1 parent 2c937d0 commit 7a9b4fb

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
30203020
/// assignment to `x.f`).
30213021
pub(crate) fn report_illegal_reassignment(
30223022
&mut self,
3023-
_location: Location,
30243023
(place, span): (Place<'tcx>, Span),
30253024
assigned_span: Span,
30263025
err_place: Place<'tcx>,
@@ -3072,7 +3071,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
30723071
format!("mut {name}"),
30733072
Applicability::MachineApplicable,
30743073
);
3075-
if !from_arg && decl.has_pattern_match() {
3074+
if !from_arg
3075+
&& matches!(
3076+
decl.local_info(),
3077+
LocalInfo::User(BindingForm::Var(VarBindingForm {
3078+
opt_match_place: Some((Some(_), _)),
3079+
..
3080+
}))
3081+
)
3082+
{
30763083
err.span_suggestion(
30773084
decl.source_info.span,
30783085
"to modify the original value, take a borrow instead",

compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21742174
// report the error as an illegal reassignment
21752175
let init = &self.move_data.inits[init_index];
21762176
let assigned_span = init.span(self.body);
2177-
self.report_illegal_reassignment(location, (place, span), assigned_span, place);
2177+
self.report_illegal_reassignment((place, span), assigned_span, place);
21782178
} else {
21792179
self.report_mutability_error(place, span, the_place_err, error_access, location)
21802180
}

compiler/rustc_middle/src/mir/mod.rs

-11
Original file line numberDiff line numberDiff line change
@@ -1061,17 +1061,6 @@ impl<'tcx> LocalDecl<'tcx> {
10611061
)
10621062
}
10631063

1064-
pub fn has_pattern_match(&self) -> bool {
1065-
matches!(
1066-
self.local_info(),
1067-
LocalInfo::User(BindingForm::Var(VarBindingForm {
1068-
binding_mode: ty::BindingMode::BindByValue(Mutability::Not),
1069-
opt_match_place: Some((Some(_), _)),
1070-
..
1071-
}))
1072-
)
1073-
}
1074-
10751064
/// Returns `true` if local is definitely not a `ref ident` or
10761065
/// `ref mut ident` binding. (Such bindings cannot be made into
10771066
/// mutable bindings, but the inverse does not necessarily hold).

tests/ui/pattern/bindings-after-at/pat-at-same-name-both.stderr

+10-4
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,19 @@ error[E0384]: cannot assign twice to immutable variable `a`
7070
--> $DIR/pat-at-same-name-both.rs:13:15
7171
|
7272
LL | Ok(a @ b @ a)
73-
| -
74-
| |
75-
| first assignment to `a`
76-
| help: consider making this binding mutable: `mut a`
73+
| - first assignment to `a`
7774
LL |
7875
LL | | Err(a @ b @ a)
7976
| ^ cannot assign twice to immutable variable
77+
|
78+
help: consider making this binding mutable
79+
|
80+
LL | Ok(a @ b @ mut a)
81+
| ~~~~~
82+
help: to modify the original value, take a borrow instead
83+
|
84+
LL | Ok(a @ b @ ref mut a)
85+
| ~~~~~~~~~
8086

8187
error: aborting due to 12 previous errors
8288

0 commit comments

Comments
 (0)