Skip to content

Commit 926bfe5

Browse files
committed
s/mt/mutability/
1 parent d3514a0 commit 926bfe5

File tree

11 files changed

+28
-21
lines changed

11 files changed

+28
-21
lines changed

compiler/rustc_const_eval/src/interpret/intern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn intern_as_new_static<'tcx>(
102102
let feed = tcx.create_def(
103103
static_id,
104104
sym::nested,
105-
DefKind::Static { mt: alloc.0.mutability, nested: true },
105+
DefKind::Static { mutability: alloc.0.mutability, nested: true },
106106
);
107107
tcx.set_nested_alloc_id_static(alloc_id, feed.def_id());
108108
feed.codegen_fn_attrs(tcx.codegen_fn_attrs(static_id).clone());

compiler/rustc_const_eval/src/interpret/validity.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,11 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
484484
// Return alloc mutability. For "root" statics we look at the type to account for interior
485485
// mutability; for nested statics we have no type and directly use the annotated mutability.
486486
match self.ecx.tcx.def_kind(did) {
487-
DefKind::Static { mt: Mutability::Mut, .. } => Mutability::Mut,
488-
DefKind::Static { mt: Mutability::Not, nested: true } => {
487+
DefKind::Static { mutability: Mutability::Mut, .. } => Mutability::Mut,
488+
DefKind::Static { mutability: Mutability::Not, nested: true } => {
489489
Mutability::Not
490490
}
491-
DefKind::Static { mt: Mutability::Not, nested: false }
491+
DefKind::Static { mutability: Mutability::Not, nested: false }
492492
if !self
493493
.ecx
494494
.tcx

compiler/rustc_hir/src/def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub enum DefKind {
7777
ConstParam,
7878
Static {
7979
/// Whether it's a `static mut` or just a `static`.
80-
mt: ast::Mutability,
80+
mutability: ast::Mutability,
8181
/// Whether it's an anonymous static generated for nested allocations.
8282
nested: bool,
8383
},

compiler/rustc_hir_analysis/src/check/errs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ fn is_path_static_mut(expr: hir::Expr<'_>) -> Option<String> {
4848
if let hir::ExprKind::Path(qpath) = expr.kind
4949
&& let hir::QPath::Resolved(_, path) = qpath
5050
&& let hir::def::Res::Def(def_kind, _) = path.res
51-
&& let hir::def::DefKind::Static { mt, nested: false } = def_kind
52-
&& matches!(mt, Mutability::Mut)
51+
&& let hir::def::DefKind::Static { mutability: Mutability::Mut, nested: false } = def_kind
5352
{
5453
return Some(qpath_to_string(&qpath));
5554
}

compiler/rustc_metadata/src/rmeta/table.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ fixed_size_enum! {
155155
( Impl { of_trait: false } )
156156
( Impl { of_trait: true } )
157157
( Closure )
158-
( Static{mt:ast::Mutability::Not, nested: false})
159-
( Static{mt:ast::Mutability::Mut, nested: false})
160-
( Static{mt:ast::Mutability::Not, nested: true})
161-
( Static{mt:ast::Mutability::Mut, nested: true})
158+
( Static { mutability: ast::Mutability::Not, nested: false } )
159+
( Static { mutability: ast::Mutability::Mut, nested: false } )
160+
( Static { mutability: ast::Mutability::Not, nested: true } )
161+
( Static { mutability: ast::Mutability::Mut, nested: true } )
162162
( Ctor(CtorOf::Struct, CtorKind::Fn) )
163163
( Ctor(CtorOf::Struct, CtorKind::Const) )
164164
( Ctor(CtorOf::Variant, CtorKind::Fn) )

compiler/rustc_middle/src/hir/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<'hir> Map<'hir> {
343343
DefKind::InlineConst => BodyOwnerKind::Const { inline: true },
344344
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => BodyOwnerKind::Fn,
345345
DefKind::Closure => BodyOwnerKind::Closure,
346-
DefKind::Static { mt, nested: false } => BodyOwnerKind::Static(mt),
346+
DefKind::Static { mutability, nested: false } => BodyOwnerKind::Static(mutability),
347347
dk => bug!("{:?} is not a body node: {:?}", def_id, dk),
348348
}
349349
}
@@ -359,7 +359,7 @@ impl<'hir> Map<'hir> {
359359
let def_id = def_id.into();
360360
let ccx = match self.body_owner_kind(def_id) {
361361
BodyOwnerKind::Const { inline } => ConstContext::Const { inline },
362-
BodyOwnerKind::Static(mt) => ConstContext::Static(mt),
362+
BodyOwnerKind::Static(mutability) => ConstContext::Static(mutability),
363363

364364
BodyOwnerKind::Fn if self.tcx.is_constructor(def_id) => return None,
365365
BodyOwnerKind::Fn | BodyOwnerKind::Closure if self.tcx.is_const_fn_raw(def_id) => {

compiler/rustc_middle/src/mir/pretty.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,10 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io:
498498
match (kind, body.source.promoted) {
499499
(_, Some(_)) => write!(w, "const ")?, // promoteds are the closest to consts
500500
(DefKind::Const | DefKind::AssocConst, _) => write!(w, "const ")?,
501-
(DefKind::Static { mt: hir::Mutability::Not, nested: false }, _) => write!(w, "static ")?,
502-
(DefKind::Static { mt: hir::Mutability::Mut, nested: false }, _) => {
501+
(DefKind::Static { mutability: hir::Mutability::Not, nested: false }, _) => {
502+
write!(w, "static ")?
503+
}
504+
(DefKind::Static { mutability: hir::Mutability::Mut, nested: false }, _) => {
503505
write!(w, "static mut ")?
504506
}
505507
(_, _) if is_function => write!(w, "fn ")?,

compiler/rustc_middle/src/ty/util.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,11 @@ impl<'tcx> TyCtxt<'tcx> {
621621

622622
#[inline]
623623
pub fn static_mutability(self, def_id: DefId) -> Option<hir::Mutability> {
624-
if let DefKind::Static { mt, .. } = self.def_kind(def_id) { Some(mt) } else { None }
624+
if let DefKind::Static { mutability, .. } = self.def_kind(def_id) {
625+
Some(mutability)
626+
} else {
627+
None
628+
}
625629
}
626630

627631
/// Returns `true` if this is a `static` item with the `#[thread_local]` attribute.

compiler/rustc_resolve/src/def_collector.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
127127
ItemKind::Union(..) => DefKind::Union,
128128
ItemKind::ExternCrate(..) => DefKind::ExternCrate,
129129
ItemKind::TyAlias(..) => DefKind::TyAlias,
130-
ItemKind::Static(s) => DefKind::Static { mt: s.mutability, nested: false },
130+
ItemKind::Static(s) => DefKind::Static { mutability: s.mutability, nested: false },
131131
ItemKind::Const(..) => DefKind::Const,
132132
ItemKind::Fn(..) | ItemKind::Delegation(..) => DefKind::Fn,
133133
ItemKind::MacroDef(..) => {
@@ -214,7 +214,9 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
214214

215215
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
216216
let def_kind = match fi.kind {
217-
ForeignItemKind::Static(_, mt, _) => DefKind::Static { mt, nested: false },
217+
ForeignItemKind::Static(_, mutability, _) => {
218+
DefKind::Static { mutability, nested: false }
219+
}
218220
ForeignItemKind::Fn(_) => DefKind::Fn,
219221
ForeignItemKind::TyAlias(_) => DefKind::ForeignTy,
220222
ForeignItemKind::MacCall(_) => return self.visit_macro_invoc(fi.id),

src/librustdoc/passes/collect_intra_doc_links.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ impl Disambiguator {
15141514
"union" => Kind(DefKind::Union),
15151515
"module" | "mod" => Kind(DefKind::Mod),
15161516
"const" | "constant" => Kind(DefKind::Const),
1517-
"static" => Kind(DefKind::Static { mt: Mutability::Not, nested: false }),
1517+
"static" => Kind(DefKind::Static { mutability: Mutability::Not, nested: false }),
15181518
"function" | "fn" | "method" => Kind(DefKind::Fn),
15191519
"derive" => Kind(DefKind::Macro(MacroKind::Derive)),
15201520
"type" => NS(Namespace::TypeNS),

src/tools/clippy/clippy_lints/src/multiple_unsafe_ops_per_block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn collect_unsafe_exprs<'tcx>(
109109
ExprKind::Path(QPath::Resolved(
110110
_,
111111
hir::Path {
112-
res: Res::Def(DefKind::Static{mt:Mutability::Mut, ..}, _),
112+
res: Res::Def(DefKind::Static{mutability:Mutability::Mut, ..}, _),
113113
..
114114
},
115115
)) => {
@@ -149,7 +149,7 @@ fn collect_unsafe_exprs<'tcx>(
149149
ExprKind::Path(QPath::Resolved(
150150
_,
151151
hir::Path {
152-
res: Res::Def(DefKind::Static{mt:Mutability::Mut, ..}, _),
152+
res: Res::Def(DefKind::Static{mutability:Mutability::Mut, ..}, _),
153153
..
154154
}
155155
))

0 commit comments

Comments
 (0)