From e7b44972f7dcfd2ff52b2161871c38b3007265e7 Mon Sep 17 00:00:00 2001 From: Frank King Date: Thu, 13 Feb 2025 11:32:41 +0800 Subject: [PATCH] Remove suggestions of making `pin const` mutable --- compiler/rustc_middle/src/mir/mod.rs | 4 +++- .../async-await/pin-ergonomics/pinned-local.stderr | 14 -------------- .../feature-gate-pin_ergonomics.stderr | 5 ----- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 87048dfd3d41f..c38fb4d917e72 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -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}; @@ -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: _, diff --git a/tests/ui/async-await/pin-ergonomics/pinned-local.stderr b/tests/ui/async-await/pin-ergonomics/pinned-local.stderr index 903229844757b..97c7e70388992 100644 --- a/tests/ui/async-await/pin-ergonomics/pinned-local.stderr +++ b/tests/ui/async-await/pin-ergonomics/pinned-local.stderr @@ -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 @@ -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 diff --git a/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr b/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr index ea0470e3edda5..92273640b4604 100644 --- a/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr +++ b/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr @@ -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