Skip to content

Commit 7003222

Browse files
committed
Remove suggestions of making pin const mutable
1 parent 772c576 commit 7003222

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

compiler/rustc_middle/src/mir/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use rustc_hir::def::{CtorKind, Namespace};
1919
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
2020
use rustc_hir::{
2121
self as hir, BindingMode, ByRef, CoroutineDesugaring, CoroutineKind, HirId, ImplicitSelfKind,
22+
Pinnedness,
2223
};
2324
use rustc_index::bit_set::DenseBitSet;
2425
use rustc_index::{Idx, IndexSlice, IndexVec};
@@ -1094,7 +1095,8 @@ impl<'tcx> LocalDecl<'tcx> {
10941095
self.local_info(),
10951096
LocalInfo::User(
10961097
BindingForm::Var(VarBindingForm {
1097-
binding_mode: BindingMode(ByRef::No, _, _),
1098+
// FIXME(pin_ergonomics): `pin const` can also be made mutable, but needs special handling.
1099+
binding_mode: BindingMode(ByRef::No, Pinnedness::Not, _),
10981100
opt_ty_info: _,
10991101
opt_match_place: _,
11001102
pat_span: _,

tests/ui/async-await/pin-ergonomics/pinned-local.stderr

-14
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ LL | let pin const y = Foo;
66
LL | x = Foo; // FIXME: this should be an error
77
LL | y = Foo;
88
| ^^^^^^^ cannot assign twice to immutable variable
9-
|
10-
help: consider making this binding mutable
11-
|
12-
LL | let mut pin const y = Foo;
13-
| +++
149

1510
error[E0384]: cannot assign twice to immutable variable `y`
1611
--> $DIR/pinned-local.rs:16:5
@@ -20,15 +15,6 @@ LL | let (pin mut x, pin const y) = (Foo, Foo);
2015
LL | x = Foo; // FIXME: this should be an error
2116
LL | y = Foo;
2217
| ^^^^^^^ cannot assign twice to immutable variable
23-
|
24-
help: consider making this binding mutable
25-
|
26-
LL | let (pin mut x, mut pin const y) = (Foo, Foo);
27-
| +++
28-
help: to modify the original value, take a borrow instead
29-
|
30-
LL | let (pin mut x, ref mut pin const y) = (Foo, Foo);
31-
| +++++++
3218

3319
error: aborting due to 2 previous errors
3420

tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ LL | let pin const y = Foo;
9494
LL | x = Foo; // FIXME: this should be an error
9595
LL | y = Foo;
9696
| ^^^^^^^ cannot assign twice to immutable variable
97-
|
98-
help: consider making this binding mutable
99-
|
100-
LL | let mut pin const y = Foo;
101-
| +++
10297

10398
error: aborting due to 8 previous errors
10499

0 commit comments

Comments
 (0)