Skip to content

Commit

Permalink
Remove suggestions of making pin const mutable
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-king committed Feb 19, 2025
1 parent 753e682 commit e7b4497
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
use rustc_hir::{
self as hir, BindingMode, ByRef, CoroutineDesugaring, CoroutineKind, HirId, ImplicitSelfKind,
Pinnedness,
};
use rustc_index::bit_set::DenseBitSet;
use rustc_index::{Idx, IndexSlice, IndexVec};
Expand Down Expand Up @@ -1121,7 +1122,8 @@ impl<'tcx> LocalDecl<'tcx> {
self.local_info(),
LocalInfo::User(
BindingForm::Var(VarBindingForm {
binding_mode: BindingMode(ByRef::No, _, _),
// FIXME(pin_ergonomics): `pin const` can also be made mutable, but needs special handling.
binding_mode: BindingMode(ByRef::No, Pinnedness::Not, _),
opt_ty_info: _,
opt_match_place: _,
pat_span: _,
Expand Down
14 changes: 0 additions & 14 deletions tests/ui/async-await/pin-ergonomics/pinned-local.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ LL | let pin const y = Foo;
LL | x = Foo; // FIXME: this should be an error
LL | y = Foo;
| ^^^^^^^ cannot assign twice to immutable variable
|
help: consider making this binding mutable
|
LL | let mut pin const y = Foo;
| +++

error[E0384]: cannot assign twice to immutable variable `y`
--> $DIR/pinned-local.rs:16:5
Expand All @@ -20,15 +15,6 @@ LL | let (pin mut x, pin const y) = (Foo, Foo);
LL | x = Foo; // FIXME: this should be an error
LL | y = Foo;
| ^^^^^^^ cannot assign twice to immutable variable
|
help: consider making this binding mutable
|
LL | let (pin mut x, mut pin const y) = (Foo, Foo);
| +++
help: to modify the original value, take a borrow instead
|
LL | let (pin mut x, ref mut pin const y) = (Foo, Foo);
| +++++++

error: aborting due to 2 previous errors

Expand Down
5 changes: 0 additions & 5 deletions tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ LL | let pin const y = Foo;
LL | x = Foo; // FIXME: this should be an error
LL | y = Foo;
| ^^^^^^^ cannot assign twice to immutable variable
|
help: consider making this binding mutable
|
LL | let mut pin const y = Foo;
| +++

error: aborting due to 8 previous errors

Expand Down

0 comments on commit e7b4497

Please sign in to comment.