Skip to content

Commit f1bbfaf

Browse files
committed
introduce ty::Mutability
1 parent b0c3e0f commit f1bbfaf

File tree

123 files changed

+456
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+456
-351
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
249249
// If we're in pattern, we do nothing in favor of the previous suggestion (#80913).
250250
// Same for if we're in a loop, see #101119.
251251
if is_loop_move & !in_pattern && !matches!(use_spans, UseSpans::ClosureUse { .. }) {
252-
if let ty::Ref(_, _, hir::Mutability::Mut) = ty.kind() {
252+
if let ty::Ref(_, _, ty::Mutability::Mut) = ty.kind() {
253253
// We have a `&mut` ref, we need to reborrow on each iteration (#62112).
254254
err.span_suggestion_verbose(
255255
span.shrink_to_lo(),

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10661066
// If the moved place was a `&mut` ref, then we can
10671067
// suggest to reborrow it where it was moved, so it
10681068
// will still be valid by the time we get to the usage.
1069-
if let ty::Ref(_, _, hir::Mutability::Mut) =
1069+
if let ty::Ref(_, _, ty::Mutability::Mut) =
10701070
moved_place.ty(self.body, self.infcx.tcx).ty.kind()
10711071
{
10721072
// If we are in a loop this will be suggested later.
@@ -1105,7 +1105,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11051105

11061106
if let ty::Adt(def, substs) = ty.kind()
11071107
&& Some(def.did()) == tcx.lang_items().pin_type()
1108-
&& let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind()
1108+
&& let ty::Ref(_, _, ty::Mutability::Mut) = substs.type_at(0).kind()
11091109
&& let self_ty = self.infcx.instantiate_binder_with_fresh_vars(
11101110
fn_call_span,
11111111
LateBoundRegionConversionTime::FnCall,

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
7070
.place
7171
.place
7272
.deref_tys()
73-
.any(|ty| matches!(ty.kind(), ty::Ref(.., hir::Mutability::Not)));
73+
.any(|ty| matches!(ty.kind(), ty::Ref(.., ty::Mutability::Not)));
7474

7575
// If the place is immutable then:
7676
//
@@ -1147,7 +1147,7 @@ pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<
11471147
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
11481148
binding_mode: ty::BindingMode::BindByValue(Mutability::Not),
11491149
..
1150-
})) => matches!(local_decl.ty.kind(), ty::Ref(_, _, hir::Mutability::Mut)),
1150+
})) => matches!(local_decl.ty.kind(), ty::Ref(_, _, ty::Mutability::Mut)),
11511151
LocalInfo::User(mir::BindingForm::ImplicitSelf(kind)) => {
11521152
// Check if the user variable is a `&mut self` and we can therefore
11531153
// suggest removing the `&mut`.
@@ -1160,7 +1160,7 @@ pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<
11601160
// Otherwise, check if the name is the `self` keyword - in which case
11611161
// we have an explicit self. Do the same thing in this case and check
11621162
// for a `self: &mut Self` to suggest removing the `&mut`.
1163-
matches!(local_decl.ty.kind(), ty::Ref(_, _, hir::Mutability::Mut))
1163+
matches!(local_decl.ty.kind(), ty::Ref(_, _, ty::Mutability::Mut))
11641164
}
11651165
_ => false,
11661166
}

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
490490
ty::VarianceDiagInfo::Invariant { ty, param_index } => {
491491
let (desc, note) = match ty.kind() {
492492
ty::RawPtr(ty_mut) => {
493-
assert_eq!(ty_mut.mutbl, rustc_hir::Mutability::Mut);
493+
assert_eq!(ty_mut.mutbl, ty::Mutability::Mut);
494494
(
495495
format!("a mutable pointer to `{}`", ty_mut.ty),
496496
"mutable pointers are invariant over their type parameter".to_string(),
497497
)
498498
}
499499
ty::Ref(_, inner_ty, mutbl) => {
500-
assert_eq!(*mutbl, rustc_hir::Mutability::Mut);
500+
assert_eq!(*mutbl, ty::Mutability::Mut);
501501
(
502502
format!("a mutable reference to `{inner_ty}`"),
503503
"mutable references are invariant over their type parameter"

compiler/rustc_borrowck/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13431343
if proj == ProjectionElem::Deref {
13441344
match place_ref.ty(this.body(), this.infcx.tcx).ty.kind() {
13451345
// We aren't modifying a variable directly
1346-
ty::Ref(_, _, hir::Mutability::Mut) => return,
1346+
ty::Ref(_, _, ty::Mutability::Mut) => return,
13471347

13481348
_ => {}
13491349
}
@@ -2136,10 +2136,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21362136
ty::Ref(_, _, mutbl) => {
21372137
match mutbl {
21382138
// Shared borrowed data is never mutable
2139-
hir::Mutability::Not => Err(place),
2139+
ty::Mutability::Not => Err(place),
21402140
// Mutably borrowed data is mutable, but only if we have a
21412141
// unique path to the `&mut`
2142-
hir::Mutability::Mut => {
2142+
ty::Mutability::Mut => {
21432143
let mode = match self.is_upvar_field_projection(place) {
21442144
Some(field) if self.upvars[field.index()].by_ref => {
21452145
is_local_mutation_allowed
@@ -2154,10 +2154,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21542154
ty::RawPtr(tnm) => {
21552155
match tnm.mutbl {
21562156
// `*const` raw pointers are not mutable
2157-
hir::Mutability::Not => Err(place),
2157+
ty::Mutability::Not => Err(place),
21582158
// `*mut` raw pointers are always mutable, regardless of
21592159
// context. The users have to check by themselves.
2160-
hir::Mutability::Mut => Ok(RootPlace {
2160+
ty::Mutability::Mut => Ok(RootPlace {
21612161
place_local: place.local,
21622162
place_projection: place.projection,
21632163
is_local_mutation_allowed,

compiler/rustc_borrowck/src/place_ext.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![deny(rustc::untranslatable_diagnostic)]
22
#![deny(rustc::diagnostic_outside_of_impl)]
33
use crate::borrow_set::LocalsStateAtExit;
4-
use rustc_hir as hir;
54
use rustc_middle::mir::ProjectionElem;
65
use rustc_middle::mir::{Body, Mutability, Place};
76
use rustc_middle::ty::{self, TyCtxt};
@@ -52,15 +51,15 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {
5251
if elem == ProjectionElem::Deref {
5352
let ty = Place::ty_from(self.local, proj_base, body, tcx).ty;
5453
match ty.kind() {
55-
ty::Ref(_, _, hir::Mutability::Not) if i == 0 => {
54+
ty::Ref(_, _, ty::Mutability::Not) if i == 0 => {
5655
// For references to thread-local statics, we do need
5756
// to track the borrow.
5857
if body.local_decls[self.local].is_ref_to_thread_local() {
5958
continue;
6059
}
6160
return true;
6261
}
63-
ty::RawPtr(..) | ty::Ref(_, _, hir::Mutability::Not) => {
62+
ty::RawPtr(..) | ty::Ref(_, _, ty::Mutability::Not) => {
6463
// For both derefs of raw pointers and `&T`
6564
// references, the original path is `Copy` and
6665
// therefore not significant. In particular,

compiler/rustc_borrowck/src/places_conflict.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::ArtificialField;
44
use crate::Overlap;
55
use crate::{AccessDepth, Deep, Shallow};
6-
use rustc_hir as hir;
76
use rustc_middle::mir::{Body, BorrowKind, Local, Place, PlaceElem, PlaceRef, ProjectionElem};
87
use rustc_middle::ty::{self, TyCtxt};
98
use std::cmp::max;
@@ -227,11 +226,11 @@ fn place_components_conflict<'tcx>(
227226
debug!("borrow_conflicts_with_place: shallow access behind ptr");
228227
return false;
229228
}
230-
(ProjectionElem::Deref, ty::Ref(_, _, hir::Mutability::Not), _) => {
229+
(ProjectionElem::Deref, ty::Ref(_, _, ty::Mutability::Not), _) => {
231230
// Shouldn't be tracked
232231
bug!("Tracking borrow behind shared reference.");
233232
}
234-
(ProjectionElem::Deref, ty::Ref(_, _, hir::Mutability::Mut), AccessDepth::Drop) => {
233+
(ProjectionElem::Deref, ty::Ref(_, _, ty::Mutability::Mut), AccessDepth::Drop) => {
235234
// Values behind a mutable reference are not access either by dropping a
236235
// value, or by StorageDead
237236
debug!("borrow_conflicts_with_place: drop access behind ptr");

compiler/rustc_borrowck/src/prefixes.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
1212
use super::MirBorrowckCtxt;
1313

14-
use rustc_hir as hir;
1514
use rustc_middle::mir::{Body, PlaceRef, ProjectionElem};
1615
use rustc_middle::ty::{self, TyCtxt};
1716

@@ -122,14 +121,14 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
122121

123122
let ty = cursor_base.ty(self.body, self.tcx).ty;
124123
match ty.kind() {
125-
ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => {
124+
ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, ty::Mutability::Not) => {
126125
// don't continue traversing over derefs of raw pointers or shared
127126
// borrows.
128127
self.next = None;
129128
return Some(cursor);
130129
}
131130

132-
ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Mut) => {
131+
ty::Ref(_ /*rgn*/, _ /*ty*/, ty::Mutability::Mut) => {
133132
self.next = Some(cursor_base);
134133
return Some(cursor);
135134
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20332033
CastKind::Pointer(PointerCast::MutToConstPointer) => {
20342034
let ty::RawPtr(ty::RawPtr {
20352035
ty: ty_from,
2036-
mutbl: hir::Mutability::Mut,
2036+
mutbl: ty::Mutability::Mut,
20372037
}) = op.ty(body, tcx).kind() else {
20382038
span_mirbug!(
20392039
self,
@@ -2045,7 +2045,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20452045
};
20462046
let ty::RawPtr(ty::RawPtr {
20472047
ty: ty_to,
2048-
mutbl: hir::Mutability::Not,
2048+
mutbl: ty::Mutability::Not,
20492049
}) = ty.kind() else {
20502050
span_mirbug!(
20512051
self,
@@ -2532,13 +2532,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25322532
});
25332533

25342534
match mutbl {
2535-
hir::Mutability::Not => {
2535+
ty::Mutability::Not => {
25362536
// Immutable reference. We don't need the base
25372537
// to be valid for the entire lifetime of
25382538
// the borrow.
25392539
break;
25402540
}
2541-
hir::Mutability::Mut => {
2541+
ty::Mutability::Mut => {
25422542
// Mutable reference. We *do* need the base
25432543
// to be valid, because after the base becomes
25442544
// invalid, someone else can use our mutable deref.

compiler/rustc_codegen_cranelift/src/abi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ pub(crate) fn codegen_drop<'tcx>(
668668
fx.layout_of(fx.tcx.mk_ref(
669669
fx.tcx.lifetimes.re_erased,
670670
ty,
671-
crate::rustc_hir::Mutability::Mut,
671+
ty::Mutability::Mut,
672672
)),
673673
);
674674
let arg_value = adjust_arg_for_abi(fx, arg_value, &fn_abi.args[0], true);

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn clif_pair_type_from_ty<'tcx>(
9999

100100
/// Is a pointer to this type a fat ptr?
101101
pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
102-
let ptr_ty = tcx.mk_ptr(RawPtr { ty, mutbl: rustc_hir::Mutability::Not });
102+
let ptr_ty = tcx.mk_ptr(RawPtr { ty, mutbl: ty::Mutability::Not });
103103
match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi {
104104
Abi::Scalar(_) => false,
105105
Abi::ScalarPair(_, _) => true,

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub(crate) fn data_id_for_alloc_id(
264264
cx: &mut ConstantCx,
265265
module: &mut dyn Module,
266266
alloc_id: AllocId,
267-
mutability: rustc_hir::Mutability,
267+
mutability: ty::Mutability,
268268
) -> DataId {
269269
cx.todo.push(TodoItem::Alloc(alloc_id));
270270
*cx.anon_allocs

compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
720720
let (_, element_ty1) = arg_tys[1].simd_size_and_type(bx.tcx());
721721
let (_, element_ty2) = arg_tys[2].simd_size_and_type(bx.tcx());
722722
let (pointer_count, underlying_ty) = match element_ty1.kind() {
723-
ty::RawPtr(p) if p.ty == in_elem && p.mutbl == hir::Mutability::Mut => {
723+
ty::RawPtr(p) if p.ty == in_elem && p.mutbl == ty::Mutability::Mut => {
724724
(ptr_count(element_ty1), non_ptr(element_ty1))
725725
}
726726
_ => {

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ use crate::type_::Type;
77
use crate::type_of::LayoutLlvmExt;
88
use crate::value::Value;
99

10-
use rustc_ast::Mutability;
1110
use rustc_codegen_ssa::mir::place::PlaceRef;
1211
use rustc_codegen_ssa::traits::*;
1312
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher};
1413
use rustc_hir::def_id::DefId;
1514
use rustc_middle::bug;
1615
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
1716
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
18-
use rustc_middle::ty::TyCtxt;
17+
use rustc_middle::ty::{Mutability, TyCtxt};
1918
use rustc_session::cstore::{DllCallingConvention, DllImport, PeImportNameType};
2019
use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer, Size};
2120
use rustc_target::spec::Target;

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ use rustc_data_structures::fx::FxHashSet;
1515
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
1616
use rustc_hir::def_id::DefId;
1717
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
18-
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Mutability};
18+
use rustc_hir::{AsyncGeneratorKind, GeneratorKind};
1919
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
2020
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
21-
use rustc_middle::ty::{self, ExistentialProjection, ParamEnv, Ty, TyCtxt};
21+
use rustc_middle::ty::{self, ExistentialProjection, Mutability, ParamEnv, Ty, TyCtxt};
2222
use rustc_target::abi::Integer;
2323
use smallvec::SmallVec;
2424

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_hir::{LangItem, CRATE_HIR_ID};
33
use rustc_middle::mir;
44
use rustc_middle::mir::interpret::PointerArithmetic;
55
use rustc_middle::ty::layout::{FnAbiOf, TyAndLayout};
6-
use rustc_middle::ty::{self, Ty, TyCtxt};
6+
use rustc_middle::ty::{self, Mutability, Ty, TyCtxt};
77
use rustc_session::lint::builtin::INVALID_ALIGNMENT;
88
use std::borrow::Borrow;
99
use std::hash::Hash;
@@ -13,7 +13,6 @@ use rustc_data_structures::fx::FxIndexMap;
1313
use rustc_data_structures::fx::IndexEntry;
1414
use std::fmt;
1515

16-
use rustc_ast::Mutability;
1716
use rustc_hir::def_id::DefId;
1817
use rustc_middle::mir::AssertMessage;
1918
use rustc_session::Limit;

compiler/rustc_const_eval/src/const_eval/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use crate::interpret::{
55
intern_const_alloc_recursive, ConstValue, InternKind, InterpCx, InterpResult, MemPlaceMeta,
66
Scalar,
77
};
8-
use rustc_hir::Mutability;
98
use rustc_middle::mir;
109
use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId};
11-
use rustc_middle::ty::{self, TyCtxt};
10+
use rustc_middle::ty::{self, Mutability, TyCtxt};
1211
use rustc_span::{source_map::DUMMY_SP, symbol::Symbol};
1312

1413
mod error;

compiler/rustc_const_eval/src/interpret/intern.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717
use super::validity::RefTracking;
1818
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
1919
use rustc_errors::ErrorGuaranteed;
20-
use rustc_hir as hir;
2120
use rustc_middle::mir::interpret::InterpResult;
22-
use rustc_middle::ty::{self, layout::TyAndLayout, Ty};
23-
24-
use rustc_ast::Mutability;
21+
use rustc_middle::ty::{self, layout::TyAndLayout, Mutability, Ty};
2522

2623
use super::{
2724
AllocId, Allocation, ConstAllocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy,
@@ -62,7 +59,7 @@ enum InternMode {
6259
/// A static and its current mutability. Below shared references inside a `static mut`,
6360
/// this is *immutable*, and below mutable references inside an `UnsafeCell`, this
6461
/// is *mutable*.
65-
Static(hir::Mutability),
62+
Static(ty::Mutability),
6663
/// A `const`.
6764
Const,
6865
}
@@ -323,7 +320,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
323320
#[derive(Copy, Clone, Debug, PartialEq, Hash, Eq)]
324321
pub enum InternKind {
325322
/// The `mutability` of the static, ignoring the type which may have interior mutability.
326-
Static(hir::Mutability),
323+
Static(ty::Mutability),
327324
Constant,
328325
Promoted,
329326
}

compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use rustc_ast::Mutability;
21
use rustc_hir::lang_items::LangItem;
32
use rustc_middle::mir::TerminatorKind;
43
use rustc_middle::ty::layout::LayoutOf;
4+
use rustc_middle::ty::Mutability;
55
use rustc_span::{Span, Symbol};
66

77
use crate::interpret::{

compiler/rustc_const_eval/src/interpret/memory.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use std::collections::VecDeque;
1212
use std::fmt;
1313
use std::ptr;
1414

15-
use rustc_ast::Mutability;
1615
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1716
use rustc_middle::mir::display_allocation;
18-
use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TyCtxt};
17+
use rustc_middle::ty::{self, Instance, Mutability, ParamEnv, Ty, TyCtxt};
1918
use rustc_target::abi::{Align, HasDataLayout, Size};
2019

2120
use crate::const_eval::CheckAlignment;

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
55
use either::{Either, Left, Right};
66

7-
use rustc_ast::Mutability;
87
use rustc_index::IndexSlice;
98
use rustc_middle::mir;
10-
use rustc_middle::ty;
119
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
10+
use rustc_middle::ty::{self, Mutability};
1211
use rustc_target::abi::{self, Abi, Align, FieldIdx, HasDataLayout, Size, FIRST_VARIANT};
1312

1413
use super::{

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ use std::num::NonZeroUsize;
99

1010
use either::{Left, Right};
1111

12-
use rustc_ast::Mutability;
1312
use rustc_data_structures::fx::FxHashSet;
1413
use rustc_hir as hir;
1514
use rustc_middle::mir::interpret::InterpError;
16-
use rustc_middle::ty;
17-
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
15+
use rustc_middle::ty::{
16+
self,
17+
layout::{LayoutOf, TyAndLayout},
18+
Mutability,
19+
};
1820
use rustc_span::symbol::{sym, Symbol};
1921
use rustc_target::abi::{
2022
Abi, FieldIdx, Scalar as ScalarAbi, Size, VariantIdx, Variants, WrappingRange,

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
350350
};
351351

352352
match *ty.kind() {
353-
ty::Ref(_, _, hir::Mutability::Mut) => self.check_op(ops::ty::MutRef(kind)),
353+
ty::Ref(_, _, ty::Mutability::Mut) => self.check_op(ops::ty::MutRef(kind)),
354354
_ => {}
355355
}
356356
}

0 commit comments

Comments
 (0)