Skip to content

Commit 3f81506

Browse files
committed
Remove suggestions of making pin const mutable
1 parent 47df7c5 commit 3f81506

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

compiler/rustc_middle/src/mir/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_hir::def::{CtorKind, Namespace};
2020
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
2121
use rustc_hir::{
2222
self as hir, BindingMode, ByRef, CoroutineDesugaring, CoroutineKind, HirId, ImplicitSelfKind,
23+
Pinnedness,
2324
};
2425
use rustc_index::bit_set::DenseBitSet;
2526
use rustc_index::{Idx, IndexSlice, IndexVec};
@@ -1122,7 +1123,8 @@ impl<'tcx> LocalDecl<'tcx> {
11221123
self.local_info(),
11231124
LocalInfo::User(
11241125
BindingForm::Var(VarBindingForm {
1125-
binding_mode: BindingMode(ByRef::No, _, _),
1126+
// FIXME(pin_ergonomics): `pin const` can also be made mutable, but needs special handling.
1127+
binding_mode: BindingMode(ByRef::No, Pinnedness::Not, _),
11261128
opt_ty_info: _,
11271129
opt_match_place: _,
11281130
pat_span: _,

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ LL | let pin x = Foo;
66
|
77
help: there is a keyword `in` with a similar name
88
|
9-
LL | let in x = Foo;
10-
| ~~
9+
LL - let pin x = Foo;
10+
LL + let in x = Foo;
11+
|
1112

1213
error: aborting due to 1 previous error
1314

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)